Search in sources :

Example 6 with LSIDException

use of com.ibm.lsid.LSIDException in project cdmlib by cybertaxonomy.

the class LsidWsdlWrapperImpl method extractPorts.

/**
 * Extract the port info for data and meta data
 */
private void extractPorts() throws LSIDException {
    Map services = definition.getServices();
    Object[] serviceKeys = services.keySet().toArray();
    for (int j = 0; j < serviceKeys.length; j++) {
        Service service = (Service) services.get(serviceKeys[j]);
        Map ports = service.getPorts();
        Object[] portKeys = ports.keySet().toArray();
        // go through the ports, meta data and data
        for (int i = 0; i < portKeys.length; i++) {
            Port port = (Port) ports.get(portKeys[i]);
            Binding binding = port.getBinding();
            PortType portType = binding.getPortType();
            QName qname = portType.getQName();
            if (qname.getLocalPart().equals(METADATA_PORT_TYPE) && qname.getNamespaceURI().equals(OMG_LSID_PORT_TYPES_WSDL_NS_URI)) {
                if (!binding.getQName().equals(METADATA_SOAP_BINDING) && !binding.getQName().equals(METADATA_HTTP_BINDING) && !binding.getQName().equals(METADATA_FTP_BINDING) && !binding.getQName().equals(METADATA_FILE_BINDING))
                    throw new LSIDException(LSIDException.UNKNOWN_METHOD, "Unrecognized metadata binding: " + binding.getQName());
                LsidStandardPortImpl portImpl = extractPort(service, port, qname);
                lsidMetadataPorts.put(portImpl.getKey(), portImpl);
            } else if (qname.getLocalPart().equals(DATA_PORT_TYPE) && qname.getNamespaceURI().equals(OMG_LSID_PORT_TYPES_WSDL_NS_URI)) {
                if (!binding.getQName().equals(DATA_SOAP_BINDING) && !binding.getQName().equals(DATA_HTTP_BINDING) && !binding.getQName().equals(DATA_FTP_BINDING) && !binding.getQName().equals(DATA_FILE_BINDING))
                    throw new LSIDException(LSIDException.UNKNOWN_METHOD, "Unrecognized data binding: " + binding.getQName());
                LsidStandardPortImpl portImpl = extractPort(service, port, qname);
                lsidDataPorts.put(portImpl.getKey(), portImpl);
            } else if (qname.getLocalPart().equals(AUTHORITY_PORT_TYPE) && qname.getNamespaceURI().equals(OMG_LSID_PORT_TYPES_WSDL_NS_URI)) {
                if (!binding.getQName().equals(AUTHORITY_SOAP_BINDING) && !binding.getQName().equals(AUTHORITY_HTTP_BINDING))
                    throw new LSIDException(LSIDException.UNKNOWN_METHOD, "Unrecognized authority binding: " + binding.getQName());
                LsidStandardPortImpl portImpl = extractPort(service, port, qname);
                lsidAuthorityPorts.put(portImpl.getKey(), portImpl);
            } else {
                LSIDPortFactory lpf = LSIDResolver.getConfig().getLSIDPortFactory(portType);
                LSIDPort newPort = null;
                if (lpf == null) {
                    newPort = new DefaultLSIDPort(service.getQName().getLocalPart(), port.getName(), port);
                } else {
                    // might have to use whole qname, not sure for now
                    newPort = lpf.createPort(service.getQName().getLocalPart(), port);
                }
                wsdlExtensionPorts.put(getPortKey(newPort), newPort);
            }
        }
    }
}
Also used : FTPBinding(com.ibm.wsdl.extensions.ftp.FTPBinding) Binding(javax.wsdl.Binding) FileBinding(com.ibm.wsdl.extensions.file.FileBinding) DefaultLSIDPort(com.ibm.lsid.wsdl.DefaultLSIDPort) 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) LSIDPortFactory(com.ibm.lsid.wsdl.LSIDPortFactory) LSIDException(com.ibm.lsid.LSIDException) LSIDPort(com.ibm.lsid.wsdl.LSIDPort) DefaultLSIDPort(com.ibm.lsid.wsdl.DefaultLSIDPort) Map(java.util.Map) PortType(javax.wsdl.PortType)

Example 7 with LSIDException

use of com.ibm.lsid.LSIDException in project cdmlib by cybertaxonomy.

the class LsidAuthorityServiceImpl method getAuthorityWSDL.

@Override
public ExpiringResponse getAuthorityWSDL() throws LSIDServerException {
    LSID lsid = null;
    LSIDWSDLWrapper wsdl = lsidWSDLWrapperFactory.getLSIDWSDLWrapper(lsid);
    try {
        wsdl.setAuthorityLocation(new HTTPLocation("AuthorityServiceHTTP", "HTTPPort", lsidDomain, lsidPort, null));
        // lsidWSDLWrapperFactory.setAuthorityLocation(new SOAPLocation("AuthorityServiceSOAP", "SOAPPort", "http://" + lsidDomain	+ ":" + lsidPort + "/authority/soap/"), wsdl);
        return new ExpiringResponse(wsdl.getWSDLSource(), getExpiration());
    } catch (LSIDException e) {
        throw new LSIDServerException(e, e.getErrorCode(), "LSIDAuthorityServiceImpl Error in getAuthorityWSDL");
    } catch (WSDLException e) {
        throw new LSIDServerException(e, LSIDServerException.INTERNAL_PROCESSING_ERROR, "LSIDAuthorityServiceImpl Error in getAuthorityWSDL");
    }
}
Also used : LSID(eu.etaxonomy.cdm.model.common.LSID) LSIDException(com.ibm.lsid.LSIDException) WSDLException(javax.wsdl.WSDLException) LSIDWSDLWrapper(eu.etaxonomy.cdm.api.service.lsid.LSIDWSDLWrapper) LSIDServerException(com.ibm.lsid.server.LSIDServerException) HTTPLocation(com.ibm.lsid.wsdl.HTTPLocation) ExpiringResponse(com.ibm.lsid.ExpiringResponse)

Example 8 with LSIDException

use of com.ibm.lsid.LSIDException in project cdmlib by cybertaxonomy.

the class LsidDataServiceImpl method getDataByRange.

public InputStream getDataByRange(LSID lsid, Integer start, Integer length) throws LSIDServerException {
    IIdentifiableDao<?> identfiableDAO = lsidRegistry.lookupDAO(lsid);
    if (identfiableDAO == null) {
        // we do not have a mapping for lsids with this authority or namespace
        throw new LSIDServerException(LSIDException.UNKNOWN_LSID, "Unknown LSID");
    }
    try {
        IIdentifiableEntity i = identfiableDAO.find(lsid);
        if (i == null) {
            // we have a mapping for lsids with this authority and namespace, but no lsid stored
            throw new LSIDServerException(LSIDException.UNKNOWN_LSID, "Unknown LSID");
        }
        if (i.getData() != null) {
            byte[] subset = new byte[length];
            System.arraycopy(i.getData(), start, subset, 0, length);
            return new ByteArrayInputStream(subset);
        } else {
            return null;
        }
    } catch (LSIDException e) {
        throw new LSIDServerException(e, e.getErrorCode(), e.getMessage());
    }
}
Also used : LSIDException(com.ibm.lsid.LSIDException) ByteArrayInputStream(java.io.ByteArrayInputStream) LSIDServerException(com.ibm.lsid.server.LSIDServerException) IIdentifiableEntity(eu.etaxonomy.cdm.model.common.IIdentifiableEntity)

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