001: /*
002: * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
003: * @author <a href="mailto:oliver@wehrens.de">Oliver Wehrens</a>
004: * @version $Id: PortletRole.java 6385 2007-10-25 14:02:26Z wehrens $
005: */
006: package org.gridsphere.services.core.security.role;
007:
008: import java.io.Serializable;
009:
010: /**
011: * The <code>PortletRole</code> describes the supported portlet roles used
012: * by the portal.
013: */
014: public class PortletRole implements Serializable, Cloneable {
015:
016: private String oid = null;
017:
018: private String roleName = null;
019: private String description = "";
020: // if 0 isdefault is false
021: private Integer isDefault = 0;
022:
023: private static final String USER_ROLE_STRING = "USER";
024: private static final String ADMIN_ROLE_STRING = "ADMIN";
025:
026: public static final PortletRole USER = new PortletRole(
027: USER_ROLE_STRING);
028: public static final PortletRole ADMIN = new PortletRole(
029: ADMIN_ROLE_STRING);
030:
031: public PortletRole() {
032: }
033:
034: /**
035: * Constructs an instance of PortletRole
036: *
037: * @param roleName the role name
038: */
039: public PortletRole(String roleName) {
040: this .roleName = roleName;
041: }
042:
043: public String getOid() {
044: return oid;
045: }
046:
047: public void setOid(String oid) {
048: this .oid = oid;
049: }
050:
051: public void setIsDefault(Integer isDefault) {
052: this .isDefault = isDefault;
053: }
054:
055: public Integer getIsDefault() {
056: return isDefault;
057: }
058:
059: /**
060: * Returns the role name
061: *
062: * @return the role name
063: */
064: public String getName() {
065: return roleName;
066: }
067:
068: /**
069: * Sets the role name
070: *
071: * @param roleName the role name
072: */
073: public void setName(String roleName) {
074: this .roleName = roleName;
075: }
076:
077: public String getDescription() {
078: return description;
079: }
080:
081: public void setDescription(String description) {
082: this .description = description;
083: }
084:
085: public String toString() {
086: return roleName;
087: }
088:
089: public Object clone() throws CloneNotSupportedException {
090: PortletRole r = (PortletRole) super .clone();
091: r.roleName = this .roleName;
092: return r;
093: }
094:
095: public boolean equals(Object object) {
096: if (object != null
097: && (object.getClass().equals(this .getClass()))) {
098: PortletRole portletRole = (PortletRole) object;
099: return (roleName.equals(portletRole.getName()));
100: }
101: return false;
102: }
103:
104: public int hashCode() {
105: return roleName.hashCode();
106: }
107:
108: }
|