KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > security > permissions > impl > hibernate > NodePermissionEntryImpl


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.security.permissions.impl.hibernate;
18
19 import java.util.HashSet JavaDoc;
20 import java.util.Set JavaDoc;
21
22 import org.alfresco.repo.domain.NodeKey;
23 import org.alfresco.service.cmr.repository.NodeRef;
24 import org.alfresco.service.cmr.repository.StoreRef;
25
26 /**
27  * The hibernate persisted class for node permission entries.
28  *
29  * @author andyh
30  */

31 public class NodePermissionEntryImpl implements NodePermissionEntry
32 {
33     /**
34      * The key to find node permission entries
35      */

36     private NodeKey nodeKey;
37
38     /**
39      * Inherit permissions from the parent node?
40      */

41     private boolean inherits;
42
43     /**
44      * The set of permission entries.
45      */

46     private Set JavaDoc<PermissionEntry> permissionEntries = new HashSet JavaDoc<PermissionEntry>();
47
48     public NodePermissionEntryImpl()
49     {
50         super();
51     }
52
53     public NodeKey getNodeKey()
54     {
55         return nodeKey;
56     }
57
58     public void setNodeKey(NodeKey nodeKey)
59     {
60         this.nodeKey = nodeKey;
61     }
62
63     public NodeRef getNodeRef()
64     {
65         return new NodeRef(new StoreRef(nodeKey.getProtocol(), nodeKey
66                 .getIdentifier()), nodeKey.getGuid());
67     }
68
69     public boolean getInherits()
70     {
71         return inherits;
72     }
73
74     public void setInherits(boolean inherits)
75     {
76         this.inherits = inherits;
77     }
78
79     public Set JavaDoc<PermissionEntry> getPermissionEntries()
80     {
81         return permissionEntries;
82     }
83     
84     // Hibernate
85

86     /* package */ void setPermissionEntries(Set JavaDoc<PermissionEntry> permissionEntries)
87     {
88         this.permissionEntries = permissionEntries;
89     }
90
91     // Hibernate pattern
92

93     @Override JavaDoc
94     public boolean equals(Object JavaDoc o)
95     {
96         if (this == o)
97         {
98             return true;
99         }
100         if (!(o instanceof NodePermissionEntryImpl))
101         {
102             return false;
103         }
104         NodePermissionEntryImpl other = (NodePermissionEntryImpl) o;
105
106         return this.nodeKey.equals(other.nodeKey)
107                 && (this.inherits == other.inherits)
108                 && (this.permissionEntries.equals(other.permissionEntries));
109     }
110
111     @Override JavaDoc
112     public int hashCode()
113     {
114         return nodeKey.hashCode();
115     }
116
117 }
118
Popular Tags