Examples of BatchException


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

      if (result.groupCount() == 2) {
        statusCode = result.group(1);
        statusInfo = result.group(2);
      } else {
        currentLineNumber++;
        throw new BatchException(BatchException.INVALID_STATUS_LINE.addContent(scanner.next()).addContent(
            currentLineNumber));
      }

      Map<String, String> headers = parseResponseHeaders(scanner);
      parseNewLine(scanner);
      String contentLengthHeader = getHeaderValue(headers, HttpHeaders.CONTENT_LENGTH);
      String body =
          (contentLengthHeader != null) ? parseBody(scanner, Integer.parseInt(contentLengthHeader))
              : parseBody(scanner);
      response.setStatusCode(statusCode);
      response.setStatusInfo(statusInfo);
      response.setHeaders(headers);
      response.setContentId(currentContentId);
      response.setBody(body);
    } else {
      currentLineNumber++;
      throw new BatchException(BatchException.INVALID_STATUS_LINE.addContent(scanner.next()).addContent(
          currentLineNumber));
    }
    return response;
  }
View Full Code Here

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

    return response;
  }

  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

            headers.put(headerName, headerValue);
          }
        }
      } 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

    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

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