/** * <p> * Builds an instance of {@code ACLImpl} for the specified resource, and initialize it with the specified entries. * </p> * * @param resource a reference to the {@code Resource} associated with the ACL being constructed. * @param entries a {@code Collection} containing the ACL's initial entries. */ public ACLImpl(Resource resource, Collection<ACLEntry> entries) { this(Util.getResourceAsString(resource), entries); this.resource = resource; }
/** * <p> * Builds an instance of {@code ACLImpl} for the specified resource, and initialize it with the specified entries. * </p> * * @param resource a reference to the {@code Resource} associated with the ACL being constructed. * @param entries a {@code Collection} containing the ACL's initial entries. */ public ACLImpl(Resource resource, Collection<ACLEntry> entries) { this(Util.getResourceAsString(resource), entries); this.resource = resource; }
public ACL getACL(Resource resource) { String resourceString = Util.getResourceAsString(resource); Map<String, Object> context = new HashMap<String, Object>(); context.put("resource", resourceString); return (ACL) this.registration.getPolicy(null, PolicyRegistration.ACL, context); }
/** * <p> * Searches the database for the {@code ACL} associated with the specified resource. * </p> * * @param resource the {@code Resource} that is associated with the {@code ACL} being searched. * @param entityManager the {@code EntityManager} used to search the database. * @return the {@code ACL} retrieved from the database, or {@code null} if no {@code ACL} could be found. */ private ACLImpl findACLByResource(Resource resource, EntityManager entityManager) { ACLImpl acl = null; try { acl = (ACLImpl) entityManager.createQuery( "SELECT a FROM ACLImpl a WHERE a.resourceAsString LIKE '" + Util.getResourceAsString(resource) + "'") .getSingleResult(); acl.setResource(resource); } catch (NoResultException nre) { // ignore the exception when no ACL could be found for the given resource. } return acl; } }
/** * <p> * Searches the database for the {@code ACL} associated with the specified resource. * </p> * * @param resource the {@code Resource} that is associated with the {@code ACL} being searched. * @param entityManager the {@code EntityManager} used to search the database. * @return the {@code ACL} retrieved from the database, or {@code null} if no {@code ACL} could be found. */ private ACLImpl findACLByResource(Resource resource, EntityManager entityManager) { ACLImpl acl = null; try { acl = (ACLImpl) entityManager.createQuery( "SELECT a FROM ACLImpl a WHERE a.resourceAsString LIKE '" + Util.getResourceAsString(resource) + "'") .getSingleResult(); acl.setResource(resource); } catch (NoResultException nre) { // ignore the exception when no ACL could be found for the given resource. } return acl; } }