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.i18n.I18n;
27 import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
28 import org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator;
29 import org.apache.directory.api.ldap.codec.search.Filter;
30 import org.apache.directory.api.ldap.codec.search.NotFilter;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34
35
36
37
38
39
40 public class InitNotFilter extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
41 {
42
43 private static final Logger LOG = LoggerFactory.getLogger( InitNotFilter.class );
44
45
46 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
47
48
49
50
51
52 public InitNotFilter()
53 {
54 super( "Initialize NOT filter" );
55 }
56
57
58
59
60
61 public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
62 {
63 TLV tlv = container.getCurrentTLV();
64
65 if ( tlv.getLength() == 0 )
66 {
67 String msg = I18n.err( I18n.ERR_04009 );
68 LOG.error( msg );
69 throw new DecoderException( msg );
70 }
71
72 SearchRequestDecorator searchRequestDecorator = container.getMessage();
73
74
75 Filter notFilter = new NotFilter( container.getTlvId() );
76
77
78 searchRequestDecorator.addCurrentFilter( notFilter );
79
80 if ( IS_DEBUG )
81 {
82 LOG.debug( "Initialize NOT filter" );
83 }
84 }
85 }