if (set.contains(READ_ACTION)) {
try {
targetId = hierMgr.resolvePath(targetPath);
if (targetId == null) {
// target does not exist, throw exception
throw new AccessControlException(READ_ACTION);
}
accessMgr.checkPermission(targetId, AccessManager.READ);
} catch (AccessDeniedException re) {
// otherwise the RepositoryException catch clause will
// log a warn message, which is not appropriate in this case.
throw new AccessControlException(READ_ACTION);
}
}
Path parentPath = null;
ItemId parentId = null;
/**
* "add_node" action:
* requires WRITE permission on parent item
*/
if (set.contains(ADD_NODE_ACTION)) {
try {
parentPath = targetPath.getAncestor(1);
parentId = hierMgr.resolvePath(parentPath);
if (parentId == null) {
// parent does not exist (i.e. / was specified), throw exception
throw new AccessControlException(ADD_NODE_ACTION);
}
accessMgr.checkPermission(parentId, AccessManager.WRITE);
} catch (AccessDeniedException re) {
// otherwise the RepositoryException catch clause will
// log a warn message, which is not appropriate in this case.
throw new AccessControlException(ADD_NODE_ACTION);
}
}
/**
* "remove" action:
* requires REMOVE permission on target item
*/
if (set.contains(REMOVE_ACTION)) {
try {
if (targetId == null) {
targetId = hierMgr.resolvePath(targetPath);
if (targetId == null) {
// parent does not exist, throw exception
throw new AccessControlException(REMOVE_ACTION);
}
}
accessMgr.checkPermission(targetId, AccessManager.REMOVE);
} catch (AccessDeniedException re) {
// otherwise the RepositoryException catch clause will
// log a warn message, which is not appropriate in this case.
throw new AccessControlException(REMOVE_ACTION);
}
}
/**
* "set_property" action:
* requires WRITE permission on parent item if property is going to be
* added or WRITE permission on target item if property is going to be
* modified
*/
if (set.contains(SET_PROPERTY_ACTION)) {
try {
if (targetId == null) {
targetId = hierMgr.resolvePath(targetPath);
if (targetId == null) {
// property does not exist yet,
// check WRITE permission on parent
if (parentPath == null) {
parentPath = targetPath.getAncestor(1);
}
if (parentId == null) {
parentId = hierMgr.resolvePath(parentPath);
if (parentId == null) {
// parent does not exist, throw exception
throw new AccessControlException(SET_PROPERTY_ACTION);
}
}
accessMgr.checkPermission(parentId, AccessManager.WRITE);
} else {
// property does already exist,
// check WRITE permission on target
accessMgr.checkPermission(targetId, AccessManager.WRITE);
}
}
} catch (AccessDeniedException re) {
// otherwise the RepositoryException catch clause will
// log a warn message, which is not appropriate in this case.
throw new AccessControlException(SET_PROPERTY_ACTION);
}
}
}