use of org.craftercms.studio.api.v1.exception.security.GroupAlreadyExistsException in project studio by craftercms.
the class GroupServiceInternalImpl method createGroup.
@Override
public Group createGroup(long orgId, String groupName, String groupDescription) throws GroupAlreadyExistsException, ServiceLayerException {
if (groupExists(-1, groupName)) {
throw new GroupAlreadyExistsException("Group '" + groupName + "' already exists");
}
Map<String, Object> params = new HashMap<>();
params.put(ORG_ID, orgId);
params.put(GROUP_NAME, groupName);
params.put(GROUP_DESCRIPTION, groupDescription);
try {
groupDao.createGroup(params);
Group group = new Group();
group.setId((Long) params.get(ID));
group.setGroupName(groupName);
group.setGroupDescription(groupDescription);
return group;
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
}
use of org.craftercms.studio.api.v1.exception.security.GroupAlreadyExistsException in project studio by craftercms.
the class GroupServiceImpl method createGroup.
@Override
@HasPermission(type = DefaultPermission.class, action = "create_groups")
public Group createGroup(long orgId, String groupName, String groupDescription) throws GroupAlreadyExistsException, ServiceLayerException, AuthenticationException {
Group toRet = groupServiceInternal.createGroup(orgId, groupName, groupDescription);
SiteFeed siteFeed = siteService.getSite(studioConfiguration.getProperty(CONFIGURATION_GLOBAL_SYSTEM_SITE));
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_CREATE);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(userService.getCurrentUser().getUsername());
auditLog.setPrimaryTargetId(groupName);
auditLog.setPrimaryTargetType(TARGET_TYPE_GROUP);
auditLog.setPrimaryTargetValue(groupName);
auditServiceInternal.insertAuditLog(auditLog);
return toRet;
}
Aggregations