public Workspace getSiteWorkspace(String name, String state) { Map<String, String> attributes = new HashMap<String, String>(); attributes.put(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE); attributes.put(WORKSPACE_ATTRIBUTE_NAME, name); if (state != null) { attributes.put(WORKSPACE_ATTRIBUTE_STATE, state); } List<Workspace> res = brix.getWorkspaceManager().getWorkspacesFiltered(attributes); return res.isEmpty() ? null : res.get(0); }
public List<Workspace> getWorkspaces(Workspace currentWorkspace, boolean isFrontend) { if (isFrontend) { Map<String, String> attributes = new HashMap<String, String>(); attributes.put(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE); return brix.getWorkspaceManager().getWorkspacesFiltered(attributes); } else { return null; } }
public List<Workspace> getPrototypes() { Map<String, String> attributes = new HashMap<String, String>(); attributes.put(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE); return brix.getWorkspaceManager().getWorkspacesFiltered(attributes); }
public boolean prototypeExists(String protypeName) { Map<String, String> attributes = new HashMap<String, String>(); attributes.put(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE); attributes.put(WORKSPACE_ATTRIBUTE_PROTOTYPE_NAME, protypeName); return !brix.getWorkspaceManager().getWorkspacesFiltered(attributes).isEmpty(); }
public List<Workspace> getWorkspaces(Workspace currentWorkspace, boolean isFrontend) { Map<String, String> attributes = new HashMap<String, String>(); attributes.put(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE); List<Workspace> workspaces = new ArrayList<Workspace>(brix.getWorkspaceManager() .getWorkspacesFiltered(attributes)); Collections.sort(workspaces, new Comparator<Workspace>() { public int compare(Workspace o1, Workspace o2) { String n1 = getWorkspaceName(o1); String n2 = getWorkspaceName(o2); int r = n1.compareTo(n2); if (r == 0) { String s1 = getWorkspaceState(o1); String s2 = getWorkspaceState(o2); if (s1 != null && s2 != null) { if (stateComparator != null) { return stateComparator.compare(s1, s2); } else { return s1.compareTo(s2); } } else { return 0; } } else { return r; } } }); return workspaces; }
public Workspace getObject() { if (workspace == null && workspaceId != null) { workspace = Brix.get().getWorkspaceManager().getWorkspace(workspaceId); } return workspace; } }
private static boolean checkSession(String workspaceId) { return Brix.get().getWorkspaceManager().workspaceExists(workspaceId); }
private boolean isCurrentWorkspaceValid() { WorkspaceManager manager = getBrix().getWorkspaceManager(); Workspace workspace = getModelObject(); return workspace != null && manager.workspaceExists(workspace.getId()); }
public List<Workspace> getSnapshotsForWorkspace(Workspace workspace) { String siteName = null; if (SitePlugin.get().isSiteWorkspace(workspace)) { siteName = SitePlugin.get().getWorkspaceName(workspace); } else if (SnapshotPlugin.get().isSnapshotWorkspace(workspace)) { siteName = getSnapshotSiteName(workspace); } if (siteName != null) { Map<String, String> attributes = new HashMap<String, String>(); attributes.put(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE); attributes.put(WORKSPACE_ATTRIBUTE_SITE_NAME, siteName); return brix.getWorkspaceManager().getWorkspacesFiltered(attributes); } else { return Collections.emptyList(); } }
private boolean isCurrentWorkspaceValid() { WorkspaceManager manager = getBrix().getWorkspaceManager(); Workspace workspace = getModelObject(); return workspace != null && manager.workspaceExists(workspace.getId()); }
public Workspace createSite(String name, String state) { Workspace workspace = brix.getWorkspaceManager().createWorkspace(); workspace.setAttribute(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE); setWorkspaceName(workspace, name); setWorkspaceState(workspace, state); return workspace; }
public Workspace getWorkspace() { if (node == null) { return null; } else { String id = node.getSession().getWorkspace().getName(); return node.getBrix().getWorkspaceManager().getWorkspace(id); } } }
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(); }
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(); } }
private List<WorkspaceEntry> loadWorkspaces() { Brix brix = Brix.get(); List<WorkspaceEntry> workspaces = new ArrayList<WorkspaceEntry>(); Workspace currentWorkspace = getCurrentWorkspaceId() != null ? brix.getWorkspaceManager() .getWorkspace(getCurrentWorkspaceId()) : null; for (Plugin p : brix.getPlugins()) { List<Workspace> filtered = brix.filterVisibleWorkspaces(p.getWorkspaces( currentWorkspace, true), Context.PRESENTATION); for (Workspace w : filtered) { WorkspaceEntry we = new WorkspaceEntry(); we.id = w.getId(); we.visibleName = p.getUserVisibleName(w, true); workspaces.add(we); } } return workspaces; }
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); }
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); }
Workspace newWorkspace = node.getBrix().getWorkspaceManager().getWorkspace( nodeWorkspaceName); workspaceModel.setObject(newWorkspace);