org.apache.cxf.ws.mex.MEXUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cxf-rt-ws-mex Show documentation
Show all versions of cxf-rt-ws-mex Show documentation
Apache CXF Runtime WS MetadataExchange
The newest version!
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cxf.ws.mex;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.w3c.dom.Element;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.common.util.UrlUtils;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.frontend.WSDLGetUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.PhaseInterceptorChain;
import org.apache.cxf.service.model.EndpointInfo;
/**
*
*/
public final class MEXUtils {
private MEXUtils() {
//utility
}
public static List getWSDLs(Server server) {
Message message = PhaseInterceptorChain.getCurrentMessage();
message.put(WSDLGetUtils.AUTO_REWRITE_ADDRESS_ALL, true);
String base = (String)message.get(Message.REQUEST_URL);
String ctxUri = (String)message.get(Message.PATH_INFO);
WSDLGetUtils utils = new WSDLGetUtils();
EndpointInfo info = server.getEndpoint().getEndpointInfo();
List ret = new LinkedList<>();
for (String id : utils.getWSDLIds(message, base, ctxUri, info)) {
Map params = new HashMap<>();
params.put("wsdl", id);
ret.add(utils.getDocument(message, base,
params, ctxUri,
info).getDocumentElement());
}
return ret;
}
public static Map getSchemaLocations(Server server) {
Message message = PhaseInterceptorChain.getCurrentMessage();
String base = (String)message.get(Message.REQUEST_URL);
String ctxUri = (String)message.get(Message.PATH_INFO);
WSDLGetUtils utils = new WSDLGetUtils();
EndpointInfo info = server.getEndpoint().getEndpointInfo();
return utils.getSchemaLocations(message, base, ctxUri, info);
}
public static List getSchemas(Server server, String id) {
Message message = PhaseInterceptorChain.getCurrentMessage();
String base = (String)message.get(Message.REQUEST_URL);
String ctxUri = (String)message.get(Message.PATH_INFO);
WSDLGetUtils utils = new WSDLGetUtils();
EndpointInfo info = server.getEndpoint().getEndpointInfo();
Map locs = utils.getSchemaLocations(message,
base,
ctxUri,
info);
List ret = new LinkedList<>();
for (Map.Entry xsd : locs.entrySet()) {
if (StringUtils.isEmpty(id)
|| id.equals(xsd.getKey())) {
String query = xsd.getValue().substring(xsd.getValue().indexOf('?') + 1);
Map params = UrlUtils.parseQueryString(query);
ret.add(utils.getDocument(message, base, params, ctxUri, info).getDocumentElement());
}
}
return ret;
}
public static Map getPolicyLocations(Server server) {
return null;
}
public static List getPolicies(Server server, String id) {
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy