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.reponse;
021
022
023import org.apache.directory.api.ldap.codec.api.LdapApiService;
024import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
025import org.apache.directory.api.ldap.model.message.ModifyResponse;
026import org.apache.directory.api.ldap.model.message.ModifyResponseImpl;
027import org.dom4j.Element;
028import org.dom4j.tree.DefaultElement;
029
030
031/**
032 * DSML Decorator for ModifyResponse
033 *
034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
035 */
036public class ModifyResponseDsml extends AbstractResultResponseDsml<ModifyResponse>
037    implements ModifyResponse
038{
039    private static final String MODIFY_RESPONSE_TAG = "modifyResponse";
040
041
042    /**
043     * Creates a new getDecoratedMessage() of ModifyResponseDsml.
044     */
045    public ModifyResponseDsml( LdapApiService codec )
046    {
047        super( codec, new ModifyResponseImpl() );
048    }
049
050
051    /**
052     * Creates a new getDecoratedMessage() of ModifyResponseDsml.
053     *
054     * @param ldapMessage
055     *      the message to decorate
056     */
057    public ModifyResponseDsml( LdapApiService codec, ModifyResponse ldapMessage )
058    {
059        super( codec, ldapMessage );
060    }
061
062
063    /**
064     * {@inheritDoc}
065     */
066    public MessageTypeEnum getType()
067    {
068        return getDecorated().getType();
069    }
070
071
072    /**
073     * {@inheritDoc}
074     */
075    public Element toDsml( Element root )
076    {
077        Element element = null;
078
079        if ( root != null )
080        {
081            element = root.addElement( MODIFY_RESPONSE_TAG );
082        }
083        else
084        {
085            element = new DefaultElement( MODIFY_RESPONSE_TAG );
086        }
087
088        LdapResultDsml ldapResultDsml = new LdapResultDsml( getCodecService(),
089            getDecorated().getLdapResult(), getDecorated() );
090        ldapResultDsml.toDsml( element );
091        return element;
092    }
093}