001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.dsmlv2.request; 021 022 023import org.apache.directory.api.ldap.codec.api.LdapApiService; 024import org.apache.directory.api.ldap.model.message.Control; 025import org.apache.directory.api.ldap.model.message.MessageTypeEnum; 026import org.apache.directory.api.ldap.model.message.ModifyDnRequest; 027import org.apache.directory.api.ldap.model.message.ModifyDnRequestImpl; 028import org.apache.directory.api.ldap.model.message.ModifyDnResponse; 029import org.apache.directory.api.ldap.model.name.Dn; 030import org.apache.directory.api.ldap.model.name.Rdn; 031import org.dom4j.Element; 032 033 034/** 035 * DSML Decorator for ModifyDNRequest 036 * 037 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 038 */ 039public class ModifyDNRequestDsml 040 extends AbstractResultResponseRequestDsml<ModifyDnRequest, ModifyDnResponse> 041 implements ModifyDnRequest 042{ 043 /** 044 * Creates a new getDecoratedMessage() of ModifyDNRequestDsml. 045 * 046 * @param codec The LDAP Service to use 047 */ 048 public ModifyDNRequestDsml( LdapApiService codec ) 049 { 050 super( codec, new ModifyDnRequestImpl() ); 051 } 052 053 054 /** 055 * Creates a new getDecoratedMessage() of ModifyDNRequestDsml. 056 * 057 * @param codec The LDAP Service to use 058 * @param ldapMessage the message to decorate 059 */ 060 public ModifyDNRequestDsml( LdapApiService codec, ModifyDnRequest ldapMessage ) 061 { 062 super( codec, ldapMessage ); 063 } 064 065 066 /** 067 * {@inheritDoc} 068 */ 069 public MessageTypeEnum getType() 070 { 071 return getDecorated().getType(); 072 } 073 074 075 /** 076 * {@inheritDoc} 077 */ 078 public Element toDsml( Element root ) 079 { 080 Element element = super.toDsml( root ); 081 082 ModifyDnRequest request = getDecorated(); 083 084 // Dn 085 if ( request.getName() != null ) 086 { 087 element.addAttribute( "dn", request.getName().getName() ); 088 } 089 090 // NewRDN 091 if ( request.getNewRdn() != null ) 092 { 093 element.addAttribute( "newrdn", request.getNewRdn().getName() ); 094 } 095 096 // DeleteOldRDN 097 element.addAttribute( "deleteoldrdn", ( request.getDeleteOldRdn() ? "true" : "false" ) ); 098 099 // 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}