use of org.craftercms.studio.api.v2.dal.QueryParameterNames.GROUP_NAME 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.v2.dal.QueryParameterNames.GROUP_NAME in project studio by craftercms.
the class GroupServiceInternalImpl method groupExists.
@Override
public boolean groupExists(long groupId, String groupName) throws ServiceLayerException {
Map<String, Object> params = new HashMap<>();
params.put(GROUP_ID, groupId);
params.put(GROUP_NAME, groupName);
try {
Integer result = groupDao.groupExists(params);
return (result > 0);
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
}
use of org.craftercms.studio.api.v2.dal.QueryParameterNames.GROUP_NAME in project studio by craftercms.
the class GroupServiceInternalImpl method updateGroup.
@RetryingOperation
@Override
public Group updateGroup(long orgId, Group group) throws GroupNotFoundException, ServiceLayerException {
if (!groupExists(group.getId(), StringUtils.EMPTY)) {
throw new GroupNotFoundException("No group found for id '" + group.getId() + "'");
}
Map<String, Object> params = new HashMap<>();
params.put(ID, group.getId());
params.put(ORG_ID, orgId);
params.put(GROUP_NAME, group.getGroupName());
params.put(GROUP_DESCRIPTION, group.getGroupDescription());
try {
groupDao.updateGroup(params);
return group;
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
}
use of org.craftercms.studio.api.v2.dal.QueryParameterNames.GROUP_NAME in project studio by craftercms.
the class GroupServiceInternalImpl method getGroupByName.
@Override
public Group getGroupByName(String groupName) throws GroupNotFoundException, ServiceLayerException {
Map<String, Object> params = new HashMap<>();
params.put(GROUP_NAME, groupName);
Group group;
try {
group = groupDao.getGroupByName(params);
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
if (group != null) {
return group;
} else {
throw new GroupNotFoundException("No group found for name '" + groupName + "'");
}
}
use of org.craftercms.studio.api.v2.dal.QueryParameterNames.GROUP_NAME in project studio by craftercms.
the class UserServiceInternalImpl method isUserMemberOfGroup.
@Override
public boolean isUserMemberOfGroup(String username, String groupName) throws UserNotFoundException, ServiceLayerException {
if (!userExists(-1, username)) {
throw new UserNotFoundException("No user found for username '" + username + "'");
}
Map<String, Object> params = new HashMap<>();
params.put(GROUP_NAME, groupName);
params.put(USERNAME, username);
try {
int result = userDao.isUserMemberOfGroup(params);
return result > 0;
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
}
Aggregations