use of org.apache.jackrabbit.core.PropertyImpl in project jackrabbit by apache.
the class MembershipCache method collectDeclaredMembershipFromReferences.
/**
* Collects the declared memberships for the given authorizable by resolving the week references to the authorizable.
* If the lookup fails, <code>null</code> is returned. This most likely the case if the authorizable does not exit (yet)
* in the session that is used for the lookup.
*
* @param authorizableNodeIdentifier Identifier of the authorizable node
* @param session the session to read from
* @return a collection of group node ids or <code>null</code> if the lookup failed.
* @throws RepositoryException if an error occurs
*/
private Collection<String> collectDeclaredMembershipFromReferences(String authorizableNodeIdentifier, Session session) throws RepositoryException {
Set<String> pIds = new HashSet<String>();
Set<String> nIds = new HashSet<String>();
// Try to get membership information from references
PropertyIterator refs = getMembershipReferences(authorizableNodeIdentifier, session);
if (refs == null) {
return null;
}
while (refs.hasNext()) {
try {
PropertyImpl pMember = (PropertyImpl) refs.nextProperty();
NodeImpl nGroup = (NodeImpl) pMember.getParent();
Set<String> groupNodeIdentifiers;
if (P_MEMBERS.equals(pMember.getQName())) {
// Found membership information in members property
groupNodeIdentifiers = pIds;
} else {
// Found membership information in members node
groupNodeIdentifiers = nIds;
while (nGroup.isNodeType(NT_REP_MEMBERS)) {
nGroup = (NodeImpl) nGroup.getParent();
}
}
if (nGroup.isNodeType(NT_REP_GROUP)) {
groupNodeIdentifiers.add(nGroup.getIdentifier());
} else {
// weak-ref property 'rep:members' that doesn't reside under an
// group node -> doesn't represent a valid group member.
log.debug("Invalid member reference to '{}' -> Not included in membership set.", this);
}
} catch (ItemNotFoundException e) {
// group node doesn't exist -> -> ignore exception
// and skip this reference from membership list.
} catch (AccessDeniedException e) {
// not allowed to see the group node -> ignore exception
// and skip this reference from membership list.
}
}
// Based on the user's setting return either of the found membership information
return select(pIds, nIds);
}
Aggregations