View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   *
19   */
20  package org.apache.directory.api.ldap.model.subtree;
21  
22  
23  import java.util.Set;
24  
25  
26  
27  /**
28   * An operational view of a subentry within the system. A Subentry can have
29   * many types (Collective, Schema, AccessControl or Trigger) but only one
30   * Subtree Specification.
31   *
32   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33   */
34  public class Subentry
35  {
36      /** The Subtree Specification associated with this subentry */
37      private SubtreeSpecification ss;
38  
39      /** The administratives roles */
40      private Set<AdministrativeRole> administrativeRoles;
41  
42  
43      /**
44       * Stores the subtree
45       *
46       * @param ss The subtree specification
47       */
48      public final void setSubtreeSpecification( SubtreeSpecification ss )
49      {
50          this.ss = ss;
51      }
52  
53  
54      /**
55       * @return The subtree specification
56       */
57      public final SubtreeSpecification getSubtreeSpecification()
58      {
59          return ss;
60      }
61  
62  
63      /**
64       *
65       * TODO setAdministrativeRoles.
66       *
67       * @param administrativeRoles
68       */
69      public final void setAdministrativeRoles( Set<AdministrativeRole> administrativeRoles )
70      {
71          this.administrativeRoles = administrativeRoles;
72      }
73  
74  
75      public final Set<AdministrativeRole> getAdministrativeRoles()
76      {
77          return administrativeRoles;
78      }
79  
80  
81      /**
82       * Tells if the type contains the Collective attribute Administrative Role
83       */
84      public final boolean isCollectiveAdminRole()
85      {
86          return administrativeRoles.contains( AdministrativeRole.CollectiveAttributeInnerArea ) ||
87              administrativeRoles.contains( AdministrativeRole.CollectiveAttributeSpecificArea );
88      }
89  
90  
91      /**
92       * Tells if the type contains the SubSchema Administrative Role
93       */
94      public final boolean isSchemaAdminRole()
95      {
96          return administrativeRoles.contains( AdministrativeRole.SubSchemaSpecificArea );
97      }
98  
99  
100     /**
101      * Tells if the type contains the Access Control Administrative Role
102      */
103     public final boolean isAccessControlAdminRole()
104     {
105         return administrativeRoles.contains( AdministrativeRole.AccessControlSpecificArea ) ||
106             administrativeRoles.contains( AdministrativeRole.AccessControlInnerArea );
107     }
108 
109 
110     /**
111      * Tells if the type contains the Triggers Administrative Role
112      */
113     public final boolean isTriggersAdminRole()
114     {
115         return administrativeRoles.contains( AdministrativeRole.TriggerExecutionSpecificArea ) ||
116             administrativeRoles.contains( AdministrativeRole.TriggerExecutionInnerArea );
117     }
118 
119 
120     /**
121      * @see Object#toString()
122      */
123     public String toString()
124     {
125         return "Subentry[" + administrativeRoles + ", " + ss + "]";
126     }
127 }