Examples of BatchRequestPart


Examples of org.apache.olingo.odata2.api.batch.BatchRequestPart

      List<ODataRequest> changeSetRequests = new LinkedList<ODataRequest>();
      parseNewLine(scanner);// mandatory
      Pattern changeSetCloseDelimiter =
          Pattern.compile("--" + changeSetBoundary + "--" + REG_EX_ZERO_OR_MORE_WHITESPACES);
      while (!scanner.hasNext(changeSetCloseDelimiter)) {
        BatchRequestPart part = parseMultipart(scanner, changeSetBoundary, true);
        changeSetRequests.addAll(part.getRequests());
      }
      scanner.next(changeSetCloseDelimiter);
      currentLineNumber++;
      return new BatchRequestPartImpl(true, changeSetRequests);
    } else {
View Full Code Here

Examples of org.apache.olingo.odata2.api.batch.BatchRequestPart

  }

  private BatchRequestPart parseMultipart(final Scanner scanner, final String boundary, final boolean isChangeSet)
      throws BatchException {
    Map<String, String> mimeHeaders = new HashMap<String, String>();
    BatchRequestPart multipart = null;
    List<ODataRequest> requests = new ArrayList<ODataRequest>();
    if (scanner.hasNext("--" + boundary + REG_EX_ZERO_OR_MORE_WHITESPACES)) {
      scanner.next();
      currentLineNumber++;
      mimeHeaders = parseHeaders(scanner);
      currentMimeHeaderContentId = mimeHeaders.get(BatchHelper.HTTP_CONTENT_ID.toLowerCase(Locale.ENGLISH));

      String contentType = mimeHeaders.get(HttpHeaders.CONTENT_TYPE.toLowerCase(Locale.ENGLISH));
      if (contentType == null) {
        throw new BatchException(BatchException.MISSING_CONTENT_TYPE);
      }
      if (isChangeSet) {
        if (HttpContentType.APPLICATION_HTTP.equalsIgnoreCase(contentType)) {
          validateEncoding(mimeHeaders.get(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING.toLowerCase(Locale.ENGLISH)));
          parseNewLine(scanner);// mandatory

          requests.add(parseRequest(scanner, isChangeSet));
          multipart = new BatchRequestPartImpl(false, requests);
        } else {
          throw new BatchException(BatchException.INVALID_CONTENT_TYPE.addContent(HttpContentType.APPLICATION_HTTP));
        }
      } else {
        if (HttpContentType.APPLICATION_HTTP.equalsIgnoreCase(contentType)) {
          validateEncoding(mimeHeaders.get(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING.toLowerCase(Locale.ENGLISH)));
          parseNewLine(scanner);// mandatory
          requests.add(parseRequest(scanner, isChangeSet));
          multipart = new BatchRequestPartImpl(false, requests);
        } else if (contentType.matches(REG_EX_OPTIONAL_WHITESPACE + HttpContentType.MULTIPART_MIXED + ANY_CHARACTERS)) {
          String changeSetBoundary = getBoundary(contentType);
          if (boundary.equals(changeSetBoundary)) {
            throw new BatchException(BatchException.INVALID_CHANGESET_BOUNDARY.addContent(currentLineNumber));
          }
          List<ODataRequest> changeSetRequests = new LinkedList<ODataRequest>();
          parseNewLine(scanner);// mandatory
          Pattern changeSetCloseDelimiter =
              Pattern.compile("--" + changeSetBoundary + "--" + REG_EX_ZERO_OR_MORE_WHITESPACES);
          while (!scanner.hasNext(changeSetCloseDelimiter)) {
            BatchRequestPart part = parseMultipart(scanner, changeSetBoundary, true);
            changeSetRequests.addAll(part.getRequests());
          }
          scanner.next(changeSetCloseDelimiter);
          currentLineNumber++;
          multipart = new BatchRequestPartImpl(true, changeSetRequests);
        } else {
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.