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.server.core.api.administrative;
21  
22  
23  import java.util.Map;
24  import java.util.concurrent.ConcurrentHashMap;
25  
26  import org.apache.directory.api.ldap.model.name.Dn;
27  import org.apache.directory.api.ldap.model.subtree.AdministrativeRole;
28  
29  
30  /**
31   * Abstract implementation for the AdministrativePoint
32   * 
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   */
35  public abstract class AbstractAdministrativePoint implements AdministrativePoint
36  {
37      /** The AA's Dn */
38      protected Dn dn;
39  
40      /** The AA's UUID */
41      protected String uuid;
42  
43      /** The AdmonistrativeRole */
44      protected AdministrativeRole role;
45  
46      /** The parent AdministrativePoint */
47      protected AdministrativePoint parent;
48  
49      /** The children AdministrativePoints */
50      protected Map<String, AdministrativePoint> children;
51  
52  
53      /**
54       * Creates a new instance of AbstractAdministrativePoint.
55       * 
56       * @param dn The AP Dn
57       * @param uuid The AP UUID
58       * @param role The role
59       */
60      protected AbstractAdministrativePoint( Dn dn, String uuid, AdministrativeRole role )
61      {
62          this.dn = dn;
63          this.uuid = uuid;
64          this.role = role;
65          this.children = new ConcurrentHashMap<>();
66      }
67  
68  
69      /**
70       * {@inheritDoc}
71       */
72      public AdministrativeRole getRole()
73      {
74          return role;
75      }
76  
77  
78      /**
79       * {@inheritDoc}
80       */
81      public Dn getDn()
82      {
83          return dn;
84      }
85  
86  
87      /**
88       * {@inheritDoc}
89       */
90      public String getUuid()
91      {
92          return uuid;
93      }
94  
95  
96      /**
97       * {@inheritDoc}
98       */
99      public boolean isAutonomous()
100     {
101         // Default to false
102         return false;
103     }
104 
105 
106     /**
107      * {@inheritDoc}
108      */
109     public AdministrativePoint getParent()
110     {
111         return parent;
112     }
113 
114 
115     /**
116      * {@inheritDoc}
117      */
118     public void setParent( AdministrativePoint parent )
119     {
120         this.parent = parent;
121     }
122 
123 
124     /**
125      * {@inheritDoc}
126      */
127     public String toString()
128     {
129         StringBuilder sb = new StringBuilder();
130 
131         sb.append( "Role: '" ).append( role ).append( "', " );
132         sb.append( "Dn: '" ).append( dn ).append( "', " );
133         sb.append( "UUID: " ).append( uuid ).append( '\n' );
134 
135         return sb.toString();
136     }
137 }