Search in sources :

Example 1 with ODataException

use of org.apache.olingo.commons.api.ex.ODataException in project teiid by teiid.

the class OlingoBridge method getHandler.

public ODataHttpHandler getHandler(String baseUri, Client client, String schemaName) throws ServletException {
    if (this.handlers.get(schemaName) == null) {
        org.teiid.metadata.Schema teiidSchema = client.getMetadataStore().getSchema(schemaName);
        if (teiidSchema == null || !isVisible(client.getVDB(), teiidSchema)) {
            throw new ServletException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16022));
        }
        try {
            OData odata = OData4Impl.newInstance();
            VDBMetaData vdb = client.getVDB();
            CsdlSchema schema = ODataSchemaBuilder.buildMetadata(vdb.getFullName(), teiidSchema);
            TeiidEdmProvider edmProvider = new TeiidEdmProvider(baseUri, schema, client.getProperty(Client.INVALID_CHARACTER_REPLACEMENT));
            ServiceMetadata metadata = odata.createServiceMetadata(edmProvider, edmProvider.getReferences());
            ODataHttpHandler handler = odata.createHandler(metadata);
            handler.register(new TeiidServiceHandler(schemaName));
            this.handlers.put(schemaName, handler);
        } catch (XMLStreamException e) {
            throw new ServletException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16054));
        } catch (ODataException e) {
            throw new ServletException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16054));
        }
    }
    return this.handlers.get(schemaName);
}
Also used : OData(org.apache.olingo.server.api.OData) CsdlSchema(org.apache.olingo.commons.api.edm.provider.CsdlSchema) ODataHttpHandler(org.apache.olingo.server.api.ODataHttpHandler) ServletException(javax.servlet.ServletException) ODataException(org.apache.olingo.commons.api.ex.ODataException) XMLStreamException(javax.xml.stream.XMLStreamException) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ServiceMetadata(org.apache.olingo.server.api.ServiceMetadata)

Example 2 with ODataException

use of org.apache.olingo.commons.api.ex.ODataException in project arctic-sea by 52North.

the class ODataFesParser method decode.

@Override
public Filter<?> decode(String objectToDecode) throws DecodingException {
    LOG.debug("Parsing filter: {}", objectToDecode);
    if (objectToDecode == null || objectToDecode.isEmpty()) {
        return null;
    }
    try {
        String encode = urlEscaper.escape(objectToDecode);
        // >=4.4.0
        // UriInfo parseUri = parser.parseUri(PATH, "$filter=" + encode, FRAGMENT, BASE_URI);
        // >=4.2.0 <4.4.0
        // UriInfo parseUri = parser.parseUri(PATH, "$filter=" + encode, FRAGMENT);
        // >=4.0.0 <4.2.0
        UriInfo parseUri = parser.parseUri(PATH, "$filter=" + encode, FRAGMENT, this.edm);
        return parseUri.getFilterOption().getExpression().accept(new ExpressionGenerator()).accept(new RenamingVisitor(csdlProvider::mapProperty)).accept(new FilterGenerator());
    } catch (ODataException ex) {
        throw new DecodingException(ex);
    }
}
Also used : ODataException(org.apache.olingo.commons.api.ex.ODataException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) UriInfo(org.apache.olingo.server.api.uri.UriInfo)

Aggregations

ODataException (org.apache.olingo.commons.api.ex.ODataException)2 ServletException (javax.servlet.ServletException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 CsdlSchema (org.apache.olingo.commons.api.edm.provider.CsdlSchema)1 OData (org.apache.olingo.server.api.OData)1 ODataHttpHandler (org.apache.olingo.server.api.ODataHttpHandler)1 ServiceMetadata (org.apache.olingo.server.api.ServiceMetadata)1 UriInfo (org.apache.olingo.server.api.uri.UriInfo)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)1