public abstract class CRUDServiceSecurity<DTO extends EntityDTO,E extends BaseEntity,D extends EntityData<DTO>,DP> extends BaseServiceSecurity implements CRUDWithConfirmationPasswordService<DTO,D,DP>
CRUDServices, handling the idea of view and manage authorizations.
hasViewAccess(BaseEntity) hasManageAccess(BaseEntity)| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Class<E> |
entityClass |
| Constructor and Description |
|---|
CRUDServiceSecurity(java.lang.Class<E> entityClass) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canPerformOperation(E entity,
CRUDOperation operation)
Returns whether the logged user can perform the given operation over the given entity
|
protected boolean |
canViewHistoryLog(E entity)
Subclasses working with entities which generates log can override this method for customization.
The default implementation delegates to EntityLogServiceSecurity.canViewEntityLog(BaseEntity) |
protected abstract void |
checkCreateNew(DP params)
Checks whether creating new entities with the given context parameters is allowed, throwing
PermissionDeniedException if not |
void |
checkManageAccess(E entity)
Checks whether the caller is allowed to manage the given entity
|
void |
checkOperation(E entity,
CRUDOperation operation)
Throws a
PermissionDeniedException if canPerformOperation(BaseEntity, CRUDOperation) returns
false |
void |
checkViewAccess(E entity)
Checks whether the caller is allowed to view the given entity
|
protected void |
customizeData(D data)
Can be overridden in order to process the returned data object for the given entity
|
protected abstract boolean |
doHasManageAccess(E entity)
Should be implemented in order to return whether the caller is allowed to manage the given entity, for the given
operation
|
abstract boolean |
doHasViewAccess(E entity)
Should be implemented in order to return whether the caller is allowed to view the given entity.
|
<Entity extends E> |
find(java.lang.Long id)
Returns the entity with the given id
|
PasswordInputDTO |
getConfirmationPasswordInputForRemove(java.lang.Long id)
Returns the
PasswordInputDTO for the confirmation password that would be required if removing the entity
with the given id |
D |
getData(java.lang.Long id)
Returns data for details of the given entity
|
D |
getDataForNew(DP params)
Returns data for a new entity with the given context parameters
|
java.lang.Class<E> |
getEntityClass() |
protected abstract CRUDServiceLocal<E,DTO,D,DP> |
getImplementation()
Should be implemented in order to return the actual implementation of the service
|
boolean |
hasManageAccess(E entity)
Returns whether the logged user can manage the given entity
|
boolean |
hasViewAccess(E entity)
Returns whether the logged user can view the given entity
|
abstract boolean |
isAccessible(SessionData sessionData,
E entity)
Must be implemented in order to determine whether the given entity is accessible for the given session data.
|
DTO |
load(java.lang.Long id)
Loads a DTO for the entity with the given id, ensuring that the logged user can see the record
|
protected void |
onBeforeSave(DTO dto,
E entity) |
void |
remove(java.lang.Long id)
Removes the entity associated with the given identifier
|
void |
removeAll(java.util.Collection<java.lang.Long> ids)
Removes the entities associated with the given identifiers
|
void |
removeAllWithConfirmationPassword(java.util.Collection<java.lang.Long> ids,
java.lang.String confirmationPassword)
Removes the entities associated with the given identifiers, checking the confirmation password first (if enabled)
|
void |
removeWithConfirmationPassword(java.lang.Long id,
java.lang.String confirmationPassword)
Removes an entity, checking the confirmation password first (if enabled)
|
protected org.cyclos.impl.access.EntityCheck<E> |
resolveEntityCheck()
Must be implemented in order to resolve the corresponding
EntityCheck for the root entity type |
java.lang.Long |
save(DTO dto)
Saves the given object, returning the generated identifier
|
java.lang.Long |
saveWithConfirmationPassword(DTO dto,
java.lang.String confirmationPassword)
Saves the given object, returning the generated identifier, checking the confirmation password first (if enabled)
|
checkGuest, checkId, checkIds, checkInternalName, checkLoggedIn, checkManagesUser, checkRelatesToUser, checkVO, checkVOs, doInitialize, getEntityCheckRegistry, getUser, initializecanManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getAccountHandler, getAuthHandler, getBaseEntityManagerHandler, getChannelConfiguration, getConfiguration, getConversionHandler, getCustomFieldValueHandler, getEntityManagerHandler, getGroupsHandler, getLoggedBasicUser, getLoggedUser, getProducts, getProductsHandler, getReportHandler, getTranslatedName, getTranslatedValue, getUserLocatorHandler, getValidationResult, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, toDate, toDateTime, validatedelete, detach, find, flush, from, getApplicationContext, getConfigurationHandler, getDataTranslationHandler, getFormatter, getFormatter, getFormatter, getLogger, getNotificationHandler, getProfileFieldHandler, getRemoteAddress, getSessionData, getTransactionHandler, getTranslationHandler, message, message, persist, processBatch, refresh, remove, subQuery, updateprotected final java.lang.Class<E extends BaseEntity> entityClass
public CRUDServiceSecurity(java.lang.Class<E> entityClass)
public boolean canPerformOperation(E entity, CRUDOperation operation)
public final void checkManageAccess(E entity) throws PermissionDeniedException
PermissionDeniedExceptionpublic final void checkOperation(E entity, CRUDOperation operation)
PermissionDeniedException if canPerformOperation(BaseEntity, CRUDOperation) returns
falsepublic final void checkViewAccess(E entity) throws PermissionDeniedException
PermissionDeniedExceptionpublic abstract boolean doHasViewAccess(E entity)
public <Entity extends E> Entity find(java.lang.Long id)
public final PasswordInputDTO getConfirmationPasswordInputForRemove(java.lang.Long id) throws FrameworkException
CRUDWithConfirmationPasswordServicePasswordInputDTO for the confirmation password that would be required if removing the entity
with the given idgetConfirmationPasswordInputForRemove in interface CRUDWithConfirmationPasswordService<DTO extends EntityDTO,D extends EntityData<DTO>,DP>FrameworkExceptionpublic final D getData(java.lang.Long id) throws FrameworkException
CRUDServicegetData in interface CRUDService<DTO extends EntityDTO,D extends EntityData<DTO>,DP>EntityNotFoundException - When the given id is not valid (or represents a not visible entity)FrameworkExceptionpublic final D getDataForNew(DP params) throws FrameworkException
CRUDServicegetDataForNew in interface CRUDService<DTO extends EntityDTO,D extends EntityData<DTO>,DP>FrameworkExceptionpublic java.lang.Class<E> getEntityClass()
public final boolean hasManageAccess(E entity)
public final boolean hasViewAccess(E entity)
public abstract boolean isAccessible(SessionData sessionData, E entity)
hasViewAccess(BaseEntity). If the only condition for an entity is
hasViewAccess(BaseEntity), this method
should return false.public final DTO load(java.lang.Long id) throws EntityNotFoundException
CRUDServiceload in interface CRUDService<DTO extends EntityDTO,D extends EntityData<DTO>,DP>EntityNotFoundException - When the entity with the given id was not found (or not visible)public final void remove(java.lang.Long id)
throws EntityNotFoundException,
DataAccessException,
ValidationException
CRUDServiceremove in interface CRUDService<DTO extends EntityDTO,D extends EntityData<DTO>,DP>EntityNotFoundException - When the given id is not valid (or represents a not visible entity)ConstraintViolatedOnRemoveException - When the given id represents an entity which is referenced by other
entities, and the
delete is not cascaded to themDataAccessExceptionValidationExceptionpublic final void removeAll(java.util.Collection<java.lang.Long> ids)
throws EntityNotFoundException,
DataAccessException,
ValidationException
CRUDServiceremoveAll in interface CRUDService<DTO extends EntityDTO,D extends EntityData<DTO>,DP>EntityNotFoundException - When any of the given ids are not valid (or represents not visible entities)ConstraintViolatedOnRemoveException - When any of the given ids represents an entity which is referenced by
other entities, and the
delete is not cascaded to themDataAccessExceptionValidationExceptionpublic final void removeAllWithConfirmationPassword(java.util.Collection<java.lang.Long> ids,
java.lang.String confirmationPassword)
throws EntityNotFoundException,
DataAccessException,
ValidationException
CRUDWithConfirmationPasswordServiceremoveAllWithConfirmationPassword in interface CRUDWithConfirmationPasswordService<DTO extends EntityDTO,D extends EntityData<DTO>,DP>EntityNotFoundExceptionDataAccessExceptionValidationExceptionCRUDService.removeAll(Collection)public final void removeWithConfirmationPassword(java.lang.Long id,
java.lang.String confirmationPassword)
throws FrameworkException
CRUDWithConfirmationPasswordServiceremoveWithConfirmationPassword in interface CRUDWithConfirmationPasswordService<DTO extends EntityDTO,D extends EntityData<DTO>,DP>FrameworkExceptionCRUDService.remove(Long)public final java.lang.Long save(DTO dto) throws ValidationException, DataAccessException
CRUDServicesave in interface CRUDService<DTO extends EntityDTO,D extends EntityData<DTO>,DP>ValidationException - When the given object has invalid fieldsEntityNotFoundException - When the given id is not valid (or represents a not visible entity)DataAccessException - When a data access error prevented the object of being savedpublic final java.lang.Long saveWithConfirmationPassword(DTO dto, java.lang.String confirmationPassword) throws FrameworkException
CRUDWithConfirmationPasswordServicesaveWithConfirmationPassword in interface CRUDWithConfirmationPasswordService<DTO extends EntityDTO,D extends EntityData<DTO>,DP>FrameworkExceptionCRUDService.save(EntityDTO)protected boolean canViewHistoryLog(E entity)
EntityLogServiceSecurity.canViewEntityLog(BaseEntity)protected abstract void checkCreateNew(DP params)
PermissionDeniedException if notprotected void customizeData(D data)
protected abstract boolean doHasManageAccess(E entity)
protected abstract CRUDServiceLocal<E,DTO,D,DP> getImplementation()
protected final org.cyclos.impl.access.EntityCheck<E> resolveEntityCheck()
EntityCheck for the root entity typeresolveEntityCheck in class BaseServiceSecurity