- try (InputStream in = Files.newInputStream(deployConfigPath)) {
- deployConfigs = new LdifParser().read(in);
- }
- if (isClean) {
- if (log.isDebugEnabled())
- log.debug("Clean state, loading from framework properties...");
- setFromFrameworkProperties(isFirstInit);
- loadConfigs();
+ boolean isClean = true;
+ if (configurationAdmin != null)
+ try {
+ Configuration[] confs = configurationAdmin
+ .listConfigurations("(service.factoryPid=" + CmsConstants.NODE_USER_ADMIN_PID + ")");
+ isClean = confs == null || confs.length == 0;
+ } catch (Exception e) {
+ throw new IllegalStateException("Cannot analyse clean state", e);
+ }
+
+ try (InputStream in = Files.newInputStream(deployConfigPath)) {
+ deployConfigs = new LdifParser().read(in);
+ }
+ if (isClean) {
+ if (log.isDebugEnabled())
+ log.debug("Clean state, loading from framework properties...");
+ setFromFrameworkProperties(isFirstInit);
+ if (configurationAdmin != null)
+ loadConfigs();
+ }
+ // TODO check consistency if not clean
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot load deploy configuration", e);