Examples of PathInfoImpl


Examples of org.apache.olingo.odata2.core.PathInfoImpl

      + LF
      + LF;

  @BeforeClass
  public static void setProperties() throws URISyntaxException {
    PathInfoImpl pathInfo = new PathInfoImpl();
    pathInfo.setServiceRoot(new URI(SERVICE_ROOT));
    batchProperties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build();

  }
View Full Code Here

Examples of org.apache.olingo.odata2.core.PathInfoImpl

  private static final String SERVICE_ROOT = "http://localhost/odata/";

  private EntityProviderBatchProperties parseProperties;

  public BatchRequestTest() throws URISyntaxException {
    PathInfoImpl pathInfo = new PathInfoImpl();
    pathInfo.setServiceRoot(new URI(SERVICE_ROOT));
    parseProperties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build();
  }
View Full Code Here

Examples of org.apache.olingo.odata2.core.PathInfoImpl

    }
    return requestHeaders;
  }

  public static PathInfo buildODataPathInfo(final HttpServletRequest req, final int pathSplit) throws ODataException {
    PathInfoImpl pathInfo = splitPath(req, pathSplit);

    pathInfo.setServiceRoot(buildBaseUri(req, pathInfo.getPrecedingSegments()));
    pathInfo.setRequestUri(buildRequestUri(req));
    return pathInfo;
  }
View Full Code Here

Examples of org.apache.olingo.odata2.core.PathInfoImpl

    return requestUri;
  }

  private static PathInfoImpl splitPath(final HttpServletRequest servletRequest, final int pathSplit)
      throws ODataException {
    PathInfoImpl pathInfo = new PathInfoImpl();
    List<String> precedingPathSegments;
    List<String> pathSegments;

    String pathInfoString = extractPathInfo(servletRequest);
    while (pathInfoString.startsWith("/")) {
      pathInfoString = pathInfoString.substring(1);
    }
    List<String> segments = Arrays.asList(pathInfoString.split("/", -1));

    if (pathSplit == 0) {
      precedingPathSegments = Collections.emptyList();
      pathSegments = segments;
    } else {
      if (segments.size() < pathSplit) {
        throw new ODataBadRequestException(ODataBadRequestException.URLTOOSHORT);
      }

      precedingPathSegments = segments.subList(0, pathSplit);
      final int pathSegmentCount = segments.size();
      pathSegments = segments.subList(pathSplit, pathSegmentCount);
    }

    // Percent-decode only the preceding path segments.
    // The OData path segments are decoded during URI parsing.
    pathInfo.setPrecedingPathSegment(convertPathSegmentList(precedingPathSegments));

    List<PathSegment> odataSegments = new ArrayList<PathSegment>();
    for (final String segment : pathSegments) {

      int index = segment.indexOf(";");
      if (index < 0) {
        odataSegments.add(new ODataPathSegmentImpl(segment, null));
      } else {
        // post condition: we do not allow matrix parameters in OData path segments
        String path = segment.substring(0, index);
        Map<String, List<String>> parameterMap = extractMatrixParameter(segment, index);
        throw new ODataNotFoundException(ODataNotFoundException.MATRIX.addContent(parameterMap.keySet(), path));
      }
    }
    pathInfo.setODataPathSegment(odataSegments);
    return pathInfo;
  }
View Full Code Here

Examples of org.apache.olingo.odata2.core.PathInfoImpl

    }
    return headers;
  }

  private PathInfo parseRequestUri(final String uri) throws BatchException {
    PathInfoImpl pathInfo = new PathInfoImpl();
    pathInfo.setServiceRoot(batchRequestPathInfo.getServiceRoot());
    pathInfo.setPrecedingPathSegment(batchRequestPathInfo.getPrecedingSegments());
    final String odataPathSegmentsAsString;
    final String queryParametersAsString;
    try {
      Scanner uriScanner = new Scanner(uri);
      uriScanner.useDelimiter(LF);
      URI uriObject = new URI(uri);
      if (uriObject.isAbsolute()) {
        Pattern regexRequestUri = Pattern.compile(baseUri + "/([^/][^?]*)(\\?.*)?");
        if (uriScanner.hasNext(regexRequestUri)) {
          uriScanner.next(regexRequestUri);
          MatchResult result = uriScanner.match();
          if (result.groupCount() == 2) {
            odataPathSegmentsAsString = result.group(1);
            queryParametersAsString = result.group(2) != null ? result.group(2) : "";
          } else {
            uriScanner.close();
            throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
          }
        } else {
          uriScanner.close();
          throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
        }
      } else {
        Pattern regexRequestUri = Pattern.compile("([^/][^?]*)(\\?.*)?");
        if (uriScanner.hasNext(regexRequestUri)) {
          uriScanner.next(regexRequestUri);
          MatchResult result = uriScanner.match();
          if (result.groupCount() == 2) {
            odataPathSegmentsAsString = result.group(1);
            queryParametersAsString = result.group(2) != null ? result.group(2) : "";
          } else {
            uriScanner.close();
            throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
          }
        } else if (uriScanner.hasNext("/(.*)")) {
          uriScanner.close();
          throw new BatchException(BatchException.UNSUPPORTED_ABSOLUTE_PATH.addContent(currentLineNumber));
        } else {
          uriScanner.close();
          throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
        }

      }
      uriScanner.close();
      pathInfo.setODataPathSegment(parseODataPathSegments(odataPathSegmentsAsString));
      if (!odataPathSegmentsAsString.startsWith("$")) {
        String requestUri = baseUri + "/" + odataPathSegmentsAsString + queryParametersAsString;
        pathInfo.setRequestUri(new URI(requestUri));
      }
      return pathInfo;
    } catch (URISyntaxException e) {
      throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber), e);
    }
