Search in sources :

Example 11 with ODataApplicationException

use of org.apache.olingo.server.api.ODataApplicationException in project teiid by teiid.

the class TeiidServiceHandler method sendResults.

private void sendResults(final DataRequest request, final ODataSQLBuilder visitor, final BaseResponse queryResponse, EdmComplexResponse response) throws ODataApplicationException, SerializerException {
    if (request.getPreference(ODATA_MAXPAGESIZE) != null) {
        response.writeHeader(PREFERENCE_APPLIED, // $NON-NLS-1$
        ODATA_MAXPAGESIZE + "=" + request.getPreference(ODATA_MAXPAGESIZE));
    }
    CrossJoinResult result = (CrossJoinResult) queryResponse;
    URI next = null;
    if (result.getNextToken() != null) {
        try {
            next = new URI(request.getODataRequest().getRawRequestUri() + (request.getODataRequest().getRawQueryPath() == null ? "?$skiptoken=" : "&$skiptoken=") + result.getNextToken());
        } catch (URISyntaxException e) {
            throw new ODataApplicationException(e.getMessage(), 500, Locale.getDefault(), e);
        }
    }
    response.writeComplexType(result, next);
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ODataApplicationException(org.apache.olingo.server.api.ODataApplicationException)

Example 12 with ODataApplicationException

use of org.apache.olingo.server.api.ODataApplicationException in project teiid by teiid.

the class TeiidServiceHandler method sendResults.

private void sendResults(final DataRequest request, final ODataSQLBuilder visitor, final BaseResponse queryResponse, EntitySetResponse response) throws ODataApplicationException, SerializerException {
    if (request.getPreference(ODATA_MAXPAGESIZE) != null) {
        response.writeHeader(PREFERENCE_APPLIED, // $NON-NLS-1$
        ODATA_MAXPAGESIZE + "=" + request.getPreference(ODATA_MAXPAGESIZE));
    }
    EntityCollectionResponse result = (EntityCollectionResponse) queryResponse;
    if (result.getNextToken() != null) {
        try {
            String nextUri = request.getODataRequest().getRawBaseUri() + request.getODataRequest().getRawODataPath() + "?" + buildNextToken(request.getODataRequest().getRawQueryPath(), result.getNextToken());
            result.setNext(new URI(nextUri));
        } catch (URISyntaxException e) {
            throw new ODataApplicationException(e.getMessage(), 500, Locale.getDefault(), e);
        } catch (MalformedURLException e) {
            throw new ODataApplicationException(e.getMessage(), 500, Locale.getDefault(), e);
        }
    }
    response.writeReadEntitySet(visitor.getContext().getEdmEntityType(), result);
}
Also used : MalformedURLException(java.net.MalformedURLException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ODataApplicationException(org.apache.olingo.server.api.ODataApplicationException)

Aggregations

ODataApplicationException (org.apache.olingo.server.api.ODataApplicationException)12 SQLException (java.sql.SQLException)10 TeiidException (org.teiid.core.TeiidException)6 UpdateResponse (org.teiid.odata.api.UpdateResponse)6 URISyntaxException (java.net.URISyntaxException)5 Query (org.teiid.query.sql.lang.Query)5 EdmProperty (org.apache.olingo.commons.api.edm.EdmProperty)4 ODataLibraryException (org.apache.olingo.server.api.ODataLibraryException)4 Update (org.teiid.query.sql.lang.Update)4 MalformedURLException (java.net.MalformedURLException)3 URI (java.net.URI)3 EdmPrimitiveTypeException (org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException)3 Property (org.apache.olingo.commons.api.data.Property)2 EdmEntityType (org.apache.olingo.commons.api.edm.EdmEntityType)2 EdmNavigationProperty (org.apache.olingo.commons.api.edm.EdmNavigationProperty)2 SerializerException (org.apache.olingo.server.api.serializer.SerializerException)2 TeiidProcessingException (org.teiid.core.TeiidProcessingException)2 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)2 TransformationException (org.teiid.core.types.TransformationException)2 BaseResponse (org.teiid.odata.api.BaseResponse)2