X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Facr%2FCmsContentRepository.java;h=3b47c1630aa4f63a41a30d0909d2ace7b13350de;hb=0e533d2562def311fdd7aa71f1d0d704e466861e;hp=46222ce1ac0d2248b58f67ed8bdb3e13b8a6e68a;hpb=da9d144b6b241e1526a3bd255dff905a7969a5bc;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/acr/CmsContentRepository.java b/org.argeo.cms/src/org/argeo/cms/acr/CmsContentRepository.java index 46222ce1a..3b47c1630 100644 --- a/org.argeo.cms/src/org/argeo/cms/acr/CmsContentRepository.java +++ b/org.argeo.cms/src/org/argeo/cms/acr/CmsContentRepository.java @@ -13,15 +13,18 @@ import org.argeo.api.acr.spi.ProvidedRepository; import org.argeo.api.cms.CmsAuth; import org.argeo.api.cms.CmsSession; import org.argeo.api.cms.CmsState; +import org.argeo.api.cms.DataAdminPrincipal; import org.argeo.api.uuid.UuidFactory; -import org.argeo.cms.auth.CurrentUser; +import org.argeo.cms.CurrentUser; import org.argeo.cms.internal.runtime.CmsContextImpl; +import org.argeo.cms.util.CurrentSubject; /** * Multi-session {@link ProvidedRepository}, integrated with a CMS. */ public class CmsContentRepository extends AbstractContentRepository { public final static String RUN_BASE = "/run"; + public final static String DIRECTORY_BASE = "/directory"; private Map userSessions = Collections.synchronizedMap(new HashMap<>()); @@ -39,12 +42,19 @@ public class CmsContentRepository extends AbstractContentRepository { @Override public ContentSession get(Locale locale) { - // Subject subject = Subject.getSubject(AccessController.getContext()); + if (!CmsSession.hasCmsSession(CurrentSubject.current())) { + if (DataAdminPrincipal.isDataAdmin(CurrentSubject.current())) { + // TODO open multiple data admin sessions? + return getSystemSession(); + } + throw new IllegalStateException("Caller must be authenticated"); + } + CmsSession cmsSession = CurrentUser.getCmsSession(); CmsContentSession contentSession = userSessions.get(cmsSession); if (contentSession == null) { final CmsContentSession newContentSession = new CmsContentSession(this, cmsSession.getUuid(), - cmsSession.getSubject(), locale); + cmsSession.getSubject(), locale, uuidFactory); cmsSession.addOnCloseCallback((c) -> { newContentSession.close(); userSessions.remove(cmsSession); @@ -64,8 +74,8 @@ public class CmsContentRepository extends AbstractContentRepository { throw new RuntimeException("Could not login as data admin", e1); } finally { } - return new CmsContentSession(this, getCmsState().getUuid(), loginContext.getSubject(), - Locale.getDefault()); + return new CmsContentSession(this, getCmsState().getUuid(), loginContext.getSubject(), Locale.getDefault(), + uuidFactory); } protected CmsState getCmsState() {