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;
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.util.Strings;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 public class StoreSearchRequestAttributeDesc extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
46 {
47
48 private static final Logger LOG = LoggerFactory.getLogger( StoreSearchRequestAttributeDesc.class );
49
50
51 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
52
53
54
55
56
57 public StoreSearchRequestAttributeDesc()
58 {
59 super( "Store attribute description" );
60 }
61
62
63
64
65
66 public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
67 {
68 SearchRequestDecorator searchRequestDecorator = container.getMessage();
69 TLV tlv = container.getCurrentTLV();
70 String attributeDescription = null;
71
72 if ( tlv.getLength() != 0 )
73 {
74 attributeDescription = Strings.utf8ToString( tlv.getValue().getData() );
75
76
77 if ( !Strings.isEmpty( attributeDescription.trim() ) )
78 {
79 searchRequestDecorator.getDecorated().addAttributes( attributeDescription );
80 }
81 }
82
83
84 container.setGrammarEndAllowed( true );
85
86 if ( IS_DEBUG )
87 {
88 LOG.debug( "Decoded Attribute Description : {}", attributeDescription );
89 }
90 }
91 }