Massive Argeo APIs refactoring
[gpl/argeo-suite.git] / org.argeo.suite.core / src / org / argeo / suite / core / CustomMaintenanceService.java
index b6e997af2d1508380f02f047afd9526511c7959d..4cd05cfc92e903818e02ac2e6ff3127c795f4858 100644 (file)
@@ -11,15 +11,14 @@ import javax.jcr.ItemExistsException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
 import org.argeo.entity.EntityType;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.maintenance.AbstractMaintenanceService;
 
 /** Base for custom initialisations. */
 public abstract class CustomMaintenanceService extends AbstractMaintenanceService {
-       private final static Log log = LogFactory.getLog(AbstractMaintenanceService.class);
+       private final static CmsLog log = CmsLog.getLog(AbstractMaintenanceService.class);
 
        protected List<String> getTypologies() {
                return new ArrayList<>();
@@ -36,14 +35,15 @@ public abstract class CustomMaintenanceService extends AbstractMaintenanceServic
                        for (String terms : typologies) {
                                loadTerms(termsBase, terms);
                        }
+                       // TODO do not save here, so that upper layers can decide when to save
                        termsBase.getSession().save();
                }
        }
 
        protected void loadTerms(Node termsBase, String name) throws IOException, RepositoryException {
                try {
-                       if (termsBase.hasNode(name))
-                               return;
+//                     if (termsBase.hasNode(name))
+//                             return;
 
                        String termsLoadPath = getTypologiesLoadBase() + '/' + name + ".xml";
                        URL termsUrl = getClass().getClassLoader().getResource(termsLoadPath);
@@ -62,6 +62,7 @@ public abstract class CustomMaintenanceService extends AbstractMaintenanceServic
                        }
                        if (log.isDebugEnabled())
                                log.debug("Terms '" + name + "' loaded.");
+                       // TODO do not save here, so that upper layers can decide when to save
                        termsBase.getSession().save();
                } catch (RepositoryException | IOException e) {
                        log.error("Cannot load terms '" + name + "': " + e.getMessage());