/** * <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> * Returns a {@code String} representation of the specified resource. The format of this representation * is as follows: {@code resource_fqn:resource_id}, where {@code resource_fqn} is the fully-qualified * name of the resource class, and {@code resource_id} is the unique identifier of the resource. * </p> * * @param resource the {@code Resource} to be converted. * @return a {@code String} representation of the resource. */ public static String getResourceAsString(Resource resource) { String resourceString = null; if (resource != null) { String resourceClass = resource.getClass().getCanonicalName(); resourceString = resourceClass + ":" + getResourceKey(resource); } return resourceString; }
resourceKey = executeNoArgMethod(resource, methodName); resourceKey = executeNoArgMethod(resource, "getId"); return resourceKey;
/** * <p> * Returns a {@code String} representation of the specified resource. The format of this representation * is as follows: {@code resource_fqn:resource_id}, where {@code resource_fqn} is the fully-qualified * name of the resource class, and {@code resource_id} is the unique identifier of the resource. * </p> * * @param resource the {@code Resource} to be converted. * @return a {@code String} representation of the resource. */ public static String getResourceAsString(Resource resource) { String resourceString = null; if (resource != null) { String resourceClass = resource.getClass().getCanonicalName(); resourceString = resourceClass + ":" + getResourceKey(resource); } return resourceString; }
resourceKey = executeNoArgMethod(resource, methodName); resourceKey = executeNoArgMethod(resource, "getId"); return resourceKey;
/** * <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; } }