use of com.ibm.lsid.LSIDException in project cdmlib by cybertaxonomy.
the class LsidWsdlWrapperImpl method setAuthorityLocation.
public void setAuthorityLocation(LSIDAuthorityPort authorityPort) throws LSIDException {
String serviceName = authorityPort.getServiceName();
if (serviceName == null)
serviceName = SERVICE_NAME;
Map services = definition.getServices();
QName key = new QName(definition.getTargetNamespace(), serviceName);
Service service = (Service) services.get(key);
if (service == null) {
service = definition.createService();
service.setQName(key);
definition.addService(service);
}
// remove data port if it already exists.
String portName = authorityPort.getName();
if (portName != null) {
Port port = service.getPort(portName);
if (port != null) {
definition.removeBinding(port.getBinding().getQName());
service.getPorts().remove(portName);
}
lsidAuthorityPorts.remove(getPortKey(authorityPort));
}
String protocol = authorityPort.getProtocol();
// we have to create a new port and possibly a binding
// make sure we have the namespaces set in the defintion
configureAuthorityServiceDef(protocol);
PortType authorityPortType = definition.getPortType(new QName(OMG_LSID_PORT_TYPES_WSDL_NS_URI, AUTHORITY_PORT_TYPE));
Binding binding = null;
if (protocol.equals(SOAP))
binding = definition.getBinding(AUTHORITY_SOAP_BINDING);
else if (protocol.equals(HTTP))
binding = definition.getBinding(AUTHORITY_HTTP_BINDING);
if (binding == null)
throw new LSIDException("Unsuported protocol for authority port: " + protocol);
Port authport = createPort(binding, authorityPort);
service.addPort(authport);
lsidAuthorityPorts.put(getPortKey(authorityPort), authorityPort);
// indicate that the WSDL has changed, so the string rep is no longer valid...
wsdl = null;
}
use of com.ibm.lsid.LSIDException in project cdmlib by cybertaxonomy.
the class LsidWsdlWrapperImpl method extractPort.
private static LsidStandardPortImpl extractPort(Service service, Port port, QName portTypeName) throws LSIDException {
String portName = port.getName();
LsidStandardPortImpl portImpl = new LsidStandardPortImpl();
portImpl.setName(portName);
// might have to use whole QName, not sure for now
portImpl.setServiceName(service.getQName().getLocalPart());
Iterator portElts = port.getExtensibilityElements().listIterator();
while (portElts.hasNext()) {
// expecting only 1
Object portElt = portElts.next();
if (portElt instanceof SOAPAddress) {
SOAPAddress soapaddr = (SOAPAddress) portElt;
portImpl.setLocation(soapaddr.getLocationURI());
portImpl.setProtocol(SOAP);
} else if (portElt instanceof HTTPAddress) {
HTTPAddress httpaddr = (HTTPAddress) portElt;
portImpl.setLocation(httpaddr.getLocationURI());
portImpl.setProtocol(HTTP);
QName bindingName = port.getBinding().getQName();
if (bindingName.equals(DATA_HTTP_BINDING_DIRECT))
portImpl.setPath(LSIDStandardPort.PATH_TYPE_DIRECT);
else
portImpl.setPath(LSIDStandardPort.PATH_TYPE_URL_ENCODED);
} else if (portElt instanceof FTPLocation) {
FTPLocation ftploc = (FTPLocation) portElt;
portImpl.setLocation(ftploc.getServer());
portImpl.setPath(ftploc.getFilePath());
portImpl.setProtocol(FTP);
} else if (portElt instanceof FileLocation) {
FileLocation fileloc = (FileLocation) portElt;
portImpl.setLocation(fileloc.getFilename());
portImpl.setProtocol(FILE);
} else {
throw new LSIDException("Unknown Port impl");
}
}
return portImpl;
}
use of com.ibm.lsid.LSIDException in project cdmlib by cybertaxonomy.
the class LsidWsdlWrapperImpl method importNamespace.
/**
* import the given namespace into the def.
*/
private void importNamespace(String prefix, String ns, String location) throws LSIDException {
Definition importDef = null;
try {
WSDLReader wsdlReader = WSDLFactoryImpl.newInstance().newWSDLReader();
;
String resource = baseURI + location;
Reader reader = new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream(resource));
WSDLLocator locator = new LSIDWSDLLocator(baseURI, reader, Thread.currentThread().getContextClassLoader());
importDef = wsdlReader.readWSDL(locator);
} catch (WSDLException e) {
throw new LSIDException(e, "Error importing namespace: " + ns);
}
definition.addNamespace(prefix, ns);
Import imp = definition.createImport();
imp.setLocationURI(location);
imp.setNamespaceURI(ns);
imp.setDefinition(importDef);
definition.addImport(imp);
}
use of com.ibm.lsid.LSIDException in project cdmlib by cybertaxonomy.
the class CdmExceptionResolver method doResolveException.
@Override
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) {
ModelAndView mv = new ModelAndView("error");
if (exception instanceof LSIDException) {
LSIDException lsidException = (LSIDException) exception;
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.addHeader(CdmExceptionResolver.LSID_ERROR_CODE_HEADER, Integer.toString(lsidException.getErrorCode()));
// return mv;
}
return super.doResolveException(request, response, handler, exception);
}
use of com.ibm.lsid.LSIDException in project cdmlib by cybertaxonomy.
the class LsidWsdlWrapperImpl method updateStringRepresentation.
/**
* Updates the string representation of the WSDL. This should be called if the WSDL Definition changes
*/
private void updateStringRepresentation() throws LSIDException {
StringWriter strWriter = new StringWriter();
WSDLWriter writer = new WSDLWriterImpl();
try {
writer.writeWSDL(definition, strWriter);
} catch (WSDLException e) {
throw new LSIDException(e, "Error writing WSDL def to string");
}
wsdl = strWriter.getBuffer().toString();
}
Aggregations