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