1 16 package com.blandware.atleap.service.core.impl; 17 18 import com.blandware.atleap.service.core.GroupManager; 19 import com.blandware.atleap.service.exception.BeanAlreadyExistsException; 20 import com.blandware.atleap.service.exception.BeanNotFoundException; 21 import com.blandware.atleap.persistence.core.RoleDAO; 22 import com.blandware.atleap.persistence.core.GroupDAO; 23 import com.blandware.atleap.model.core.Role; 24 import com.blandware.atleap.model.core.Group; 25 import com.blandware.atleap.common.util.PartialCollection; 26 import com.blandware.atleap.common.util.QueryInfo; 27 28 37 public class GroupManagerImpl extends BaseManagerImpl implements GroupManager { 38 39 42 protected GroupDAO groupDAO; 43 44 49 public void setGroupDAO(GroupDAO dao) { 50 this.groupDAO = dao; 51 } 52 53 55 58 public void createGroup(Group group) throws BeanAlreadyExistsException { 59 if ( log.isDebugEnabled() ) { 60 log.debug("Creating new Group [groupName=" + group.getName() + "]..."); 61 } 62 63 Group tmp = groupDAO.retrieveGroup(group.getName()); 65 if ( tmp != null ) { 66 String errorMessage = "Group with the name '" + group.getName() + "' already exists"; 68 if ( log.isErrorEnabled() ) { 69 log.error(errorMessage); 70 } 71 throw new BeanAlreadyExistsException(errorMessage); 72 } 73 tmp = groupDAO.findGroupByTitle(group.getTitle()); 74 if ( tmp != null ) { 75 String errorMessage = "Group with the title '" + group.getTitle() + "' already exists"; 77 if ( log.isErrorEnabled() ) { 78 log.error(errorMessage); 79 } 80 throw new BeanAlreadyExistsException(errorMessage); 81 } 82 groupDAO.createGroup(group); 83 84 if ( log.isDebugEnabled() ) { 85 log.debug("New group has been created succesfully"); 86 } 87 } 88 89 92 public Group retrieveGroup(String groupName) { 93 Group group = null; 94 group = groupDAO.retrieveGroup(groupName); 95 return group; 96 } 97 98 101 public void updateGroup(Group group) throws BeanAlreadyExistsException { 102 103 groupDAO.removeFromCache(group); 105 if ( log.isDebugEnabled() ) { 106 log.debug("Updating Group [groupName=" + group.getName() + "]..."); 107 } 108 109 if ( groupDAO.hasDuplicates(group) ) { 110 throw new BeanAlreadyExistsException("Group with the same title already exists"); 111 } 112 113 groupDAO.updateGroup(group); 114 115 if ( log.isDebugEnabled() ) { 116 log.debug("Group has been updated succesfully"); 117 } 118 } 119 120 123 public void deleteGroup(String groupName) throws BeanNotFoundException { 124 Group group = groupDAO.retrieveGroup(groupName); 125 if ( group == null ) { 126 String errorMessage = "No group with ID=" + group + "could be found"; 127 throw new BeanNotFoundException(errorMessage); 128 } 129 groupDAO.deleteGroup(group); 130 } 131 132 134 137 public PartialCollection listGroups(QueryInfo queryInfo) { 138 return groupDAO.listGroups(queryInfo); 139 } 140 141 } 142 | Popular Tags |