Examples of ODataResponseBuilder


Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder

      producer.writeErrorDocument(writer, errorCode, message, locale, innerError);

      writer.flush();
      csb.closeWrite();

      ODataResponseBuilder response = ODataResponse.entity(csb.getInputStream())
          .header(ODataHttpHeaders.DATASERVICEVERSION, ODataServiceVersion.V10)
          .status(status);
      return response.build();
    } catch (Exception e) {
      csb.close();
      throw new ODataRuntimeException(e);
    }
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder

      as.append(writer, eia, data, true, false);

      writer.flush();
      csb.closeWrite();

      ODataResponseBuilder response = ODataResponse.entity(csb.getInputStream())
          .eTag(as.getETag())
          .idLiteral(as.getLocation());
      return response.build();
    } catch (EntityProviderException e) {
      csb.close();
      throw e;
    } catch (Exception e) {
      csb.close();
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder

      odataResponse =
          dispatcher.dispatch(method, uriInfo, request.getBody(), request.getContentType(), acceptContentType
              .toContentTypeString());
      context.stopRuntimeMeasurement(timingHandle2);

      ODataResponseBuilder extendedResponse = ODataResponse.fromResponse(odataResponse);
      final UriType uriType = uriInfo.getUriType();
      final String location =
          (method == ODataHttpMethod.POST && (uriType == UriType.URI1 || uriType == UriType.URI6B)) ? odataResponse
              .getIdLiteral() : null;
      final HttpStatusCodes s = getStatusCode(odataResponse, method, uriType);
      extendedResponse = extendedResponse.idLiteral(location).status(s);

      if (!odataResponse.containsHeader(ODataHttpHeaders.DATASERVICEVERSION)) {
        extendedResponse = extendedResponse.header(ODataHttpHeaders.DATASERVICEVERSION, serverDataServiceVersion);
      }
      if (!HttpStatusCodes.NO_CONTENT.equals(s) && !odataResponse.containsHeader(HttpHeaders.CONTENT_TYPE)) {
        extendedResponse.header(HttpHeaders.CONTENT_TYPE, acceptContentType.toContentTypeString());
      }

      odataResponse = extendedResponse.build();
    } catch (final Exception e) {
      exception = e;
      odataResponse = new ODataExceptionWrapper(context, request.getQueryParameters(), request.getAcceptHeaders())
          .wrapInExceptionResponse(e);
    }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder

      throws ODataException {
    final Edm entityDataModel = getContext().getService().getEntityDataModel();
    final String serviceRoot = getContext().getPathInfo().getServiceRoot().toASCIIString();

    final ODataResponse response = EntityProvider.writeServiceDocument(contentType, entityDataModel, serviceRoot);
    final ODataResponseBuilder odataResponseBuilder = ODataResponse.fromResponse(response).header(
        ODataHttpHeaders.DATASERVICEVERSION, ODataServiceVersion.V10);

    return odataResponseBuilder.build();
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder

public class ODataErrorHandlerCallbackImpl implements ODataErrorCallback {

  @Override
  public ODataResponse handleError(final ODataErrorContext context) {
    ODataResponseBuilder responseBuilder =
        ODataResponse.entity("bla").status(HttpStatusCodes.BAD_REQUEST).contentHeader("text/html");

    if (context.getRequestUri() != null) {
      responseBuilder.header("RequestUri", context.getRequestUri().toASCIIString());
      PathInfo pathInfo = context.getPathInfo();
      if (pathInfo == null) {
        responseBuilder.header("PathInfo", "NULL");
      } else {
        responseBuilder.header("PathInfo", "TRUE");
        responseBuilder.header("PathInfo.oDataSegments", pathInfo.getODataSegments().toString());
        responseBuilder.header("PathInfo.precedingSegments", pathInfo.getPrecedingSegments().toString());
        responseBuilder.header("PathInfo.requestUri", pathInfo.getRequestUri().toString());
        responseBuilder.header("PathInfo.serviceRoot", pathInfo.getServiceRoot().toString());
      }
    }

    Map<String, List<String>> requestHeaders = context.getRequestHeaders();
    if (requestHeaders != null && requestHeaders.entrySet() != null) {
      Set<Entry<String, List<String>>> entries = requestHeaders.entrySet();
      for (Entry<String, List<String>> entry : entries) {
        responseBuilder.header(entry.getKey(), entry.getValue().toString());
      }
    }

    return responseBuilder.build();
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder

      BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(buffer.getOutputStream(), DEFAULT_CHARSET));
      new JsonLinksEntityProducer(properties).append(writer, entityInfo, data);
      writer.flush();
      buffer.closeWrite();

      ODataResponseBuilder response = ODataResponse.entity(buffer.getInputStream());
      if (properties.getInlineCountType() != InlineCount.ALLPAGES) {
        response = response.header(ODataHttpHeaders.DATASERVICEVERSION, ODataServiceVersion.V10);
      }
      return response.build();
    } catch (EntityProviderException e) {
      buffer.close();
      throw e;
    } catch (Exception e) {
      buffer.close();
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder

      BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(buffer.getOutputStream(), DEFAULT_CHARSET));
      new JsonLinksEntityProducer(properties).append(writer, entityInfo, data);
      writer.flush();
      buffer.closeWrite();

      ODataResponseBuilder response = ODataResponse.entity(buffer.getInputStream());
      if (properties.getInlineCountType() != InlineCount.ALLPAGES) {
        response = response.header(ODataHttpHeaders.DATASERVICEVERSION, ODataServiceVersion.V10);
      }
      return response.build();
    } catch (EntityProviderException e) {
      buffer.close();
      throw e;
    } catch (Exception e) {
      buffer.close();
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder

      odataResponse =
          dispatcher.dispatch(method, uriInfo, request.getBody(), request.getContentType(), acceptContentType
              .toContentTypeString());
      context.stopRuntimeMeasurement(timingHandle2);

      ODataResponseBuilder extendedResponse = ODataResponse.fromResponse(odataResponse);
      final UriType uriType = uriInfo.getUriType();
      final String location =
          (method == ODataHttpMethod.POST && (uriType == UriType.URI1 || uriType == UriType.URI6B)) ? odataResponse
              .getIdLiteral() : null;
      final HttpStatusCodes s = getStatusCode(odataResponse, method, uriType);
      extendedResponse = extendedResponse.idLiteral(location).status(s);

      if (!odataResponse.containsHeader(ODataHttpHeaders.DATASERVICEVERSION)) {
        extendedResponse = extendedResponse.header(ODataHttpHeaders.DATASERVICEVERSION, serverDataServiceVersion);
      }
      if (!HttpStatusCodes.NO_CONTENT.equals(s) && !odataResponse.containsHeader(HttpHeaders.CONTENT_TYPE)) {
        extendedResponse.header(HttpHeaders.CONTENT_TYPE, acceptContentType.toContentTypeString());
      }

      odataResponse = extendedResponse.build();
    } catch (final Exception e) {
      exception = e;
      odataResponse =
          new ODataExceptionWrapper(context, request.getQueryParameters(), request.getAcceptHeaders())
              .wrapInExceptionResponse(e);
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder

      producer.writeErrorDocument(writer, errorCode, message, locale, innerError);

      writer.flush();
      csb.closeWrite();

      ODataResponseBuilder response = ODataResponse.entity(csb.getInputStream())
          .header(ODataHttpHeaders.DATASERVICEVERSION, ODataServiceVersion.V10)
          .status(status);
      return response.build();
    } catch (Exception e) {
      csb.close();
      throw new ODataRuntimeException(e);
    }
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder

      as.append(writer, eia, data, true, false);

      writer.flush();
      csb.closeWrite();

      ODataResponseBuilder response = ODataResponse.entity(csb.getInputStream())
          .eTag(as.getETag())
          .idLiteral(as.getLocation());
      return response.build();
    } catch (EntityProviderException e) {
      csb.close();
      throw e;
    } catch (Exception e) {
      csb.close();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.