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.entry;
21
22
23 import java.io.IOException;
24 import java.io.ObjectInput;
25 import java.io.ObjectOutput;
26 import java.util.Collections;
27 import java.util.Iterator;
28 import java.util.List;
29 import java.util.Set;
30
31 import javax.naming.NamingException;
32
33 import org.apache.directory.shared.ldap.entry.Entry;
34 import org.apache.directory.shared.ldap.entry.EntryAttribute;
35 import org.apache.directory.shared.ldap.entry.Value;
36 import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
37 import org.apache.directory.shared.ldap.name.LdapDN;
38 import org.apache.directory.shared.ldap.schema.AttributeType;
39
40
41
42
43
44
45
46
47
48 public class ClonedServerEntry implements ServerEntry
49 {
50
51 private final ServerEntry originalEntry;
52
53
54 private final ServerEntry clonedEntry;
55
56
57
58
59
60
61
62
63
64 public ClonedServerEntry( ServerEntry originalEntry )
65 {
66 this.originalEntry = originalEntry;
67 this.clonedEntry = ( ServerEntry ) originalEntry.clone();
68 }
69
70
71
72
73
74 public ServerEntry getOriginalEntry()
75 {
76 return originalEntry;
77 }
78
79
80
81
82
83 public Entry getClonedEntry()
84 {
85 return clonedEntry;
86 }
87
88
89 public void add( AttributeType attributeType, byte[]... values ) throws NamingException
90 {
91 clonedEntry.add( attributeType, values );
92 }
93
94
95 public void add( AttributeType attributeType, String... values ) throws NamingException
96 {
97 clonedEntry.add( attributeType, values );
98 }
99
100
101 public void add( AttributeType attributeType, Value<?>... values ) throws NamingException
102 {
103 clonedEntry.add( attributeType, values );
104 }
105
106
107 public void add( String upId, AttributeType attributeType, byte[]... values ) throws NamingException
108 {
109 clonedEntry.add( attributeType, values );
110 }
111
112
113 public void add( String upId, AttributeType attributeType, String... values ) throws NamingException
114 {
115 clonedEntry.add( attributeType, values );
116 }
117
118
119 public void add( String upId, AttributeType attributeType, Value<?>... values ) throws NamingException
120 {
121 clonedEntry.add( attributeType, values );
122 }
123
124
125 public boolean contains( AttributeType attributeType, byte[]... values )
126 {
127 return clonedEntry.contains( attributeType, values );
128 }
129
130
131 public boolean contains( AttributeType attributeType, String... values )
132 {
133 return clonedEntry.contains( attributeType, values );
134 }
135
136
137 public boolean contains( AttributeType attributeType, Value<?>... values )
138 {
139 return clonedEntry.contains( attributeType, values );
140 }
141
142
143 public boolean containsAttribute( AttributeType attributeType )
144 {
145 return clonedEntry.containsAttribute( attributeType );
146 }
147
148
149 public EntryAttribute get( AttributeType attributeType )
150 {
151 return clonedEntry.get( attributeType );
152 }
153
154
155 public Set<AttributeType> getAttributeTypes()
156 {
157 return clonedEntry.getAttributeTypes();
158 }
159
160
161 public boolean hasObjectClass( EntryAttribute objectClass )
162 {
163 return clonedEntry.hasObjectClass( objectClass );
164 }
165
166
167 public boolean isValid()
168 {
169 return clonedEntry.isValid();
170 }
171
172
173 public boolean isValid( String objectClass )
174 {
175 return clonedEntry.isValid( objectClass );
176 }
177
178
179 public boolean isValid( EntryAttribute objectClass )
180 {
181 return clonedEntry.isValid( objectClass );
182 }
183
184
185 public EntryAttribute put( AttributeType attributeType, byte[]... values ) throws NamingException
186 {
187 return clonedEntry.put( attributeType, values );
188 }
189
190
191 public EntryAttribute put( AttributeType attributeType, String... values ) throws NamingException
192 {
193 return clonedEntry.put( attributeType, values );
194 }
195
196
197 public EntryAttribute put( AttributeType attributeType, Value<?>... values ) throws NamingException
198 {
199 return clonedEntry.put( attributeType, values );
200 }
201
202
203 public EntryAttribute put( String upId, AttributeType attributeType, byte[]... values ) throws NamingException
204 {
205 return clonedEntry.put( attributeType, values );
206 }
207
208
209 public EntryAttribute put( String upId, AttributeType attributeType, String... values ) throws NamingException
210 {
211 return clonedEntry.put( upId, attributeType, values );
212 }
213
214
215 public EntryAttribute put( String upId, AttributeType attributeType, Value<?>... values ) throws NamingException
216 {
217 return clonedEntry.put( upId, attributeType, values );
218 }
219
220
221 public boolean remove( AttributeType attributeType, byte[]... values ) throws NamingException
222 {
223 return clonedEntry.remove( attributeType, values );
224 }
225
226
227 public boolean remove( AttributeType attributeType, String... values ) throws NamingException
228 {
229 return clonedEntry.remove( attributeType, values );
230 }
231
232
233 public boolean remove( AttributeType attributeType, Value<?>... values ) throws NamingException
234 {
235 return clonedEntry.remove( attributeType, values );
236 }
237
238
239 public List<EntryAttribute> remove( EntryAttribute... attributes ) throws NamingException
240 {
241 return clonedEntry.remove( attributes );
242 }
243
244
245 public List<EntryAttribute> removeAttributes( AttributeType... attributes )
246 {
247 return clonedEntry.removeAttributes( attributes );
248 }
249
250
251 public List<EntryAttribute> set( AttributeType... attributeTypes )
252 {
253 return clonedEntry.set( attributeTypes );
254 }
255
256
257 public void add( EntryAttribute... attributes ) throws NamingException
258 {
259 clonedEntry.add( attributes );
260 }
261
262
263 public void add( String upId, String... values ) throws NamingException
264 {
265 clonedEntry.add( upId, values );
266 }
267
268
269 public void add( String upId, byte[]... values ) throws NamingException
270 {
271 clonedEntry.add( upId, values );
272 }
273
274
275 public void add( String upId, Value<?>... values ) throws NamingException
276 {
277 clonedEntry.add( upId, values );
278 }
279
280
281 public void clear()
282 {
283 clonedEntry.clear();
284 }
285
286
287 public boolean contains( EntryAttribute... attributes ) throws NamingException
288 {
289 return clonedEntry.contains( attributes );
290 }
291
292
293 public boolean contains( String upId, byte[]... values )
294 {
295 return clonedEntry.contains( upId, values );
296 }
297
298
299 public boolean contains( String upId, String... values )
300 {
301 return clonedEntry.contains( upId, values );
302 }
303
304
305 public boolean contains( String upId, Value<?>... values )
306 {
307 return clonedEntry.contains( upId, values );
308 }
309
310
311 public boolean containsAttribute( String... attributes )
312 {
313 return clonedEntry.containsAttribute( attributes );
314 }
315
316
317 public EntryAttribute get( String alias )
318 {
319 return clonedEntry.get( alias );
320 }
321
322
323 public LdapDN getDn()
324 {
325 return clonedEntry.getDn();
326 }
327
328
329 public boolean hasObjectClass( String objectClass )
330 {
331 return clonedEntry.hasObjectClass( objectClass );
332 }
333
334
335 public Iterator<EntryAttribute> iterator()
336 {
337 return clonedEntry.iterator();
338 }
339
340
341 public List<EntryAttribute> put( EntryAttribute... attributes ) throws NamingException
342 {
343 return clonedEntry.put( attributes );
344 }
345
346
347 public EntryAttribute put( String upId, byte[]... values )
348 {
349 return clonedEntry.put( upId, values );
350 }
351
352
353 public EntryAttribute put( String upId, String... values )
354 {
355 return clonedEntry.put( upId, values );
356 }
357
358
359 public EntryAttribute put( String upId, Value<?>... values )
360 {
361 return clonedEntry.put( upId, values );
362 }
363
364
365 public boolean remove( String upId, byte[]... values ) throws NamingException
366 {
367 return clonedEntry.remove( upId, values );
368 }
369
370
371 public boolean remove( String upId, String... values ) throws NamingException
372 {
373 return clonedEntry.remove( upId, values );
374 }
375
376
377 public boolean remove( String upId, Value<?>... values ) throws NamingException
378 {
379 return clonedEntry.remove( upId, values );
380 }
381
382
383 public List<EntryAttribute> removeAttributes( String... attributes )
384 {
385 return clonedEntry.removeAttributes( attributes );
386 }
387
388
389 public List<EntryAttribute> set( String... upIds )
390 {
391 return clonedEntry.set( upIds );
392 }
393
394
395 public void setDn( LdapDN dn )
396 {
397 clonedEntry.setDn( dn );
398 }
399
400
401 public int size()
402 {
403 return clonedEntry.size();
404 }
405
406
407 public Entry toClientEntry() throws NamingException
408 {
409
410 Entry clientEntry = new DefaultClientEntry( clonedEntry.getDn() );
411
412
413 for ( EntryAttribute clonedEntry:this )
414 {
415 EntryAttribute clientAttribute = ((ServerAttribute)clonedEntry).toClientAttribute();
416 clientEntry.add( clientAttribute );
417 }
418
419 return clientEntry;
420 }
421
422
423
424
425
426
427
428 public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
429 {
430 throw new IllegalStateException( "Cannot use standard serialization for a ServerAttribute" );
431 }
432
433
434
435
436
437
438
439 public void writeExternal( ObjectOutput out ) throws IOException
440 {
441 throw new IllegalStateException( "Cannot use standard serialization for a ServerEntry" );
442 }
443
444
445 public ServerEntry clone()
446 {
447 return ( ServerEntry ) clonedEntry.clone();
448 }
449
450
451 public String toString()
452 {
453 return clonedEntry.toString();
454 }
455
456
457 class EmptyEntry implements ServerEntry
458 {
459 LdapDN dn;
460
461 EmptyEntry( LdapDN dn )
462 {
463 this.dn = dn;
464 }
465
466 public void add( AttributeType attributeType, byte[]... values ) throws NamingException
467 {
468 }
469
470 public void add( AttributeType attributeType, String... values ) throws NamingException
471 {
472 }
473
474 public void add( AttributeType attributeType, Value<?>... values ) throws NamingException
475 {
476 }
477
478 public void add( String upId, AttributeType attributeType, byte[]... values ) throws NamingException
479 {
480 }
481
482 public void add( String upId, AttributeType attributeType, String... values ) throws NamingException
483 {
484 }
485
486 public void add( String upId, AttributeType attributeType, Value<?>... values ) throws NamingException
487 {
488 }
489
490 public boolean contains( AttributeType attributeType, byte[]... values )
491 {
492 return false;
493 }
494
495 public boolean contains( AttributeType attributeType, String... values )
496 {
497 return false;
498 }
499
500 public boolean contains( AttributeType attributeType, Value<?>... values )
501 {
502 return false;
503 }
504
505 public boolean containsAttribute( AttributeType attributeType )
506 {
507 return false;
508 }
509
510 public EntryAttribute get( AttributeType attributeType )
511 {
512 return null;
513 }
514
515 public Set<AttributeType> getAttributeTypes()
516 {
517 return null;
518 }
519
520 public boolean hasObjectClass( EntryAttribute objectClass )
521 {
522 return false;
523 }
524
525 public boolean isValid()
526 {
527 return false;
528 }
529
530 public boolean isValid( String objectClass )
531 {
532 return false;
533 }
534
535 public boolean isValid( EntryAttribute objectClass )
536 {
537 return false;
538 }
539
540 public EntryAttribute put( AttributeType attributeType, byte[]... values ) throws NamingException
541 {
542 return null;
543 }
544
545 public EntryAttribute put( AttributeType attributeType, String... values ) throws NamingException
546 {
547 return null;
548 }
549
550 public EntryAttribute put( AttributeType attributeType, Value<?>... values ) throws NamingException
551 {
552 return null;
553 }
554
555 public EntryAttribute put( String upId, AttributeType attributeType, byte[]... values ) throws NamingException
556 {
557 return null;
558 }
559
560 public EntryAttribute put( String upId, AttributeType attributeType, String... values ) throws NamingException
561 {
562 return null;
563 }
564
565 public EntryAttribute put( String upId, AttributeType attributeType, Value<?>... values )
566 throws NamingException
567 {
568 return null;
569 }
570
571 public boolean remove( AttributeType attributeType, byte[]... values ) throws NamingException
572 {
573 return false;
574 }
575
576 public boolean remove( AttributeType attributeType, String... values ) throws NamingException
577 {
578 return false;
579 }
580
581 public boolean remove( AttributeType attributeType, Value<?>... values ) throws NamingException
582 {
583 return false;
584 }
585
586 public List<EntryAttribute> remove( EntryAttribute... attributes ) throws NamingException
587 {
588 return Collections.emptyList();
589 }
590
591 public List<EntryAttribute> removeAttributes( AttributeType... attributes )
592 {
593 return Collections.emptyList();
594 }
595
596 public List<EntryAttribute> set( AttributeType... attributeTypes )
597 {
598 return Collections.emptyList();
599 }
600
601 public void add( EntryAttribute... attributes ) throws NamingException
602 {
603 }
604
605 public void add( String upId, String... values ) throws NamingException
606 {
607 }
608
609 public void add( String upId, byte[]... values ) throws NamingException
610 {
611 }
612
613 public void add( String upId, Value<?>... values ) throws NamingException
614 {
615 }
616
617 public void clear()
618 {
619 }
620
621 public boolean contains( EntryAttribute... attributes ) throws NamingException
622 {
623 return false;
624 }
625
626 public boolean contains( String upId, byte[]... values )
627 {
628 return false;
629 }
630
631 public boolean contains( String upId, String... values )
632 {
633 return false;
634 }
635
636 public boolean contains( String upId, Value<?>... values )
637 {
638 return false;
639 }
640
641 public boolean containsAttribute( String... attributes )
642 {
643 return false;
644 }
645
646 public EntryAttribute get( String alias )
647 {
648 return null;
649 }
650
651 public LdapDN getDn()
652 {
653 return null;
654 }
655
656 public boolean hasObjectClass( String objectClass )
657 {
658 return false;
659 }
660
661 @SuppressWarnings("unchecked")
662 public Iterator<EntryAttribute> iterator()
663 {
664 return ( ( List <EntryAttribute> ) Collections.EMPTY_LIST ).iterator();
665 }
666
667 public List<EntryAttribute> put( EntryAttribute... attributes ) throws NamingException
668 {
669 return Collections.emptyList();
670 }
671
672 public EntryAttribute put( String upId, byte[]... values )
673 {
674 return null;
675 }
676
677 public EntryAttribute put( String upId, String... values )
678 {
679 return null;
680 }
681
682 public EntryAttribute put( String upId, Value<?>... values )
683 {
684 return null;
685 }
686
687 public boolean remove( String upId, byte[]... values ) throws NamingException
688 {
689 return false;
690 }
691
692 public boolean remove( String upId, String... values ) throws NamingException
693 {
694 return false;
695 }
696
697 public boolean remove( String upId, Value<?>... values ) throws NamingException
698 {
699 return false;
700 }
701
702 public List<EntryAttribute> removeAttributes( String... attributes )
703 {
704 return Collections.emptyList();
705 }
706
707 public List<EntryAttribute> set( String... upIds )
708 {
709 return Collections.emptyList();
710 }
711
712 public void setDn( LdapDN dn )
713 {
714 this.dn = dn;
715 }
716
717 public int size()
718 {
719 return 0;
720 }
721
722
723 public ServerEntry clone()
724 {
725 return new EmptyEntry( dn );
726 }
727
728
729 public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
730 {
731 }
732
733
734 public void writeExternal( ObjectOutput out ) throws IOException
735 {
736 }
737
738
739 public Entry toClientEntry() throws NamingException
740 {
741
742 Entry clientEntry = new DefaultClientEntry( dn );
743
744
745 for ( EntryAttribute serverAttribute:this )
746 {
747 EntryAttribute clientAttribute = ((ServerAttribute)serverAttribute).toClientAttribute();
748 clientEntry.add( clientAttribute );
749 }
750
751 return clientEntry;
752 }
753 }
754 }