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.reponse;
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    public DelResponseDsml( LdapApiService codec )
047    {
048        super( codec, new DeleteResponseImpl() );
049    }
050
051
052    /**
053     * Creates a new getDecoratedMessage() of DelResponseDsml.
054     *
055     * @param ldapMessage
056     *      the message to decorate
057     */
058    public DelResponseDsml( LdapApiService codec, DeleteResponse ldapMessage )
059    {
060        super( codec, ldapMessage );
061    }
062
063
064    /**
065     * {@inheritDoc}
066     */
067    public MessageTypeEnum getType()
068    {
069        return getDecorated().getType();
070    }
071
072
073    /**
074     * {@inheritDoc}
075     */
076    public Element toDsml( Element root )
077    {
078        Element element = null;
079
080        if ( root != null )
081        {
082            element = root.addElement( DEL_RESPONSE_TAG );
083        }
084        else
085        {
086            element = new DefaultElement( DEL_RESPONSE_TAG );
087        }
088
089        LdapResultDsml ldapResultDsml = new LdapResultDsml( getCodecService(),
090            getDecorated().getLdapResult(), getDecorated() );
091        ldapResultDsml.toDsml( element );
092        return element;
093    }
094}