Commits

Sebastian Sdorra committed c837722

move event to correct package, serializable, toString, equals and hashCode

  • Participants
  • Parent commits a8cc573
  • Branches issue-340

Comments (0)

Files changed (6)

scm-core/src/main/java/sonia/scm/security/AssignedPermission.java

 
 package sonia.scm.security;
 
+//~--- non-JDK imports --------------------------------------------------------
+
+import com.google.common.base.Objects;
+
 //~--- JDK imports ------------------------------------------------------------
 
+import java.io.Serializable;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlRootElement(name = "assigned-permission")
-public class AssignedPermission implements PermissionObject
+public class AssignedPermission implements PermissionObject, Serializable
 {
 
+  /** Field description */
+  private static final long serialVersionUID = -7411338422110323879L;
+
+  //~--- constructors ---------------------------------------------------------
+
   /**
    * Constructor is only visible for JAXB.
    *
     this.permission = permission;
   }
 
+  //~--- methods --------------------------------------------------------------
+
+  /**
+   * Method description
+   *
+   *
+   * @param obj
+   *
+   * @return
+   */
+  @Override
+  public boolean equals(Object obj)
+  {
+    if (obj == null)
+    {
+      return false;
+    }
+
+    if (getClass() != obj.getClass())
+    {
+      return false;
+    }
+
+    final AssignedPermission other = (AssignedPermission) obj;
+
+    return Objects.equal(name, other.name)
+      && Objects.equal(groupPermission, other.groupPermission)
+      && Objects.equal(permission, other.permission);
+  }
+
+  /**
+   * Method description
+   *
+   *
+   * @return
+   */
+  @Override
+  public int hashCode()
+  {
+    return Objects.hashCode(name, groupPermission, permission);
+  }
+
+  /**
+   * Method description
+   *
+   *
+   * @return
+   */
+  @Override
+  public String toString()
+  {
+    //J-
+    return Objects.toStringHelper(this)
+                  .add("name", name)
+                  .add("groupPermisison", groupPermission)
+                  .add("permission", permission)
+                  .toString();
+    //J+
+  }
+
   //~--- get methods ----------------------------------------------------------
 
   /**

scm-core/src/main/java/sonia/scm/security/StoredAssignedPermission.java

 public class StoredAssignedPermission extends AssignedPermission
 {
 
+  /** Field description */
+  private static final long serialVersionUID = -4593919877023168090L;
+
+  //~--- constructors ---------------------------------------------------------
+
   /**
    * Constructor is only visible for JAXB.
    *

scm-core/src/main/java/sonia/scm/security/StoredAssignedPermissionEvent.java

+/**
+ * Copyright (c) 2010, Sebastian Sdorra All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. Neither the name of SCM-Manager;
+ * nor the names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ *
+ */
+
+
+
+package sonia.scm.security;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import com.google.common.base.Objects;
+
+import sonia.scm.HandlerEvent;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Sebastian Sdorra
+ * @since 1.31
+ */
+public final class StoredAssignedPermissionEvent implements Serializable
+{
+
+  /** Field description */
+  private static final long serialVersionUID = 706824497813169009L;
+
+  //~--- constructors ---------------------------------------------------------
+
+  /**
+   * Constructs ...
+   *
+   *
+   * @param type
+   * @param permission
+   */
+  public StoredAssignedPermissionEvent(HandlerEvent type,
+    StoredAssignedPermission permission)
+  {
+    this.type = type;
+    this.permission = permission;
+  }
+
+  //~--- methods --------------------------------------------------------------
+
+  /**
+   * Method description
+   *
+   *
+   * @param obj
+   *
+   * @return
+   */
+  @Override
+  public boolean equals(Object obj)
+  {
+    if (obj == null)
+    {
+      return false;
+    }
+
+    if (getClass() != obj.getClass())
+    {
+      return false;
+    }
+
+    final StoredAssignedPermissionEvent other =
+      (StoredAssignedPermissionEvent) obj;
+
+    return Objects.equal(type, other.type)
+      && Objects.equal(permission, other.permission);
+  }
+
+  /**
+   * Method description
+   *
+   *
+   * @return
+   */
+  @Override
+  public int hashCode()
+  {
+    return Objects.hashCode(type, permission);
+  }
+
+  /**
+   * Method description
+   *
+   *
+   * @return
+   */
+  @Override
+  public String toString()
+  {
+    //J-
+    return Objects.toStringHelper(this)
+                  .add("type", type)
+                  .add("permission", permission)
+                  .toString();
+    //J+
+  }
+
+  //~--- get methods ----------------------------------------------------------
+
+  /**
+   * Method description
+   *
+   *
+   * @return
+   */
+  public HandlerEvent getEventType()
+  {
+    return type;
+  }
+
+  /**
+   * Method description
+   *
+   *
+   * @return
+   */
+  public StoredAssignedPermission getPermission()
+  {
+    return permission;
+  }
+
+  //~--- fields ---------------------------------------------------------------
+
+  /** Field description */
+  private StoredAssignedPermission permission;
+
+  /** Field description */
+  private HandlerEvent type;
+}

scm-core/src/main/java/sonia/scm/store/StoredAssignedPermissionEvent.java

-/**
- * Copyright (c) 2010, Sebastian Sdorra All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer. 2. Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution. 3. Neither the name of SCM-Manager;
- * nor the names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.store;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.HandlerEvent;
-import sonia.scm.security.StoredAssignedPermission;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class StoredAssignedPermissionEvent
-{
-
-  /**
-   * Constructs ...
-   *
-   *
-   * @param type
-   * @param permission
-   */
-  public StoredAssignedPermissionEvent(HandlerEvent type,
-    StoredAssignedPermission permission)
-  {
-    this.type = type;
-    this.permission = permission;
-  }
-
-  //~--- get methods ----------------------------------------------------------
-
-  /**
-   * Method description
-   *
-   *
-   * @return
-   */
-  public HandlerEvent getEventType()
-  {
-    return type;
-  }
-
-  /**
-   * Method description
-   *
-   *
-   * @return
-   */
-  public StoredAssignedPermission getPermission()
-  {
-    return permission;
-  }
-
-  //~--- fields ---------------------------------------------------------------
-
-  /** Field description */
-  private StoredAssignedPermission permission;
-
-  /** Field description */
-  private HandlerEvent type;
-}

scm-webapp/src/main/java/sonia/scm/security/DefaultSecuritySystem.java

 import sonia.scm.group.GroupEvent;
 import sonia.scm.store.ConfigurationEntryStore;
 import sonia.scm.store.ConfigurationEntryStoreFactory;
-import sonia.scm.store.StoredAssignedPermissionEvent;
 import sonia.scm.user.UserEvent;
 
 //~--- JDK imports ------------------------------------------------------------

scm-webapp/src/main/java/sonia/scm/security/ScmRealm.java

 import sonia.scm.repository.RepositoryDAO;
 import sonia.scm.repository.RepositoryEvent;
 import sonia.scm.repository.RepositoryManager;
-import sonia.scm.store.StoredAssignedPermissionEvent;
 import sonia.scm.user.User;
 import sonia.scm.user.UserDAO;
 import sonia.scm.user.UserEvent;