Search in sources :

Example 1 with LSIDException

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;
}
Also used : FTPBinding(com.ibm.wsdl.extensions.ftp.FTPBinding) Binding(javax.wsdl.Binding) FileBinding(com.ibm.wsdl.extensions.file.FileBinding) LSIDException(com.ibm.lsid.LSIDException) QName(javax.xml.namespace.QName) LSIDPort(com.ibm.lsid.wsdl.LSIDPort) LSIDDataPort(com.ibm.lsid.wsdl.LSIDDataPort) DefaultLSIDPort(com.ibm.lsid.wsdl.DefaultLSIDPort) LSIDStandardPort(com.ibm.lsid.wsdl.LSIDStandardPort) Port(javax.wsdl.Port) LSIDMetadataPort(com.ibm.lsid.wsdl.LSIDMetadataPort) LSIDAuthorityPort(com.ibm.lsid.wsdl.LSIDAuthorityPort) Service(javax.wsdl.Service) Map(java.util.Map) PortType(javax.wsdl.PortType)

Example 2 with LSIDException

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;
}
Also used : HTTPAddress(javax.wsdl.extensions.http.HTTPAddress) LSIDException(com.ibm.lsid.LSIDException) QName(javax.xml.namespace.QName) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) FileLocation(com.ibm.wsdl.extensions.file.FileLocation) Iterator(java.util.Iterator) FTPLocation(com.ibm.wsdl.extensions.ftp.FTPLocation)

Example 3 with LSIDException

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);
}
Also used : WSDLLocator(javax.wsdl.xml.WSDLLocator) LSIDWSDLLocator(eu.etaxonomy.cdm.model.common.LSIDWSDLLocator) Import(javax.wsdl.Import) InputStreamReader(java.io.InputStreamReader) LSIDException(com.ibm.lsid.LSIDException) WSDLException(javax.wsdl.WSDLException) Definition(javax.wsdl.Definition) Reader(java.io.Reader) WSDLReader(javax.wsdl.xml.WSDLReader) InputStreamReader(java.io.InputStreamReader) LSIDWSDLLocator(eu.etaxonomy.cdm.model.common.LSIDWSDLLocator) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 4 with LSIDException

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);
}
Also used : LSIDException(com.ibm.lsid.LSIDException) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 5 with LSIDException

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();
}
Also used : StringWriter(java.io.StringWriter) LSIDException(com.ibm.lsid.LSIDException) WSDLException(javax.wsdl.WSDLException) WSDLWriterImpl(com.ibm.wsdl.xml.WSDLWriterImpl) WSDLWriter(javax.wsdl.xml.WSDLWriter)

Aggregations

LSIDException (com.ibm.lsid.LSIDException)8 WSDLException (javax.wsdl.WSDLException)3 QName (javax.xml.namespace.QName)3 LSIDServerException (com.ibm.lsid.server.LSIDServerException)2 DefaultLSIDPort (com.ibm.lsid.wsdl.DefaultLSIDPort)2 LSIDAuthorityPort (com.ibm.lsid.wsdl.LSIDAuthorityPort)2 LSIDDataPort (com.ibm.lsid.wsdl.LSIDDataPort)2 LSIDMetadataPort (com.ibm.lsid.wsdl.LSIDMetadataPort)2 LSIDPort (com.ibm.lsid.wsdl.LSIDPort)2 LSIDStandardPort (com.ibm.lsid.wsdl.LSIDStandardPort)2 FileBinding (com.ibm.wsdl.extensions.file.FileBinding)2 FTPBinding (com.ibm.wsdl.extensions.ftp.FTPBinding)2 Map (java.util.Map)2 Binding (javax.wsdl.Binding)2 Port (javax.wsdl.Port)2 PortType (javax.wsdl.PortType)2 Service (javax.wsdl.Service)2 ExpiringResponse (com.ibm.lsid.ExpiringResponse)1 HTTPLocation (com.ibm.lsid.wsdl.HTTPLocation)1 LSIDPortFactory (com.ibm.lsid.wsdl.LSIDPortFactory)1