Search in sources :

Example 1 with BaseEntity

use of org.openkilda.entity.BaseEntity in project open-kilda by telstra.

the class DaoInterceptor method updateUserInformation.

/**
 * Update user information.
 *
 * @param objEntity the obj entity
 */
public void updateUserInformation(final Object objEntity) {
    RequestContext requestContext = serverContext.getRequestContext();
    if (objEntity instanceof BaseEntity) {
        BaseEntity entity = (BaseEntity) objEntity;
        Long userId = requestContext == null || requestContext.getUserId() == null ? null : requestContext.getUserId();
        if (userId != null) {
            if (entity.id() != null && entity.id() != 0) {
                entity.setUpdatedBy(userId);
                entity.setUpdatedDate(Calendar.getInstance().getTime());
            } else {
                entity.setCreatedBy(userId);
                entity.setCreatedDate(Calendar.getInstance().getTime());
            }
            _log.debug("[updateUserInformation] Update created and updated by in entity.");
        }
    }
}
Also used : BaseEntity(org.openkilda.entity.BaseEntity) RequestContext(org.openkilda.auth.model.RequestContext)

Aggregations

RequestContext (org.openkilda.auth.model.RequestContext)1 BaseEntity (org.openkilda.entity.BaseEntity)1