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.api.interceptor.context;
21
22
23 import org.apache.directory.api.ldap.model.entry.Value;
24 import org.apache.directory.api.ldap.model.message.CompareRequest;
25 import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
26 import org.apache.directory.api.ldap.model.message.controls.ManageDsaIT;
27 import org.apache.directory.api.ldap.model.name.Dn;
28 import org.apache.directory.api.ldap.model.schema.AttributeType;
29 import org.apache.directory.api.util.Strings;
30 import org.apache.directory.server.core.api.CoreSession;
31 import org.apache.directory.server.core.api.OperationEnum;
32
33
34
35
36
37
38
39
40 public class CompareOperationContext extends AbstractOperationContext
41 {
42
43 private String oid;
44
45
46 private AttributeType attributeType;
47
48
49 private Value value;
50
51
52
53
54
55
56
57 public CompareOperationContext( CoreSession session )
58 {
59 super( session );
60
61 if ( session != null )
62 {
63 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.COMPARE ) );
64 }
65 }
66
67
68
69
70
71
72
73
74 public CompareOperationContext( CoreSession session, Dn dn )
75 {
76 super( session, dn );
77
78 if ( session != null )
79 {
80 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.COMPARE ) );
81 }
82 }
83
84
85
86
87
88
89
90
91 public CompareOperationContext( CoreSession session, String oid )
92 {
93 super( session );
94 this.oid = oid;
95
96 if ( session != null )
97 {
98 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.COMPARE ) );
99 }
100 }
101
102
103
104
105
106
107
108
109
110 public CompareOperationContext( CoreSession session, Dn dn, String oid )
111 {
112 super( session, dn );
113 this.oid = oid;
114
115 if ( session != null )
116 {
117 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.COMPARE ) );
118 }
119 }
120
121
122
123
124
125
126
127
128
129
130 public CompareOperationContext( CoreSession session, Dn dn, String oid, Value value )
131 {
132 super( session, dn );
133 this.oid = oid;
134 this.value = value;
135
136 if ( session != null )
137 {
138 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.COMPARE ) );
139 }
140 }
141
142
143
144
145
146
147
148
149 public CompareOperationContext( CoreSession session, CompareRequest compareRequest )
150 {
151 super( session, compareRequest.getName() );
152 this.oid = compareRequest.getAttributeId();
153 this.value = compareRequest.getAssertionValue();
154 this.requestControls = compareRequest.getControls();
155
156 if ( session != null )
157 {
158 setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.COMPARE ) );
159 }
160
161 if ( requestControls.containsKey( ManageDsaIT.OID ) )
162 {
163 ignoreReferral();
164 }
165 else
166 {
167 throwReferral();
168 }
169 }
170
171
172
173
174
175 public String getOid()
176 {
177 return oid;
178 }
179
180
181
182
183
184
185 public void setOid( String oid )
186 {
187 this.oid = oid;
188 }
189
190
191
192
193
194 public Value getValue()
195 {
196 return value;
197 }
198
199
200
201
202
203
204 public void setValue( Value value )
205 {
206 this.value = value;
207 }
208
209
210
211
212
213 public AttributeType getAttributeType()
214 {
215 return attributeType;
216 }
217
218
219
220
221
222
223
224 public void setAttributeType( AttributeType attributeType )
225 {
226 this.attributeType = attributeType;
227 }
228
229
230
231
232
233 public String getName()
234 {
235 return MessageTypeEnum.COMPARE_REQUEST.name();
236 }
237
238
239
240
241
242 public String toString()
243 {
244 return "CompareContext for Dn '" + getDn().getName() + "'"
245 + ( ( oid != null ) ? ", oid : <" + oid + ">" : "" )
246 + ( ( value != null )
247 ? ", value :'"
248 + ( ( value.isHumanReadable() )
249 ? value.getString()
250 : ( ( !value.isHumanReadable() )
251 ? Strings.dumpBytes( value.getBytes() )
252 : "unknown value type" ) )
253 + "'"
254 : "" );
255 }
256 }