use of org.apache.jackrabbit.spi.Path in project jackrabbit by apache.
the class SessionImpl method getImportContentHandler.
/**
* {@inheritDoc}
*/
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException {
// check sanity of this session
sanityCheck();
NodeImpl parent;
try {
Path p = getQPath(parentAbsPath).getNormalizedPath();
if (!p.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + parentAbsPath);
}
parent = getItemManager().getNode(p);
} catch (NameException e) {
String msg = parentAbsPath + ": invalid path";
log.debug(msg);
throw new RepositoryException(msg, e);
} catch (AccessDeniedException ade) {
throw new PathNotFoundException(parentAbsPath);
}
// verify that parent node is checked-out, not locked and not protected
// by either node type constraints nor by some retention or hold.
int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD | ItemValidator.CHECK_RETENTION;
context.getItemValidator().checkModify(parent, options, Permission.NONE);
SessionImporter importer = new SessionImporter(parent, this, uuidBehavior, context.getWorkspace().getConfig().getImportConfig());
return new ImportHandler(importer, this);
}
use of org.apache.jackrabbit.spi.Path in project jackrabbit by apache.
the class QueryImpl method storeAsNode.
/**
* @see Query#storeAsNode(String)
*/
public Node storeAsNode(String absPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
NamePathResolver resolver = mgrProvider.getNamePathResolver();
try {
Path p = resolver.getQPath(absPath).getNormalizedPath();
if (!p.isAbsolute()) {
throw new RepositoryException(absPath + " is not an absolute path");
}
String jcrParent = resolver.getJCRPath(p.getAncestor(1));
if (!session.itemExists(jcrParent)) {
throw new PathNotFoundException(jcrParent);
}
String relPath = resolver.getJCRPath(p).substring(1);
String ntName = resolver.getJCRName(NameConstants.NT_QUERY);
Node queryNode = session.getRootNode().addNode(relPath, ntName);
// set properties
queryNode.setProperty(resolver.getJCRName(NameConstants.JCR_LANGUAGE), getLanguage());
queryNode.setProperty(resolver.getJCRName(NameConstants.JCR_STATEMENT), getStatement());
node = queryNode;
return node;
} catch (NameException e) {
throw new RepositoryException(e.getMessage(), e);
}
}
use of org.apache.jackrabbit.spi.Path in project jackrabbit by apache.
the class LockManagerImpl method getLock.
/**
* {@inheritDoc}
*/
public Lock getLock(NodeImpl node) throws LockException, RepositoryException {
acquire();
try {
SessionImpl session = (SessionImpl) node.getSession();
Path path = getPath(session, node.getId());
PathMap.Element<LockInfo> element = lockMap.map(path, false);
LockInfo info = element.get();
if (info != null && (element.hasPath(path) || info.isDeep())) {
NodeImpl lockHolder = (NodeImpl) session.getItemManager().getItem(info.getId());
return new LockImpl(info, lockHolder);
} else {
throw new LockException("Node not locked: " + node);
}
} catch (ItemNotFoundException e) {
throw new LockException("Node not locked: " + node);
} finally {
release();
}
}
use of org.apache.jackrabbit.spi.Path in project jackrabbit by apache.
the class DefaultAccessManager method hasPrivileges.
//-----------------------------------------------< AccessControlManager >---
/**
* @see javax.jcr.security.AccessControlManager#hasPrivileges(String, Privilege[])
*/
public boolean hasPrivileges(String absPath, Privilege[] privileges) throws PathNotFoundException, RepositoryException {
checkInitialized();
checkValidNodePath(absPath);
if (privileges == null || privileges.length == 0) {
// null or empty privilege array -> return true
log.debug("No privileges passed -> allowed.");
return true;
} else {
Path p = getPath(absPath);
return compiledPermissions.hasPrivileges(p, privileges);
}
}
use of org.apache.jackrabbit.spi.Path in project jackrabbit by apache.
the class UserAccessControlProviderTest method testNoNodeForPrincipal.
/**
* @see <a href="https://issues.apache.org/jira/browse/JCR-2630">JCR-2630</a>
*/
public void testNoNodeForPrincipal() throws RepositoryException {
final Principal testPrincipal = getTestPrincipal();
String path = "/home/users/t/" + testPrincipal.getName();
while (s.nodeExists(path)) {
path += "_";
}
final String principalPath = path;
List<Set<Principal>> principalSets = new ArrayList<Set<Principal>>();
principalSets.add(Collections.<Principal>singleton(testPrincipal));
principalSets.add(Collections.<Principal>singleton(new ItemBasedPrincipal() {
public String getPath() {
return principalPath;
}
public String getName() {
return testPrincipal.getName();
}
}));
Path rootPath = ((SessionImpl) s).getQPath("/");
for (Set<Principal> principals : principalSets) {
CompiledPermissions cp = provider.compilePermissions(principals);
assertFalse(cp.canReadAll());
assertFalse(cp.grants(rootPath, Permission.READ));
assertTrue(cp.getPrivilegeSet(rootPath).isEmpty());
assertSame(CompiledPermissions.NO_PERMISSION, cp);
}
}
Aggregations