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 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 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); }
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); }