View Full Code Here

Examples of org.apache.olingo.odata2.core.PathInfoImpl

      assertFalse(getContext().isInBatchMode());

      ODataResponse batchResponse;
      List<BatchResponsePart> batchResponseParts = new ArrayList<BatchResponsePart>();
      PathInfoImpl pathInfo = new PathInfoImpl();
      try {
        pathInfo.setServiceRoot(new URI("http://localhost:19000/odata"));

        EntityProviderBatchProperties batchProperties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build();
        List<BatchRequestPart> batchParts =
            EntityProvider.parseBatchRequest(requestContentType, content, batchProperties);
        for (BatchRequestPart batchPart : batchParts) {
View Full Code Here

Examples of org.apache.olingo.odata2.core.PathInfoImpl

      + LF
      + LF;

  @BeforeClass
  public static void setProperties() throws URISyntaxException {
    PathInfoImpl pathInfo = new PathInfoImpl();
    pathInfo.setServiceRoot(new URI(SERVICE_ROOT));
    batchProperties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build();

  }
View Full Code Here

Examples of org.apache.olingo.odata2.core.PathInfoImpl

    }
    return headers;
  }

  private PathInfo parseRequestUri(final String uri) throws BatchException {
    PathInfoImpl pathInfo = new PathInfoImpl();
    pathInfo.setServiceRoot(batchRequestPathInfo.getServiceRoot());
    pathInfo.setPrecedingPathSegment(batchRequestPathInfo.getPrecedingSegments());
    final String odataPathSegmentsAsString;
    final String queryParametersAsString;
    try {
      Scanner uriScanner = new Scanner(uri).useDelimiter(LF);
      URI uriObject = new URI(uri);
      if (uriObject.isAbsolute()) {
        Pattern regexRequestUri = Pattern.compile(baseUri + "/([^/][^?]*)(\\?.*)?");
        if (uriScanner.hasNext(regexRequestUri)) {
          uriScanner.next(regexRequestUri);
          MatchResult result = uriScanner.match();
          if (result.groupCount() == 2) {
            odataPathSegmentsAsString = result.group(1);
            queryParametersAsString = result.group(2) != null ? result.group(2) : "";
          } else {
            uriScanner.close();
            throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
          }
        } else {
          uriScanner.close();
          throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
        }
      } else {
        Pattern regexRequestUri = Pattern.compile("([^/][^?]*)(\\?.*)?");
        if (uriScanner.hasNext(regexRequestUri)) {
          uriScanner.next(regexRequestUri);
          MatchResult result = uriScanner.match();
          if (result.groupCount() == 2) {
            odataPathSegmentsAsString = result.group(1);
            queryParametersAsString = result.group(2) != null ? result.group(2) : "";
          } else {
            uriScanner.close();
            throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
          }
        } else if (uriScanner.hasNext("/(.*)")) {
          uriScanner.close();
          throw new BatchException(BatchException.UNSUPPORTED_ABSOLUTE_PATH.addContent(currentLineNumber));
        } else {
          uriScanner.close();
          throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
        }

      }
      uriScanner.close();
      pathInfo.setODataPathSegment(parseODataPathSegments(odataPathSegmentsAsString));
      if (!odataPathSegmentsAsString.startsWith("$")) {
        String requestUri = baseUri + "/" + odataPathSegmentsAsString + queryParametersAsString;
        pathInfo.setRequestUri(new URI(requestUri));
      }
      return pathInfo;
    } catch (URISyntaxException e) {
      throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber), e);
    }
View Full Code Here

Examples of org.apache.olingo.odata2.core.PathInfoImpl

  }

  private ODataRequest modifyRequest(final ODataRequest request, final List<PathSegment> odataSegments)
      throws ODataException {
    String contentId = contentIdMap.get(odataSegments.get(0).getPath());
    PathInfoImpl pathInfo = new PathInfoImpl();
    try {
      List<PathSegment> modifiedODataSegments = new ArrayList<PathSegment>();
      String[] segments = contentId.split("/");
      for (String segment : segments) {
        modifiedODataSegments.add(new ODataPathSegmentImpl(segment, null));
      }
      String newRequestUri = getBaseUri(request);
      newRequestUri += "/" + contentId;
      for (int i = 1; i < odataSegments.size(); i++) {
        newRequestUri += "/" + odataSegments.get(i).getPath();
        modifiedODataSegments.add(odataSegments.get(i));
      }
      for (Map.Entry<String, String> entry : request.getQueryParameters().entrySet()) {
        newRequestUri += "/" + entry;
      }

      pathInfo.setServiceRoot(request.getPathInfo().getServiceRoot());
      pathInfo.setPrecedingPathSegment(request.getPathInfo().getPrecedingSegments());
      pathInfo.setRequestUri(new URI(newRequestUri));
      pathInfo.setODataPathSegment(modifiedODataSegments);
    } catch (URISyntaxException e) {
      throw new ODataException(e);
    }
    ODataRequest modifiedRequest = ODataRequest.fromRequest(request).pathInfo(pathInfo).build();
    return modifiedRequest;
View Full Code Here

Examples of org.apache.olingo.odata2.core.PathInfoImpl

    }
    return requestHeaders;
  }

  public static PathInfo buildODataPathInfo(final HttpServletRequest req, final int pathSplit) throws ODataException {
    PathInfoImpl pathInfo = splitPath(req, pathSplit);

    pathInfo.setServiceRoot(buildBaseUri(req, pathInfo.getPrecedingSegments()));
    pathInfo.setRequestUri(buildRequestUri(req));
    return pathInfo;
  }
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.