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.shared.dsmlv2.request;
021
022
023import org.apache.directory.shared.ldap.codec.api.LdapApiService;
024import org.apache.directory.shared.ldap.model.exception.MessageException;
025import org.apache.directory.shared.ldap.model.message.AbandonRequest;
026import org.apache.directory.shared.ldap.model.message.AbandonRequestImpl;
027import org.apache.directory.shared.ldap.model.message.Control;
028import org.apache.directory.shared.ldap.model.message.MessageTypeEnum;
029import org.dom4j.Element;
030
031
032/**
033 * DSML Decorator for AbandonRequest
034 *
035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036 */
037public class AbandonRequestDsml extends AbstractRequestDsml<AbandonRequest> 
038    implements AbandonRequest
039{
040    /**
041     * Creates a new instance of AbandonRequestDsml.
042     */
043    public AbandonRequestDsml( LdapApiService codec )
044    {
045        super( codec, new AbandonRequestImpl() );
046    }
047
048
049    /**
050     * Creates a new instance of AbandonRequestDsml.
051     *
052     * @param ldapMessage the message to decorate
053     */
054    public AbandonRequestDsml( LdapApiService codec, AbandonRequest ldapMessage )
055    {
056        super( codec, ldapMessage );
057    }
058
059
060    /**
061     * {@inheritDoc}
062     */
063    public MessageTypeEnum getType()
064    {
065        return getDecorated().getType();
066    }
067
068
069    /**
070     * {@inheritDoc}
071     */
072    public Element toDsml( Element root )
073    {
074        Element element = super.toDsml( root );
075
076        // AbandonID
077        if ( getDecorated().getAbandoned() != 0 )
078        {
079            element.addAttribute( "abandonID", "" + getDecorated().getAbandoned() );
080        }
081
082        return element;
083    }
084
085
086    /**
087     * Get the abandoned message ID
088     * 
089     * @return Returns the abandoned MessageId.
090     */
091    public int getAbandonedMessageId()
092    {
093        return getDecorated().getAbandoned();
094    }
095
096
097    /**
098     * Set the abandoned message ID
099     * 
100     * @param abandonedMessageId The abandoned messageID to set.
101     */
102    public AbandonRequest setAbandonedMessageId( int abandonedMessageId )
103    {
104        getDecorated().setAbandoned( abandonedMessageId );
105        
106        return this;
107    }
108
109
110    /**
111     * {@inheritDoc}
112     */
113    public int getAbandoned()
114    {
115        return getDecorated().getAbandoned();
116    }
117
118
119    /**
120     * {@inheritDoc}
121     */
122    public AbandonRequest setAbandoned( int requestId )
123    {
124        getDecorated().setAbandoned( requestId );
125        
126        return this;
127    }
128    
129    
130    /**
131     * {@inheritDoc}
132     */
133    public AbandonRequest setMessageId( int messageId )
134    {
135        super.setMessageId( messageId );
136        
137        return this;
138    }
139
140    
141    /**
142     * {@inheritDoc}
143     */
144    public AbandonRequest addControl( Control control ) throws MessageException
145    {
146        return (AbandonRequest)super.addControl( control );
147    }
148    
149    
150    /**
151     * {@inheritDoc}
152     */
153    public AbandonRequest addAllControls( Control[] controls ) throws MessageException
154    {
155        return (AbandonRequest)super.addAllControls( controls );
156    }
157    
158    
159    /**
160     * {@inheritDoc}
161     */
162    public AbandonRequest removeControl( Control control ) throws MessageException
163    {
164        return (AbandonRequest)super.removeControl( control );
165    }
166}