Adapt after connect refactoring
[gpl/argeo-suite.git] / org.argeo.suite.core / src / org / argeo / suite / core / DefaultSuiteAppService.java
index 3718eae490f5d5b4855fe12321eabc9ea3ffd0ad..24cf37dff2e4087c3d00fddd6ac1206a57c08e24 100644 (file)
@@ -4,21 +4,44 @@ import java.util.List;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 
 import org.argeo.connect.AppService;
+import org.argeo.connect.SystemAppService;
 import org.argeo.suite.SuiteConstants;
+import org.argeo.suite.SuiteException;
 
-public class DefaultSuiteAppService implements AppService {
+public class DefaultSuiteAppService implements SystemAppService {
 
        // Injected known AppWorkbenchServices: order is important, first found
        // result will be returned by the various methods.
        private List<AppService> knownAppServices;
 
+       @Override
+       public Node publishEntity(Node parent, String nodeType, Node srcNode, boolean removeSrcNode)
+                       throws RepositoryException {
+               for (AppService appService : knownAppServices) {
+                       if (appService.isKnownType(nodeType))
+                               return appService.publishEntity(parent, nodeType, srcNode, removeSrcNode);
+               }
+               return null;
+       }
+
        @Override
        public String getAppBaseName() {
                return SuiteConstants.SUITE_APP_BASE_NAME;
        }
 
+       @Override
+       public String getBaseRelPath(String nodeType) {
+               for (AppService appService : knownAppServices) {
+                       if (appService.isKnownType(nodeType))
+                               return appService.getBaseRelPath(nodeType);
+               }
+               return null;
+               // return getAppBaseName();
+       }
+
        @Override
        public String getDefaultRelPath(Node entity) throws RepositoryException {
                for (AppService appService : knownAppServices) {
@@ -29,10 +52,10 @@ public class DefaultSuiteAppService implements AppService {
        }
 
        @Override
-       public String getDefaultRelPath(String nodetype, String id) {
+       public String getDefaultRelPath(Session session, String nodetype, String id) {
                for (AppService appService : knownAppServices) {
                        if (appService.isKnownType(nodetype))
-                               return appService.getDefaultRelPath(nodetype, id);
+                               return appService.getDefaultRelPath(session, nodetype, id);
                }
                return null;
        }
@@ -44,7 +67,8 @@ public class DefaultSuiteAppService implements AppService {
                        if (appService.isKnownType(entity))
                                return appService.saveEntity(entity, publish);
                }
-               return AppService.super.saveEntity(entity, publish);
+               throw new SuiteException("Unknown NodeType for " + entity + ". Cannot save");
+               // return AppService.super.saveEntity(entity, publish);
        }
 
        @Override
@@ -68,4 +92,5 @@ public class DefaultSuiteAppService implements AppService {
        public void setKnownAppServices(List<AppService> knownAppServices) {
                this.knownAppServices = knownAppServices;
        }
+
 }