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