use of org.craftercms.studio.api.v2.dal.AuditLogConstants.OPERATION_ENABLE in project studio by craftercms.
the class UserServiceImpl method enableUsers.
@Override
@HasPermission(type = DefaultPermission.class, action = "update_users")
public List<User> enableUsers(List<Long> userIds, List<String> usernames, boolean enabled) throws ServiceLayerException, UserNotFoundException, AuthenticationException {
List<User> users = userServiceInternal.enableUsers(userIds, usernames, enabled);
SiteFeed siteFeed = siteService.getSite(studioConfiguration.getProperty(CONFIGURATION_GLOBAL_SYSTEM_SITE));
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setSiteId(siteFeed.getId());
if (enabled) {
auditLog.setOperation(OPERATION_ENABLE);
} else {
auditLog.setOperation(OPERATION_DISABLE);
}
auditLog.setActorId(getCurrentUser().getUsername());
auditLog.setPrimaryTargetId(siteFeed.getSiteId());
auditLog.setPrimaryTargetType(TARGET_TYPE_USER);
auditLog.setPrimaryTargetValue(siteFeed.getName());
List<AuditLogParameter> paramters = new ArrayList<AuditLogParameter>();
for (User u : users) {
AuditLogParameter paramter = new AuditLogParameter();
paramter.setTargetId(Long.toString(u.getId()));
paramter.setTargetType(TARGET_TYPE_USER);
paramter.setTargetValue(u.getUsername());
paramters.add(paramter);
}
auditLog.setParameters(paramters);
auditServiceInternal.insertAuditLog(auditLog);
return users;
}
Aggregations