copyright messages updated in all java filees.
[utils] / security / src / main / java / org / wamblee / usermgt / UserMgtException.java
index e2f057c0bce8801ff1aff5c1ae07bf690ea6fbf4..588018aef136da31aca43df165f2adbeecb41caa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 the original author or authors.
+ * Copyright 2005-2010 the original author or authors.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */ 
-
 package org.wamblee.usermgt;
 
 import java.util.EnumMap;
 
 /**
- * User management exception. 
- *
+ * User management exception.
+ * 
  * @author Erik Brakkee
  */
 public class UserMgtException extends Exception {
-    
-    static final long serialVersionUID = 5585349754997507529L; 
-    
-    /**
-     * Possible causes for the exception. 
-     *
-     */
-    public enum Reason { 
-        UNKNOWN_USER, 
-        UNKNOWN_GROUP,
-        DUPLICATE_USER, 
-        DUPLICATE_GROUP, 
-        USER_ALREADY_IN_GROUP,
-        USER_NOT_IN_GROUP,
-        TRIVIAL_RENAME,
-        INVALID_PASSWORD, 
-        GROUP_STILL_OCCUPIED, 
-        USER_MUST_BE_IN_A_GROUP,
-        INVALID_USERNAME,
-        INVALID_GROUPNAME
-    }
-   
+    static final long serialVersionUID = 5585349754997507529L;
+
     /**
-     * Mapping of enum to exception message text. 
+     * Mapping of enum to exception message text.
      */
-    private static final EnumMap<Reason,String> MESSAGES = new EnumMap<Reason,String>(Reason.class);
-    
+    private static final EnumMap<Reason, String> MESSAGES = new EnumMap<Reason, String>(
+        Reason.class);
+
     static {
         MESSAGES.put(Reason.UNKNOWN_USER, "Unknown user");
         MESSAGES.put(Reason.UNKNOWN_GROUP, "Unknown group");
@@ -61,68 +41,97 @@ public class UserMgtException extends Exception {
         MESSAGES.put(Reason.TRIVIAL_RENAME, "Trivial rename");
         MESSAGES.put(Reason.INVALID_PASSWORD, "Invalid password");
         MESSAGES.put(Reason.GROUP_STILL_OCCUPIED, "Group still occupied");
-        MESSAGES.put(Reason.USER_MUST_BE_IN_A_GROUP, "User must be in at least one group");
+        MESSAGES.put(Reason.USER_MUST_BE_IN_A_GROUP,
+            "User must be in at least one group");
         MESSAGES.put(Reason.INVALID_USERNAME, "Invalid user name");
         MESSAGES.put(Reason.INVALID_GROUPNAME, "Invalid group name");
     }
-    
+
     /**
-     * Cause of the exception. 
+     * Cause of the exception.
      */
-    private Reason cause; 
-    
+    private Reason cause;
+
     /**
-     * User or null if no user is relevant for the problem. 
+     * User or null if no user is relevant for the problem.
      */
-    private User user; 
-    
+    private User user;
+
     /**
-     * Group or null if no group is relevant for the problem. 
+     * Group or null if no group is relevant for the problem.
      */
-    private Group group; 
+    private Group group;
 
+    /**
+     * Creates a new UserMgtException object.
+     * 
+     */
     public UserMgtException(Reason aCause, String aMessage) {
         super(MESSAGES.get(aCause) + ": " + aMessage);
-        cause = aCause; 
+        cause = aCause;
     }
-    
+
+    /**
+     * Creates a new UserMgtException object.
+     * 
+     */
     public UserMgtException(Reason aCause, User aUser) {
         this(aCause, "for user '" + aUser.getName() + "'");
-        user = aUser; 
+        user = aUser;
     }
-    
+
+    /**
+     * Creates a new UserMgtException object.
+     * 
+     */
     public UserMgtException(Reason aCause, Group aGroup) {
         this(aCause, "for group '" + aGroup.getName() + "'");
-        group = aGroup; 
+        group = aGroup;
     }
-    
+
+    /**
+     * Creates a new UserMgtException object.
+     * 
+     */
     public UserMgtException(Reason aCause, User aUser, Group aGroup) {
-        this(aCause, "for user '" + aUser.getName() + "' and group '" + aGroup.getName() + "'");
-        user = aUser; 
-        group = aGroup; 
+        this(aCause, "for user '" + aUser.getName() + "' and group '" +
+            aGroup.getName() + "'");
+        user = aUser;
+        group = aGroup;
     }
 
     /**
-     * Gets the cause of the problem. 
-     * @return Cause. 
+     * Gets the cause of the problem.
+     * 
+     * @return Cause.
      */
     public Reason getReason() {
-        return cause; 
+        return cause;
     }
-    
+
     /**
-     * Gets the user for which the problem occurred. 
-     * @return User or null if not applicable.  
+     * Gets the user for which the problem occurred.
+     * 
+     * @return User or null if not applicable.
      */
     public User getUser() {
-        return user; 
+        return user;
     }
-    
+
     /**
-     * Gets the group for which the problem occured. 
-     * @return Group or null if not applicable. 
+     * Gets the group for which the problem occured.
+     * 
+     * @return Group or null if not applicable.
      */
     public Group getGroup() {
         return group;
-    }   
+    }
+
+    /**
+     * Possible causes for the exception.
+     * 
+     */
+    public enum Reason {
+        UNKNOWN_USER, UNKNOWN_GROUP, DUPLICATE_USER, DUPLICATE_GROUP, USER_ALREADY_IN_GROUP, USER_NOT_IN_GROUP, TRIVIAL_RENAME, INVALID_PASSWORD, GROUP_STILL_OCCUPIED, USER_MUST_BE_IN_A_GROUP, INVALID_USERNAME, INVALID_GROUPNAME;
+    }
 }