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 java.util.List;
24
25 import org.apache.directory.api.ldap.model.exception.LdapException;
26 import org.apache.directory.api.ldap.model.schema.NameForm;
27 import org.apache.directory.api.ldap.model.schema.ObjectClass;
28 import org.apache.directory.api.ldap.model.schema.registries.AttributeTypeRegistry;
29 import org.apache.directory.api.ldap.model.schema.registries.Registries;
30
31
32
33
34
35
36
37
38 public final class NameFormHelper
39 {
40 private NameFormHelper()
41 {
42 }
43
44
45
46
47
48
49
50
51
52
53
54 public static void addToRegistries( NameForm nameForm, List<Throwable> errors, Registries registries )
55 throws LdapException
56 {
57 if ( registries != null )
58 {
59 try
60 {
61 nameForm.unlock();
62
63 AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
64
65 ObjectClass structuralObjectClass = registries.getObjectClassRegistry().lookup(
66 nameForm.getStructuralObjectClassOid() );
67 nameForm.setStructuralObjectClass( structuralObjectClass );
68
69 nameForm.getMayAttributeTypes().clear();
70
71 for ( String oid : nameForm.getMayAttributeTypeOids() )
72 {
73 nameForm.getMayAttributeTypes().add( atRegistry.lookup( oid ) );
74 }
75
76 nameForm.getMustAttributeTypes().clear();
77
78 for ( String oid : nameForm.getMustAttributeTypeOids() )
79 {
80 nameForm.getMustAttributeTypes().add( atRegistry.lookup( oid ) );
81 }
82 }
83 finally
84 {
85 nameForm.lock();
86 }
87 }
88 }
89 }