]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/internal/kernel/CmsDeployment.java
Move Eclipse components which are JCR specific.
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / kernel / CmsDeployment.java
index 57ce898097c61cfe05c14068e684fd0bad447a3f..026f9186bc710fdac802ee13d650db681555818f 100644 (file)
@@ -15,6 +15,7 @@ import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Dictionary;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -45,6 +46,7 @@ import org.argeo.cms.ArgeoNames;
 import org.argeo.cms.internal.http.CmsRemotingServlet;
 import org.argeo.cms.internal.http.CmsWebDavServlet;
 import org.argeo.cms.internal.http.HttpUtils;
+import org.argeo.cms.internal.jcr.JcrInitUtils;
 import org.argeo.jcr.Jcr;
 import org.argeo.jcr.JcrException;
 import org.argeo.jcr.JcrUtils;
@@ -155,6 +157,7 @@ public class CmsDeployment implements NodeDeployment {
                                        throw new IllegalStateException("Cannot analyse clean state", e);
                                }
                                deployConfig = new DeployConfig(configurationAdmin, dataModels, isClean);
+                               JcrInitUtils.addToDeployment(CmsDeployment.this);
                                httpExpected = deployConfig.getProps(KernelConstants.JETTY_FACTORY_PID, "default") != null;
                                try {
                                        Configuration[] configs = configurationAdmin
@@ -181,6 +184,20 @@ public class CmsDeployment implements NodeDeployment {
                KernelUtils.asyncOpen(confAdminSt);
        }
 
+       public void addFactoryDeployConfig(String factoryPid, Dictionary<String, Object> props) {
+               deployConfig.putFactoryDeployConfig(factoryPid, props);
+               deployConfig.save();
+               try {
+                       deployConfig.loadConfigs();
+               } catch (IOException e) {
+                       throw new IllegalStateException(e);
+               }
+       }
+
+       public Dictionary<String, Object> getProps(String factoryPid, String cn) {
+               return deployConfig.getProps(factoryPid, cn);
+       }
+
        private String httpPortsMsg(Object httpPort, Object httpsPort) {
                return (httpPort != null ? "HTTP " + httpPort + " " : " ") + (httpsPort != null ? "HTTPS " + httpsPort : "");
        }
@@ -295,13 +312,15 @@ public class CmsDeployment implements NodeDeployment {
                prepareDataModel(NodeConstants.NODE_REPOSITORY, deployedNodeRepository, publishAsLocalRepo);
 
                // init from backup
-               Path restorePath = Paths.get(System.getProperty("user.dir"), "restore");
-               if (Files.exists(restorePath)) {
-                       if (log.isDebugEnabled())
-                               log.debug("Found backup " + restorePath + ", restoring it...");
-                       LogicalRestore logicalRestore = new LogicalRestore(bc, deployedNodeRepository, restorePath);
-                       KernelUtils.doAsDataAdmin(logicalRestore);
-                       log.info("Restored backup from " + restorePath);
+               if (deployConfig.isFirstInit()) {
+                       Path restorePath = Paths.get(System.getProperty("user.dir"), "restore");
+                       if (Files.exists(restorePath)) {
+                               if (log.isDebugEnabled())
+                                       log.debug("Found backup " + restorePath + ", restoring it...");
+                               LogicalRestore logicalRestore = new LogicalRestore(bc, deployedNodeRepository, restorePath);
+                               KernelUtils.doAsDataAdmin(logicalRestore);
+                               log.info("Restored backup from " + restorePath);
+                       }
                }
 
                // init from repository