Move JCR utilities from API to CMS JCR
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 7 Dec 2021 09:36:05 +0000 (10:36 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 7 Dec 2021 09:36:05 +0000 (10:36 +0100)
24 files changed:
org.argeo.api/src/org/argeo/api/NodeNames.java [deleted file]
org.argeo.api/src/org/argeo/api/NodeTypes.java [deleted file]
org.argeo.api/src/org/argeo/api/NodeUtils.java [deleted file]
org.argeo.cms.e4/src/org/argeo/cms/e4/files/NodeFsBrowserView.java
org.argeo.cms.e4/src/org/argeo/cms/e4/jcr/handlers/AddRemoteRepository.java
org.argeo.cms.e4/src/org/argeo/cms/e4/users/GroupEditor.java
org.argeo.cms.jcr/src/org/argeo/cms/jcr/CmsJcrUtils.java [new file with mode: 0644]
org.argeo.cms.jcr/src/org/argeo/cms/jcr/internal/CmsFsProvider.java
org.argeo.cms.jcr/src/org/argeo/cms/jcr/internal/EgoRepository.java
org.argeo.cms.jcr/src/org/argeo/cms/jcr/internal/JcrDeployment.java
org.argeo.cms.jcr/src/org/argeo/cms/jcr/internal/JcrKeyring.java
org.argeo.cms.jcr/src/org/argeo/cms/jcr/internal/servlet/LinkServlet.java
org.argeo.cms.jcr/src/org/argeo/maintenance/AbstractMaintenanceService.java
org.argeo.cms.jcr/src/org/argeo/maintenance/backup/LogicalBackup.java
org.argeo.cms.jcr/src/org/argeo/maintenance/backup/LogicalRestore.java
org.argeo.cms.ui.rap/bnd.bnd
org.argeo.cms.ui.rap/src/org/argeo/cms/web/SimpleApp.java
org.argeo.cms.ui/src/org/argeo/cms/ui/fs/CmsFsBrowser.java
org.argeo.cms.ui/src/org/argeo/cms/ui/jcr/NodeContentProvider.java
org.argeo.cms.ui/src/org/argeo/cms/ui/jcr/model/RemoteRepositoryElem.java
org.argeo.cms.ui/src/org/argeo/cms/ui/jcr/model/RepositoriesElem.java
org.argeo.cms.ui/src/org/argeo/cms/ui/util/CmsLink.java
org.argeo.cms.ui/src/org/argeo/cms/ui/util/CmsUiUtils.java
org.argeo.cms/src/org/argeo/cms/internal/kernel/SecurityProfile.java

diff --git a/org.argeo.api/src/org/argeo/api/NodeNames.java b/org.argeo.api/src/org/argeo/api/NodeNames.java
deleted file mode 100644 (file)
index b74069f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.api;
-
-/** JCR types in the http://www.argeo.org/node namespace */
-@Deprecated
-public interface NodeNames {
-       String LDAP_UID = "ldap:"+NodeConstants.UID;
-       String LDAP_CN = "ldap:"+NodeConstants.CN;
-}
diff --git a/org.argeo.api/src/org/argeo/api/NodeTypes.java b/org.argeo.api/src/org/argeo/api/NodeTypes.java
deleted file mode 100644 (file)
index ca41ad2..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.api;
-
-/** JCR types in the http://www.argeo.org/node namespace */
-@Deprecated
-public interface NodeTypes {
-       String NODE_USER_HOME = "node:userHome";
-       String NODE_GROUP_HOME = "node:groupHome";
-}
diff --git a/org.argeo.api/src/org/argeo/api/NodeUtils.java b/org.argeo.api/src/org/argeo/api/NodeUtils.java
deleted file mode 100644 (file)
index 0370511..0000000
+++ /dev/null
@@ -1,273 +0,0 @@
-package org.argeo.api;
-
-import java.security.PrivilegedAction;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-import javax.security.auth.AuthPermission;
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-/** Utilities related to Argeo model in JCR */
-public class NodeUtils {
-       /**
-        * Wraps the call to the repository factory based on parameter
-        * {@link NodeConstants#CN} in order to simplify it and protect against future
-        * API changes.
-        */
-       public static Repository getRepositoryByAlias(RepositoryFactory repositoryFactory, String alias) {
-               try {
-                       Map<String, String> parameters = new HashMap<String, String>();
-                       parameters.put(NodeConstants.CN, alias);
-                       return repositoryFactory.getRepository(parameters);
-               } catch (RepositoryException e) {
-                       throw new RuntimeException("Unexpected exception when trying to retrieve repository with alias " + alias,
-                                       e);
-               }
-       }
-
-       /**
-        * Wraps the call to the repository factory based on parameter
-        * {@link NodeConstants#LABELED_URI} in order to simplify it and protect against
-        * future API changes.
-        */
-       public static Repository getRepositoryByUri(RepositoryFactory repositoryFactory, String uri) {
-               return getRepositoryByUri(repositoryFactory, uri, null);
-       }
-
-       /**
-        * Wraps the call to the repository factory based on parameter
-        * {@link NodeConstants#LABELED_URI} in order to simplify it and protect against
-        * future API changes.
-        */
-       public static Repository getRepositoryByUri(RepositoryFactory repositoryFactory, String uri, String alias) {
-               try {
-                       Map<String, String> parameters = new HashMap<String, String>();
-                       parameters.put(NodeConstants.LABELED_URI, uri);
-                       if (alias != null)
-                               parameters.put(NodeConstants.CN, alias);
-                       return repositoryFactory.getRepository(parameters);
-               } catch (RepositoryException e) {
-                       throw new RuntimeException("Unexpected exception when trying to retrieve repository with uri " + uri, e);
-               }
-       }
-
-       /**
-        * Returns the home node of the user or null if none was found.
-        * 
-        * @param session  the session to use in order to perform the search, this can
-        *                 be a session with a different user ID than the one searched,
-        *                 typically when a system or admin session is used.
-        * @param username the username of the user
-        */
-       public static Node getUserHome(Session session, String username) {
-//             try {
-//                     QueryObjectModelFactory qomf = session.getWorkspace().getQueryManager().getQOMFactory();
-//                     Selector sel = qomf.selector(NodeTypes.NODE_USER_HOME, "sel");
-//                     DynamicOperand dop = qomf.propertyValue(sel.getSelectorName(), NodeNames.LDAP_UID);
-//                     StaticOperand sop = qomf.literal(session.getValueFactory().createValue(username));
-//                     Constraint constraint = qomf.comparison(dop, QueryObjectModelFactory.JCR_OPERATOR_EQUAL_TO, sop);
-//                     Query query = qomf.createQuery(sel, constraint, null, null);
-//                     return querySingleNode(query);
-//             } catch (RepositoryException e) {
-//                     throw new RuntimeException("Cannot find home for user " + username, e);
-//             }
-
-               try {
-                       checkUserWorkspace(session, username);
-                       String homePath = getHomePath(username);
-                       if (session.itemExists(homePath))
-                               return session.getNode(homePath);
-                       // legacy
-                       homePath = "/home/" + username;
-                       if (session.itemExists(homePath))
-                               return session.getNode(homePath);
-                       return null;
-               } catch (RepositoryException e) {
-                       throw new RuntimeException("Cannot find home for user " + username, e);
-               }
-       }
-
-       private static String getHomePath(String username) {
-               LdapName dn;
-               try {
-                       dn = new LdapName(username);
-               } catch (InvalidNameException e) {
-                       throw new IllegalArgumentException("Invalid name " + username, e);
-               }
-               String userId = dn.getRdn(dn.size() - 1).getValue().toString();
-               return '/' + userId;
-       }
-
-       private static void checkUserWorkspace(Session session, String username) {
-               String workspaceName = session.getWorkspace().getName();
-               if (!NodeConstants.HOME_WORKSPACE.equals(workspaceName))
-                       throw new IllegalArgumentException(workspaceName + " is not the home workspace for user " + username);
-       }
-
-       /**
-        * Returns the home node of the user or null if none was found.
-        * 
-        * @param session   the session to use in order to perform the search, this can
-        *                  be a session with a different user ID than the one searched,
-        *                  typically when a system or admin session is used.
-        * @param groupname the name of the group
-        */
-       public static Node getGroupHome(Session session, String groupname) {
-//             try {
-//                     QueryObjectModelFactory qomf = session.getWorkspace().getQueryManager().getQOMFactory();
-//                     Selector sel = qomf.selector(NodeTypes.NODE_GROUP_HOME, "sel");
-//                     DynamicOperand dop = qomf.propertyValue(sel.getSelectorName(), NodeNames.LDAP_CN);
-//                     StaticOperand sop = qomf.literal(session.getValueFactory().createValue(cn));
-//                     Constraint constraint = qomf.comparison(dop, QueryObjectModelFactory.JCR_OPERATOR_EQUAL_TO, sop);
-//                     Query query = qomf.createQuery(sel, constraint, null, null);
-//                     return querySingleNode(query);
-//             } catch (RepositoryException e) {
-//                     throw new RuntimeException("Cannot find home for group " + cn, e);
-//             }
-
-               try {
-                       checkGroupWorkspace(session, groupname);
-                       String homePath = getGroupPath(groupname);
-                       if (session.itemExists(homePath))
-                               return session.getNode(homePath);
-                       // legacy
-                       homePath = "/groups/" + groupname;
-                       if (session.itemExists(homePath))
-                               return session.getNode(homePath);
-                       return null;
-               } catch (RepositoryException e) {
-                       throw new RuntimeException("Cannot find home for group " + groupname, e);
-               }
-
-       }
-
-       private static String getGroupPath(String groupname) {
-               String cn;
-               try {
-                       LdapName dn = new LdapName(groupname);
-                       cn = dn.getRdn(dn.size() - 1).getValue().toString();
-               } catch (InvalidNameException e) {
-                       cn = groupname;
-               }
-               return '/' + cn;
-       }
-
-       private static void checkGroupWorkspace(Session session, String groupname) {
-               String workspaceName = session.getWorkspace().getName();
-               if (!NodeConstants.SRV_WORKSPACE.equals(workspaceName))
-                       throw new IllegalArgumentException(workspaceName + " is not the group workspace for group " + groupname);
-       }
-
-       /**
-        * Queries one single node.
-        * 
-        * @return one single node or null if none was found
-        * @throws ArgeoJcrException if more than one node was found
-        */
-//     private static Node querySingleNode(Query query) {
-//             NodeIterator nodeIterator;
-//             try {
-//                     QueryResult queryResult = query.execute();
-//                     nodeIterator = queryResult.getNodes();
-//             } catch (RepositoryException e) {
-//                     throw new RuntimeException("Cannot execute query " + query, e);
-//             }
-//             Node node;
-//             if (nodeIterator.hasNext())
-//                     node = nodeIterator.nextNode();
-//             else
-//                     return null;
-//
-//             if (nodeIterator.hasNext())
-//                     throw new RuntimeException("Query returned more than one node.");
-//             return node;
-//     }
-
-       /** Returns the home node of the session user or null if none was found. */
-       public static Node getUserHome(Session session) {
-               String userID = session.getUserID();
-               return getUserHome(session, userID);
-       }
-
-       /** Whether this node is the home of the user of the underlying session. */
-       public static boolean isUserHome(Node node) {
-               try {
-                       String userID = node.getSession().getUserID();
-                       return node.hasProperty(Property.JCR_ID) && node.getProperty(Property.JCR_ID).getString().equals(userID);
-               } catch (RepositoryException e) {
-                       throw new IllegalStateException(e);
-               }
-       }
-
-       /**
-        * Translate the path to this node into a path containing the name of the
-        * repository and the name of the workspace.
-        */
-       public static String getDataPath(String cn, Node node) {
-               assert node != null;
-               StringBuilder buf = new StringBuilder(NodeConstants.PATH_DATA);
-               try {
-                       return buf.append('/').append(cn).append('/').append(node.getSession().getWorkspace().getName())
-                                       .append(node.getPath()).toString();
-               } catch (RepositoryException e) {
-                       throw new IllegalStateException("Cannot get data path for " + node + " in repository " + cn, e);
-               }
-       }
-
-       /**
-        * Translate the path to this node into a path containing the name of the
-        * repository and the name of the workspace.
-        */
-       public static String getDataPath(Node node) {
-               return getDataPath(NodeConstants.NODE, node);
-       }
-
-       /**
-        * Open a JCR session with full read/write rights on the data, as
-        * {@link NodeConstants#ROLE_USER_ADMIN}, using the
-        * {@link NodeConstants#LOGIN_CONTEXT_DATA_ADMIN} login context. For security
-        * hardened deployement, use {@link AuthPermission} on this login context.
-        */
-       public static Session openDataAdminSession(Repository repository, String workspaceName) {
-               ClassLoader currentCl = Thread.currentThread().getContextClassLoader();
-               LoginContext loginContext;
-               try {
-                       loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN);
-                       loginContext.login();
-               } catch (LoginException e1) {
-                       throw new RuntimeException("Could not login as data admin", e1);
-               } finally {
-                       Thread.currentThread().setContextClassLoader(currentCl);
-               }
-               return Subject.doAs(loginContext.getSubject(), new PrivilegedAction<Session>() {
-
-                       @Override
-                       public Session run() {
-                               try {
-                                       return repository.login(workspaceName);
-                               } catch (NoSuchWorkspaceException e) {
-                                       throw new IllegalArgumentException("No workspace " + workspaceName + " available", e);
-                               } catch (RepositoryException e) {
-                                       throw new RuntimeException("Cannot open data admin session", e);
-                               }
-                       }
-
-               });
-       }
-
-       /** Singleton. */
-       private NodeUtils() {
-       }
-
-}
index 1eb6daef152b867332ce24bef9a9e799846e8ab3..cb9f9b97a474e68bf5fd3215067f8be0cccba967 100644 (file)
@@ -9,8 +9,8 @@ import java.nio.file.spi.FileSystemProvider;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 
-import org.argeo.api.NodeUtils;
 import org.argeo.cms.CmsException;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.eclipse.ui.fs.AdvancedFsBrowser;
 import org.argeo.eclipse.ui.fs.SimpleFsBrowser;
 import org.eclipse.swt.SWT;
