Search in sources :

Example 1 with GROUP_NAME

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);
    }
}
Also used : Group(org.craftercms.studio.api.v2.dal.Group) HashMap(java.util.HashMap) GroupAlreadyExistsException(org.craftercms.studio.api.v1.exception.security.GroupAlreadyExistsException) 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 2 with GROUP_NAME

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);
    }
}
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 3 with GROUP_NAME

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);
    }
}
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 4 with GROUP_NAME

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 + "'");
    }
}
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 5 with GROUP_NAME

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);
    }
}
Also used : UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) HashMap(java.util.HashMap) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) PasswordDoesNotMatchException(org.craftercms.studio.api.v1.exception.security.PasswordDoesNotMatchException) UserAlreadyExistsException(org.craftercms.studio.api.v1.exception.security.UserAlreadyExistsException) UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) UserExternallyManagedException(org.craftercms.studio.api.v1.exception.security.UserExternallyManagedException) PasswordRequirementsFailedException(org.craftercms.studio.api.v2.exception.PasswordRequirementsFailedException) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException)

Aggregations

HashMap (java.util.HashMap)7 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)7 UserNotFoundException (org.craftercms.studio.api.v1.exception.security.UserNotFoundException)7 GroupAlreadyExistsException (org.craftercms.studio.api.v1.exception.security.GroupAlreadyExistsException)4 GroupNotFoundException (org.craftercms.studio.api.v1.exception.security.GroupNotFoundException)4 Group (org.craftercms.studio.api.v2.dal.Group)4 ConfigurationException (org.craftercms.studio.api.v2.exception.configuration.ConfigurationException)4 UserAlreadyExistsException (org.craftercms.studio.api.v1.exception.security.UserAlreadyExistsException)3 ArrayList (java.util.ArrayList)2 SiteFeed (org.craftercms.studio.api.v1.dal.SiteFeed)2 AuthenticationSystemException (org.craftercms.studio.api.v1.exception.security.AuthenticationSystemException)2 SiteService (org.craftercms.studio.api.v1.service.site.SiteService)2 AuditLog (org.craftercms.studio.api.v2.dal.AuditLog)2 GroupDAO (org.craftercms.studio.api.v2.dal.GroupDAO)2 User (org.craftercms.studio.api.v2.dal.User)2 UserDAO (org.craftercms.studio.api.v2.dal.UserDAO)2 UserGroup (org.craftercms.studio.api.v2.dal.UserGroup)2 AuditServiceInternal (org.craftercms.studio.api.v2.service.audit.internal.AuditServiceInternal)2 StudioConfiguration (org.craftercms.studio.api.v2.utils.StudioConfiguration)2 NamingException (javax.naming.NamingException)1