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.DeleteRequest; 026import org.apache.directory.api.ldap.model.message.DeleteRequestImpl; 027import org.apache.directory.api.ldap.model.message.DeleteResponse; 028import org.apache.directory.api.ldap.model.message.MessageTypeEnum; 029import org.apache.directory.api.ldap.model.name.Dn; 030import org.dom4j.Element; 031 032 033/** 034 * DSML Decorator for DeleteRequest 035 * 036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 037 */ 038public class DelRequestDsml 039 extends AbstractResultResponseRequestDsml<DeleteRequest, DeleteResponse> 040 implements DeleteRequest 041{ 042 /** 043 * Creates a new getDecoratedMessage() of DelRequestDsml. 044 * 045 * @param codec The LDAP Service to use 046 */ 047 public DelRequestDsml( LdapApiService codec ) 048 { 049 super( codec, new DeleteRequestImpl() ); 050 } 051 052 053 /** 054 * Creates a new getDecoratedMessage() of DelRequestDsml. 055 * 056 * @param codec The LDAP Service to use 057 * @param ldapMessage the message to decorate 058 */ 059 public DelRequestDsml( LdapApiService codec, DeleteRequest ldapMessage ) 060 { 061 super( codec, ldapMessage ); 062 } 063 064 065 /** 066 * {@inheritDoc} 067 */ 068 public MessageTypeEnum getType() 069 { 070 return getDecorated().getType(); 071 } 072 073 074 /** 075 * {@inheritDoc} 076 */ 077 public Element toDsml( Element root ) 078 { 079 Element element = super.toDsml( root ); 080 081 // Dn 082 if ( getDecorated().getName() != null ) 083 { 084 element.addAttribute( "dn", getDecorated().getName().getName() ); 085 } 086 087 return element; 088 } 089 090 091 /** 092 * Get the entry to be deleted 093 * 094 * @return Returns the entry. 095 */ 096 public Dn getEntry() 097 { 098 return getDecorated().getName(); 099 } 100 101 102 /** 103 * Set the entry to be deleted 104 * 105 * @param entry The entry to set. 106 */ 107 public void setEntry( Dn entry ) 108 { 109 getDecorated().setName( entry ); 110 } 111 112 113 /** 114 * {@inheritDoc} 115 */ 116 public MessageTypeEnum getResponseType() 117 { 118 return getDecorated().getResponseType(); 119 } 120 121 122 /** 123 * {@inheritDoc} 124 */ 125 public Dn getName() 126 { 127 return getDecorated().getName(); 128 } 129 130 131 /** 132 * {@inheritDoc} 133 */ 134 public DeleteRequest setName( Dn name ) 135 { 136 getDecorated().setName( name ); 137 138 return this; 139 } 140 141 142 /** 143 * {@inheritDoc} 144 */ 145 public DeleteRequest setMessageId( int messageId ) 146 { 147 super.setMessageId( messageId ); 148 149 return this; 150 } 151 152 153 /** 154 * {@inheritDoc} 155 */ 156 public DeleteRequest addControl( Control control ) 157 { 158 return ( DeleteRequest ) super.addControl( control ); 159 } 160 161 162 /** 163 * {@inheritDoc} 164 */ 165 public DeleteRequest addAllControls( Control[] controls ) 166 { 167 return ( DeleteRequest ) super.addAllControls( controls ); 168 } 169 170 171 /** 172 * {@inheritDoc} 173 */ 174 public DeleteRequest removeControl( Control control ) 175 { 176 return ( DeleteRequest ) super.removeControl( control ); 177 } 178}