+++ /dev/null
-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;
-}
+++ /dev/null
-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";
-}
+++ /dev/null
-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() {
- }
-
-}
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;
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;
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);
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;
// 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
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
--- /dev/null
+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() {
+ }
+
+}
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;
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;
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);
}
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;
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);
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);
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;
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);
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;
// 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);
// 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");
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);
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);
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;
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);
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;
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);
} finally {
Jcr.logout(defaultAdminSession);
}
- adminSession = NodeUtils.openDataAdminSession(repository, workspaceName);
+ adminSession = CmsJcrUtils.openDataAdminSession(repository, workspaceName);
} else
throw e1;
}
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;
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);
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;
Import-Package:\
org.eclipse.swt,\
+org.argeo.api,\
org.argeo.eclipse.ui,\
javax.jcr.nodetype,\
javax.jcr.security,\
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;
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);
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;
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);
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;
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)
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;
@Override
public Repository getRepository() {
if (repository == null)
- repository = NodeUtils.getRepositoryByUri(repositoryFactory, uri);
+ repository = CmsJcrUtils.getRepositoryByUri(repositoryFactory, uri);
return super.getRepository();
}
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;
}
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()) {
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;
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) {
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;
}
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. */
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;
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,