Examples of BatchException


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

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

            String systemQueryOption = result.group(1);
            String value = result.group(2);
            queryParametersMap.put(systemQueryOption, Decoder.decode(value));
          } else {
            queryParamsScanner.close();
            throw new BatchException(BatchException.INVALID_QUERY_PARAMETER);
          }
        }
        queryParamsScanner.close();

      } else {
        uriScanner.close();
        throw new BatchException(BatchException.INVALID_URI.addContent(currentLineNumber));
      }
    }
    uriScanner.close();
    return queryParametersMap;
  }
View Full Code Here

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

    Scanner contentTypeScanner = new Scanner(contentType).useDelimiter(";\\s?");
    if (contentTypeScanner.hasNext(REG_EX_CONTENT_TYPE)) {
      contentTypeScanner.next(REG_EX_CONTENT_TYPE);
    } else {
      contentTypeScanner.close();
      throw new BatchException(BatchException.INVALID_CONTENT_TYPE.addContent(HttpContentType.MULTIPART_MIXED));
    }
    if (contentTypeScanner.hasNext(REG_EX_BOUNDARY_PARAMETER)) {
      contentTypeScanner.next(REG_EX_BOUNDARY_PARAMETER);
      MatchResult result = contentTypeScanner.match();
      contentTypeScanner.close();
      if (result.groupCount() == 1 && result.group(1).trim().matches(REG_EX_BOUNDARY)) {
        return trimQuota(result.group(1).trim());
      } else {
        throw new BatchException(BatchException.INVALID_BOUNDARY);
      }
    } else {
      contentTypeScanner.close();
      throw new BatchException(BatchException.MISSING_PARAMETER_IN_CONTENT_TYPE);
    }
  }
View Full Code Here

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

    }
  }

  private void validateEncoding(final String encoding) throws BatchException {
    if (!BatchHelper.BINARY_ENCODING.equalsIgnoreCase(encoding)) {
      throw new BatchException(BatchException.INVALID_CONTENT_TRANSFER_ENCODING);
    }
  }
View Full Code Here

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

          String headerName = result.group(1).trim().toLowerCase(Locale.ENGLISH);
          String headerValue = result.group(2).trim();
          headers.put(headerName, headerValue);
        }
      } else {
        throw new BatchException(BatchException.INVALID_HEADER.addContent(scanner.next()));
      }
    }
    return headers;
  }
View Full Code Here

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

          baseUri = baseUri + "/" + precedingPS.getPath();
        }
        return baseUri;
      }
    } else {
      throw new BatchException(BatchException.INVALID_PATHINFO);
    }
    return null;
  }
View Full Code Here

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

  }

  private String readBody(final InputStream in) throws BatchException {
    byte[] tmp = new byte[2048];
    int count;
    BatchException cachedException = null;
    StringBuffer b = new StringBuffer();
    try {
      count = in.read(tmp);
      while (count >= 0) {
        b.append(new String(tmp, 0, count, BatchHelper.DEFAULT_ENCODING));
        count = in.read(tmp);
      }
    } catch (IOException e) {
      cachedException = new BatchException(ODataMessageException.COMMON, e);
      throw cachedException;
    } finally {// NOPMD (suppress DoNotThrowExceptionInFinally)
      try {
        in.close();
      } catch (IOException e) {
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 responses;

  }
View Full Code Here

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

      mimeHeaders = parseMimeHeaders(scanner);
      currentContentId = mimeHeaders.get(BatchHelper.HTTP_CONTENT_ID.toLowerCase(Locale.ENGLISH));

      final 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
          BatchSingleResponseImpl response = parseResponse(scanner, isChangeSet);
          responses.add(response);
        } 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
          BatchSingleResponseImpl response = parseResponse(scanner, isChangeSet);
          responses.add(response);
        } 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));
          }
          parseNewLine(scanner);// mandatory
          Pattern changeSetCloseDelimiter =
              Pattern.compile("--" + changeSetBoundary + "--" + REG_EX_ZERO_OR_MORE_WHITESPACES);
          while (!scanner.hasNext(changeSetCloseDelimiter)) {
            responses.addAll(parseMultipart(scanner, changeSetBoundary, true));
          }
          scanner.next(changeSetCloseDelimiter);
          currentLineNumber++;
          parseNewLine(scanner);
        } else {
          throw new BatchException(BatchException.INVALID_CONTENT_TYPE.addContent(HttpContentType.MULTIPART_MIXED
              + " or " + HttpContentType.APPLICATION_HTTP));
        }
      }
    } 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));
    }
    return responses;

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