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       * Store the Set of administrative roles supported by this Subentry
65       *
66       * @param administrativeRoles The Administrative roles to set
67       */
68      public final void setAdministrativeRoles( Set<AdministrativeRole> administrativeRoles )
69      {
70          this.administrativeRoles = administrativeRoles;
71      }
72  
73  
74      /**
75       * @return The Set of administratoveRole supported by this Subentry
76       */
77      public final Set<AdministrativeRole> getAdministrativeRoles()
78      {
79          return administrativeRoles;
80      }
81  
82  
83      /**
84       * Tells if the type contains the Collective attribute Administrative Role
85       * 
86       * @return <tt>true</tt> if the type contains the Collective Attribute Administrative Role, <tt>false</tt> otherwise
87       */
88      public final boolean isCollectiveAdminRole()
89      {
90          return administrativeRoles.contains( AdministrativeRole.CollectiveAttributeInnerArea )
91              || administrativeRoles.contains( AdministrativeRole.CollectiveAttributeSpecificArea );
92      }
93  
94  
95      /**
96       * Tells if the type contains the SubSchema Administrative Role
97       * 
98       * @return <tt>true</tt> if the type contains the SubSchema Administrative Role, <tt>false</tt> otherwise
99       */
100     public final boolean isSchemaAdminRole()
101     {
102         return administrativeRoles.contains( AdministrativeRole.SubSchemaSpecificArea );
103     }
104 
105 
106     /**
107      * Tells if the type contains the Access Control Administrative Role
108      * 
109      * @return <tt>true</tt> if the type contains the Access Control Administrative Role, <tt>false</tt> otherwise
110      */
111     public final boolean isAccessControlAdminRole()
112     {
113         return administrativeRoles.contains( AdministrativeRole.AccessControlSpecificArea )
114             || administrativeRoles.contains( AdministrativeRole.AccessControlInnerArea );
115     }
116 
117 
118     /**
119      * Tells if the type contains the Triggers Administrative Role
120      * 
121      * @return <tt>true</tt> if the type contains the Triggers Administrative Role, <tt>false</tt> otherwise
122      */
123     public final boolean isTriggersAdminRole()
124     {
125         return administrativeRoles.contains( AdministrativeRole.TriggerExecutionSpecificArea )
126             || administrativeRoles.contains( AdministrativeRole.TriggerExecutionInnerArea );
127     }
128 
129 
130     /**
131      * @see Object#toString()
132      */
133     @Override
134     public String toString()
135     {
136         return "Subentry[" + administrativeRoles + ", " + ss + "]";
137     }
138 }