Search in sources :

Example 11 with ServiceLayerException

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 + "'");
    }
}
Also used : Group(org.craftercms.studio.api.v2.dal.Group) HashMap(java.util.HashMap) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) GroupNotFoundException(org.craftercms.studio.api.v1.exception.security.GroupNotFoundException) GroupAlreadyExistsException(org.craftercms.studio.api.v1.exception.security.GroupAlreadyExistsException) UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) GroupNotFoundException(org.craftercms.studio.api.v1.exception.security.GroupNotFoundException) ConfigurationException(org.craftercms.studio.api.v2.exception.configuration.ConfigurationException) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException)

Example 12 with ServiceLayerException

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);
    }
}
Also used : HashMap(java.util.HashMap) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) GroupAlreadyExistsException(org.craftercms.studio.api.v1.exception.security.GroupAlreadyExistsException) UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) GroupNotFoundException(org.craftercms.studio.api.v1.exception.security.GroupNotFoundException) ConfigurationException(org.craftercms.studio.api.v2.exception.configuration.ConfigurationException) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException)

Example 13 with ServiceLayerException

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);
    }
}
Also used : HashMap(java.util.HashMap) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) GroupNotFoundException(org.craftercms.studio.api.v1.exception.security.GroupNotFoundException) GroupAlreadyExistsException(org.craftercms.studio.api.v1.exception.security.GroupAlreadyExistsException) UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) GroupNotFoundException(org.craftercms.studio.api.v1.exception.security.GroupNotFoundException) ConfigurationException(org.craftercms.studio.api.v2.exception.configuration.ConfigurationException) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) RetryingOperation(org.craftercms.studio.api.v2.annotation.RetryingOperation)

Example 14 with ServiceLayerException

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 + "'");
    }
}
Also used : Group(org.craftercms.studio.api.v2.dal.Group) HashMap(java.util.HashMap) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) GroupNotFoundException(org.craftercms.studio.api.v1.exception.security.GroupNotFoundException) GroupAlreadyExistsException(org.craftercms.studio.api.v1.exception.security.GroupAlreadyExistsException) UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) GroupNotFoundException(org.craftercms.studio.api.v1.exception.security.GroupNotFoundException) ConfigurationException(org.craftercms.studio.api.v2.exception.configuration.ConfigurationException) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException)

Example 15 with ServiceLayerException

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 + "'");
    }
}
Also used : Group(org.craftercms.studio.api.v2.dal.Group) HashMap(java.util.HashMap) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) GroupNotFoundException(org.craftercms.studio.api.v1.exception.security.GroupNotFoundException) GroupAlreadyExistsException(org.craftercms.studio.api.v1.exception.security.GroupAlreadyExistsException) UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) GroupNotFoundException(org.craftercms.studio.api.v1.exception.security.GroupNotFoundException) ConfigurationException(org.craftercms.studio.api.v2.exception.configuration.ConfigurationException) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException)

Aggregations

ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)124 UserNotFoundException (org.craftercms.studio.api.v1.exception.security.UserNotFoundException)62 HashMap (java.util.HashMap)55 ArrayList (java.util.ArrayList)45 IOException (java.io.IOException)39 User (org.craftercms.studio.api.v2.dal.User)36 Repository (org.eclipse.jgit.lib.Repository)35 Git (org.eclipse.jgit.api.Git)33 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)33 ContentRepository (org.craftercms.studio.api.v1.repository.ContentRepository)32 RemoteRepository (org.craftercms.studio.api.v2.dal.RemoteRepository)30 SiteFeed (org.craftercms.studio.api.v1.dal.SiteFeed)29 SiteNotFoundException (org.craftercms.studio.api.v1.exception.SiteNotFoundException)29 CryptoException (org.craftercms.commons.crypto.CryptoException)28 ValidateParams (org.craftercms.commons.validation.annotations.param.ValidateParams)27 GitRepositoryHelper (org.craftercms.studio.api.v2.utils.GitRepositoryHelper)24 ContentItemTO (org.craftercms.studio.api.v1.to.ContentItemTO)23 Path (java.nio.file.Path)21 InvalidRemoteUrlException (org.craftercms.studio.api.v1.exception.repository.InvalidRemoteUrlException)21 AuditLog (org.craftercms.studio.api.v2.dal.AuditLog)20