public String getWebRootPath() { return brix.getRootPath() + "/" + WEB_NODE_NAME; }
public String getRootPath() { return brix.getRootPath() + "/" + ROOT_NODE_NAME; }
private void cleanWorkspace(JcrSession session) { if (session.itemExists(getRootPath())) { JcrNode root = (JcrNode) session.getItem(getRootPath()); root.remove(); session.save(); } session.save(); }
private void cloneWorkspace(JcrSession srcSession, JcrSession destSession) { String root = getRootPath(); destSession.getWorkspace().clone(srcSession.getWorkspace().getName(), root, root, true); }
private void buildChildren() { children = new ArrayList<JcrTreeNode>(); JcrSession session = Brix.get().getCurrentSession(workspaceId); BrixNode root = (BrixNode) session.getItem(Brix.get().getRootPath()); JcrNodeIterator iterator = root.getNodes(); while (iterator.hasNext()) { BrixNode node = (BrixNode) iterator.nextNode(); if (node instanceof TreeAwareNode) { JcrTreeNode treeNode = ((TreeAwareNode) node).getTreeNode(node); if (treeNode != null) { children.add(treeNode); } } } Collections.sort(children, new Comparator<JcrTreeNode>() { public int compare(JcrTreeNode o1, JcrTreeNode o2) { return o1.getClass().getName().compareTo(o2.getClass().getName()); } }); }
public void initWorkspace(org.brixcms.workspace.Workspace workspace, JcrSession session) { JcrNode root; if (session.itemExists(getRootPath())) { root = (JcrNode) session.getItem(getRootPath()); } else { root = session.getRootNode().addNode(ROOT_NODE_NAME, "nt:folder"); } if (!root.isNodeType(BrixNode.JCR_TYPE_BRIX_NODE)) { root.addMixin(BrixNode.JCR_TYPE_BRIX_NODE); } for (Plugin p : getPlugins()) { p.initWorkspace(workspace, session); } session.save(); }
private BrixNode getRootNode(String workspaceId, boolean createIfNotExist) { JcrSession session = brix.getCurrentSession(workspaceId); if (session.itemExists(getRootPath()) == false) { if (createIfNotExist) { BrixNode parent = (BrixNode) session.getItem(brix.getRootPath()); parent.addNode(ROOT_NODE_NAME, "nt:unstructured"); } else { return null; } } return (BrixNode) session.getItem(getRootPath()); }
@Override public void onSubmit() { List<FileUpload> uploadList = upload.getModelObject(); if (uploadList != null) { for (FileUpload u : uploadList) { try { InputStream s = u.getInputStream(); String id = ManageSnapshotsPanel.this.getModelObject().getId(); Brix brix = getBrix(); JcrSession session = brix.getCurrentSession(id); if (session.itemExists(brix.getRootPath())) { session.getItem(brix.getRootPath()).remove(); session.save(); } session.importXML("/", s, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING); session.save(); brix.initWorkspace(ManageSnapshotsPanel.this.getModelObject(), session); getSession().info(ManageSnapshotsPanel.this.getString("restoreSuccessful")); } catch (IOException e) { throw new BrixException(e); } } } } });
public void initWorkspace(Workspace workspace, JcrSession workspaceSession) { JcrNode root = (JcrNode) workspaceSession.getItem(brix.getRootPath()); JcrNode web = null; if (root.hasNode(WEB_NODE_NAME)) { web = root.getNode(WEB_NODE_NAME); } else if (isSiteWorkspace(workspace)) { web = root.addNode(WEB_NODE_NAME, "nt:folder"); } if (web != null) { if (!web.isNodeType(BrixNode.JCR_TYPE_BRIX_NODE)) { web.addMixin(BrixNode.JCR_TYPE_BRIX_NODE); } checkForSiteRoot(web); if (!web.hasNode(GLOBAL_CONTAINER_NODE_NAME)) { GlobalContainerNode.initialize(web.addNode(GLOBAL_CONTAINER_NODE_NAME, "nt:file")); } if (!web.hasNode(WEBDAV_RULES_NODE_NAME)) { RulesNode.initialize((BrixNode) web.addNode(WEBDAV_RULES_NODE_NAME, "nt:unstructured")); } } }