- public Content get(ProvidedSession session, String mountPath, String relativePath) {
- // TODO Auto-generated method stub
- return null;
+ public Content get(ProvidedSession contentSession, String mountPath, String relativePath) {
+ String workspace = ContentUtils.getParentPath(mountPath)[1];
+ JcrSessionAdapter sessionAdapter = sessionAdapters.get(contentSession);
+ if (sessionAdapter == null) {
+ final JcrSessionAdapter newSessionAdapter = new JcrSessionAdapter(jcrRepository,
+ contentSession.getSubject());
+ sessionAdapters.put(contentSession, newSessionAdapter);
+ contentSession.onClose().thenAccept((s) -> newSessionAdapter.close());
+ sessionAdapter = newSessionAdapter;
+ }
+
+ Session jcrSession = sessionAdapter.getSession(workspace);
+ String jcrPath = "/" + relativePath;
+ try {
+ Node node = jcrSession.getNode(jcrPath);
+ return new JcrContent(contentSession, this, node);
+ } catch (RepositoryException e) {
+ throw new JcrException("Cannot get JCR content '" + jcrPath + ", mounted from '" + mountPath
+ + "' with JCR session " + jcrSession, e);
+ }