001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.model;
022:
023: import java.io.Serializable;
024:
025: /**
026: * <a href="PermissionDisplay.java.html"><b><i>View Source</i></b></a>
027: *
028: * @author Brian Wing Shun Chan
029: * @author Jorge Ferrer
030: *
031: */
032: public class PermissionDisplay implements Comparable, Serializable {
033:
034: public PermissionDisplay(Permission permission, Resource resource,
035: String portletName, String portletLabel, String modelName,
036: String modelLabel, String actionId, String actionLabel) {
037:
038: _permission = permission;
039: _resource = resource;
040: _portletName = portletName;
041: _portletLabel = portletLabel;
042: _modelName = modelName;
043: _modelLabel = modelLabel;
044: _actionId = actionId;
045: _actionLabel = actionLabel;
046: }
047:
048: public Permission getPermission() {
049: return _permission;
050: }
051:
052: public Resource getResource() {
053: return _resource;
054: }
055:
056: public String getPortletName() {
057: return _portletName;
058: }
059:
060: public String getPortletLabel() {
061: return _portletLabel;
062: }
063:
064: public String getModelName() {
065: return _modelName;
066: }
067:
068: public String getModelLabel() {
069: return _modelLabel;
070: }
071:
072: public String getActionId() {
073: return _actionId;
074: }
075:
076: public String getActionLabel() {
077: return _actionLabel;
078: }
079:
080: public int compareTo(Object obj) {
081: if (obj == null) {
082: return -1;
083: }
084:
085: PermissionDisplay permissionDisplay = (PermissionDisplay) obj;
086:
087: int value = getPortletLabel().compareTo(
088: permissionDisplay.getPortletLabel());
089:
090: if (value == 0) {
091: value = getModelLabel().compareTo(
092: permissionDisplay.getModelLabel());
093:
094: if (value == 0) {
095: value = getActionLabel().compareTo(
096: permissionDisplay.getActionLabel());
097: }
098: }
099:
100: return value;
101: }
102:
103: public boolean equals(Object obj) {
104: if (obj == null) {
105: return false;
106: }
107:
108: if (!(obj instanceof PermissionDisplay)) {
109: return false;
110: }
111:
112: PermissionDisplay permissionDisplay = (PermissionDisplay) obj;
113:
114: if (_portletName.equals(permissionDisplay.getPortletName())
115: && _modelName.equals(permissionDisplay.getModelName())
116: && _actionId.equals(permissionDisplay.getActionId())) {
117:
118: return true;
119: } else {
120: return false;
121: }
122: }
123:
124: private Permission _permission;
125: private Resource _resource;
126: private String _portletName;
127: private String _portletLabel;
128: private String _modelName;
129: private String _modelLabel;
130: private String _actionId;
131: private String _actionLabel;
132:
133: }
|