Code clean up
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / acr / CmsContentSession.java
index 9f10d3f3176ce2d127b679035f42b1d323e26d9b..73adc7012860c99503bacf683488d6b0c2fb0235 100644 (file)
@@ -12,7 +12,7 @@ import javax.security.auth.Subject;
 
 import org.argeo.api.acr.Content;
 import org.argeo.api.acr.ContentSession;
-import org.argeo.api.acr.CrName;
+import org.argeo.api.acr.DName;
 import org.argeo.api.acr.spi.ContentProvider;
 import org.argeo.api.acr.spi.ProvidedContent;
 import org.argeo.api.acr.spi.ProvidedRepository;
@@ -61,6 +61,8 @@ class CmsContentSession implements ProvidedSession {
 
        @Override
        public Content get(String path) {
+               if (!path.startsWith(ContentUtils.ROOT_SLASH))
+                       throw new IllegalArgumentException(path + " is not an absolute path");
                ContentProvider contentProvider = contentRepository.getMountManager().findContentProvider(path);
                String mountPath = contentProvider.getMountPath();
                String relativePath = extractRelativePath(mountPath, path);
@@ -70,6 +72,8 @@ class CmsContentSession implements ProvidedSession {
 
        @Override
        public boolean exists(String path) {
+               if (!path.startsWith(ContentUtils.ROOT_SLASH))
+                       throw new IllegalArgumentException(path + " is not an absolute path");
                ContentProvider contentProvider = contentRepository.getMountManager().findContentProvider(path);
                String mountPath = contentProvider.getMountPath();
                String relativePath = extractRelativePath(mountPath, path);
@@ -114,23 +118,8 @@ class CmsContentSession implements ProvidedSession {
        }
 
        /*
-        * NAMESPACE CONTEXT
+        * EDITION
         */
-
-//     @Override
-//     public String getNamespaceURI(String prefix) {
-//             return RuntimeNamespaceContext.getNamespaceContext().getNamespaceURI(prefix);
-////           return NamespaceUtils.getNamespaceURI((p) -> contentRepository.getTypesManager().getPrefixes().get(p), prefix);
-//     }
-//
-//     @Override
-//     public Iterator<String> getPrefixes(String namespaceURI) {
-//             return RuntimeNamespaceContext.getNamespaceContext().getPrefixes(namespaceURI);
-////           return NamespaceUtils.getPrefixes((ns) -> contentRepository.getTypesManager().getPrefixes().entrySet().stream()
-////                           .filter(e -> e.getValue().equals(ns)).map(Map.Entry::getKey).collect(Collectors.toUnmodifiableSet()),
-////                           namespaceURI);
-//     }
-
        @Override
        public CompletionStage<ContentSession> edit(Consumer<ContentSession> work) {
                edition = CompletableFuture.supplyAsync(() -> {
@@ -176,7 +165,7 @@ class CmsContentSession implements ProvidedSession {
                        else {
                                Content runDir = get(CmsContentRepository.RUN_BASE);
                                // TODO deal with no run dir available?
-                               sessionRunDir = runDir.add(uuid.toString(), CrName.collection.qName());
+                               sessionRunDir = runDir.add(uuid.toString(), DName.collection.qName());
                        }
                }
                return sessionRunDir;