}
try {
NamespaceResolver nr = new SessionNamespaceResolver(getSecuritySession());
PathResolver pr = new DefaultNamePathResolver(nr);
String jcrPath = pr.getJCRPath(absPath);
if (deniedPathes.get() != null && deniedPathes.get().contains(jcrPath)) {
cache.put(cacheKey, false);
return false;
}
if (isSystemPrincipal()) {
cache.put(cacheKey, true);
return true;
}
Item i = null;
Boolean itemExists = null;
// Always deny write access on system folders
if (permissions.contains(getPrivilegeName(Privilege.JCR_WRITE, workspaceName)) ||
permissions.contains(getPrivilegeName(Privilege.JCR_MODIFY_PROPERTIES, workspaceName)) ||
permissions.contains(getPrivilegeName(Privilege.JCR_REMOVE_NODE, workspaceName))) {
itemExists = getSecuritySession().itemExists(jcrPath);
if (itemExists.booleanValue()) {
i = getSecuritySession().getItem(jcrPath);
if (i.isNode()) {
if (((Node) i).isNodeType(Constants.JAHIAMIX_SYSTEMNODE)) {
cache.put(cacheKey, false);
return false;
}
}
}
}
if (permissions.size() != 1 || !permissions.contains(getPrivilegeName(Privilege.JCR_ADD_CHILD_NODES, workspaceName))) {
if (itemExists == null) {
itemExists = getSecuritySession().itemExists(jcrPath);
}
boolean newItem = !itemExists.booleanValue(); // Jackrabbit checks the ADD_NODE permission on non-existing nodes
if (newItem) {
// If node is new (local to the session), always grant permission
cache.put(cacheKey, true);
return true;
}
}
// Administrators are always granted
if (jahiaPrincipal != null) {
if (isAdmin(jahiaPrincipal.getName(), 0)) {
cache.put(cacheKey, true);
return true;
}
}
int depth = 1;
if (itemExists == null) {
itemExists = getSecuritySession().itemExists(jcrPath);
}
while (!itemExists.booleanValue()) {
jcrPath = pr.getJCRPath(absPath.getAncestor(depth++));
itemExists = getSecuritySession().itemExists(jcrPath);
}
if (i == null) {
i = getSecuritySession().getItem(jcrPath);