1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.model.schema.registries.helper;
21
22
23 import org.apache.directory.api.ldap.model.exception.LdapException;
24 import org.apache.directory.api.ldap.model.schema.NameForm;
25 import org.apache.directory.api.ldap.model.schema.ObjectClass;
26 import org.apache.directory.api.ldap.model.schema.SchemaErrorHandler;
27 import org.apache.directory.api.ldap.model.schema.registries.AttributeTypeRegistry;
28 import org.apache.directory.api.ldap.model.schema.registries.Registries;
29
30
31
32
33
34
35
36
37 public final class NameFormHelper
38 {
39 private NameFormHelper()
40 {
41 }
42
43
44
45
46
47
48
49
50
51
52
53 public static void addToRegistries( NameForm nameForm, SchemaErrorHandler errorHandler, Registries registries )
54 throws LdapException
55 {
56 if ( registries != null )
57 {
58 try
59 {
60 nameForm.unlock();
61
62 AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
63
64 ObjectClass structuralObjectClass = registries.getObjectClassRegistry().lookup(
65 nameForm.getStructuralObjectClassOid() );
66 nameForm.setStructuralObjectClass( structuralObjectClass );
67
68 nameForm.getMayAttributeTypes().clear();
69
70 for ( String oid : nameForm.getMayAttributeTypeOids() )
71 {
72 nameForm.getMayAttributeTypes().add( atRegistry.lookup( oid ) );
73 }
74
75 nameForm.getMustAttributeTypes().clear();
76
77 for ( String oid : nameForm.getMustAttributeTypeOids() )
78 {
79 nameForm.getMustAttributeTypes().add( atRegistry.lookup( oid ) );
80 }
81 }
82 finally
83 {
84 nameForm.lock();
85 }
86 }
87 }
88 }