X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Facr%2FSingleUserContentRepository.java;h=cac407495a70be147447e9c27986ccecf448cbe4;hb=ddc70245fe7413b7341205914c91015600726b4a;hp=0e3d1ad3fbf701b87b82f760548e2057de0342d4;hpb=dcdbf77c4ec46f1dcad5d3fa011fe072e921f187;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/acr/SingleUserContentRepository.java b/org.argeo.cms/src/org/argeo/cms/acr/SingleUserContentRepository.java index 0e3d1ad3f..cac407495 100644 --- a/org.argeo.cms/src/org/argeo/cms/acr/SingleUserContentRepository.java +++ b/org.argeo.cms/src/org/argeo/cms/acr/SingleUserContentRepository.java @@ -4,6 +4,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Locale; import java.util.Objects; +import java.util.UUID; import javax.security.auth.Subject; import javax.security.auth.x500.X500Principal; @@ -21,13 +22,13 @@ public class SingleUserContentRepository extends AbstractContentRepository { private final Subject subject; private final Locale locale; + private UUID uuid; + // the single session private CmsContentSession contentSession; public SingleUserContentRepository(Subject subject) { this(subject, Locale.getDefault()); - - initRootContentProvider(null); } public SingleUserContentRepository(Subject subject, Locale locale) { @@ -36,6 +37,9 @@ public class SingleUserContentRepository extends AbstractContentRepository { this.subject = subject; this.locale = locale; + + // TODO use an UUID factory + this.uuid = UUID.randomUUID(); } @Override @@ -44,9 +48,10 @@ public class SingleUserContentRepository extends AbstractContentRepository { Objects.requireNonNull(locale); super.start(); + initRootContentProvider(null); if (contentSession != null) throw new IllegalStateException("Repository is already started, stop it first."); - contentSession = new CmsContentSession(this, subject, locale); + contentSession = new CmsContentSession(this, uuid, subject, locale); } @Override @@ -71,7 +76,7 @@ public class SingleUserContentRepository extends AbstractContentRepository { @Override protected CmsContentSession newSystemSession() { - return new CmsContentSession(this, subject, Locale.getDefault()); + return new CmsContentSession(this, uuid, subject, Locale.getDefault()); } public static void main(String... args) { @@ -82,10 +87,10 @@ public class SingleUserContentRepository extends AbstractContentRepository { subject.getPrincipals().add(principal); SingleUserContentRepository contentRepository = new SingleUserContentRepository(subject); + contentRepository.start(); FsContentProvider homeContentProvider = new FsContentProvider("/home", homePath); contentRepository.addProvider(homeContentProvider); Runtime.getRuntime().addShutdownHook(new Thread(() -> contentRepository.stop(), "Shutdown content repository")); - contentRepository.start(); ContentSession contentSession = contentRepository.get(); ContentUtils.traverse(contentSession.get("/"), (c, depth) -> ContentUtils.print(c, System.out, depth, false),