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.interceptor.context;
21
22
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.List;
26
27 import org.apache.directory.server.core.CoreSession;
28 import org.apache.directory.shared.ldap.constants.SchemaConstants;
29 import org.apache.directory.shared.ldap.name.LdapDN;
30 import org.apache.directory.shared.ldap.util.StringTools;
31
32
33
34
35
36
37
38
39
40 public class LookupOperationContext extends AbstractOperationContext
41 {
42 private static final String[] EMPTY = new String[] {};
43
44
45 private List<String> attrsId = new ArrayList<String>();
46
47 private Boolean allOperational;
48
49 private Boolean allUser;
50
51
52
53
54
55
56
57 public LookupOperationContext( CoreSession session )
58 {
59 super( session );
60 }
61
62
63
64
65
66
67
68 public LookupOperationContext( CoreSession session, LdapDN dn )
69 {
70 super( session, dn );
71 }
72
73
74
75
76
77
78
79 public LookupOperationContext( CoreSession session, String attrsId[] )
80 {
81 super( session );
82 setAttrsId( attrsId );
83 }
84
85
86
87
88
89
90
91 public LookupOperationContext( CoreSession session, LdapDN dn, String attrsId[] )
92 {
93 super( session, dn );
94 setAttrsId( attrsId );
95 }
96
97
98
99
100
101 public String[] getAttrsIdArray()
102 {
103 if ( attrsId == null || attrsId.size() == 0 )
104 {
105 return EMPTY;
106 }
107 else
108 {
109 String[] attrs = new String[ attrsId.size()];
110 return attrsId.toArray( attrs );
111 }
112 }
113
114
115
116
117
118
119
120 public void setAttrsId( String[] attrsId )
121 {
122 if ( attrsId != null && attrsId.length > 0 )
123 {
124 this.attrsId = new ArrayList<String>( Arrays.asList( attrsId ) );
125
126
127 for ( String id : this.attrsId )
128 {
129 if ( id.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
130 {
131 allOperational = true;
132 }
133 else if ( id.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) )
134 {
135 allUser = true;
136 }
137 }
138
139 if ( allOperational != null && allOperational )
140 {
141 this.attrsId.remove( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES );
142 }
143
144 if ( allUser != null && allUser )
145 {
146 this.attrsId.remove( SchemaConstants.ALL_USER_ATTRIBUTES );
147 }
148 }
149 }
150
151
152
153
154
155
156
157 public void addAttrsId( String attrId )
158 {
159 if ( attrId.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) )
160 {
161 allUser = true;
162 return;
163 }
164
165 if ( attrId.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
166 {
167 allOperational = true;
168 return;
169 }
170
171 if ( attrsId == null )
172 {
173 attrsId = new ArrayList<String>();
174 }
175
176 attrsId.add( attrId );
177 }
178
179
180
181
182
183 public List<String> getAttrsId()
184 {
185 return attrsId;
186 }
187
188
189 public Boolean getAllUser()
190 {
191 return allUser;
192 }
193
194
195 public Boolean getAllOperational()
196 {
197 return allOperational;
198 }
199
200
201
202
203
204 public String getName()
205 {
206 return "Lookup";
207 }
208
209
210
211
212
213 public String toString()
214 {
215 return "LookupContext for DN '" + getDn().getUpName() + "'" + ( ( attrsId != null ) ? ", attributes : <" + StringTools.listToString( attrsId ) + ">" : "" );
216 }
217 }