use of javax.jcr.Workspace in project jackrabbit by apache.
the class WorkspaceTest method testDeleteWorkspace.
public void testDeleteWorkspace() throws Exception {
try {
Workspace wsp = superuser.getWorkspace();
String name = getNewWorkspaceName(wsp);
wsp.createWorkspace(name, wsp.getName());
List<String> wsps = Arrays.asList(wsp.getAccessibleWorkspaceNames());
assertTrue(wsps.contains(name));
wsp.deleteWorkspace(name);
wsps = Arrays.asList(wsp.getAccessibleWorkspaceNames());
assertFalse(wsps.contains(name));
Session s = null;
try {
s = getHelper().getSuperuserSession(name);
fail(name + " has been deleted.");
} catch (NoSuchWorkspaceException e) {
// success
} finally {
if (s != null) {
s.logout();
}
}
} catch (UnsupportedRepositoryOperationException e) {
throw new NotExecutableException();
} catch (UnsupportedOperationException e) {
throw new NotExecutableException();
}
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class RepositoryServiceImpl method getPrivilegeDefinitions.
@Override
public PrivilegeDefinition[] getPrivilegeDefinitions(SessionInfo sessionInfo) throws RepositoryException {
SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
Session session = sInfo.getSession();
Workspace wsp = session.getWorkspace();
Collection<Privilege> privs;
if (wsp instanceof JackrabbitWorkspace) {
privs = Arrays.asList(((JackrabbitWorkspace) wsp).getPrivilegeManager().getRegisteredPrivileges());
} else {
Privilege jcrAll = session.getAccessControlManager().privilegeFromName(Privilege.JCR_ALL);
privs = new HashSet<Privilege>();
privs.add(jcrAll);
for (Privilege p : jcrAll.getAggregatePrivileges()) {
privs.add(p);
}
}
PrivilegeDefinition[] pDefs = new PrivilegeDefinition[privs.size()];
NamePathResolver npResolver = sInfo.getNamePathResolver();
int i = 0;
for (Privilege p : privs) {
Set<Name> aggrnames = null;
if (p.isAggregate()) {
aggrnames = new HashSet<Name>();
for (Privilege dap : p.getDeclaredAggregatePrivileges()) {
aggrnames.add(npResolver.getQName(dap.getName()));
}
}
PrivilegeDefinition def = new PrivilegeDefinitionImpl(npResolver.getQName(p.getName()), p.isAbstract(), aggrnames);
pDefs[i++] = def;
}
return pDefs;
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class RepositoryServiceImpl method createWorkspace.
/**
* {@inheritDoc}
*/
public void createWorkspace(SessionInfo sessionInfo, String name, String srcWorkspaceName) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
Workspace wsp = sInfo.getSession().getWorkspace();
if (srcWorkspaceName == null) {
wsp.createWorkspace(name);
} else {
wsp.createWorkspace(name, srcWorkspaceName);
}
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class RepositoryServiceImpl method deleteWorkspace.
/**
* {@inheritDoc}
*/
public void deleteWorkspace(SessionInfo sessionInfo, String name) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
Workspace wsp = sInfo.getSession().getWorkspace();
wsp.deleteWorkspace(name);
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class Copy method execute.
/**
* {@inheritDoc}
*/
public boolean execute(Context ctx) throws Exception {
String srcWorkspace = (String) ctx.get(this.srcWorkspaceKey);
String srcAbsPath = (String) ctx.get(this.srcAbsPathKey);
String destAbsPath = (String) ctx.get(this.destAbsPathKey);
Workspace w = CommandHelper.getSession(ctx).getWorkspace();
if (srcWorkspace == null) {
srcWorkspace = w.getName();
}
if (log.isDebugEnabled()) {
log.debug("copying node from [" + srcWorkspace + ":" + srcAbsPath + "] to [" + w.getName() + ":" + destAbsPath + "]");
}
if (destAbsPath.endsWith("/")) {
Item source = CommandHelper.getSession(ctx).getItem(srcAbsPath);
destAbsPath = destAbsPath + source.getName();
}
w.copy(srcWorkspace, srcAbsPath, destAbsPath);
return false;
}
Aggregations