Package org.cyclos.impl.system
Class BaseEntityLogHandlerImpl<E extends BaseEntity,DTO extends EntityDTO>
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseNetworkedHandlerImpl
-
- org.cyclos.impl.system.BaseEntityLogHandlerImpl<E,DTO>
-
- All Implemented Interfaces:
EntityLogHandler<E,DTO>
- Direct Known Subclasses:
AccountFeeEntityLogHandlerImpl,AccountTypeEntityLogHandlerImpl,AddressEntityLogHandlerImpl,AdEntityLogHandlerImpl,AgreementEntityLogHandlerImpl,AuthorizationLevelEntityLogHandlerImpl,ChannelConfigurationEntityLogHandlerImpl,ConfigurationEntityLogHandlerImpl,CurrencyEntityLogHandlerImpl,CustomScriptEntityLogHandlerImpl,IdentityProviderEntityLogHandlerImpl,OidcClientEntityLogHandlerImpl,PasswordTypeEntityLogHandlerImpl,PhoneEntityLogHandlerImpl,PrincipalTypeEntityLogHandlerImpl,ProductEntityLogHandlerImpl,RecordEntityLogHandlerImpl,TransferFeeEntityLogHandlerImpl,TransferTypeEntityLogHandlerImpl,UserEntityLogHandlerImpl,VoucherConfigurationEntityLogHandlerImpl,VoucherTypeEntityLogHandlerImpl
public abstract class BaseEntityLogHandlerImpl<E extends BaseEntity,DTO extends EntityDTO> extends BaseNetworkedHandlerImpl implements EntityLogHandler<E,DTO>
Base class for all implementation ofEntityLogHandler. The handlers are automatically registered by theEntityLogRegistryimplementation.
-
-
Field Summary
Fields Modifier and Type Field Description protected static QEntityPropertyLog$protected static QEntityLogelprotected static StringMASKED_VALUEused for sensitive data like passwords, private keys.-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description BaseEntityLogHandlerImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidapplyLogFilters(DBQuery<?> query, EntityPropertyLogQuery params)Apply filters to the given query to ensure only the entity log the logged user can view are returnedbooleanareEquals(E oldEntity, E newEntity, PropertyAccess access, Object oldValue, Object newValue)Returns true if the old and new values extracted from its corresponding entities must be considered equals.booleancanViewEntityLog(long entityId)Returns true if the entity's log type is not null and the logged user can view its log.protected EntityPropertyLogcreateEntityPropertyLog(String name, String propertyName, String oldValue, String newValue)Creates a new property log WITHOUT setting the order.
Clients of this code must set the correct order before adding it to the generated logs list.protected booleancustomLogForCreation()By default the built-in log generation for the create event is applied.protected Set<EntityLogType>doApplyLogFilters(DBQuery<?> query, long entityId)Subclasses can implement this method to add specific filters to the query when searching for logs of an entity.protected List<EntityPropertyLog>doOnBeforeLog(E oldEntity, E newEntity, List<EntityPropertyLog> result, EntityLogEvent event)StringgetEntityLogName(E oldEntity, E newEntity, EntityLogEvent event)Return the name of the entity log being generated.protected abstract EgetEntityToViewLog(long entityId)Returns the entity with the given id ONLY if the logged user can view its logs.protected BasicUsergetRelatedUser(E entity)Subclasses can implement this method to return the related user of the entity Returns the associated user to the given entity.Pair<Object,Object>getValues(E oldEntity, E newEntity, PropertyLogDescriptor<DTO> propertyDescriptor)Allows custom logic for a specific property to be logged bypassing the default log generation for it.booleanisLogEnabled(E entity)Returns true if the log is enabled for this specific entity instance.List<EntityPropertyLog>onBeforeLog(E oldEntity, E newEntity, List<EntityPropertyLog> result, EntityLogEvent event)Allows perform custom logic before logging (i.e saving) the given property logs.-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, delete, detach, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.impl.system.EntityLogHandler
getEntityClass, getType, resolveLogDescriptor
-
-
-
-
Field Detail
-
$
protected static final QEntityPropertyLog $
-
el
protected static final QEntityLog el
-
MASKED_VALUE
protected static final String MASKED_VALUE
used for sensitive data like passwords, private keys.- See Also:
- Constant Field Values
-
-
Method Detail
-
applyLogFilters
public void applyLogFilters(DBQuery<?> query, EntityPropertyLogQuery params)
Description copied from interface:EntityLogHandlerApply filters to the given query to ensure only the entity log the logged user can view are returned- Specified by:
applyLogFiltersin interfaceEntityLogHandler<E extends BaseEntity,DTO extends EntityDTO>
-
areEquals
public boolean areEquals(E oldEntity, E newEntity, PropertyAccess access, Object oldValue, Object newValue)
Description copied from interface:EntityLogHandlerReturns true if the old and new values extracted from its corresponding entities must be considered equals.- Specified by:
areEqualsin interfaceEntityLogHandler<E extends BaseEntity,DTO extends EntityDTO>
-
canViewEntityLog
public boolean canViewEntityLog(long entityId)
Returns true if the entity's log type is not null and the logged user can view its log.- Specified by:
canViewEntityLogin interfaceEntityLogHandler<E extends BaseEntity,DTO extends EntityDTO>
-
getEntityLogName
public String getEntityLogName(E oldEntity, E newEntity, EntityLogEvent event)
Description copied from interface:EntityLogHandlerReturn the name of the entity log being generated.- Specified by:
getEntityLogNamein interfaceEntityLogHandler<E extends BaseEntity,DTO extends EntityDTO>
-
getValues
public Pair<Object,Object> getValues(E oldEntity, E newEntity, PropertyLogDescriptor<DTO> propertyDescriptor)
Description copied from interface:EntityLogHandlerAllows custom logic for a specific property to be logged bypassing the default log generation for it.- Specified by:
getValuesin interfaceEntityLogHandler<E extends BaseEntity,DTO extends EntityDTO>- Returns:
- null for the default generation (i.e no custom logic implemented) or a pair of the form
to be saved as-is only if EntityLogHandler.areEquals(BaseEntity, BaseEntity, PropertyAccess, Object, Object)return false.
-
isLogEnabled
public boolean isLogEnabled(E entity)
Description copied from interface:EntityLogHandlerReturns true if the log is enabled for this specific entity instance.- Specified by:
isLogEnabledin interfaceEntityLogHandler<E extends BaseEntity,DTO extends EntityDTO>
-
onBeforeLog
public final List<EntityPropertyLog> onBeforeLog(E oldEntity, E newEntity, List<EntityPropertyLog> result, EntityLogEvent event)
Description copied from interface:EntityLogHandlerAllows perform custom logic before logging (i.e saving) the given property logs. The returned list will be final logs to be saved (subclasses can add / remove logs). In case ofEntityLogEvent.CREATEevent the result list will contain only one element, this is for that case we only log one line just to indicate when and who created the entity.- Specified by:
onBeforeLogin interfaceEntityLogHandler<E extends BaseEntity,DTO extends EntityDTO>
-
createEntityPropertyLog
protected EntityPropertyLog createEntityPropertyLog(String name, String propertyName, String oldValue, String newValue)
Creates a new property log WITHOUT setting the order.
Clients of this code must set the correct order before adding it to the generated logs list.
-
customLogForCreation
protected boolean customLogForCreation()
By default the built-in log generation for the create event is applied. Subclasses can overwrite this method if they need to do some custom logic in the doOnBeforeLog method- Returns:
-
doApplyLogFilters
protected Set<EntityLogType> doApplyLogFilters(DBQuery<?> query, long entityId)
Subclasses can implement this method to add specific filters to the query when searching for logs of an entity. Also, if other log types must be included in the query result then they must be returned.- Parameters:
query- the query to add the filtersentityId- the id of the entity for which we're searching its logs- Returns:
- the list of other types that must be included in the result (e.g for users we include the addresses and phones logs). Null/empty means no other types are included.
-
doOnBeforeLog
protected List<EntityPropertyLog> doOnBeforeLog(E oldEntity, E newEntity, List<EntityPropertyLog> result, EntityLogEvent event)
-
getEntityToViewLog
protected abstract E getEntityToViewLog(long entityId)
Returns the entity with the given id ONLY if the logged user can view its logs. Otherwise it MUST return null.
-
-