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.config.beans;
21  
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import org.apache.directory.api.ldap.model.name.Dn;
27  import org.apache.directory.server.config.ConfigurationElement;
28  
29  
30  /**
31   * A class used to store the Partition configuration. It can't be instanciated
32   *
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   */
35  public abstract class PartitionBean extends AdsBaseBean
36  {
37      /** The Partition identifier */
38      @ConfigurationElement(attributeType = "ads-partitionId", isRdn = true)
39      private String partitionId;
40  
41      /** The Partition suffix */
42      @ConfigurationElement(attributeType = "ads-partitionSuffix")
43      private Dn partitionSuffix;
44  
45      /** Tells if the data should be flushed to disk immediately */
46      @ConfigurationElement(attributeType = "ads-partitionSyncOnWrite", isOptional = true)
47      private boolean partitionSyncOnWrite;
48  
49      /** The partition's ContextEntry */
50      @ConfigurationElement(attributeType = "ads-contextEntry", isOptional = true)
51      private String contextEntry;
52  
53      /** The list of declared indexes */
54      @ConfigurationElement(objectClass = "ads-index", container = "indexes")
55      private List<IndexBean> indexes = new ArrayList<>();
56  
57  
58      /**
59       * Create a new PartitionBean instance
60       */
61      public PartitionBean()
62      {
63      }
64  
65  
66      /**
67       * @return the partitionId
68       */
69      public String getPartitionId()
70      {
71          return partitionId;
72      }
73  
74  
75      /**
76       * @param partitionId the partitionId to set
77       */
78      public void setPartitionId( String partitionId )
79      {
80          this.partitionId = partitionId;
81      }
82  
83  
84      /**
85       * @return the partitionSuffix
86       */
87      public Dn getPartitionSuffix()
88      {
89          return partitionSuffix;
90      }
91  
92  
93      /**
94       * @param partitionSuffix the partitionSuffix to set
95       */
96      public void setPartitionSuffix( Dn partitionSuffix )
97      {
98          this.partitionSuffix = partitionSuffix;
99      }
100 
101 
102     /**
103      * @return the partitionSyncOnWrite
104      */
105     public boolean isPartitionSyncOnWrite()
106     {
107         return partitionSyncOnWrite;
108     }
109 
110 
111     /**
112      * @param partitionSyncOnWrite the partitionSyncOnWrite to set
113      */
114     public void setPartitionSyncOnWrite( boolean partitionSyncOnWrite )
115     {
116         this.partitionSyncOnWrite = partitionSyncOnWrite;
117     }
118 
119 
120     /**
121      * @return the indexes
122      */
123     public List<IndexBean> getIndexes()
124     {
125         return indexes;
126     }
127 
128 
129     /**
130      * @param indexes the indexes to set
131      */
132     public void setIndexes( List<IndexBean> indexes )
133     {
134         this.indexes = indexes;
135     }
136 
137 
138     /**
139      * @param contextEntry the contextEntry to set
140      */
141     public void setContextEntry( String contextEntry )
142     {
143         this.contextEntry = contextEntry;
144     }
145 
146 
147     /**
148      * @return the contextEntry
149      */
150     public String getContextEntry()
151     {
152         return contextEntry;
153     }
154 
155 
156     /**
157      * {@inheritDoc}
158      */
159     @Override
160     public String toString( String tabs )
161     {
162         StringBuilder sb = new StringBuilder();
163 
164         sb.append( super.toString( tabs + "  " ) );
165         sb.append( tabs ).append( "  partition ID : " ).append( partitionId ).append( '\n' );
166         sb.append( tabs ).append( "  suffix : " ).append( partitionSuffix.getName() ).append( '\n' );
167         sb.append( toString( tabs, "  sync on write", partitionSyncOnWrite ) );
168         sb.append( toString( tabs, "  contextEntry", contextEntry ) );
169 
170         sb.append( tabs ).append( "  indexes : \n" );
171 
172         if ( indexes != null )
173         {
174             for ( IndexBean index : indexes )
175             {
176                 sb.append( index.toString( tabs + "    " ) );
177             }
178         }
179 
180         return sb.toString();
181     }
182 
183 
184     /**
185      * {@inheritDoc}
186      */
187     @Override
188     public String toString()
189     {
190         return toString( "" );
191     }
192 }