001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.admin.std.meta;
028
029
030
031 import org.opends.server.admin.AdministratorAction;
032 import org.opends.server.admin.BooleanPropertyDefinition;
033 import org.opends.server.admin.ClassPropertyDefinition;
034 import org.opends.server.admin.client.AuthorizationException;
035 import org.opends.server.admin.client.CommunicationException;
036 import org.opends.server.admin.client.ConcurrentModificationException;
037 import org.opends.server.admin.client.ManagedObject;
038 import org.opends.server.admin.client.MissingMandatoryPropertiesException;
039 import org.opends.server.admin.client.OperationRejectedException;
040 import org.opends.server.admin.DefaultBehaviorProvider;
041 import org.opends.server.admin.DefinedDefaultBehaviorProvider;
042 import org.opends.server.admin.ManagedObjectAlreadyExistsException;
043 import org.opends.server.admin.ManagedObjectDefinition;
044 import org.opends.server.admin.PropertyIsReadOnlyException;
045 import org.opends.server.admin.PropertyOption;
046 import org.opends.server.admin.PropertyProvider;
047 import org.opends.server.admin.server.ConfigurationChangeListener;
048 import org.opends.server.admin.server.ServerManagedObject;
049 import org.opends.server.admin.std.client.DirectoryStringAttributeSyntaxCfgClient;
050 import org.opends.server.admin.std.server.AttributeSyntaxCfg;
051 import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg;
052 import org.opends.server.admin.Tag;
053 import org.opends.server.types.DN;
054
055
056
057 /**
058 * An interface for querying the Directory String Attribute Syntax
059 * managed object definition meta information.
060 * <p>
061 * The Directory String Attribute Syntax defines an attribute syntax
062 * for storing arbitrary string (and sometimes binary) data.
063 */
064 public final class DirectoryStringAttributeSyntaxCfgDefn extends ManagedObjectDefinition<DirectoryStringAttributeSyntaxCfgClient, DirectoryStringAttributeSyntaxCfg> {
065
066 // The singleton configuration definition instance.
067 private static final DirectoryStringAttributeSyntaxCfgDefn INSTANCE = new DirectoryStringAttributeSyntaxCfgDefn();
068
069
070
071 // The "allow-zero-length-values" property definition.
072 private static final BooleanPropertyDefinition PD_ALLOW_ZERO_LENGTH_VALUES;
073
074
075
076 // The "java-class" property definition.
077 private static final ClassPropertyDefinition PD_JAVA_CLASS;
078
079
080
081 // Build the "allow-zero-length-values" property definition.
082 static {
083 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "allow-zero-length-values");
084 builder.setOption(PropertyOption.ADVANCED);
085 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "allow-zero-length-values"));
086 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false");
087 builder.setDefaultBehaviorProvider(provider);
088 PD_ALLOW_ZERO_LENGTH_VALUES = builder.getInstance();
089 INSTANCE.registerPropertyDefinition(PD_ALLOW_ZERO_LENGTH_VALUES);
090 }
091
092
093
094 // Build the "java-class" property definition.
095 static {
096 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
097 builder.setOption(PropertyOption.READ_ONLY);
098 builder.setOption(PropertyOption.MANDATORY);
099 builder.setOption(PropertyOption.ADVANCED);
100 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
101 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.schema.DirectoryStringSyntax");
102 builder.setDefaultBehaviorProvider(provider);
103 builder.addInstanceOf("org.opends.server.api.AttributeSyntax");
104 PD_JAVA_CLASS = builder.getInstance();
105 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
106 }
107
108
109
110 // Register the tags associated with this managed object definition.
111 static {
112 INSTANCE.registerTag(Tag.valueOf("core-server"));
113 }
114
115
116
117 /**
118 * Get the Directory String Attribute Syntax configuration
119 * definition singleton.
120 *
121 * @return Returns the Directory String Attribute Syntax
122 * configuration definition singleton.
123 */
124 public static DirectoryStringAttributeSyntaxCfgDefn getInstance() {
125 return INSTANCE;
126 }
127
128
129
130 /**
131 * Private constructor.
132 */
133 private DirectoryStringAttributeSyntaxCfgDefn() {
134 super("directory-string-attribute-syntax", AttributeSyntaxCfgDefn.getInstance());
135 }
136
137
138
139 /**
140 * {@inheritDoc}
141 */
142 public DirectoryStringAttributeSyntaxCfgClient createClientConfiguration(
143 ManagedObject<? extends DirectoryStringAttributeSyntaxCfgClient> impl) {
144 return new DirectoryStringAttributeSyntaxCfgClientImpl(impl);
145 }
146
147
148
149 /**
150 * {@inheritDoc}
151 */
152 public DirectoryStringAttributeSyntaxCfg createServerConfiguration(
153 ServerManagedObject<? extends DirectoryStringAttributeSyntaxCfg> impl) {
154 return new DirectoryStringAttributeSyntaxCfgServerImpl(impl);
155 }
156
157
158
159 /**
160 * {@inheritDoc}
161 */
162 public Class<DirectoryStringAttributeSyntaxCfg> getServerConfigurationClass() {
163 return DirectoryStringAttributeSyntaxCfg.class;
164 }
165
166
167
168 /**
169 * Get the "allow-zero-length-values" property definition.
170 * <p>
171 * Indicates whether zero-length (that is, an empty string) values
172 * are allowed.
173 * <p>
174 * This is technically not allowed by the revised LDAPv3
175 * specification, but some environments may require it for backward
176 * compatibility with servers that do allow it.
177 *
178 * @return Returns the "allow-zero-length-values" property definition.
179 */
180 public BooleanPropertyDefinition getAllowZeroLengthValuesPropertyDefinition() {
181 return PD_ALLOW_ZERO_LENGTH_VALUES;
182 }
183
184
185
186 /**
187 * Get the "enabled" property definition.
188 * <p>
189 * Indicates whether the Directory String Attribute Syntax is
190 * enabled.
191 *
192 * @return Returns the "enabled" property definition.
193 */
194 public BooleanPropertyDefinition getEnabledPropertyDefinition() {
195 return AttributeSyntaxCfgDefn.getInstance().getEnabledPropertyDefinition();
196 }
197
198
199
200 /**
201 * Get the "java-class" property definition.
202 * <p>
203 * Specifies the fully-qualified name of the Java class that
204 * provides the Directory String Attribute Syntax implementation.
205 *
206 * @return Returns the "java-class" property definition.
207 */
208 public ClassPropertyDefinition getJavaClassPropertyDefinition() {
209 return PD_JAVA_CLASS;
210 }
211
212
213
214 /**
215 * Managed object client implementation.
216 */
217 private static class DirectoryStringAttributeSyntaxCfgClientImpl implements
218 DirectoryStringAttributeSyntaxCfgClient {
219
220 // Private implementation.
221 private ManagedObject<? extends DirectoryStringAttributeSyntaxCfgClient> impl;
222
223
224
225 // Private constructor.
226 private DirectoryStringAttributeSyntaxCfgClientImpl(
227 ManagedObject<? extends DirectoryStringAttributeSyntaxCfgClient> impl) {
228 this.impl = impl;
229 }
230
231
232
233 /**
234 * {@inheritDoc}
235 */
236 public boolean isAllowZeroLengthValues() {
237 return impl.getPropertyValue(INSTANCE.getAllowZeroLengthValuesPropertyDefinition());
238 }
239
240
241
242 /**
243 * {@inheritDoc}
244 */
245 public void setAllowZeroLengthValues(Boolean value) {
246 impl.setPropertyValue(INSTANCE.getAllowZeroLengthValuesPropertyDefinition(), value);
247 }
248
249
250
251 /**
252 * {@inheritDoc}
253 */
254 public Boolean isEnabled() {
255 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
256 }
257
258
259
260 /**
261 * {@inheritDoc}
262 */
263 public void setEnabled(boolean value) {
264 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
265 }
266
267
268
269 /**
270 * {@inheritDoc}
271 */
272 public String getJavaClass() {
273 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
274 }
275
276
277
278 /**
279 * {@inheritDoc}
280 */
281 public void setJavaClass(String value) throws PropertyIsReadOnlyException {
282 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
283 }
284
285
286
287 /**
288 * {@inheritDoc}
289 */
290 public ManagedObjectDefinition<? extends DirectoryStringAttributeSyntaxCfgClient, ? extends DirectoryStringAttributeSyntaxCfg> definition() {
291 return INSTANCE;
292 }
293
294
295
296 /**
297 * {@inheritDoc}
298 */
299 public PropertyProvider properties() {
300 return impl;
301 }
302
303
304
305 /**
306 * {@inheritDoc}
307 */
308 public void commit() throws ManagedObjectAlreadyExistsException,
309 MissingMandatoryPropertiesException, ConcurrentModificationException,
310 OperationRejectedException, AuthorizationException,
311 CommunicationException {
312 impl.commit();
313 }
314
315 }
316
317
318
319 /**
320 * Managed object server implementation.
321 */
322 private static class DirectoryStringAttributeSyntaxCfgServerImpl implements
323 DirectoryStringAttributeSyntaxCfg {
324
325 // Private implementation.
326 private ServerManagedObject<? extends DirectoryStringAttributeSyntaxCfg> impl;
327
328 // The value of the "allow-zero-length-values" property.
329 private final boolean pAllowZeroLengthValues;
330
331 // The value of the "enabled" property.
332 private final boolean pEnabled;
333
334 // The value of the "java-class" property.
335 private final String pJavaClass;
336
337
338
339 // Private constructor.
340 private DirectoryStringAttributeSyntaxCfgServerImpl(ServerManagedObject<? extends DirectoryStringAttributeSyntaxCfg> impl) {
341 this.impl = impl;
342 this.pAllowZeroLengthValues = impl.getPropertyValue(INSTANCE.getAllowZeroLengthValuesPropertyDefinition());
343 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
344 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
345 }
346
347
348
349 /**
350 * {@inheritDoc}
351 */
352 public void addDirectoryStringChangeListener(
353 ConfigurationChangeListener<DirectoryStringAttributeSyntaxCfg> listener) {
354 impl.registerChangeListener(listener);
355 }
356
357
358
359 /**
360 * {@inheritDoc}
361 */
362 public void removeDirectoryStringChangeListener(
363 ConfigurationChangeListener<DirectoryStringAttributeSyntaxCfg> listener) {
364 impl.deregisterChangeListener(listener);
365 }
366 /**
367 * {@inheritDoc}
368 */
369 public void addChangeListener(
370 ConfigurationChangeListener<AttributeSyntaxCfg> listener) {
371 impl.registerChangeListener(listener);
372 }
373
374
375
376 /**
377 * {@inheritDoc}
378 */
379 public void removeChangeListener(
380 ConfigurationChangeListener<AttributeSyntaxCfg> listener) {
381 impl.deregisterChangeListener(listener);
382 }
383
384
385
386 /**
387 * {@inheritDoc}
388 */
389 public boolean isAllowZeroLengthValues() {
390 return pAllowZeroLengthValues;
391 }
392
393
394
395 /**
396 * {@inheritDoc}
397 */
398 public boolean isEnabled() {
399 return pEnabled;
400 }
401
402
403
404 /**
405 * {@inheritDoc}
406 */
407 public String getJavaClass() {
408 return pJavaClass;
409 }
410
411
412
413 /**
414 * {@inheritDoc}
415 */
416 public Class<? extends DirectoryStringAttributeSyntaxCfg> configurationClass() {
417 return DirectoryStringAttributeSyntaxCfg.class;
418 }
419
420
421
422 /**
423 * {@inheritDoc}
424 */
425 public DN dn() {
426 return impl.getDN();
427 }
428
429 }
430 }