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 */
020
021package org.apache.directory.api.dsmlv2.response;
022
023
024import org.apache.directory.api.ldap.codec.api.LdapApiService;
025import org.apache.directory.api.ldap.model.message.DeleteResponse;
026import org.apache.directory.api.ldap.model.message.DeleteResponseImpl;
027import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
028import org.dom4j.Element;
029import org.dom4j.tree.DefaultElement;
030
031
032/**
033 * DSML Decorator for DelResponse
034 *
035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036 */
037public class DelResponseDsml extends AbstractResultResponseDsml<DeleteResponse>
038    implements DeleteResponse
039{
040    private static final String DEL_RESPONSE_TAG = "delResponse";
041
042
043    /**
044     * Creates a new getDecoratedMessage() of DelResponseDsml.
045     * 
046     * @param codec The LDAP Service to use
047     */
048    public DelResponseDsml( LdapApiService codec )
049    {
050        super( codec, new DeleteResponseImpl() );
051    }
052
053
054    /**
055     * Creates a new getDecoratedMessage() of DelResponseDsml.
056     *
057     * @param codec The LDAP Service to use
058     * @param ldapMessage the message to decorate
059     */
060    public DelResponseDsml( LdapApiService codec, DeleteResponse 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 = null;
081
082        if ( root != null )
083        {
084            element = root.addElement( DEL_RESPONSE_TAG );
085        }
086        else
087        {
088            element = new DefaultElement( DEL_RESPONSE_TAG );
089        }
090
091        LdapResultDsml ldapResultDsml = new LdapResultDsml( getCodecService(),
092            getDecorated().getLdapResult(), getDecorated() );
093        ldapResultDsml.toDsml( element );
094        return element;
095    }
096}