View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    https://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.dsmlv2.request;
21  
22  
23  import org.apache.directory.api.dsmlv2.DsmlLiterals;
24  import org.apache.directory.api.ldap.codec.api.LdapApiService;
25  import org.apache.directory.api.ldap.model.message.AbandonRequest;
26  import org.apache.directory.api.ldap.model.message.AbandonRequestImpl;
27  import org.apache.directory.api.ldap.model.message.Control;
28  import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
29  import org.dom4j.Element;
30  
31  
32  /**
33   * DSML Decorator for AbandonRequest
34   *
35   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
36   */
37  public class AbandonRequestDsml extends AbstractRequestDsml<AbandonRequest>
38      implements AbandonRequest
39  {
40      /**
41       * Creates a new instance of AbandonRequestDsml.
42       * 
43       * @param codec The LDAP Service to use
44       */
45      public AbandonRequestDsml( LdapApiService codec )
46      {
47          super( codec, new AbandonRequestImpl() );
48      }
49  
50  
51      /**
52       * Creates a new instance of AbandonRequestDsml.
53       *
54       * @param codec The LDAP Service to use
55       * @param ldapMessage the message to decorate
56       */
57      public AbandonRequestDsml( LdapApiService codec, AbandonRequest ldapMessage )
58      {
59          super( codec, ldapMessage );
60      }
61  
62  
63      /**
64       * {@inheritDoc}
65       */
66      @Override
67      public MessageTypeEnum getType()
68      {
69          return getDecorated().getType();
70      }
71  
72  
73      /**
74       * {@inheritDoc}
75       */
76      @Override
77      public Element toDsml( Element root )
78      {
79          Element element = super.toDsml( root );
80  
81          // AbandonID
82          if ( getDecorated().getAbandoned() != 0 )
83          {
84              element.addAttribute( DsmlLiterals.ABANDON_ID, Integer.toString( getDecorated().getAbandoned() ) );
85          }
86  
87          return element;
88      }
89  
90  
91      /**
92       * Get the abandoned message ID
93       * 
94       * @return Returns the abandoned MessageId.
95       */
96      public int getAbandonedMessageId()
97      {
98          return getDecorated().getAbandoned();
99      }
100 
101 
102     /**
103      * Set the abandoned message ID
104      * 
105      * @param abandonedMessageId The abandoned messageID to set.
106      * @return The modified AbandonRequest instance
107      */
108     public AbandonRequest setAbandonedMessageId( int abandonedMessageId )
109     {
110         getDecorated().setAbandoned( abandonedMessageId );
111 
112         return this;
113     }
114 
115 
116     /**
117      * {@inheritDoc}
118      */
119     @Override
120     public int getAbandoned()
121     {
122         return getDecorated().getAbandoned();
123     }
124 
125 
126     /**
127      * {@inheritDoc}
128      */
129     @Override
130     public AbandonRequest setAbandoned( int requestId )
131     {
132         getDecorated().setAbandoned( requestId );
133 
134         return this;
135     }
136 
137 
138     /**
139      * {@inheritDoc}
140      */
141     @Override
142     public AbandonRequest setMessageId( int messageId )
143     {
144         super.setMessageId( messageId );
145 
146         return this;
147     }
148 
149 
150     /**
151      * {@inheritDoc}
152      */
153     @Override
154     public AbandonRequest addControl( Control control )
155     {
156         return ( AbandonRequest ) super.addControl( control );
157     }
158 
159 
160     /**
161      * {@inheritDoc}
162      */
163     @Override
164     public AbandonRequest addAllControls( Control[] controls )
165     {
166         return ( AbandonRequest ) super.addAllControls( controls );
167     }
168 
169 
170     /**
171      * {@inheritDoc}
172      */
173     @Override
174     public AbandonRequest removeControl( Control control )
175     {
176         return ( AbandonRequest ) super.removeControl( control );
177     }
178 }