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   *    https://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.dsmlv2.DsmlLiterals;
24  import org.apache.directory.api.ldap.codec.api.LdapApiService;
25  import org.apache.directory.api.ldap.model.message.Control;
26  import org.apache.directory.api.ldap.model.message.DeleteRequest;
27  import org.apache.directory.api.ldap.model.message.DeleteRequestImpl;
28  import org.apache.directory.api.ldap.model.message.DeleteResponse;
29  import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
30  import org.apache.directory.api.ldap.model.name.Dn;
31  import org.dom4j.Element;
32  
33  
34  /**
35   * DSML Decorator for DeleteRequest
36   *
37   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
38   */
39  public class DelRequestDsml
40      extends AbstractResultResponseRequestDsml<DeleteRequest, DeleteResponse>
41      implements DeleteRequest
42  {
43      /**
44       * Creates a new getDecoratedMessage() of DelRequestDsml.
45       * 
46       * @param codec The LDAP Service to use
47       */
48      public DelRequestDsml( LdapApiService codec )
49      {
50          super( codec, new DeleteRequestImpl() );
51      }
52  
53  
54      /**
55       * Creates a new getDecoratedMessage() of DelRequestDsml.
56       *
57       * @param codec The LDAP Service to use
58       * @param ldapMessage the message to decorate
59       */
60      public DelRequestDsml( LdapApiService codec, DeleteRequest ldapMessage )
61      {
62          super( codec, ldapMessage );
63      }
64  
65  
66      /**
67       * {@inheritDoc}
68       */
69      @Override
70      public MessageTypeEnum getType()
71      {
72          return getDecorated().getType();
73      }
74  
75  
76      /**
77       * {@inheritDoc}
78       */
79      @Override
80      public Element toDsml( Element root )
81      {
82          Element element = super.toDsml( root );
83  
84          // Dn
85          if ( getDecorated().getName() != null )
86          {
87              element.addAttribute( DsmlLiterals.DN, getDecorated().getName().getName() );
88          }
89  
90          return element;
91      }
92  
93  
94      /**
95       * Get the entry to be deleted
96       * 
97       * @return Returns the entry.
98       */
99      public Dn getEntry()
100     {
101         return getDecorated().getName();
102     }
103 
104 
105     /**
106      * Set the entry to be deleted
107      * 
108      * @param entry The entry to set.
109      */
110     public void setEntry( Dn entry )
111     {
112         getDecorated().setName( entry );
113     }
114 
115 
116     /**
117      * {@inheritDoc}
118      */
119     @Override
120     public MessageTypeEnum getResponseType()
121     {
122         return getDecorated().getResponseType();
123     }
124 
125 
126     /**
127      * {@inheritDoc}
128      */
129     @Override
130     public Dn getName()
131     {
132         return getDecorated().getName();
133     }
134 
135 
136     /**
137      * {@inheritDoc}
138      */
139     @Override
140     public DeleteRequest setName( Dn name )
141     {
142         getDecorated().setName( name );
143 
144         return this;
145     }
146 
147 
148     /**
149      * {@inheritDoc}
150      */
151     @Override
152     public DeleteRequest setMessageId( int messageId )
153     {
154         super.setMessageId( messageId );
155 
156         return this;
157     }
158 
159 
160     /**
161      * {@inheritDoc}
162      */
163     @Override
164     public DeleteRequest addControl( Control control )
165     {
166         return ( DeleteRequest ) super.addControl( control );
167     }
168 
169 
170     /**
171      * {@inheritDoc}
172      */
173     @Override
174     public DeleteRequest addAllControls( Control[] controls )
175     {
176         return ( DeleteRequest ) super.addAllControls( controls );
177     }
178 
179 
180     /**
181      * {@inheritDoc}
182      */
183     @Override
184     public DeleteRequest removeControl( Control control )
185     {
186         return ( DeleteRequest ) super.removeControl( control );
187     }
188 }