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 *    https://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    @Override
069    public MessageTypeEnum getType()
070    {
071        return getDecorated().getType();
072    }
073
074
075    /**
076     * {@inheritDoc}
077     */
078    @Override
079    public Element toDsml( Element root )
080    {
081        Element element = super.toDsml( root );
082
083        // Dn
084        if ( getDecorated().getName() != null )
085        {
086            element.addAttribute( "dn", getDecorated().getName().getName() );
087        }
088
089        return element;
090    }
091
092
093    /**
094     * Get the entry to be deleted
095     * 
096     * @return Returns the entry.
097     */
098    public Dn getEntry()
099    {
100        return getDecorated().getName();
101    }
102
103
104    /**
105     * Set the entry to be deleted
106     * 
107     * @param entry The entry to set.
108     */
109    public void setEntry( Dn entry )
110    {
111        getDecorated().setName( entry );
112    }
113
114
115    /**
116     * {@inheritDoc}
117     */
118    @Override
119    public MessageTypeEnum getResponseType()
120    {
121        return getDecorated().getResponseType();
122    }
123
124
125    /**
126     * {@inheritDoc}
127     */
128    @Override
129    public Dn getName()
130    {
131        return getDecorated().getName();
132    }
133
134
135    /**
136     * {@inheritDoc}
137     */
138    @Override
139    public DeleteRequest setName( Dn name )
140    {
141        getDecorated().setName( name );
142
143        return this;
144    }
145
146
147    /**
148     * {@inheritDoc}
149     */
150    @Override
151    public DeleteRequest setMessageId( int messageId )
152    {
153        super.setMessageId( messageId );
154
155        return this;
156    }
157
158
159    /**
160     * {@inheritDoc}
161     */
162    @Override
163    public DeleteRequest addControl( Control control )
164    {
165        return ( DeleteRequest ) super.addControl( control );
166    }
167
168
169    /**
170     * {@inheritDoc}
171     */
172    @Override
173    public DeleteRequest addAllControls( Control[] controls )
174    {
175        return ( DeleteRequest ) super.addAllControls( controls );
176    }
177
178
179    /**
180     * {@inheritDoc}
181     */
182    @Override
183    public DeleteRequest removeControl( Control control )
184    {
185        return ( DeleteRequest ) super.removeControl( control );
186    }
187}