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 package org.apache.directory.shared.dsmlv2.request;
021
022
023 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
024 import org.apache.directory.shared.ldap.codec.abandon.AbandonRequestCodec;
025 import org.dom4j.Element;
026
027
028 /**
029 * DSML Decorator for AbandonRequest
030 *
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 * @version $Rev$, $Date$
033 */
034 public class AbandonRequestDsml extends AbstractRequestDsml
035 {
036 /**
037 * Creates a new instance of AbandonRequestDsml.
038 */
039 public AbandonRequestDsml()
040 {
041 super( new AbandonRequestCodec() );
042 }
043
044
045 /**
046 * Creates a new instance of AbandonRequestDsml.
047 *
048 * @param ldapMessage
049 * the message to decorate
050 */
051 public AbandonRequestDsml( AbandonRequestCodec ldapMessage )
052 {
053 super( ldapMessage );
054 }
055
056
057 /**
058 * {@inheritDoc}
059 */
060 public MessageTypeEnum getMessageType()
061 {
062 return instance.getMessageType();
063 }
064
065
066 /**
067 * {@inheritDoc}
068 */
069 public Element toDsml( Element root )
070 {
071 Element element = super.toDsml( root );
072
073 AbandonRequestCodec request = ( AbandonRequestCodec ) instance;
074
075 // AbandonID
076 if ( request.getAbandonedMessageId() != 0 )
077 {
078 element.addAttribute( "abandonID", "" + request.getAbandonedMessageId() );
079 }
080
081 return element;
082 }
083
084
085 /**
086 * Get the abandoned message ID
087 *
088 * @return Returns the abandoned MessageId.
089 */
090 public int getAbandonedMessageId()
091 {
092 return ( ( AbandonRequestCodec ) instance ).getAbandonedMessageId();
093 }
094
095
096 /**
097 * Set the abandoned message ID
098 *
099 * @param abandonedMessageId The abandoned messageID to set.
100 */
101 public void setAbandonedMessageId( int abandonedMessageId )
102 {
103 ( ( AbandonRequestCodec ) instance ).setAbandonedMessageId( abandonedMessageId );
104 }
105 }