Search in sources :

Example 1 with LSIDWSDLLocator

use of eu.etaxonomy.cdm.model.common.LSIDWSDLLocator 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 2 with LSIDWSDLLocator

use of eu.etaxonomy.cdm.model.common.LSIDWSDLLocator in project cdmlib by cybertaxonomy.

the class WSDLDefinitionUserType method assemble.

// not tested if this works with jadira.usertype
@Override
public Object assemble(Serializable cached, Object owner) throws HibernateException {
    try {
        WSDLFactory wsdlFactory = WSDLFactoryImpl.newInstance();
        WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
        Reader reader = new StringReader(cached.toString());
        WSDLLocator locator = new LSIDWSDLLocator("wsdl", reader, Thread.currentThread().getContextClassLoader());
        Definition definition = wsdlReader.readWSDL(locator);
        return definition;
    } catch (Exception e) {
        throw new HibernateException(e);
    }
}
Also used : WSDLLocator(javax.wsdl.xml.WSDLLocator) LSIDWSDLLocator(eu.etaxonomy.cdm.model.common.LSIDWSDLLocator) WSDLFactory(javax.wsdl.factory.WSDLFactory) HibernateException(org.hibernate.HibernateException) StringReader(java.io.StringReader) Definition(javax.wsdl.Definition) WSDLReader(javax.wsdl.xml.WSDLReader) Reader(java.io.Reader) StringReader(java.io.StringReader) LSIDWSDLLocator(eu.etaxonomy.cdm.model.common.LSIDWSDLLocator) WSDLReader(javax.wsdl.xml.WSDLReader) WSDLException(javax.wsdl.WSDLException) SQLException(java.sql.SQLException) HibernateException(org.hibernate.HibernateException)

Example 3 with LSIDWSDLLocator

use of eu.etaxonomy.cdm.model.common.LSIDWSDLLocator in project cdmlib by cybertaxonomy.

the class WSDLDefinitionUserType method deepCopy.

public Object deepCopy(Object o) throws HibernateException {
    if (o == null) {
        return null;
    }
    Definition d = (Definition) o;
    try {
        WSDLFactory wsdlFactory = WSDLFactoryImpl.newInstance();
        StringWriter stringWriter = new StringWriter();
        WSDLWriter writer = wsdlFactory.newWSDLWriter();
        writer.writeWSDL(d, stringWriter);
        WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
        Reader reader = new StringReader(stringWriter.getBuffer().toString());
        WSDLLocator locator = new LSIDWSDLLocator("wsdl", reader, Thread.currentThread().getContextClassLoader());
        Definition definition = wsdlReader.readWSDL(locator);
        return definition;
    } catch (Exception e) {
        throw new HibernateException(e);
    }
}
Also used : WSDLLocator(javax.wsdl.xml.WSDLLocator) LSIDWSDLLocator(eu.etaxonomy.cdm.model.common.LSIDWSDLLocator) StringWriter(java.io.StringWriter) WSDLFactory(javax.wsdl.factory.WSDLFactory) HibernateException(org.hibernate.HibernateException) Definition(javax.wsdl.Definition) StringReader(java.io.StringReader) WSDLReader(javax.wsdl.xml.WSDLReader) Reader(java.io.Reader) StringReader(java.io.StringReader) WSDLWriter(javax.wsdl.xml.WSDLWriter) LSIDWSDLLocator(eu.etaxonomy.cdm.model.common.LSIDWSDLLocator) WSDLReader(javax.wsdl.xml.WSDLReader) WSDLException(javax.wsdl.WSDLException) SQLException(java.sql.SQLException) HibernateException(org.hibernate.HibernateException)

Example 4 with LSIDWSDLLocator

use of eu.etaxonomy.cdm.model.common.LSIDWSDLLocator in project cdmlib by cybertaxonomy.

the class WSDLDefinitionUserType method nullSafeGet.

@Override
public Definition nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object o) throws HibernateException, SQLException {
    Clob val = (Clob) StandardBasicTypes.CLOB.nullSafeGet(rs, names, session, o);
    // Clob val = (Clob) rs.getClob(names[0]);
    if (val == null) {
        return null;
    } else {
        try {
            WSDLFactory wsdlFactory = WSDLFactoryImpl.newInstance();
            WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
            Reader reader = val.getCharacterStream();
            WSDLLocator locator = new LSIDWSDLLocator("wsdl", reader, Thread.currentThread().getContextClassLoader());
            Definition definition = wsdlReader.readWSDL(locator);
            return definition;
        } catch (Exception e) {
            throw new HibernateException(e);
        }
    }
}
Also used : WSDLLocator(javax.wsdl.xml.WSDLLocator) LSIDWSDLLocator(eu.etaxonomy.cdm.model.common.LSIDWSDLLocator) WSDLFactory(javax.wsdl.factory.WSDLFactory) HibernateException(org.hibernate.HibernateException) Definition(javax.wsdl.Definition) WSDLReader(javax.wsdl.xml.WSDLReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Clob(java.sql.Clob) LSIDWSDLLocator(eu.etaxonomy.cdm.model.common.LSIDWSDLLocator) WSDLReader(javax.wsdl.xml.WSDLReader) WSDLException(javax.wsdl.WSDLException) SQLException(java.sql.SQLException) HibernateException(org.hibernate.HibernateException)

Aggregations

LSIDWSDLLocator (eu.etaxonomy.cdm.model.common.LSIDWSDLLocator)4 Reader (java.io.Reader)4 Definition (javax.wsdl.Definition)4 WSDLException (javax.wsdl.WSDLException)4 WSDLLocator (javax.wsdl.xml.WSDLLocator)4 WSDLReader (javax.wsdl.xml.WSDLReader)4 StringReader (java.io.StringReader)3 SQLException (java.sql.SQLException)3 WSDLFactory (javax.wsdl.factory.WSDLFactory)3 HibernateException (org.hibernate.HibernateException)3 LSIDException (com.ibm.lsid.LSIDException)1 InputStreamReader (java.io.InputStreamReader)1 StringWriter (java.io.StringWriter)1 Clob (java.sql.Clob)1 Import (javax.wsdl.Import)1 WSDLWriter (javax.wsdl.xml.WSDLWriter)1