use of org.craftercms.studio.api.v1.exception.ServiceLayerException in project studio by craftercms.
the class GroupServiceInternalImpl method getGroup.
@Override
public Group getGroup(long groupId) throws GroupNotFoundException, ServiceLayerException {
Map<String, Object> params = new HashMap<>();
params.put(GROUP_ID, groupId);
Group group;
try {
group = groupDao.getGroup(params);
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
if (group != null) {
return group;
} else {
throw new GroupNotFoundException("No group found for id '" + groupId + "'");
}
}
use of org.craftercms.studio.api.v1.exception.ServiceLayerException 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.v1.exception.ServiceLayerException 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.v1.exception.ServiceLayerException in project studio by craftercms.
the class GroupServiceInternalImpl method getGroups.
@Override
public List<Group> getGroups(List<Long> groupIds) throws GroupNotFoundException, ServiceLayerException {
Map<String, Object> params = new HashMap<>();
params.put(GROUP_IDS, groupIds);
List<Group> groups;
try {
groups = groupDao.getGroups(params);
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
if (groups != null) {
return groups;
} else {
throw new GroupNotFoundException("No group found for id '" + groupIds + "'");
}
}
use of org.craftercms.studio.api.v1.exception.ServiceLayerException 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 + "'");
}
}
Aggregations