Search in sources :

Example 1 with Feed

use of org.odata4j.format.Feed in project teiid by teiid.

the class BaseQueryExecution method executeWithReturnEntity.

protected ODataEntitiesResponse executeWithReturnEntity(String method, String uri, String payload, String entityTable, EdmDataServices edsMetadata, String eTag, Status... expectedStatus) throws TranslatorException {
    Map<String, List<String>> headers = getDefaultHeaders();
    if (eTag != null) {
        // $NON-NLS-1$
        headers.put("If-Match", Arrays.asList(eTag));
    }
    if (payload != null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        headers.put("Content-Type", Arrays.asList("application/atom+xml"));
    }
    BinaryWSProcedureExecution execution = executeDirect(method, uri, payload, headers);
    for (Status status : expectedStatus) {
        if (status.getStatusCode() == execution.getResponseCode()) {
            if (execution.getResponseCode() != Status.NO_CONTENT.getStatusCode() && execution.getResponseCode() != Status.NOT_FOUND.getStatusCode()) {
                Blob blob = (Blob) execution.getOutputParameterValues().get(0);
                ODataVersion version = getODataVersion(execution);
                Feed feed = parse(blob, version, entityTable, edsMetadata);
                return new ODataEntitiesResponse(uri, feed, entityTable, edsMetadata);
            }
            // this is success with no-data
            return new ODataEntitiesResponse();
        }
    }
    // throw an error
    return new ODataEntitiesResponse(buildError(execution));
}
Also used : Status(javax.ws.rs.core.Response.Status) Blob(java.sql.Blob) BinaryWSProcedureExecution(org.teiid.translator.ws.BinaryWSProcedureExecution) ODataVersion(org.odata4j.core.ODataVersion) ArrayList(java.util.ArrayList) List(java.util.List) Feed(org.odata4j.format.Feed)

Aggregations

Blob (java.sql.Blob)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Status (javax.ws.rs.core.Response.Status)1 ODataVersion (org.odata4j.core.ODataVersion)1 Feed (org.odata4j.format.Feed)1 BinaryWSProcedureExecution (org.teiid.translator.ws.BinaryWSProcedureExecution)1