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 org.apache.directory.server.core.interceptor.context.OperationContext;
24 import org.apache.directory.shared.ldap.name.LdapDN;
25 import org.apache.directory.shared.ldap.name.Rdn;
26 import org.apache.directory.shared.ldap.trigger.StoredProcedureParameter;
27
28 import javax.naming.NamingException;
29 import java.util.Map;
30
31
32 public class ModifyDNStoredProcedureParameterInjector extends AbstractStoredProcedureParameterInjector
33 {
34 private boolean deleteOldRn;
35 private LdapDN oldRDN;
36 private Rdn newRDN;
37 private LdapDN oldSuperiorDN;
38 private LdapDN newSuperiorDN;
39 private LdapDN oldDN;
40 private LdapDN newDN;
41
42
43 public ModifyDNStoredProcedureParameterInjector( OperationContext opContext, boolean deleteOldRn,
44 LdapDN oldRDN, Rdn newRDN, LdapDN oldSuperiorDN, LdapDN newSuperiorDN, LdapDN oldDN, LdapDN newDN)
45 {
46 super( opContext );
47 this.deleteOldRn = deleteOldRn;
48 this.oldRDN = oldRDN;
49 this.newRDN = newRDN;
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 MicroInjector $entryInjector = new MicroInjector()
69 {
70 public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws NamingException
71 {
72
73 return new LdapDN( oldDN.getUpName() );
74 }
75 };
76
77
78
79
80 MicroInjector $newrdnInjector = new MicroInjector()
81 {
82 public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws NamingException
83 {
84
85 return new LdapDN( newRDN.getUpName() );
86 }
87 };
88
89
90
91
92 MicroInjector $deleteoldrdnInjector = new MicroInjector()
93 {
94 public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws NamingException
95 {
96
97 return deleteOldRn;
98 }
99 };
100
101
102
103
104 MicroInjector $newSuperiorInjector = new MicroInjector()
105 {
106 public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws NamingException
107 {
108
109 return new LdapDN( newSuperiorDN.getUpName() );
110 }
111 };
112
113
114
115
116 MicroInjector $oldRDNInjector = new MicroInjector()
117 {
118 public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws NamingException
119 {
120
121 return new LdapDN( oldRDN.getUpName() );
122 }
123 };
124
125
126
127
128 MicroInjector $oldSuperiorDNInjector = new MicroInjector()
129 {
130 public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws NamingException
131 {
132
133 return new LdapDN( oldSuperiorDN.getUpName() );
134 }
135 };
136
137
138
139
140 MicroInjector $newDNInjector = new MicroInjector()
141 {
142 public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws NamingException
143 {
144
145 return new LdapDN( newDN.getUpName() );
146 }
147 };
148
149 }