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.request.search.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.i18n.I18n;
27 import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
28 import org.apache.directory.api.ldap.codec.search.PresentFilter;
29 import org.apache.directory.api.ldap.model.message.SearchRequest;
30 import org.apache.directory.api.util.Strings;
31
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34
35
36
37
38
39
40
41 public class InitPresentFilter extends GrammarAction<LdapMessageContainer<SearchRequest>>
42 {
43
44 private static final Logger LOG = LoggerFactory.getLogger( InitPresentFilter.class );
45
46
47
48
49 public InitPresentFilter()
50 {
51 super( "Init present filter Value" );
52 }
53
54
55
56
57
58 public void action( LdapMessageContainer<SearchRequest> container ) throws DecoderException
59 {
60 TLV tlv = container.getCurrentTLV();
61
62
63 PresentFilter presentFilter = new PresentFilter( container.getTlvId() );
64
65
66 container.addCurrentFilter( presentFilter );
67 container.setTerminalFilter( presentFilter );
68
69 String value = Strings.utf8ToString( tlv.getValue().getData() );
70
71 if ( Strings.isEmpty( value ) )
72 {
73 presentFilter.setAttributeDescription( "" );
74 }
75 else
76 {
77
78 String type = Strings.utf8ToString( tlv.getValue().getData() );
79 presentFilter.setAttributeDescription( type );
80 }
81
82
83
84 container.unstackFilters();
85
86 if ( LOG.isDebugEnabled() )
87 {
88 LOG.debug( I18n.msg( I18n.MSG_05151_INITIALIZE_PRESENT_FILTER ) );
89 }
90 }
91 }