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