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