index 7b1e19d062fd185dc5d5082a46a9b894090cfecf..cf7aac86a0fe0b05d432382f19a4eb5d7d520f3c 100644 (file)
@@ -12,11 +12,11 @@ import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 
 import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
 import org.argeo.api.security.Keyring;
 import org.argeo.cms.ArgeoNames;
 import org.argeo.cms.ArgeoTypes;
 import org.argeo.cms.e4.jcr.JcrBrowserView;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.eclipse.ui.EclipseUiException;
 import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
 import org.argeo.jcr.JcrUtils;
@@ -156,7 +156,7 @@ public class AddRemoteRepository {
                        Session nodeSession = null;
                        try {
                                nodeSession = nodeRepository.login();
-                               Node home = NodeUtils.getUserHome(nodeSession);
+                               Node home = CmsJcrUtils.getUserHome(nodeSession);
 
                                Node remote = home.hasNode(ArgeoNames.ARGEO_REMOTE) ? home.getNode(ArgeoNames.ARGEO_REMOTE)
                                                : home.addNode(ArgeoNames.ARGEO_REMOTE);
index 9ba7af72f32b698af229430d333881f500c091e3..708a653159f7befb3639a3fabb582478d64b4873 100644 (file)
@@ -20,13 +20,13 @@ import javax.naming.ldap.LdapName;
 
 import org.argeo.api.NodeConstants;
 import org.argeo.api.NodeInstance;
-import org.argeo.api.NodeUtils;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.auth.UserAdminUtils;
 import org.argeo.cms.e4.users.providers.CommonNameLP;
 import org.argeo.cms.e4.users.providers.MailLP;
 import org.argeo.cms.e4.users.providers.RoleIconLP;
 import org.argeo.cms.e4.users.providers.UserFilter;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.ui.eclipse.forms.AbstractFormPart;
 import org.argeo.cms.ui.eclipse.forms.IManagedForm;
 import org.argeo.cms.ui.util.CmsUiUtils;
@@ -197,7 +197,7 @@ public class GroupEditor extends AbstractRoleEditor {
                                // dnTxt.setText(group.getName());
                                // cnTxt.setText(UserAdminUtils.getProperty(group, LdapAttrs.cn.name()));
                                descTxt.setText(UserAdminUtils.getProperty(group, LdapAttrs.description.name()));
-                               Node workgroupHome = NodeUtils.getGroupHome(groupsSession, cn);
+                               Node workgroupHome = CmsJcrUtils.getGroupHome(groupsSession, cn);
                                if (workgroupHome == null)
                                        markAsWorkgroupLk.setText("<a>Mark as workgroup</a>");
                                else
@@ -216,7 +216,7 @@ public class GroupEditor extends AbstractRoleEditor {
                                boolean confirmed = MessageDialog.openConfirm(parent.getShell(), "Mark as workgroup",
                                                "Are you sure you want to mark " + cn + " as being a workgroup? ");
                                if (confirmed) {
-                                       Node workgroupHome = NodeUtils.getGroupHome(groupsSession, cn);
+                                       Node workgroupHome = CmsJcrUtils.getGroupHome(groupsSession, cn);
                                        if (workgroupHome != null)
                                                return; // already marked as workgroup, do nothing
                                        else
diff --git a/org.argeo.cms.jcr/src/org/argeo/cms/jcr/CmsJcrUtils.java b/org.argeo.cms.jcr/src/org/argeo/cms/jcr/CmsJcrUtils.java
new file mode 100644 (file)
index 0000000..ff128a2
--- /dev/null
@@ -0,0 +1,275 @@
+package org.argeo.cms.jcr;
+
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.naming.InvalidNameException;
+import javax.naming.ldap.LdapName;
+import javax.security.auth.AuthPermission;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.argeo.api.NodeConstants;
+
+/** Utilities related to Argeo model in JCR */
+public class CmsJcrUtils {
+       /**
+        * Wraps the call to the repository factory based on parameter
+        * {@link NodeConstants#CN} in order to simplify it and protect against future
+        * API changes.
+        */
+       public static Repository getRepositoryByAlias(RepositoryFactory repositoryFactory, String alias) {
+               try {
+                       Map<String, String> parameters = new HashMap<String, String>();
+                       parameters.put(NodeConstants.CN, alias);
+                       return repositoryFactory.getRepository(parameters);
+               } catch (RepositoryException e) {
+                       throw new RuntimeException("Unexpected exception when trying to retrieve repository with alias " + alias,
+                                       e);
+               }
+       }
+
+       /**
+        * Wraps the call to the repository factory based on parameter
+        * {@link NodeConstants#LABELED_URI} in order to simplify it and protect against
+        * future API changes.
+        */
+       public static Repository getRepositoryByUri(RepositoryFactory repositoryFactory, String uri) {
+               return getRepositoryByUri(repositoryFactory, uri, null);
+       }
+
+       /**
+        * Wraps the call to the repository factory based on parameter
+        * {@link NodeConstants#LABELED_URI} in order to simplify it and protect against
+        * future API changes.
+        */
+       public static Repository getRepositoryByUri(RepositoryFactory repositoryFactory, String uri, String alias) {
+               try {
+                       Map<String, String> parameters = new HashMap<String, String>();
+                       parameters.put(NodeConstants.LABELED_URI, uri);
+                       if (alias != null)
+                               parameters.put(NodeConstants.CN, alias);
+                       return repositoryFactory.getRepository(parameters);
+               } catch (RepositoryException e) {
+                       throw new RuntimeException("Unexpected exception when trying to retrieve repository with uri " + uri, e);
+               }
+       }
+
+       /**
+        * Returns the home node of the user or null if none was found.
+        * 
+        * @param session  the session to use in order to perform the search, this can
+        *                 be a session with a different user ID than the one searched,
+        *                 typically when a system or admin session is used.
+        * @param username the username of the user
+        */
+       public static Node getUserHome(Session session, String username) {
+//             try {
+//                     QueryObjectModelFactory qomf = session.getWorkspace().getQueryManager().getQOMFactory();
+//                     Selector sel = qomf.selector(NodeTypes.NODE_USER_HOME, "sel");
+//                     DynamicOperand dop = qomf.propertyValue(sel.getSelectorName(), NodeNames.LDAP_UID);
+//                     StaticOperand sop = qomf.literal(session.getValueFactory().createValue(username));
+//                     Constraint constraint = qomf.comparison(dop, QueryObjectModelFactory.JCR_OPERATOR_EQUAL_TO, sop);
+//                     Query query = qomf.createQuery(sel, constraint, null, null);
+//                     return querySingleNode(query);
+//             } catch (RepositoryException e) {
+//                     throw new RuntimeException("Cannot find home for user " + username, e);
+//             }
+
+               try {
+                       checkUserWorkspace(session, username);
+                       String homePath = getHomePath(username);
+                       if (session.itemExists(homePath))
+                               return session.getNode(homePath);
+                       // legacy
+                       homePath = "/home/" + username;
+                       if (session.itemExists(homePath))
+                               return session.getNode(homePath);
+                       return null;
+               } catch (RepositoryException e) {
+                       throw new RuntimeException("Cannot find home for user " + username, e);
+               }
+       }
+
+       private static String getHomePath(String username) {
+               LdapName dn;
+               try {
+                       dn = new LdapName(username);
+               } catch (InvalidNameException e) {
+                       throw new IllegalArgumentException("Invalid name " + username, e);
+               }
+               String userId = dn.getRdn(dn.size() - 1).getValue().toString();
+               return '/' + userId;
+       }
+
+       private static void checkUserWorkspace(Session session, String username) {
+               String workspaceName = session.getWorkspace().getName();
+               if (!NodeConstants.HOME_WORKSPACE.equals(workspaceName))
+                       throw new IllegalArgumentException(workspaceName + " is not the home workspace for user " + username);
+       }
+
+       /**
+        * Returns the home node of the user or null if none was found.
+        * 
+        * @param session   the session to use in order to perform the search, this can
+        *                  be a session with a different user ID than the one searched,
+        *                  typically when a system or admin session is used.
+        * @param groupname the name of the group
+        */
+       public static Node getGroupHome(Session session, String groupname) {
+//             try {
+//                     QueryObjectModelFactory qomf = session.getWorkspace().getQueryManager().getQOMFactory();
+//                     Selector sel = qomf.selector(NodeTypes.NODE_GROUP_HOME, "sel");
+//                     DynamicOperand dop = qomf.propertyValue(sel.getSelectorName(), NodeNames.LDAP_CN);
+//                     StaticOperand sop = qomf.literal(session.getValueFactory().createValue(cn));
+//                     Constraint constraint = qomf.comparison(dop, QueryObjectModelFactory.JCR_OPERATOR_EQUAL_TO, sop);
+//                     Query query = qomf.createQuery(sel, constraint, null, null);
+//                     return querySingleNode(query);
+//             } catch (RepositoryException e) {
+//                     throw new RuntimeException("Cannot find home for group " + cn, e);
+//             }
+
+               try {
+                       checkGroupWorkspace(session, groupname);
+                       String homePath = getGroupPath(groupname);
+                       if (session.itemExists(homePath))
+                               return session.getNode(homePath);
+                       // legacy
+                       homePath = "/groups/" + groupname;
+                       if (session.itemExists(homePath))
+                               return session.getNode(homePath);
+                       return null;
+               } catch (RepositoryException e) {
+                       throw new RuntimeException("Cannot find home for group " + groupname, e);
+               }
+
+       }
+
+       private static String getGroupPath(String groupname) {
+               String cn;
+               try {
+                       LdapName dn = new LdapName(groupname);
+                       cn = dn.getRdn(dn.size() - 1).getValue().toString();
+               } catch (InvalidNameException e) {
+                       cn = groupname;
+               }
+               return '/' + cn;
+       }
+
+       private static void checkGroupWorkspace(Session session, String groupname) {
+               String workspaceName = session.getWorkspace().getName();
+               if (!NodeConstants.SRV_WORKSPACE.equals(workspaceName))
+                       throw new IllegalArgumentException(workspaceName + " is not the group workspace for group " + groupname);
+       }
+
+       /**
+        * Queries one single node.
+        * 
+        * @return one single node or null if none was found
+        * @throws ArgeoJcrException if more than one node was found
+        */
+//     private static Node querySingleNode(Query query) {
+//             NodeIterator nodeIterator;
+//             try {
+//                     QueryResult queryResult = query.execute();
+//                     nodeIterator = queryResult.getNodes();
+//             } catch (RepositoryException e) {
+//                     throw new RuntimeException("Cannot execute query " + query, e);
+//             }
+//             Node node;
+//             if (nodeIterator.hasNext())
+//                     node = nodeIterator.nextNode();
+//             else
+//                     return null;
+//
+//             if (nodeIterator.hasNext())
+//                     throw new RuntimeException("Query returned more than one node.");
+//             return node;
+//     }
+
+       /** Returns the home node of the session user or null if none was found. */
+       public static Node getUserHome(Session session) {
+               String userID = session.getUserID();
+               return getUserHome(session, userID);
+       }
+
+       /** Whether this node is the home of the user of the underlying session. */
+       public static boolean isUserHome(Node node) {
+               try {
+                       String userID = node.getSession().getUserID();
+                       return node.hasProperty(Property.JCR_ID) && node.getProperty(Property.JCR_ID).getString().equals(userID);
+               } catch (RepositoryException e) {
+                       throw new IllegalStateException(e);
+               }
+       }
+
+       /**
+        * Translate the path to this node into a path containing the name of the
+        * repository and the name of the workspace.
+        */
+       public static String getDataPath(String cn, Node node) {
+               assert node != null;
+               StringBuilder buf = new StringBuilder(NodeConstants.PATH_DATA);
+               try {
+                       return buf.append('/').append(cn).append('/').append(node.getSession().getWorkspace().getName())
+                                       .append(node.getPath()).toString();
+               } catch (RepositoryException e) {
+                       throw new IllegalStateException("Cannot get data path for " + node + " in repository " + cn, e);
+               }
+       }
+
+       /**
+        * Translate the path to this node into a path containing the name of the
+        * repository and the name of the workspace.
+        */
+       public static String getDataPath(Node node) {
+               return getDataPath(NodeConstants.NODE, node);
+       }
+
+       /**
+        * Open a JCR session with full read/write rights on the data, as
+        * {@link NodeConstants#ROLE_USER_ADMIN}, using the
+        * {@link NodeConstants#LOGIN_CONTEXT_DATA_ADMIN} login context. For security
+        * hardened deployement, use {@link AuthPermission} on this login context.
+        */
+       public static Session openDataAdminSession(Repository repository, String workspaceName) {
+               ClassLoader currentCl = Thread.currentThread().getContextClassLoader();
+               LoginContext loginContext;
+               try {
+                       loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN);
+                       loginContext.login();
+               } catch (LoginException e1) {
+                       throw new RuntimeException("Could not login as data admin", e1);
+               } finally {
+                       Thread.currentThread().setContextClassLoader(currentCl);
+               }
+               return Subject.doAs(loginContext.getSubject(), new PrivilegedAction<Session>() {
+
+                       @Override
+                       public Session run() {
+                               try {
+                                       return repository.login(workspaceName);
+                               } catch (NoSuchWorkspaceException e) {
+                                       throw new IllegalArgumentException("No workspace " + workspaceName + " available", e);
+                               } catch (RepositoryException e) {
+                                       throw new RuntimeException("Cannot open data admin session", e);
+                               }
+                       }
+
+               });
+       }
+
+       /** Singleton. */
+       private CmsJcrUtils() {
+       }
+
+}
index 704adf15fc0bd7f49d23366d33ec9b2c96a03305..bfbca733ef653b9751e746568158b6e34aa8e91b 100644 (file)
@@ -19,8 +19,8 @@ import javax.jcr.Session;
 import javax.jcr.nodetype.NodeType;
 
 import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
 import org.argeo.cms.auth.CurrentUser;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.jackrabbit.fs.AbstractJackrabbitFsProvider;
 import org.argeo.jcr.fs.JcrFileSystem;
 import org.argeo.jcr.fs.JcrFileSystemProvider;
@@ -54,7 +54,7 @@ public class CmsFsProvider extends AbstractJackrabbitFsProvider {
                        if (host != null && !host.trim().equals("")) {
                                URI repoUri = new URI("http", uri.getUserInfo(), uri.getHost(), uri.getPort(), "/jcr/node", null, null);
                                RepositoryFactory repositoryFactory = bc.getService(bc.getServiceReference(RepositoryFactory.class));
-                               Repository repository = NodeUtils.getRepositoryByUri(repositoryFactory, repoUri.toString());
+                               Repository repository = CmsJcrUtils.getRepositoryByUri(repositoryFactory, repoUri.toString());
                                CmsFileSystem fileSystem = new CmsFileSystem(this, repository);
                                fileSystems.put(username, fileSystem);
                                return fileSystem;
@@ -98,7 +98,7 @@ public class CmsFsProvider extends AbstractJackrabbitFsProvider {
        public Node getUserHome(Repository repository) {
                try {
                        Session session = repository.login(NodeConstants.HOME_WORKSPACE);
-                       return NodeUtils.getUserHome(session);
+                       return CmsJcrUtils.getUserHome(session);
                } catch (RepositoryException e) {
                        throw new IllegalStateException("Cannot get user home", e);
                }
index 68bfce8d8b788f4bad4faa1eb4bfe960078423a0..368c3ba52c84d6de37605c17a0106986f13138a1 100644 (file)
@@ -18,8 +18,8 @@ import javax.security.auth.Subject;
 import javax.security.auth.login.LoginContext;
 
 import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
 import org.argeo.cms.CmsException;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.jcr.JcrException;
 import org.argeo.jcr.JcrRepositoryWrapper;
 import org.argeo.jcr.JcrUtils;
@@ -159,7 +159,7 @@ class EgoRepository extends JcrRepositoryWrapper implements KernelConstants {
                        return;
 
                try {
-                       Node userHome = NodeUtils.getUserHome(adminSession, username);
+                       Node userHome = CmsJcrUtils.getUserHome(adminSession, username);
                        if (userHome == null) {
 //                             String homePath = generateUserPath(username);
                                String userId = extractUserId(username);
@@ -229,7 +229,7 @@ class EgoRepository extends JcrRepositoryWrapper implements KernelConstants {
                String groupsWorkspace = getGroupsWorkspace();
                Session adminSession = KernelUtils.openAdminSession(getRepository(groupsWorkspace), groupsWorkspace);
                String cn = dn.getRdn(dn.size() - 1).getValue().toString();
-               Node newWorkgroup = NodeUtils.getGroupHome(adminSession, cn);
+               Node newWorkgroup = CmsJcrUtils.getGroupHome(adminSession, cn);
                if (newWorkgroup != null) {
                        JcrUtils.logoutQuietly(adminSession);
                        throw new CmsException("Workgroup " + newWorkgroup + " already exists for " + dn);
index d0fa841e0967cd9dc5e333f3077f7b55cf327b7f..0daaad47c95f830503c6434a75f8a6acea26e4a0 100644 (file)
@@ -34,11 +34,11 @@ import org.apache.jackrabbit.core.RepositoryImpl;
 import org.argeo.api.DataModelNamespace;
 import org.argeo.api.NodeConstants;
 import org.argeo.api.NodeDeployment;
-import org.argeo.api.NodeUtils;
 import org.argeo.api.security.CryptoKeyring;
 import org.argeo.api.security.Keyring;
 import org.argeo.cms.ArgeoNames;
 import org.argeo.cms.internal.jcr.JcrInitUtils;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.jcr.internal.servlet.CmsRemotingServlet;
 import org.argeo.cms.jcr.internal.servlet.CmsWebDavServlet;
 import org.argeo.cms.jcr.internal.servlet.JcrHttpUtils;
@@ -193,15 +193,15 @@ public class JcrDeployment {
                                Session sourceSession = null;
                                try {
                                        try {
-                                               targetSession = NodeUtils.openDataAdminSession(deployedNodeRepository, workspaceName);
+                                               targetSession = CmsJcrUtils.openDataAdminSession(deployedNodeRepository, workspaceName);
                                        } catch (IllegalArgumentException e) {// no such workspace
-                                               Session adminSession = NodeUtils.openDataAdminSession(deployedNodeRepository, null);
+                                               Session adminSession = CmsJcrUtils.openDataAdminSession(deployedNodeRepository, null);
                                                try {
                                                        adminSession.getWorkspace().createWorkspace(workspaceName);
                                                } finally {
                                                        Jcr.logout(adminSession);
                                                }
-                                               targetSession = NodeUtils.openDataAdminSession(deployedNodeRepository, workspaceName);
+                                               targetSession = CmsJcrUtils.openDataAdminSession(deployedNodeRepository, workspaceName);
                                        }
                                        sourceSession = initRepository.login(workspaceName);
 //                                     JcrUtils.copyWorkspaceXml(sourceSession, targetSession);
index ce658b8f82a2de19bbd26d08e16983bc2f5360ec..11a68ce24612ca55a6e4399b499dc8d9b546969f 100644 (file)
@@ -29,10 +29,10 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
 import org.argeo.api.security.PBEKeySpecCallback;
 import org.argeo.cms.ArgeoNames;
 import org.argeo.cms.ArgeoTypes;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.security.AbstractKeyring;
 import org.argeo.jcr.JcrException;
 import org.argeo.jcr.JcrUtils;
@@ -110,7 +110,7 @@ public class JcrKeyring extends AbstractKeyring implements ArgeoNames {
                        // return true;
                        session = session();
                        session.refresh(true);
-                       Node userHome = NodeUtils.getUserHome(session);
+                       Node userHome = CmsJcrUtils.getUserHome(session);
                        return userHome.hasNode(ARGEO_KEYRING);
                } catch (RepositoryException e) {
                        throw new JcrException("Cannot check whether keyring is setup", e);
@@ -125,7 +125,7 @@ public class JcrKeyring extends AbstractKeyring implements ArgeoNames {
                // InputStream in = null;
                try {
                        session().refresh(true);
-                       Node userHome = NodeUtils.getUserHome(session());
+                       Node userHome = CmsJcrUtils.getUserHome(session());
                        Node keyring;
                        if (userHome.hasNode(ARGEO_KEYRING)) {
                                throw new IllegalArgumentException("Keyring already set up");
@@ -187,7 +187,7 @@ public class JcrKeyring extends AbstractKeyring implements ArgeoNames {
                try {
                        session = session();
                        session.refresh(true);
-                       Node userHome = NodeUtils.getUserHome(session);
+                       Node userHome = CmsJcrUtils.getUserHome(session);
                        Node keyring;
                        if (userHome.hasNode(ARGEO_KEYRING))
                                keyring = userHome.getNode(ARGEO_KEYRING);
@@ -326,7 +326,7 @@ public class JcrKeyring extends AbstractKeyring implements ArgeoNames {
 
        protected Cipher createCipher() {
                try {
-                       Node userHome = NodeUtils.getUserHome(session());
+                       Node userHome = CmsJcrUtils.getUserHome(session());
                        if (!userHome.hasNode(ARGEO_KEYRING))
                                throw new IllegalArgumentException("Keyring not setup");
                        Node keyring = userHome.getNode(ARGEO_KEYRING);
index 1ddfc34e42830aef03c3ed31783ad41a7b07d3f5..feaa00f303b18835afa7d87d0984d335749f82f9 100644 (file)
@@ -26,8 +26,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
 import org.argeo.cms.CmsException;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.jcr.JcrUtils;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
@@ -196,7 +196,7 @@ public class LinkServlet extends HttpServlet {
        private String getDataUrl(Node node, HttpServletRequest request) throws RepositoryException {
                try {
                        StringBuilder buf = getServerBaseUrl(request);
-                       buf.append(NodeUtils.getDataPath(NodeConstants.EGO_REPOSITORY, node));
+                       buf.append(CmsJcrUtils.getDataPath(NodeConstants.EGO_REPOSITORY, node));
                        return new URL(buf.toString()).toString();
                } catch (MalformedURLException e) {
                        throw new CmsException("Cannot build data URL for " + node, e);
index ae09cd4bfdbaf1fa77e4ad9bce345392e191dcf5..804ab975886b9f211a4f800081fafea55d6a69e7 100644 (file)
@@ -12,7 +12,7 @@ import javax.jcr.Session;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeUtils;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.jcr.Jcr;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.naming.Distinguished;
@@ -47,10 +47,10 @@ public abstract class AbstractMaintenanceService {
        protected void configureJcr(Repository repository, String workspaceName) {
                Session adminSession;
                try {
-                       adminSession = NodeUtils.openDataAdminSession(repository, workspaceName);
+                       adminSession = CmsJcrUtils.openDataAdminSession(repository, workspaceName);
                } catch (RuntimeException e1) {
                        if (e1.getCause() != null && e1.getCause() instanceof NoSuchWorkspaceException) {
-                               Session defaultAdminSession = NodeUtils.openDataAdminSession(repository, null);
+                               Session defaultAdminSession = CmsJcrUtils.openDataAdminSession(repository, null);
                                try {
                                        defaultAdminSession.getWorkspace().createWorkspace(workspaceName);
                                        log.info("Created JCR workspace " + workspaceName);
@@ -59,7 +59,7 @@ public abstract class AbstractMaintenanceService {
                                } finally {
                                        Jcr.logout(defaultAdminSession);
                                }
-                               adminSession = NodeUtils.openDataAdminSession(repository, workspaceName);
+                               adminSession = CmsJcrUtils.openDataAdminSession(repository, workspaceName);
                        } else
                                throw e1;
                }
index 60e8f8e5d89d13ec5cbceb728aa8a6f33a16e0f6..c2a3582e79c5ed774807bee80e3ed8b4695a8943 100644 (file)
@@ -46,7 +46,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.JackrabbitValue;
 import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.jackrabbit.client.ClientDavexRepositoryFactory;
 import org.argeo.jcr.Jcr;
 import org.argeo.jcr.JcrException;
@@ -333,7 +333,7 @@ public class LogicalBackup implements Runnable {
 
        protected Session login(String workspaceName) {
                if (bundleContext != null) {// local
-                       return NodeUtils.openDataAdminSession(repository, workspaceName);
+                       return CmsJcrUtils.openDataAdminSession(repository, workspaceName);
                } else {// remote
                        try {
                                return repository.login(workspaceName);
index a12bb41c907204c122dcf02be9a1032d0a88116e..057a126106d72064c2ba458521f6cbe1e70dd815 100644 (file)
@@ -14,7 +14,7 @@ import javax.jcr.Session;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.jcr.Jcr;
 import org.argeo.jcr.JcrException;
 import org.argeo.jcr.JcrUtils;
index 7f5c929e530bd34fa106372538f1dbd1e4b13618..8ac12f02fb3f981248173b438dd321fbdf096820 100644 (file)
@@ -1,5 +1,6 @@
 Import-Package:\
 org.eclipse.swt,\
+org.argeo.api,\
 org.argeo.eclipse.ui,\
 javax.jcr.nodetype,\
 javax.jcr.security,\
index fd893106a0affaaea4d43744656aa0f290a1681b..4cd6874d0f35a6d59f0ab66ed79361337f7f3392 100644 (file)
@@ -23,8 +23,8 @@ import javax.jcr.version.VersionManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
 import org.argeo.cms.CmsException;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.ui.CmsConstants;
 import org.argeo.cms.ui.CmsUiProvider;
 import org.argeo.cms.ui.LifeCycleUiProvider;
@@ -174,7 +174,7 @@ public class SimpleApp implements CmsConstants, ApplicationConfiguration {
        public void init() throws RepositoryException {
                Session session = null;
                try {
-                       session = NodeUtils.openDataAdminSession(repository, workspace);
+                       session = CmsJcrUtils.openDataAdminSession(repository, workspace);
                        // session = JcrUtils.loginOrCreateWorkspace(repository, workspace);
                        VersionManager vm = session.getWorkspace().getVersionManager();
                        JcrUtils.mkdirs(session, jcrBasePath);
index 4e0067521d4c70d7ff057b1b6f52707c004f2f79..4a7e9bd3fb8dc3cc7702af54c4a7aca83e7ffec5 100644 (file)
@@ -18,9 +18,9 @@ import javax.jcr.Node;
 import javax.jcr.Repository;
 import javax.jcr.Session;
 
-import org.argeo.api.NodeUtils;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.auth.CurrentUser;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.ui.util.CmsUiUtils;
 import org.argeo.eclipse.ui.ColumnDefinition;
 import org.argeo.eclipse.ui.EclipseUiUtils;
@@ -98,7 +98,7 @@ public class CmsFsBrowser extends Composite {
                try {
                        Repository repo = currentBaseContext.getSession().getRepository();
                        session = CurrentUser.tryAs(() -> repo.login());
-                       String homepath = NodeUtils.getUserHome(session).getPath();
+                       String homepath = CmsJcrUtils.getUserHome(session).getPath();
                        return homepath;
                } catch (Exception e) {
                        throw new CmsException("Cannot retrieve Current User Home Path", e);
index bfce888bc7433cade051c18d9948b48f170eec65..602ae7f6c8073a35237b2eb47d76d4c29e48e9c1 100644 (file)
@@ -12,8 +12,8 @@ import javax.jcr.Session;
 import javax.jcr.nodetype.NodeType;
 
 import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
 import org.argeo.api.security.Keyring;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.ui.jcr.model.RepositoriesElem;
 import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
 import org.argeo.eclipse.ui.TreeParent;
@@ -56,7 +56,7 @@ public class NodeContentProvider implements ITreeContentProvider {
                        return;
 
                if (userSession != null) {
-                       Node userHome = NodeUtils.getUserHome(userSession);
+                       Node userHome = CmsJcrUtils.getUserHome(userSession);
                        if (userHome != null) {
                                // TODO : find a way to dynamically get alias for the node
                                if (homeNode != null)
index 27cfbbb1da5076687120d710da12f1e2e07dd3cf..3c035fc7766d7064905516efb22ff670d2ab9063 100644 (file)
@@ -9,9 +9,9 @@ import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 
-import org.argeo.api.NodeUtils;
 import org.argeo.api.security.Keyring;
 import org.argeo.cms.ArgeoNames;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.eclipse.ui.EclipseUiException;
 import org.argeo.eclipse.ui.TreeParent;
 
@@ -59,7 +59,7 @@ public class RemoteRepositoryElem extends RepositoryElem {
        @Override
        public Repository getRepository() {
                if (repository == null)
-                       repository = NodeUtils.getRepositoryByUri(repositoryFactory, uri);
+                       repository = CmsJcrUtils.getRepositoryByUri(repositoryFactory, uri);
                return super.getRepository();
        }
 
index 54bb469a36fd6609a63a04a79a9dde46203cbcc9..f5306d639ed1225ee7581a1790db37136ce67c8b 100644 (file)
@@ -9,9 +9,9 @@ import javax.jcr.RepositoryException;
 import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 
-import org.argeo.api.NodeUtils;
 import org.argeo.api.security.Keyring;
 import org.argeo.cms.ArgeoNames;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.ui.jcr.RepositoryRegister;
 import org.argeo.eclipse.ui.EclipseUiException;
 import org.argeo.eclipse.ui.TreeParent;
@@ -81,7 +81,7 @@ public class RepositoriesElem extends TreeParent implements ArgeoNames {
        }
 
        protected void addRemoteRepositories(Keyring jcrKeyring) throws RepositoryException {
-               Node userHome = NodeUtils.getUserHome(userSession);
+               Node userHome = CmsJcrUtils.getUserHome(userSession);
                if (userHome != null && userHome.hasNode(ARGEO_REMOTE)) {
                        NodeIterator it = userHome.getNode(ARGEO_REMOTE).getNodes();
                        while (it.hasNext()) {
index 4cad1de60fa74eb2f2fb487a6bd6dd008d5b7b63..33772bc8ed1ae88fb9e07d559939e100fcc523b2 100644 (file)
@@ -10,8 +10,8 @@ import javax.jcr.RepositoryException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeUtils;
 import org.argeo.cms.auth.CurrentUser;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.ui.CmsUiProvider;
 import org.argeo.jcr.JcrException;
 import org.eclipse.rap.rwt.RWT;
@@ -113,7 +113,7 @@ public class CmsLink implements CmsUiProvider {
                        labelText.append("<a style='color:inherit;text-decoration:inherit;' href=\"");
                        if (loggedInTarget.equals("")) {
                                try {
-                                       Node homeNode = NodeUtils.getUserHome(context.getSession());
+                                       Node homeNode = CmsJcrUtils.getUserHome(context.getSession());
                                        String homePath = homeNode.getPath();
                                        labelText.append("/#" + homePath);
                                } catch (RepositoryException e) {
index b90c017d9ac653f586f05149d325c56d42b53d80..2bfeb43cfb593e7f62e6686acfe3cc55d308576c 100644 (file)
@@ -15,7 +15,7 @@ import javax.jcr.RepositoryException;
 import javax.servlet.http.HttpServletRequest;
 
 import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
+import org.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.cms.ui.CmsConstants;
 import org.argeo.cms.ui.CmsView;
 import org.argeo.eclipse.ui.Selected;
@@ -115,7 +115,7 @@ public class CmsUiUtils implements CmsConstants {
        }
 
        public static String getDataPath(String cn, Node node) throws RepositoryException {
-               return NodeUtils.getDataPath(cn, node);
+               return CmsJcrUtils.getDataPath(cn, node);
        }
 
        /** Clean reserved URL characters for use in HTTP links. */
index 127cb9a8a6207928f3b93f2475629c7e4ef951e4..34ec9bcbaab4ceb2f39543b2538b2531994cab09 100644 (file)
@@ -8,7 +8,6 @@ import java.util.PropertyPermission;
 
 import javax.security.auth.AuthPermission;
 
-import org.argeo.api.NodeUtils;
 import org.osgi.framework.AdminPermission;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -30,13 +29,13 @@ public interface SecurityProfile {
        default void applySystemPermissions(ConditionalPermissionAdmin permissionAdmin) {
                ConditionalPermissionUpdate update = permissionAdmin.newConditionalPermissionUpdate();
                // Self
-               String nodeAPiBundleLocation = locate(NodeUtils.class);
-               update.getConditionalPermissionInfos()
-                               .add(permissionAdmin.newConditionalPermissionInfo(null,
-                                               new ConditionInfo[] { new ConditionInfo(BundleLocationCondition.class.getName(),
-                                                               new String[] { nodeAPiBundleLocation }) },
-                                               new PermissionInfo[] { new PermissionInfo(AllPermission.class.getName(), null, null) },
-                                               ConditionalPermissionInfo.ALLOW));
+//             String nodeAPiBundleLocation = locate(NodeUtils.class);
+//             update.getConditionalPermissionInfos()
+//                             .add(permissionAdmin.newConditionalPermissionInfo(null,
+//                                             new ConditionInfo[] { new ConditionInfo(BundleLocationCondition.class.getName(),
+//                                                             new String[] { nodeAPiBundleLocation }) },
+//                                             new PermissionInfo[] { new PermissionInfo(AllPermission.class.getName(), null, null) },
+//                                             ConditionalPermissionInfo.ALLOW));
                String cmsBundleLocation = locate(SecurityProfile.class);
                update.getConditionalPermissionInfos()
                                .add(permissionAdmin.newConditionalPermissionInfo(null,