*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
package org.wamblee.usermgt;
import static org.wamblee.usermgt.UserMgtException.Reason.DUPLICATE_GROUP;
package org.wamblee.usermgt;
import static org.wamblee.usermgt.UserMgtException.Reason.DUPLICATE_GROUP;
- public UserAdministrationImpl(UserSet aUsers, GroupSet aGroups, NameValidator aUserValidator,
- NameValidator aGroupValidator) {
+ public UserAdministrationImpl(UserSet aUsers, GroupSet aGroups,
+ NameValidator aUserValidator, NameValidator aGroupValidator) {
if (groups.contains(group)) {
throw new UserMgtException(DUPLICATE_GROUP, group);
}
if (groups.contains(group)) {
throw new UserMgtException(DUPLICATE_GROUP, group);
}
if (getUsers(aGroup).size() > 0) {
throw new UserMgtException(GROUP_STILL_OCCUPIED, aGroup);
}
if (getUsers(aGroup).size() > 0) {
throw new UserMgtException(GROUP_STILL_OCCUPIED, aGroup);
}
if (aUser.getName().equals(aUserName)) {
throw new UserMgtException(TRIVIAL_RENAME, aUser);
}
if (aUser.getName().equals(aUserName)) {
throw new UserMgtException(TRIVIAL_RENAME, aUser);
}
if (users.find(aUserName) != null) {
throw new UserMgtException(DUPLICATE_USER, aUser);
}
if (users.find(aUserName) != null) {
throw new UserMgtException(DUPLICATE_USER, aUser);
}
userValidator.validate(aUserName);
// we are modifying the user so we should re-insert it into the set
// after renaming it.
userValidator.validate(aUserName);
// we are modifying the user so we should re-insert it into the set
// after renaming it.
if (aGroup.getName().equals(aGroupName)) {
throw new UserMgtException(TRIVIAL_RENAME, aGroup);
}
if (aGroup.getName().equals(aGroupName)) {
throw new UserMgtException(TRIVIAL_RENAME, aGroup);
}
if (groups.find(aGroupName) != null) {
throw new UserMgtException(DUPLICATE_GROUP, aGroup);
}
if (groups.find(aGroupName) != null) {
throw new UserMgtException(DUPLICATE_GROUP, aGroup);
}
groupValidator.validate(aGroupName);
// we are renaming the group so we should re-insert it into the set
// after renaming it.
groupValidator.validate(aGroupName);
// we are renaming the group so we should re-insert it into the set
// after renaming it.
- * @see org.wamblee.usermgt.UserAdministration#addUserToGroup(org.wamblee.usermgt.User,
- * org.wamblee.usermgt.Group)
+ * @see
+ * org.wamblee.usermgt.UserAdministration#addUserToGroup(org.wamblee.usermgt
+ * .User, org.wamblee.usermgt.Group)
- * @see org.wamblee.usermgt.UserAdministration#removeUserFromGroup(org.wamblee.usermgt.User,
- * org.wamblee.usermgt.Group)
+ * @see
+ * org.wamblee.usermgt.UserAdministration#removeUserFromGroup(org.wamblee
+ * .usermgt.User, org.wamblee.usermgt.Group)