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.BerValue;
26 import org.apache.directory.api.asn1.ber.tlv.BooleanDecoder;
27 import org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException;
28 import org.apache.directory.api.asn1.ber.tlv.TLV;
29 import org.apache.directory.api.i18n.I18n;
30 import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
31 import org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator;
32 import org.apache.directory.api.ldap.model.message.SearchRequest;
33 import org.apache.directory.api.util.Strings;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36
37
38
39
40
41
42
43
44
45
46
47
48 public class StoreSearchRequestTypesOnly extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
49 {
50
51 private static final Logger LOG = LoggerFactory.getLogger( StoreSearchRequestTypesOnly.class );
52
53
54 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
55
56
57
58
59
60 public StoreSearchRequestTypesOnly()
61 {
62 super( "Store SearchRequest typesOnly flag" );
63 }
64
65
66
67
68
69 public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
70 {
71 SearchRequest searchRequest = container.getMessage().getDecorated();
72
73 TLV tlv = container.getCurrentTLV();
74
75
76
77
78
79
80
81 BerValue value = tlv.getValue();
82
83 try
84 {
85 searchRequest.setTypesOnly( BooleanDecoder.parse( value ) );
86 }
87 catch ( BooleanDecoderException bde )
88 {
89 LOG.error( I18n
90 .err( I18n.ERR_04105, Strings.dumpBytes( value.getData() ), bde.getMessage() ) );
91
92 throw new DecoderException( bde.getMessage(), bde );
93 }
94
95 if ( IS_DEBUG )
96 {
97 LOG.debug( "The search will return {}", searchRequest.getTypesOnly() ? "only attributs type"
98 : "attributes types and values" );
99 }
100 }
101 }