KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > dsmlv2 > request > ExtendedRequestDsml


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.ldapstudio.dsmlv2.request;
21
22 import org.apache.directory.ldapstudio.dsmlv2.ParserUtils;
23 import org.apache.directory.shared.ldap.codec.LdapMessage;
24 import org.apache.directory.shared.ldap.codec.extended.ExtendedRequest;
25 import org.dom4j.Element;
26 import org.dom4j.Namespace;
27 import org.dom4j.QName;
28
29 /**
30  * DSML Decorator for ExtendedRequest
31  *
32  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
33  * @version $Rev$, $Date$
34  */

35 public class ExtendedRequestDsml extends AbstractRequestDsml
36 {
37     /**
38      * Creates a new instance of ExtendedRequestDsml.
39      *
40      * @param ldapMessage
41      * the message to decorate
42      */

43     public ExtendedRequestDsml( LdapMessage ldapMessage )
44     {
45         super( ldapMessage );
46     }
47     
48     
49     /**
50      * {@inheritDoc}
51      */

52     public int getMessageType()
53     {
54         return instance.getMessageType();
55     }
56
57     
58     /**
59      * {@inheritDoc}
60      */

61     public Element toDsml( Element root )
62     {
63         Element element = super.toDsml( root );
64         
65         ExtendedRequest request = ( ExtendedRequest ) instance;
66         
67         // Request Name
68
if ( request.getRequestName() != null )
69         {
70             element.addElement( "requestName" ).setText( request.getRequestName() );
71         }
72         
73         // Request Value
74
Namespace xsdNamespace = new Namespace( "xsd", ParserUtils.XML_SCHEMA_URI );
75         Namespace xsiNamespace = new Namespace( "xsi", ParserUtils.XML_SCHEMA_INSTANCE_URI );
76         element.getDocument().getRootElement().add( xsdNamespace );
77         element.getDocument().getRootElement().add( xsiNamespace );
78
79         Element valueElement = element.addElement( "requestValue" ).addText(
80             ParserUtils.base64Encode( request.getRequestValue() ) );
81         valueElement
82             .addAttribute( new QName( "type", xsiNamespace ), "xsd:" + ParserUtils.BASE64BINARY );
83         
84         return element;
85     }
86 }
87
Popular Tags