QManMetadataExchangeCapability.java
01 /*
02  *
03  * Licensed to the Apache Software Foundation (ASF) under one
04  * or more contributor license agreements.  See the NOTICE file
05  * distributed with this work for additional information
06  * regarding copyright ownership.  The ASF licenses this file
07  * to you under the Apache License, Version 2.0 (the
08  * "License"); you may not use this file except in compliance
09  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  */
21 package org.apache.qpid.management.wsdm.capabilities;
22 
23 import org.apache.muse.util.xml.XmlUtils;
24 import org.apache.muse.ws.resource.metadata.ext.WsrfMetadataExchange;
25 import org.apache.muse.ws.wsdl.WsdlUtils;
26 import org.apache.qpid.management.wsdm.muse.resources.QManWsResource;
27 import org.w3c.dom.Document;
28 import org.w3c.dom.Element;
29 
30 /**
31  * QMan resource metadata exchange.
32  * We cannot resuse the preexisting classes directly because the wsdl of the service instance
33  * is retrieved using a file path.
34  * Since the owner resource (QManWsResource) is dynamic (I mean, its interface is dynamic), the corresponding
35  * WSDL cannot defined at compile time but needs some changes when the resource is created.
36  * As part of that, the WSDL template found under wsdl folder is modified with the additional properties of the given 
37  * resource. The metadata exchange capability must include those properties too.
38  
39  * Note that this capability is appliable only to a QManWsResource.
40  
41  @author Andrea Gazzarini
42  */
43 public class QManMetadataExchangeCapability extends WsrfMetadataExchange 
44 {    
45   /**
46    * Returns the WSDL associated with the owner of this capability.
47    
48    *  @return the WSDL associated with the owner of this capability.
49    */
50   @Override
51   protected Element getWSDL() 
52   {
53     QManWsResource resource = (QManWsResourcegetResource();
54         
55         Document wsdlDoc = resource.getWsdl();
56         Element wsdl = XmlUtils.getFirstElement(wsdlDoc);
57         
58         WsdlUtils.removeWsdlReferences(wsdl);
59         WsdlUtils.removeSchemaReferences(wsdl);
60         
61         return wsdl;
62   }
63 }