001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/common/api/src/java/org/theospi/portfolio/security/model/Permission.java $
003: * $Id: Permission.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.theospi.portfolio.security.model;
021:
022: import org.apache.commons.logging.Log;
023: import org.apache.commons.logging.LogFactory;
024: import org.sakaiproject.metaobj.shared.model.Agent;
025:
026: public class Permission {
027: protected final transient Log logger = LogFactory
028: .getLog(getClass());
029:
030: private Agent agent;
031: private String function;
032: private boolean readOnly = false;
033:
034: public Permission() {
035: }
036:
037: public Permission(Agent agent, String function) {
038: this .agent = agent;
039: this .function = function;
040: }
041:
042: public Permission(Agent agent, String function, boolean readOnly) {
043: this .agent = agent;
044: this .function = function;
045: this .readOnly = readOnly;
046: }
047:
048: public String getFunction() {
049: return function;
050: }
051:
052: public void setFunction(String function) {
053: this .function = function;
054: }
055:
056: public Agent getAgent() {
057: return agent;
058: }
059:
060: public void setAgent(Agent agent) {
061: this .agent = agent;
062: }
063:
064: public boolean isReadOnly() {
065: return readOnly;
066: }
067:
068: public void setReadOnly(boolean readOnly) {
069: this .readOnly = readOnly;
070: }
071:
072: public String toString() {
073: return getAgent().getDisplayName() + "~" + getFunction();
074: }
075:
076: public boolean equals(Object o) {
077: if (this == o)
078: return true;
079: if (!(o instanceof Permission))
080: return false;
081:
082: final Permission permission = (Permission) o;
083:
084: if (agent != null ? !agent.equals(permission.agent)
085: : permission.agent != null)
086: return false;
087: if (function != null ? !function.equals(permission.function)
088: : permission.function != null)
089: return false;
090:
091: return true;
092: }
093:
094: public int hashCode() {
095: int result;
096: result = (agent != null ? agent.hashCode() : 0);
097: result = 29 * result
098: + (function != null ? function.hashCode() : 0);
099: return result;
100: }
101: }
|