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;
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) {
this.subject = subject;
this.locale = locale;
+
+ // TODO use an UUID factory
+ this.uuid = UUID.randomUUID();
}
@Override
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
@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) {
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),