This project has retired. For details please refer to its Attic page.
MemoryPermission xref
View Javadoc

1   package org.apache.archiva.redback.rbac.memory;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.archiva.redback.rbac.Operation;
23  import org.apache.archiva.redback.rbac.Resource;
24  import org.apache.archiva.redback.rbac.Permission;
25  
26  /**
27   * MemoryPermission 
28   *
29   * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
30   *
31   */
32  public class MemoryPermission
33      implements Permission, java.io.Serializable
34  {
35  
36      /**
37       * Field name
38       */
39      private String name;
40  
41      /**
42       * Field description
43       */
44      private String description;
45  
46      /**
47       * Field operation
48       */
49      private MemoryOperation operation;
50  
51      /**
52       * Field resource
53       */
54      private MemoryResource resource;
55      
56      /**
57       * Field permanent
58       */
59      private boolean permanent = false;
60  
61      /**
62       * Method equals
63       * 
64       * @param other
65       */
66      public boolean equals( Object other )
67      {
68          if ( this == other )
69          {
70              return true;
71          }
72  
73          if ( !( other instanceof MemoryPermission ) )
74          {
75              return false;
76          }
77  
78          MemoryPermission that = (MemoryPermission) other;
79          boolean result = true;
80          result = result && ( getName() == null ? that.getName() == null : getName().equals( that.getName() ) );
81          return result;
82      }
83  
84      /**
85       * Get null
86       */
87      public String getDescription()
88      {
89          return this.description;
90      }
91  
92      /**
93       * Get null
94       */
95      public String getName()
96      {
97          return this.name;
98      }
99  
100     /**
101      * Get null
102      */
103     public Operation getOperation()
104     {
105         return (Operation) this.operation;
106     }
107 
108     /**
109      * Get null
110      */
111     public Resource getResource()
112     {
113         return (Resource) this.resource;
114     }
115 
116     /**
117      * Method hashCode
118      */
119     public int hashCode()
120     {
121         int result = 17;
122         result = 37 * result + ( name != null ? name.hashCode() : 0 );
123         return result;
124     }
125 
126     /**
127      * Set null
128      * 
129      * @param description
130      */
131     public void setDescription( String description )
132     {
133         this.description = description;
134     }
135 
136     /**
137      * Set null
138      * 
139      * @param name
140      */
141     public void setName( String name )
142     {
143         this.name = name;
144     }
145 
146     /**
147      * Set null
148      * 
149      * @param operation
150      */
151     public void setOperation( Operation operation )
152     {
153         if ( !( operation instanceof Operation ) )
154         {
155             throw new ClassCastException( "MemoryPermission.setOperation(operation) parameter must be instanceof "
156                 + Operation.class.getName() );
157         }
158         this.operation = (MemoryOperation) operation;
159     }
160 
161     /**
162      * Set null
163      * 
164      * @param resource
165      */
166     public void setResource( Resource resource )
167     {
168         if ( !( resource instanceof Resource ) )
169         {
170             throw new ClassCastException( "MemoryPermission.setResource(resource) parameter must be instanceof "
171                 + Resource.class.getName() );
172         }
173         this.resource = (MemoryResource) resource;
174     }
175 
176     /**
177      * Method toString
178      */
179     public String toString()
180     {
181         StringBuilder buf = new StringBuilder();
182         buf.append( "name = '" );
183         buf.append( getName() + "'" );
184         return buf.toString();
185     }
186 
187     public boolean isPermanent()
188     {
189         return permanent;
190     }
191 
192     public void setPermanent( boolean permanent )
193     {
194         this.permanent = permanent;
195     }
196 }