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.Control;
26  import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
27  import org.apache.directory.api.ldap.model.message.ModifyDnRequest;
28  import org.apache.directory.api.ldap.model.message.ModifyDnRequestImpl;
29  import org.apache.directory.api.ldap.model.message.ModifyDnResponse;
30  import org.apache.directory.api.ldap.model.name.Dn;
31  import org.apache.directory.api.ldap.model.name.Rdn;
32  import org.dom4j.Element;
33  
34  
35  /**
36   * DSML Decorator for ModifyDNRequest
37   *
38   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
39   */
40  public class ModifyDNRequestDsml
41      extends AbstractResultResponseRequestDsml<ModifyDnRequest, ModifyDnResponse>
42      implements ModifyDnRequest
43  {
44      /**
45       * Creates a new getDecoratedMessage() of ModifyDNRequestDsml.
46       * 
47       * @param codec The LDAP Service to use
48       */
49      public ModifyDNRequestDsml( LdapApiService codec )
50      {
51          super( codec, new ModifyDnRequestImpl() );
52      }
53  
54  
55      /**
56       * Creates a new getDecoratedMessage() of ModifyDNRequestDsml.
57       *
58       * @param codec The LDAP Service to use
59       * @param ldapMessage the message to decorate
60       */
61      public ModifyDNRequestDsml( LdapApiService codec, ModifyDnRequest ldapMessage )
62      {
63          super( codec, ldapMessage );
64      }
65  
66  
67      /**
68       * {@inheritDoc}
69       */
70      @Override
71      public MessageTypeEnum getType()
72      {
73          return getDecorated().getType();
74      }
75  
76  
77      /**
78       * {@inheritDoc}
79       */
80      @Override
81      public Element toDsml( Element root )
82      {
83          Element element = super.toDsml( root );
84  
85          ModifyDnRequest request = getDecorated();
86  
87          // Dn
88          if ( request.getName() != null )
89          {
90              element.addAttribute( DsmlLiterals.DN, request.getName().getName() );
91          }
92  
93          // NewRDN
94          if ( request.getNewRdn() != null )
95          {
96              element.addAttribute( DsmlLiterals.NEW_RDN, request.getNewRdn().getName() );
97          }
98  
99          // DeleteOldRDN
100         element.addAttribute( DsmlLiterals.DELETE_OLD_RDN, request.getDeleteOldRdn() ? DsmlLiterals.TRUE : DsmlLiterals.FALSE );
101 
102         // NewSuperior
103         if ( request.getNewRdn() != null )
104         {
105             element.addAttribute( DsmlLiterals.NEW_SUPERIOR, request.getNewSuperior().getName() );
106         }
107 
108         return element;
109     }
110 
111 
112     /**
113      * Get the modification's Dn
114      * 
115      * @return Returns the name.
116      */
117     @Override
118     public Dn getName()
119     {
120         return getDecorated().getName();
121     }
122 
123 
124     /**
125      * Set the modification Dn.
126      * 
127      * @param name The name to set.
128      */
129     public void setEntry( Dn name )
130     {
131         getDecorated().setName( name );
132     }
133 
134 
135     /**
136      * Tells if the old Rdn is to be deleted
137      * 
138      * @return Returns the deleteOldRDN.
139      */
140     public boolean isDeleteOldRDN()
141     {
142         return getDecorated().getDeleteOldRdn();
143     }
144 
145 
146     /**
147      * Get the newSuperior
148      * 
149      * @return Returns the newSuperior.
150      */
151     @Override
152     public Dn getNewSuperior()
153     {
154         return getDecorated().getNewSuperior();
155     }
156 
157 
158     /**
159      * Set the new superior
160      * 
161      * @param newSuperior The newSuperior to set.
162      */
163     @Override
164     public ModifyDnRequest setNewSuperior( Dn newSuperior )
165     {
166         getDecorated().setNewSuperior( newSuperior );
167 
168         return this;
169     }
170 
171 
172     /**
173      * {@inheritDoc}
174      */
175     @Override
176     public MessageTypeEnum getResponseType()
177     {
178         return getDecorated().getResponseType();
179     }
180 
181 
182     /**
183      * {@inheritDoc}
184      */
185     @Override
186     public ModifyDnRequest setName( Dn name )
187     {
188         getDecorated().setName( name );
189 
190         return this;
191     }
192 
193 
194     /**
195      * {@inheritDoc}
196      */
197     @Override
198     public Rdn getNewRdn()
199     {
200         return getDecorated().getNewRdn();
201     }
202 
203 
204     /**
205      * {@inheritDoc}
206      */
207     @Override
208     public ModifyDnRequest setNewRdn( Rdn newRdn )
209     {
210         getDecorated().setNewRdn( newRdn );
211 
212         return this;
213     }
214 
215 
216     /**
217      * {@inheritDoc}
218      */
219     @Override
220     public boolean getDeleteOldRdn()
221     {
222         return getDecorated().getDeleteOldRdn();
223     }
224 
225 
226     /**
227      * {@inheritDoc}
228      */
229     @Override
230     public ModifyDnRequest setDeleteOldRdn( boolean deleteOldRdn )
231     {
232         getDecorated().setDeleteOldRdn( deleteOldRdn );
233 
234         return this;
235     }
236 
237 
238     /**
239      * {@inheritDoc}
240      */
241     @Override
242     public boolean isMove()
243     {
244         return getDecorated().isMove();
245     }
246 
247 
248     /**
249      * {@inheritDoc}
250      */
251     @Override
252     public ModifyDnRequest setMessageId( int messageId )
253     {
254         super.setMessageId( messageId );
255 
256         return this;
257     }
258 
259 
260     /**
261      * {@inheritDoc}
262      */
263     @Override
264     public ModifyDnRequest addControl( Control control )
265     {
266         return ( ModifyDnRequest ) super.addControl( control );
267     }
268 
269 
270     /**
271      * {@inheritDoc}
272      */
273     @Override
274     public ModifyDnRequest addAllControls( Control[] controls )
275     {
276         return ( ModifyDnRequest ) super.addAllControls( controls );
277     }
278 
279 
280     /**
281      * {@inheritDoc}
282      */
283     @Override
284     public ModifyDnRequest removeControl( Control control )
285     {
286         return ( ModifyDnRequest ) super.removeControl( control );
287     }
288 }