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.controls;
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.api.MessageDecorator;
28 import org.apache.directory.api.ldap.model.message.Message;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32
33
34
35
36
37
38
39
40
41
42
43 public class InitControls extends GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>
44 {
45
46 private static final Logger LOG = LoggerFactory.getLogger( InitControls.class );
47
48
49 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
50
51
52
53
54
55 public InitControls()
56 {
57 super( "Initialize a control" );
58 }
59
60
61
62
63
64 public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
65 {
66 TLV tlv = container.getCurrentTLV();
67 int expectedLength = tlv.getLength();
68
69
70 if ( expectedLength != 0 )
71 {
72 if ( IS_DEBUG )
73 {
74 LOG.debug( "A new list of controls has been initialized" );
75 }
76 }
77 else
78 {
79 if ( IS_DEBUG )
80 {
81 LOG.debug( "An empty list of controls has been initialized" );
82 }
83 }
84
85
86 container.setGrammarEndAllowed( true );
87 }
88 }