use of org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl in project teiid by teiid.
the class TestODataMetadataProcessor method createMetadata.
private static MetadataFactory createMetadata(final String file, final String schema, final String schemaNamespace) throws TranslatorException {
ODataMetadataProcessor processor = new ODataMetadataProcessor() {
protected XMLMetadata getSchema(WSConnection conn) throws TranslatorException {
try {
ClientODataDeserializerImpl deserializer = new ClientODataDeserializerImpl(false, ContentType.APPLICATION_XML);
XMLMetadata metadata = deserializer.toMetadata(new FileInputStream(UnitTestUtil.getTestDataFile(file)));
return metadata;
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
};
Properties props = new Properties();
props.setProperty("schemaNamespace", schemaNamespace);
processor.setSchemaNamespace(schemaNamespace);
MetadataFactory mf = new MetadataFactory("vdb", 1, schema, SystemMetadata.getInstance().getRuntimeTypeMap(), props, null);
processor.process(mf, null);
return mf;
}
use of org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl in project teiid by teiid.
the class ODataExecutionFactory method getSchema.
protected XMLMetadata getSchema(WSConnection conn) throws TranslatorException {
if (this.serviceMatadata == null) {
try {
BaseQueryExecution execution = new BaseQueryExecution(this, null, null, conn);
Map<String, List<String>> headers = new HashMap<String, List<String>>();
// $NON-NLS-1$ //$NON-NLS-2$
BinaryWSProcedureExecution call = execution.invokeHTTP("GET", "$metadata", null, headers);
if (call.getResponseCode() != HttpStatusCode.OK.getStatusCode()) {
throw execution.buildError(call);
}
Blob out = (Blob) call.getOutputParameterValues().get(0);
ClientODataDeserializerImpl deserializer = new ClientODataDeserializerImpl(false, ContentType.APPLICATION_XML);
this.serviceMatadata = deserializer.toMetadata(out.getBinaryStream());
return this.serviceMatadata;
} catch (SQLException e) {
throw new TranslatorException(e);
} catch (Exception e) {
throw new TranslatorException(e);
}
}
return this.serviceMatadata;
}
Aggregations