View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.dsmlv2.request;
21  
22  
23  import org.apache.directory.api.ldap.codec.api.LdapApiService;
24  import org.apache.directory.api.ldap.model.message.Control;
25  import org.apache.directory.api.ldap.model.message.DeleteRequest;
26  import org.apache.directory.api.ldap.model.message.DeleteRequestImpl;
27  import org.apache.directory.api.ldap.model.message.DeleteResponse;
28  import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
29  import org.apache.directory.api.ldap.model.name.Dn;
30  import org.dom4j.Element;
31  
32  
33  /**
34   * DSML Decorator for DeleteRequest
35   *
36   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
37   */
38  public class DelRequestDsml
39      extends AbstractResultResponseRequestDsml<DeleteRequest, DeleteResponse>
40      implements DeleteRequest
41  {
42      /**
43       * Creates a new getDecoratedMessage() of DelRequestDsml.
44       * 
45       * @param codec The LDAP Service to use
46       */
47      public DelRequestDsml( LdapApiService codec )
48      {
49          super( codec, new DeleteRequestImpl() );
50      }
51  
52  
53      /**
54       * Creates a new getDecoratedMessage() of DelRequestDsml.
55       *
56       * @param codec The LDAP Service to use
57       * @param ldapMessage the message to decorate
58       */
59      public DelRequestDsml( LdapApiService codec, DeleteRequest ldapMessage )
60      {
61          super( codec, ldapMessage );
62      }
63  
64  
65      /**
66       * {@inheritDoc}
67       */
68      public MessageTypeEnum getType()
69      {
70          return getDecorated().getType();
71      }
72  
73  
74      /**
75       * {@inheritDoc}
76       */
77      public Element toDsml( Element root )
78      {
79          Element element = super.toDsml( root );
80  
81          // Dn
82          if ( getDecorated().getName() != null )
83          {
84              element.addAttribute( "dn", getDecorated().getName().getName() );
85          }
86  
87          return element;
88      }
89  
90  
91      /**
92       * Get the entry to be deleted
93       * 
94       * @return Returns the entry.
95       */
96      public Dn getEntry()
97      {
98          return getDecorated().getName();
99      }
100 
101 
102     /**
103      * Set the entry to be deleted
104      * 
105      * @param entry The entry to set.
106      */
107     public void setEntry( Dn entry )
108     {
109         getDecorated().setName( entry );
110     }
111 
112 
113     /**
114      * {@inheritDoc}
115      */
116     public MessageTypeEnum getResponseType()
117     {
118         return getDecorated().getResponseType();
119     }
120 
121 
122     /**
123      * {@inheritDoc}
124      */
125     public Dn getName()
126     {
127         return getDecorated().getName();
128     }
129 
130 
131     /**
132      * {@inheritDoc}
133      */
134     public DeleteRequest setName( Dn name )
135     {
136         getDecorated().setName( name );
137 
138         return this;
139     }
140 
141 
142     /**
143      * {@inheritDoc}
144      */
145     public DeleteRequest setMessageId( int messageId )
146     {
147         super.setMessageId( messageId );
148 
149         return this;
150     }
151 
152 
153     /**
154      * {@inheritDoc}
155      */
156     public DeleteRequest addControl( Control control )
157     {
158         return ( DeleteRequest ) super.addControl( control );
159     }
160 
161 
162     /**
163      * {@inheritDoc}
164      */
165     public DeleteRequest addAllControls( Control[] controls )
166     {
167         return ( DeleteRequest ) super.addAllControls( controls );
168     }
169 
170 
171     /**
172      * {@inheritDoc}
173      */
174     public DeleteRequest removeControl( Control control )
175     {
176         return ( DeleteRequest ) super.removeControl( control );
177     }
178 }