Package org.apache.olingo.odata2.core.uri

Examples of org.apache.olingo.odata2.core.uri.UriInfoImpl


  }

  private void
      negotiateContentTypeCharset(final String requestType, final String supportedType, final boolean asFormat)
          throws ODataException {
    UriInfoImpl uriInfo = Mockito.mock(UriInfoImpl.class);
    Mockito.when(uriInfo.getUriType()).thenReturn(UriType.URI1);
    if (asFormat) {
      Mockito.when(uriInfo.getFormat()).thenReturn(requestType);
    }

    List<String> acceptedContentTypes = Arrays.asList(requestType);
    List<String> supportedContentTypes = Arrays.asList(supportedType);
View Full Code Here


      segments.add("$value");
    }

    // self-test
    try {
      final UriInfoImpl uriInfo = (UriInfoImpl) UriParser.parse(edm,
          MockFacade.getPathSegmentsAsODataPathSegmentMock(segments),
          Collections.<String, String> emptyMap());
      assertEquals(uriType, uriInfo.getUriType());
      assertEquals(uriType == UriType.URI17 || isValue, uriInfo.isValue());
    } catch (final ODataException e) {
      fail();
    }

    return segments;
View Full Code Here

    }

    @Override
    public boolean matches(final Object item) {
      if (item instanceof UriInfoImpl) {
        final UriInfoImpl upr = (UriInfoImpl) item;
        final List<KeyPredicate> keyPredicates = upr.getKeyPredicates();
        for (final KeyPredicate keyPredicate : keyPredicates) {
          if (keyLiteral.equals(keyPredicate.getLiteral())) {
            return true;
          }
        }
View Full Code Here

   * Building of the {@link ODataContext} takes place outside of this method.</p>
   * @param request the incoming request
   * @return the corresponding result
   */
  public ODataResponse handle(final ODataRequest request) {
    UriInfoImpl uriInfo = null;
    Exception exception = null;
    ODataResponse odataResponse;
    final int timingHandle = context.startRuntimeMeasurement("ODataRequestHandler", "handle");
    try {
      UriParser uriParser = new UriParserImpl(service.getEntityDataModel());
      Dispatcher dispatcher = new Dispatcher(serviceFactory, service);

      final String serverDataServiceVersion = getServerDataServiceVersion();
      final String requestDataServiceVersion = context.getRequestHeader(ODataHttpHeaders.DATASERVICEVERSION);
      validateDataServiceVersion(serverDataServiceVersion, requestDataServiceVersion);

      final List<PathSegment> pathSegments = context.getPathInfo().getODataSegments();
      int timingHandle2 = context.startRuntimeMeasurement("UriParserImpl", "parse");
      uriInfo = (UriInfoImpl) uriParser.parse(pathSegments, request.getQueryParameters());
      context.stopRuntimeMeasurement(timingHandle2);

      final ODataHttpMethod method = request.getMethod();
      validateMethodAndUri(method, uriInfo);

      if (method == ODataHttpMethod.POST || method == ODataHttpMethod.PUT || method == ODataHttpMethod.PATCH
          || method == ODataHttpMethod.MERGE) {
        checkRequestContentType(uriInfo, request.getContentType());
      }

      List<String> supportedContentTypes = getSupportedContentTypes(uriInfo, method);
      ContentType acceptContentType =
          new ContentNegotiator().doContentNegotiation(request, uriInfo, supportedContentTypes);

      checkConditions(method, uriInfo,
          context.getRequestHeader(HttpHeaders.IF_MATCH),
          context.getRequestHeader(HttpHeaders.IF_NONE_MATCH),
          context.getRequestHeader(HttpHeaders.IF_MODIFIED_SINCE),
          context.getRequestHeader(HttpHeaders.IF_UNMODIFIED_SINCE));

      timingHandle2 = context.startRuntimeMeasurement("Dispatcher", "dispatch");
      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);
View Full Code Here

    return response;
  }

  private static UriInfoImpl mockUriInfo(final UriType uriType, final boolean isValue) throws EdmException {
    UriInfoImpl uriInfo = mock(UriInfoImpl.class);
    when(uriInfo.getUriType()).thenReturn(uriType);
    when(uriInfo.isValue()).thenReturn(isValue);
    return uriInfo;
  }
View Full Code Here

    ODataServiceFactory factory = mock(ODataServiceFactory.class);
    ODataService service = Mockito.mock(ODataService.class);
    Dispatcher dispatcher = new Dispatcher(factory, service);

    UriInfoImpl uriInfo = new UriInfoImpl();
    uriInfo.setUriType(UriType.URI1); //
    if (asFormat) {
      uriInfo.setFormat(requestType);
    }

    Mockito.when(service.getSupportedContentTypes(Matchers.any(Class.class))).thenReturn(Arrays.asList(supportedType));
    EntitySetProcessor processor = Mockito.mock(EntitySetProcessor.class);
    ODataResponse response = Mockito.mock(ODataResponse.class);
View Full Code Here

   * Building of the {@link ODataContext} takes place outside of this method.</p>
   * @param request the incoming request
   * @return the corresponding result
   */
  public ODataResponse handle(final ODataRequest request) {
    UriInfoImpl uriInfo = null;
    Exception exception = null;
    ODataResponse odataResponse;
    final int timingHandle = context.startRuntimeMeasurement("ODataRequestHandler", "handle");
    try {
      UriParser uriParser = new UriParserImpl(service.getEntityDataModel());
      Dispatcher dispatcher = new Dispatcher(serviceFactory, service);

      final String serverDataServiceVersion = getServerDataServiceVersion();
      final String requestDataServiceVersion = context.getRequestHeader(ODataHttpHeaders.DATASERVICEVERSION);
      validateDataServiceVersion(serverDataServiceVersion, requestDataServiceVersion);

      final List<PathSegment> pathSegments = context.getPathInfo().getODataSegments();
      int timingHandle2 = context.startRuntimeMeasurement("UriParserImpl", "parse");
      uriInfo = (UriInfoImpl) uriParser.parse(pathSegments, request.getQueryParameters());
      context.stopRuntimeMeasurement(timingHandle2);

      final ODataHttpMethod method = request.getMethod();
      validateMethodAndUri(method, uriInfo);

      if (method == ODataHttpMethod.POST || method == ODataHttpMethod.PUT || method == ODataHttpMethod.PATCH
          || method == ODataHttpMethod.MERGE) {
        checkRequestContentType(uriInfo, request.getContentType());
      }

      List<String> supportedContentTypes = getSupportedContentTypes(uriInfo, method);
      ContentType acceptContentType =
          new ContentNegotiator().doContentNegotiation(request, uriInfo, supportedContentTypes);

      timingHandle2 = context.startRuntimeMeasurement("Dispatcher", "dispatch");
      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);
View Full Code Here

      segments.add("$value");
    }

    // self-test
    try {
      final UriInfoImpl uriInfo = (UriInfoImpl) UriParser.parse(edm,
          MockFacade.getPathSegmentsAsODataPathSegmentMock(segments),
          Collections.<String, String> emptyMap());
      assertEquals(uriType, uriInfo.getUriType());
      assertEquals(uriType == UriType.URI17 || isValue, uriInfo.isValue());
    } catch (final ODataException e) {
      fail();
    }

    return segments;
View Full Code Here

   * Building of the {@link ODataContext} takes place outside of this method.</p>
   * @param request the incoming request
   * @return the corresponding result
   */
  public ODataResponse handle(final ODataRequest request) {
    UriInfoImpl uriInfo = null;
    Exception exception = null;
    ODataResponse odataResponse;
    final int timingHandle = context.startRuntimeMeasurement("ODataRequestHandler", "handle");
    try {
      UriParser uriParser = new UriParserImpl(service.getEntityDataModel());
      Dispatcher dispatcher = new Dispatcher(serviceFactory, service);

      final String serverDataServiceVersion = getServerDataServiceVersion();
      final String requestDataServiceVersion = context.getRequestHeader(ODataHttpHeaders.DATASERVICEVERSION);
      validateDataServiceVersion(serverDataServiceVersion, requestDataServiceVersion);

      final List<PathSegment> pathSegments = context.getPathInfo().getODataSegments();
      int timingHandle2 = context.startRuntimeMeasurement("UriParserImpl", "parse");
      uriInfo = (UriInfoImpl) uriParser.parse(pathSegments, request.getQueryParameters());
      context.stopRuntimeMeasurement(timingHandle2);

      final ODataHttpMethod method = request.getMethod();
      validateMethodAndUri(method, uriInfo);

      if (method == ODataHttpMethod.POST || method == ODataHttpMethod.PUT || method == ODataHttpMethod.PATCH
          || method == ODataHttpMethod.MERGE) {
        checkRequestContentType(uriInfo, request.getContentType());
      }

      List<String> supportedContentTypes = getSupportedContentTypes(uriInfo, method);
      ContentType acceptContentType =
          new ContentNegotiator().doContentNegotiation(request, uriInfo, supportedContentTypes);

      checkConditions(method, uriInfo,
          context.getRequestHeader(HttpHeaders.IF_MATCH),
          context.getRequestHeader(HttpHeaders.IF_NONE_MATCH),
          context.getRequestHeader(HttpHeaders.IF_MODIFIED_SINCE),
          context.getRequestHeader(HttpHeaders.IF_UNMODIFIED_SINCE));

      timingHandle2 = context.startRuntimeMeasurement("Dispatcher", "dispatch");
      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);
View Full Code Here

    }

    @Override
    public boolean matches(final Object item) {
      if (item instanceof UriInfoImpl) {
        final UriInfoImpl upr = (UriInfoImpl) item;
        final List<KeyPredicate> keyPredicates = upr.getKeyPredicates();
        for (final KeyPredicate keyPredicate : keyPredicates) {
          if (keyLiteral.equals(keyPredicate.getLiteral())) {
            return true;
          }
        }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.core.uri.UriInfoImpl

Copyright © 2018 www.massapicom. 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.