Examples of BatchException


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

      scanner.next();
      currentLineNumber++;
    } else {
      currentLineNumber++;
      if (scanner.hasNext()) {
        throw new BatchException(BatchException.MISSING_BLANK_LINE.addContent(scanner.next()).addContent(
            currentLineNumber));
      } else {
        throw new BatchException(BatchException.TRUNCATED_BODY.addContent(currentLineNumber));

      }
    }
  }
View Full Code Here

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

          Accept acceptHeader = new Accept().setQuality(qualityFactor).setValue(acceptHeaderValue);
          acceptTree.add(acceptHeader);
        } else {
          String header = acceptHeaderScanner.next();
          acceptHeaderScanner.close();
          throw new BatchException(BatchException.INVALID_ACCEPT_HEADER.addContent(header), BAD_REQUEST);
        }
      } else {
        String header = acceptHeaderScanner.next();
        acceptHeaderScanner.close();
        throw new BatchException(BatchException.INVALID_ACCEPT_HEADER.addContent(header), BAD_REQUEST);
      }
    }
    for (Accept accept : acceptTree) {
      acceptHeaders.add(accept.getValue());
    }
View Full Code Here

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

          double qualityFactor = result.group(2) != null ? Double.parseDouble(result.group(2)) : 1d;
          acceptTree.add(new Accept().setQuality(qualityFactor).setValue(languagerange));
        } else {
          String acceptLanguage = acceptLanguageScanner.next();
          acceptLanguageScanner.close();
          throw new BatchException(BatchException.INVALID_ACCEPT_LANGUAGE_HEADER.addContent(acceptLanguage),
              BAD_REQUEST);
        }
      } else {
        String acceptLanguage = acceptLanguageScanner.next();
        acceptLanguageScanner.close();
        throw new BatchException(BatchException.INVALID_ACCEPT_LANGUAGE_HEADER.addContent(acceptLanguage), BAD_REQUEST);
      }
    }
    for (Accept accept : acceptTree) {
      acceptLanguages.add(accept.getValue());
    }
View Full Code Here

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

      }
      if (scanner.hasNext(closeDelimiter)) {
        scanner.next(closeDelimiter);
        currentLineNumber++;
      } else {
        throw new BatchException(BatchException.MISSING_CLOSE_DELIMITER.addContent(currentLineNumber));
      }
    } else {
      throw new BatchException(BatchException.MISSING_CONTENT_TYPE);
    }
    return requests;
  }
View Full Code Here

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

      Map<String, String> 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) {
        return parseBatchRequestPartInChangeset(scanner, boundary, mimeHeaders, contentType);
      } else {
        return parseBatchRequestPart(scanner, boundary, mimeHeaders, contentType);
      }
    } else if (scanner.hasNext(boundary + REG_EX_ZERO_OR_MORE_WHITESPACES)) {
      currentLineNumber++;
      throw new BatchException(BatchException.INVALID_BOUNDARY_DELIMITER.addContent(currentLineNumber));
    } else if (scanner.hasNext(REG_EX_ANY_BOUNDARY_STRING)) {
      currentLineNumber++;
      throw new BatchException(BatchException.NO_MATCH_WITH_BOUNDARY_STRING.addContent(boundary).addContent(
          currentLineNumber));
    } else {
      currentLineNumber++;
      throw new BatchException(BatchException.MISSING_BOUNDARY_DELIMITER.addContent(currentLineNumber));
    }
  }
View Full Code Here

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

      requests.add(parseRequest(scanner, false, boundary));
      return 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++;
      return new BatchRequestPartImpl(true, changeSetRequests);
    } else {
      throw new BatchException(BatchException.INVALID_CONTENT_TYPE.addContent(HttpContentType.MULTIPART_MIXED
          + " or " + HttpContentType.APPLICATION_HTTP));
    }
  }
View Full Code Here

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

      parseNewLine(scanner);// mandatory
      List<ODataRequest> requests = new ArrayList<ODataRequest>(1);
      requests.add(parseRequest(scanner, true, boundary));
      return new BatchRequestPartImpl(false, requests);
    } else {
      throw new BatchException(BatchException.INVALID_CONTENT_TYPE.addContent(HttpContentType.APPLICATION_HTTP));
    }
  }
View Full Code Here

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

      if (result.groupCount() == 2) {
        method = result.group(1);
        uri = result.group(2).trim();
      } else {
        currentLineNumber++;
        throw new BatchException(BatchException.INVALID_REQUEST_LINE.addContent(scanner.next()).addContent(
            currentLineNumber));
      }
      PathInfo pathInfo = parseRequestUri(uri);
      Map<String, String> queryParameters = parseQueryParameters(uri);
      if (isChangeSet) {
        if (!HTTP_CHANGESET_METHODS.contains(method)) {
          throw new BatchException(BatchException.INVALID_CHANGESET_METHOD.addContent(currentLineNumber));
        }
      } else if (!HTTP_BATCH_METHODS.contains(method)) {
        throw new BatchException(BatchException.INVALID_QUERY_OPERATION_METHOD.addContent(currentLineNumber));
      }
      ODataHttpMethod httpMethod = ODataHttpMethod.valueOf(method);
      Map<String, List<String>> headers = parseRequestHeaders(scanner, boundary);
      if (currentMimeHeaderContentId != null) {
        List<String> headerList = new ArrayList<String>();
        headerList.add(currentMimeHeaderContentId);
        headers.put(BatchHelper.MIME_HEADER_CONTENT_ID.toLowerCase(Locale.ENGLISH), headerList);
      }

      String contentType = getContentTypeHeader(headers);
      List<String> acceptHeaders = getAcceptHeader(headers);
      List<Locale> acceptLanguages = getAcceptLanguageHeader(headers);
      InputStream body = new ByteArrayInputStream(new byte[0]);
      if (isChangeSet) {
        body = parseBody(scanner);
      }

      ODataRequestBuilder requestBuilder = ODataRequest.method(httpMethod)
          .queryParameters(queryParameters)
          .requestHeaders(headers)
          .pathInfo(pathInfo)
          .acceptableLanguages(acceptLanguages)
          .body(body)
          .acceptHeaders(acceptHeaders);

      if (contentType != null) {
        requestBuilder = requestBuilder.contentType(contentType);
      }
      return requestBuilder.build();
    } else {
      currentLineNumber++;
      throw new BatchException(BatchException.INVALID_REQUEST_LINE.addContent(scanner.next()).addContent(
          currentLineNumber));
    }

  }
View Full Code Here

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

            headers.put(BatchHelper.REQUEST_HEADER_CONTENT_ID.toLowerCase(Locale.ENGLISH), headerList);
          }
        }
      } else {
        currentLineNumber++;
        throw new BatchException(BatchException.INVALID_HEADER.addContent(scanner.next())
            .addContent(currentLineNumber));
      }
    }
    return headers;
  }
View Full Code Here

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

          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
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.