1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.core.trigger;
21
22
23 import java.util.Map;
24
25 import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
26 import org.apache.directory.api.ldap.model.name.Dn;
27 import org.apache.directory.api.ldap.model.name.Rdn;
28 import org.apache.directory.api.ldap.trigger.StoredProcedureParameter;
29 import org.apache.directory.server.core.api.interceptor.context.OperationContext;
30
31
32 public class ModifyDNStoredProcedureParameterInjector extends AbstractStoredProcedureParameterInjector
33 {
34 private boolean deleteOldRn;
35 private Rdn oldRdn;
36 private Rdn newRdn;
37 private Dn oldSuperiorDn;
38 private Dn newSuperiorDn;
39 private Dn oldDn;
40 private Dn newDn;
41
42
43 public ModifyDNStoredProcedureParameterInjector( OperationContext opContext, boolean deleteOldRn,
44 Rdn oldRDN, Rdn newRdn, Dn oldSuperiorDn, Dn newSuperiorDn, Dn oldDn, Dn newDn )
45 {
46 super( opContext );
47 this.deleteOldRn = deleteOldRn;
48 this.oldRdn = oldRDN.clone();
49 this.newRdn = newRdn.clone();
50 this.oldSuperiorDn = oldSuperiorDn;
51 this.newSuperiorDn = newSuperiorDn;
52 this.oldDn = oldDn;
53 this.newDn = newDn;
54
55 Map<Class<?>, MicroInjector> injectors = super.getInjectors();
56 injectors.put( StoredProcedureParameter.ModifyDN_ENTRY.class, entryInjector );
57 injectors.put( StoredProcedureParameter.ModifyDN_NEW_RDN.class, newrdnInjector );
58 injectors.put( StoredProcedureParameter.ModifyDN_DELETE_OLD_RDN.class, deleteoldrdnInjector );
59 injectors.put( StoredProcedureParameter.ModifyDN_NEW_SUPERIOR.class, newSuperiorInjector );
60 injectors.put( StoredProcedureParameter.ModifyDN_OLD_RDN.class, oldRDNInjector );
61 injectors.put( StoredProcedureParameter.ModifyDN_OLD_SUPERIOR_DN.class, oldSuperiorDNInjector );
62 injectors.put( StoredProcedureParameter.ModifyDN_NEW_DN.class, newDNInjector );
63
64 }
65
66
67
68
69 MicroInjector entryInjector = new MicroInjector()
70 {
71 public Object inject( OperationContext opContext, StoredProcedureParameter param )
72 throws LdapInvalidDnException
73 {
74
75 return opContext.getSession().getDirectoryService().getDnFactory().create( oldDn.getName() );
76 }
77 };
78
79
80
81
82 MicroInjector newrdnInjector = new MicroInjector()
83 {
84 public Object inject( OperationContext opContext, StoredProcedureParameter param )
85 throws LdapInvalidDnException
86 {
87
88 return opContext.getSession().getDirectoryService().getDnFactory().create( newRdn.getName() );
89 }
90 };
91
92
93
94
95 MicroInjector deleteoldrdnInjector = new MicroInjector()
96 {
97 public Object inject( OperationContext opContext, StoredProcedureParameter param )
98 throws LdapInvalidDnException
99 {
100
101 return deleteOldRn;
102 }
103 };
104
105
106
107
108 MicroInjector newSuperiorInjector = new MicroInjector()
109 {
110 public Object inject( OperationContext opContext, StoredProcedureParameter param )
111 throws LdapInvalidDnException
112 {
113
114 return opContext.getSession().getDirectoryService().getDnFactory().create( newSuperiorDn.getName() );
115 }
116 };
117
118
119
120
121 MicroInjector oldRDNInjector = new MicroInjector()
122 {
123 public Object inject( OperationContext opContext, StoredProcedureParameter param )
124 throws LdapInvalidDnException
125 {
126
127 return opContext.getSession().getDirectoryService().getDnFactory().create( oldRdn.getName() );
128 }
129 };
130
131
132
133
134 MicroInjector oldSuperiorDNInjector = new MicroInjector()
135 {
136 public Object inject( OperationContext opContext, StoredProcedureParameter param )
137 throws LdapInvalidDnException
138 {
139
140 return opContext.getSession().getDirectoryService().getDnFactory().create( oldSuperiorDn.getName() );
141 }
142 };
143
144
145
146
147 MicroInjector newDNInjector = new MicroInjector()
148 {
149 public Object inject( OperationContext opContext, StoredProcedureParameter param )
150 throws LdapInvalidDnException
151 {
152
153 return opContext.getSession().getDirectoryService().getDnFactory().create( newDn.getName() );
154 }
155 };
156
157 }