1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.codec.actions.searchRequest.filter;
21
22
23 import org.apache.directory.api.asn1.DecoderException;
24 import org.apache.directory.api.asn1.ber.grammar.GrammarAction;
25 import org.apache.directory.api.asn1.ber.tlv.TLV;
26 import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
27 import org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator;
28 import org.apache.directory.api.ldap.codec.search.PresentFilter;
29 import org.apache.directory.api.util.Strings;
30
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34
35
36
37
38
39
40 public class InitPresentFilter extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
41 {
42
43 private static final Logger LOG = LoggerFactory.getLogger( InitPresentFilter.class );
44
45
46 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
47
48
49
50
51
52 public InitPresentFilter()
53 {
54 super( "Init present filter Value" );
55 }
56
57
58
59
60
61 public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
62 {
63 SearchRequestDecorator searchRequestDecorator = container.getMessage();
64
65 TLV tlv = container.getCurrentTLV();
66
67
68 PresentFilter presentFilter = new PresentFilter( container.getTlvId() );
69
70
71 searchRequestDecorator.addCurrentFilter( presentFilter );
72 searchRequestDecorator.setTerminalFilter( presentFilter );
73
74 String value = Strings.utf8ToString( tlv.getValue().getData() );
75
76 if ( Strings.isEmpty( value ) )
77 {
78 presentFilter.setAttributeDescription( "" );
79 }
80 else
81 {
82
83 String type = Strings.utf8ToString( tlv.getValue().getData() );
84 presentFilter.setAttributeDescription( type );
85 }
86
87
88
89 searchRequestDecorator.unstackFilters( container );
90
91 if ( IS_DEBUG )
92 {
93 LOG.debug( "Initialize Present filter" );
94 }
95 }
96 }