]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/acr/CmsContentSession.java
Use WebDav names
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / acr / CmsContentSession.java
index 13494dd0a8588825b23c386fa926471bbe5543dc..34d683605ac4e81240be687a04e4371f7e325d79 100644 (file)
@@ -13,6 +13,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 +62,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 +73,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);
@@ -137,13 +142,16 @@ class CmsContentSession implements ProvidedSession {
                        work.accept(this);
                        return this;
                }).thenApply((s) -> {
-                       // TODO optimise
-                       for (ContentProvider provider : modifiedProviders) {
-                               if (provider instanceof DomContentProvider) {
-                                       ((DomContentProvider) provider).persist(s);
+                       synchronized (CmsContentSession.this) {
+                               // TODO optimise
+                               for (ContentProvider provider : modifiedProviders) {
+                                       if (provider instanceof DomContentProvider) {
+                                               ((DomContentProvider) provider).persist(s);
+                                       }
                                }
+                               modifiedProviders.clear();
+                               return s;
                        }
-                       return s;
                });
                return edition.minimalCompletionStage();
        }
@@ -154,7 +162,7 @@ class CmsContentSession implements ProvidedSession {
        }
 
        @Override
-       public void notifyModification(ProvidedContent content) {
+       public synchronized void notifyModification(ProvidedContent content) {
                ContentProvider contentProvider = content.getProvider();
                modifiedProviders.add(contentProvider);
        }
@@ -173,7 +181,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;