/** * Returns whether or not an entity is shareable. * * @param entityClass the entity type to check for the shareable permissions * @return true if entityClass is shareable. False otherwise. */ public boolean isShareable(Class<?> entityClass) { return getAnnotation(entityClass, SharePermission.class) != null && getAnnotation(entityClass, SharePermission.class).sharable(); }
/** * Returns whether or not an entity is shareable. * * @param entityClass the entity type to check for the shareable permissions * @return true if entityClass is shareable. False otherwise. */ public boolean isShareable(Class<?> entityClass) { return getAnnotation(entityClass, SharePermission.class) != null && getAnnotation(entityClass, SharePermission.class).sharable(); }
/** * Return annotation from class, parents or package. * * @param record the record * @param annotationClass the annotation class * @param <A> genericClass * @return the annotation */ public <A extends Annotation> A getAnnotation(PersistentResource record, Class<A> annotationClass) { return getAnnotation(record.getResourceClass(), annotationClass); }
/** * Get the calculated {@link DeletePermission} value for the field. * * @param clazz the entity class * @return the delete permissions for an entity */ protected String getDeletePermission(Class<?> clazz) { DeletePermission classPermission = dictionary.getAnnotation(clazz, DeletePermission.class); if (classPermission != null) { return classPermission.expression(); } return null; } }
/** * Return annotation from class, parents or package. * * @param record the record * @param annotationClass the annotation class * @param <A> genericClass * @return the annotation */ public <A extends Annotation> A getAnnotation(PersistentResource record, Class<A> annotationClass) { return getAnnotation(record.getResourceClass(), annotationClass); }
/** * Get the calculated {@link CreatePermission} value for the field. * * @param clazz the entity class * @return the create permissions for an entity */ protected String getCreatePermission(Class<?> clazz) { CreatePermission classPermission = dictionary.getAnnotation(clazz, CreatePermission.class); if (classPermission != null) { return classPermission.expression(); } return null; }
/** * Get the calculated {@link UpdatePermission} value for the field. * * @param clazz the entity class * @param fieldName the field * @return the update permissions for a field */ protected String getUpdatePermission(Class<?> clazz, String fieldName) { UpdatePermission classPermission = dictionary.getAnnotation(clazz, UpdatePermission.class); UpdatePermission fieldPermission = dictionary.getAttributeOrRelationAnnotation(clazz, UpdatePermission.class, fieldName); if (fieldPermission != null) { return fieldPermission.expression(); } if (classPermission != null) { return classPermission.expression(); } return null; }
/** * Get the calculated {@link ReadPermission} value for the field. * * @param clazz the entity class * @param fieldName the field * @return the read permissions for a field */ protected String getReadPermission(Class<?> clazz, String fieldName) { ReadPermission classPermission = dictionary.getAnnotation(clazz, ReadPermission.class); ReadPermission fieldPermission = dictionary.getAttributeOrRelationAnnotation(clazz, ReadPermission.class, fieldName); if (fieldPermission != null) { return fieldPermission.expression(); } if (classPermission != null) { return classPermission.expression(); } return null; }