public void restoreSnapshot(Workspace snapshotWorkspace, Workspace targetWorkspace) { JcrSession sourceSession = brix.getCurrentSession(snapshotWorkspace.getId()); JcrSession targetSession = brix.getCurrentSession(targetWorkspace.getId()); brix.clone(sourceSession, targetSession); brix.initWorkspace(targetWorkspace, brix.getCurrentSession(targetWorkspace.getId())); }
public BrixNode getSiteRootNode(String workspaceId) { JcrSession workspaceSession = brix.getCurrentSession(workspaceId); BrixNode root = (BrixNode) workspaceSession.getItem(getSiteRootPath()); return root; }
private T loadNode(String id) { if (id != null) { JcrSession session = Brix.get().getCurrentSession(workspaceName); if (id.startsWith("/")) { return (T) session.getItem(id); } else { return (T) session.getNodeByIdentifier(id); } } else { return null; } } }
@Override protected RulesNode load() { JcrSession session = Brix.get().getCurrentSession(workspaceModel.getObject().getId()); return SitePlugin.get().getWebDavRules(session); } }
public void createPrototype(Workspace originalWorkspace, String prototypeName) { Workspace workspace = brix.getWorkspaceManager().createWorkspace(); workspace.setAttribute(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE); setPrototypeName(workspace, prototypeName); JcrSession originalSession = brix.getCurrentSession(originalWorkspace.getId()); JcrSession destSession = brix.getCurrentSession(workspace.getId()); brix.clone(originalSession, destSession); }
private static BrixNode getRootNode(IModel<Workspace> workspaceModel) { Workspace workspace = workspaceModel.getObject(); if (workspace != null) { BrixNode root = (BrixNode) Brix.get().getCurrentSession(workspace.getId()).getItem( SitePlugin.get().getSiteRootPath()); return root; } else { return null; } }
public void publish(Workspace workspace, String targetState) { if (workspace == null) { throw new IllegalArgumentException("Argument 'workspace' may not be null."); } if (targetState == null) { throw new IllegalArgumentException("Argument 'targetState' may not be null."); } SitePlugin sitePlugin = SitePlugin.get(); if (!sitePlugin.isSiteWorkspace(workspace)) { throw new IllegalStateException("Workspace must be a Site workspace."); } if (targetState.equals(sitePlugin.getWorkspaceState(workspace))) { throw new IllegalStateException("Cannot publish workspace to same state it is already."); } String name = sitePlugin.getWorkspaceName(workspace); Workspace target = sitePlugin.getSiteWorkspace(name, targetState); if (target == null) { target = sitePlugin.createSite(name, targetState); } JcrSession sourceSession = brix.getCurrentSession(workspace.getId()); JcrSession targetSession = brix.getCurrentSession(target.getId()); brix.clone(sourceSession, targetSession); }
public void createPrototype(List<JcrNode> nodes, String prototypeName) { if (nodes.isEmpty()) { throw new IllegalStateException("Node list can not be empty."); } Workspace workspace = brix.getWorkspaceManager().createWorkspace(); workspace.setAttribute(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE); setPrototypeName(workspace, prototypeName); JcrSession destSession = brix.getCurrentSession(workspace.getId()); JcrUtil.cloneNodes(nodes, destSession.getRootNode()); destSession.save(); }
private static BrixNode getContainerNode(Workspace workspace) { JcrSession session = Brix.get().getCurrentSession(workspace.getId()); return SitePlugin.get().getGlobalContainer(session); }
public void initRepository() { List<RepositoryInitializer> initializers = new ArrayList<RepositoryInitializer>(); initializers.addAll(config.getRegistry().lookupCollection(RepositoryInitializer.POINT)); initializers.addAll(config.getRegistry().lookupCollection(JcrNodeWrapperFactory.POINT)); try { JcrSession s = getCurrentSession(null); for (RepositoryInitializer initializer : initializers) { initializer.initializeRepository(this, s); } s.save(); s.logout(); } catch (RepositoryException e) { throw new RuntimeException("Couldn't initialize repository", e); } for (Workspace w : getWorkspaceManager().getWorkspaces()) { JcrSession s = getCurrentSession(w.getId()); initWorkspace(w, s); s.logout(); } }
public void createSnapshot(Workspace workspace, String comment) { if (!SitePlugin.get().isSiteWorkspace(workspace)) { throw new IllegalStateException("Workspace must be a Site workspace"); } Workspace targetWorkspace = brix.getWorkspaceManager().createWorkspace(); targetWorkspace.setAttribute(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE); targetWorkspace.setAttribute(WORKSPACE_ATTRIBUTE_SITE_NAME, SitePlugin.get().getWorkspaceName(workspace)); targetWorkspace.setAttribute(WORKSPACE_COMMENT, comment); setCreated(targetWorkspace, new Date()); JcrSession originalSession = brix.getCurrentSession(workspace.getId()); JcrSession targetSession = brix.getCurrentSession(targetWorkspace.getId()); brix.clone(originalSession, targetSession); }
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 NodePickerTreeModel(String workspaceName) { JcrSession session = Brix.get().getCurrentSession(workspaceName); root = new NodePickerTreeNode((BrixNode) session.getItem(SitePlugin.get().getSiteRootPath())); }
@Override public boolean isVisible() { final Action action = new AccessSitePluginAction(getWorkspaceModel().getObject()); final boolean granted = Brix.get().getAuthorizationStrategy().isActionAuthorized(action); if (granted) { JcrSession session = Brix.get().getCurrentSession(getWorkspaceModel().getObject().getId()); SitePlugin sp = SitePlugin.get(); return sp.canEditNode(sp.getGlobalContainer(session), Context.ADMINISTRATION); } return false; } }
@Override public boolean isVisible() { final Action action = new AccessSitePluginAction(getWorkspaceModel().getObject()); final boolean granted = Brix.get().getAuthorizationStrategy().isActionAuthorized(action); if (granted) { JcrSession session = Brix.get().getCurrentSession(getWorkspaceModel().getObject().getId()); SitePlugin sp = SitePlugin.get(); return sp.canEditNode(sp.getGlobalContainer(session), Context.ADMINISTRATION); } return false; } }
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 onClick(AjaxRequestTarget target) { List<JcrNode> nodes = getSelectedNodes(); if (!nodes.isEmpty()) { Brix brix = ((BrixNode) nodes.iterator().next()).getBrix(); JcrWorkspace targetWorkspace = brix.getCurrentSession(targetWorkspaceId).getWorkspace(); Map<JcrNode, List<JcrNode>> dependencies = JcrUtil.getUnsatisfiedDependencies( nodes, targetWorkspace); ; if (!dependencies.isEmpty()) { message.setDefaultModelObject(getDependenciesMessage(dependencies)); } else { JcrNode rootNode = targetNode.getObject(); if (rootNode == null) { rootNode = targetWorkspace.getSession().getRootNode(); } PrototypePlugin.get().restoreNodes(nodes, rootNode); findParent(ModalWindow.class).close(target); } } else { message.setDefaultModelObject("You have to select at least one node."); } target.add(message); } });
final JcrSession session = brix.getCurrentSession(workspace);
JcrSession newSession = node.getBrix().getCurrentSession(workspace.getId()); String uuid = node.getIdentifier(); BrixNode newNode = JcrUtil.getNodeByUUID(newSession, uuid);
@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); } } } } });