import org.argeo.api.acr.spi.ContentProvider;
import org.argeo.api.acr.spi.ProvidedContent;
import org.argeo.api.acr.spi.ProvidedSession;
import org.argeo.api.acr.spi.ContentProvider;
import org.argeo.api.acr.spi.ProvidedContent;
import org.argeo.api.acr.spi.ProvidedSession;
import org.argeo.cms.acr.ContentUtils;
import org.argeo.cms.jcr.CmsJcrUtils;
import org.argeo.jcr.JcrException;
import org.argeo.cms.acr.ContentUtils;
import org.argeo.cms.jcr.CmsJcrUtils;
import org.argeo.jcr.JcrException;
/** A JCR workspace accessed as an {@link ContentProvider}. */
public class JcrContentProvider implements ContentProvider, NamespaceContext {
/** A JCR workspace accessed as an {@link ContentProvider}. */
public class JcrContentProvider implements ContentProvider, NamespaceContext {
private Repository jcrRepository;
private Session adminSession;
private String mountPath;
private Repository jcrRepository;
private Session adminSession;
private String mountPath;
private Map<ProvidedSession, JcrSessionAdapter> sessionAdapters = Collections.synchronizedMap(new HashMap<>());
public void start(Map<String, String> properties) {
private Map<ProvidedSession, JcrSessionAdapter> sessionAdapters = Collections.synchronizedMap(new HashMap<>());
public void start(Map<String, String> properties) {
if ("/".equals(mountPath))
throw new IllegalArgumentException("JCR content provider cannot be root /");
Objects.requireNonNull(mountPath);
if ("/".equals(mountPath))
throw new IllegalArgumentException("JCR content provider cannot be root /");
Objects.requireNonNull(mountPath);
- adminSession = CmsJcrUtils.openDataAdminSession(jcrRepository, null);
+ jcrWorkspace = ContentUtils.getParentPath(mountPath)[1];
+ adminSession = CmsJcrUtils.openDataAdminSession(jcrRepository, jcrWorkspace);
String jcrPath = "/" + relativePath;
return new JcrContent(contentSession, this, jcrWorkspace, jcrPath);
}
String jcrPath = "/" + relativePath;
return new JcrContent(contentSession, this, jcrWorkspace, jcrPath);
}