private Node getUserSettingHome(Session session) throws Exception { Node settingNode = session.getRootNode().getNode(AbstractService.SETTING_NODE); Node userHomeNode = null; if (settingNode.hasNode(AbstractService.SETTING_USER_NODE) == false) { userHomeNode = settingNode.addNode(AbstractService.SETTING_USER_NODE, AbstractService.STG_SUBCONTEXT); session.save(); } else { userHomeNode = settingNode.getNode(AbstractService.SETTING_USER_NODE); } return userHomeNode; }
/** * Get the Magnolia system node created under the given node. * * @throws RepositoryException if failed to create system node */ protected synchronized Node getSystemNode(Node node) throws RepositoryException { if (node.hasNode(SYSTEM_NODE)) { return node.getNode(SYSTEM_NODE); } return node.addNode(SYSTEM_NODE, NodeTypes.System.NAME); } }
public void delete(String name) throws WorkflowException, MappingException, RepositoryException, RemoteException { if (name.startsWith("/")) { name = name.substring(1); } String path = subject.getPath().substring(1); Node folder = (path.equals("") ? rootSession.getRootNode() : rootSession.getRootNode().getNode(path)); if (folder.hasNode(name)) { Node offspring = folder.getNode(name); delete(folder, offspring); } }
/** * Creating the logo and search area within the branding area. */ private void createLogoAndSearchInBranding(Node templateNode) throws RepositoryException { if(templateNode.hasNode("areas") && templateNode.getNode("areas").hasNode("branding")) { Node bandingNode = templateNode.getNode("areas").getNode("branding"); Node brandingAreasNode = MigrationUtil.getOrCreateNode(bandingNode, "areas", MgnlNodeType.NT_CONTENTNODE); reportDebug("Adding areas logo and search to branding area " + brandingAreasNode.getPath()); MigrationUtil.createArea(brandingAreasNode, "logo", "/templating-kit/pages/global/logo.ftl", getPersistentMapService().getCustomMap(PersistentMapConstant.AREA_TYPE_FOR_STK).get("logo"), true, null, null, null, null, null); MigrationUtil.createArea(brandingAreasNode, "search", "/templating-kit/pages/global/search.ftl", getPersistentMapService().getCustomMap(PersistentMapConstant.AREA_TYPE_FOR_STK).get("search"), true, null, null, null, null, null); } }
public RepositoryWorkflowImpl(Session userSession, Session rootSession, Node subject) throws RemoteException, RepositoryException { this.session = rootSession; if(subject.getDepth() == 0) this.subject = rootSession.getRootNode(); else this.subject = rootSession.getRootNode().getNode(subject.getPath().substring(1)); }
protected void setUp() throws Exception { super.setUp(); nodeToMerge = testRootNodeW2.getNode(nodeName1); // node has to be checked out while merging VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager(); versionManager.checkout(nodeToMerge.getPath()); }
private void addIgnoredChild(@NotNull Node node) throws Exception { AccessControlManager acMgr = superuser.getAccessControlManager(); JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, node.getPath()); acl.addAccessControlEntry(EveryonePrincipal.getInstance(), AccessControlUtils.privilegesFromNames(acMgr, Privilege.JCR_READ)); acMgr.setPolicy(acl.getPath(), acl); superuser.save(); Node c = node.getNode(AccessControlConstants.REP_POLICY); assertEquals(OnParentVersionAction.IGNORE, c.getDefinition().getOnParentVersion()); }
public void testNodeAdded() throws RepositoryException { Event[] events = getEvents(new Callable(){ public void call() throws RepositoryException { testRootNode.addNode(nodeName1, testNodeType); testRootNode.getSession().save(); } }, Event.NODE_ADDED); Node n = testRootNode.getNode(nodeName1); assertEquals(n.getIdentifier(), getEventByPath(events, n.getPath()).getIdentifier()); }
@Override public void afterTest() throws RepositoryException { session.getRootNode().getNode(ROOT_NODE_NAME).remove(); session.save(); } }
public void delete(Document document) throws WorkflowException, MappingException, RepositoryException, RemoteException { String path = subject.getPath().substring(1); Node folderNode = (path.equals("") ? rootSession.getRootNode() : rootSession.getRootNode().getNode(path)); Node documentNode = document.getNode(rootSession); if (documentNode.getPath().startsWith(folderNode.getPath()+"/")) { delete(folderNode, documentNode); } }
private void setFolderTitle(Node child, String title) throws RepositoryException{ if (!child.getPath().equals(jcrBasePath)) { if(child.hasNode(JcrConstants.JCR_CONTENT)){ child.getNode(JcrConstants.JCR_CONTENT).setProperty(JcrConstants.JCR_TITLE, title); }else{ child.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_UNSTRUCTURED).setProperty(JcrConstants.JCR_TITLE, title); } } }
private void setFolderTitle(Node child, String title) throws RepositoryException { if (child.hasNode(JcrConstants.JCR_CONTENT)) { child.getNode(JcrConstants.JCR_CONTENT).setProperty(JcrConstants.JCR_TITLE, title); } else { child.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_UNSTRUCTURED).setProperty(JcrConstants.JCR_TITLE, title); } }
public static Node getOrAddNode(Node parent, String relPath) throws RepositoryException { Node currentParent = parent; for (final String name : PathUtils.elements(relPath)) { if (!currentParent.hasNode(name)) { currentParent.addNode(name, JcrConstants.NT_UNSTRUCTURED); } currentParent = currentParent.getNode(name); } return currentParent; }
@Override public void afterSuite() throws RepositoryException { session.getRootNode().getNode(testNodeName).remove(); session.save(); session.logout(); }
@Override protected void runTest() throws Exception { final Session session = loginWriter(); // TODO: anonymous is slow Node root = session.getRootNode().getNode(ROOT_NODE_NAME); for (int i = 0; i < NODE_COUNT; i++) { Node node = root.getNode("node" + i); for (int j = 0; j < NODE_COUNT; j++) { Node newNode = node.addNode("node" + j, "nt:unstructured"); session.save(); } } }
public static Node createHippoNamespace(final Session session, final String prefix) throws RepositoryException { if (StringUtils.isBlank(prefix)) { throw new RepositoryException("Unable to create namespace for empty prefix"); } final Node namespaces = session.getRootNode().getNode(HippoNodeType.NAMESPACES_PATH); if (namespaces.hasNode(prefix)) { log.info("Namespace '{}' already registered", prefix); return namespaces.getNode(prefix); } return namespaces.addNode(prefix, HippoNodeType.NT_NAMESPACE); }