private String parseODataPath(final String uri, final String rawBaseUri) throws BatchDeserializerException { if (uri.indexOf(rawBaseUri) == 0) { return uri.substring(rawBaseUri.length()); } else { throw new BatchDeserializerException("Invalid base uri or uri", MessageKeys.INVALID_URI, "0"); } }
private String parseODataPath(final String uri, final String rawBaseUri) throws BatchDeserializerException { if (uri.indexOf(rawBaseUri) == 0) { return uri.substring(rawBaseUri.length()); } else { throw new BatchDeserializerException("Invalid base uri or uri", MessageKeys.INVALID_URI, "0"); } }
private String parseHttpVersion(final String httpVersion) throws BatchDeserializerException { if (!HTTP_VERSION.equals(httpVersion.trim())) { throw new BatchDeserializerException("Invalid http version", MessageKeys.INVALID_HTTP_VERSION, Integer.toString(statusLine.getLineNumber())); } else { return HTTP_VERSION; } }
private void validateHttpMethod(final ODataRequest request) throws BatchDeserializerException { if (request.getMethod() != HttpMethod.POST) { throw new BatchDeserializerException("Invalid HTTP method", MessageKeys.INVALID_METHOD, "0"); } } }
private String parseHttpVersion(final String httpVersion) throws BatchDeserializerException { if (!HTTP_VERSION.equals(httpVersion.trim())) { throw new BatchDeserializerException("Invalid http version", MessageKeys.INVALID_HTTP_VERSION, Integer.toString(statusLine.getLineNumber())); } else { return HTTP_VERSION; } }
private void validateHttpMethod(final ODataRequest request) throws BatchDeserializerException { if (request.getMethod() != HttpMethod.POST) { throw new BatchDeserializerException("Invalid HTTP method", MessageKeys.INVALID_METHOD, "0"); } } }
protected Line consumeHttpStatusLine(final List<Line> message) throws BatchDeserializerException { if (!message.isEmpty() && !"".equals(message.get(0).toString().trim())) { final Line method = message.get(0); message.remove(0); return method; } else { final int line = (!message.isEmpty()) ? message.get(0).getLineNumber() : 0; throw new BatchDeserializerException("Missing http request line", BatchDeserializerException.MessageKeys.INVALID_STATUS_LINE, "" + line); } }
public static void consumeBlankLine(final List<Line> remainingMessage, final boolean isStrict) throws BatchDeserializerException { if (!remainingMessage.isEmpty() && remainingMessage.get(0).toString().matches("\\s*\r?\n\\s*")) { remainingMessage.remove(0); } else { if (isStrict) { final int lineNumber = (!remainingMessage.isEmpty()) ? remainingMessage.get(0).getLineNumber() : 0; throw new BatchDeserializerException("Missing blank line", BatchDeserializerException.MessageKeys.MISSING_BLANK_LINE, "[None]", Integer.toString(lineNumber)); } } }
public static String getBoundary(final String contentType, final int line) throws BatchDeserializerException { final ContentType type = parseContentType(contentType, ContentType.MULTIPART_MIXED, line); final String boundary = type.getParameter(BOUNDARY); if (boundary == null) { throw new BatchDeserializerException("Missing boundary.", BatchDeserializerException.MessageKeys.MISSING_BOUNDARY_DELIMITER, Integer.toString(line)); } final Matcher matcher = PATTERN_BOUNDARY.matcher(boundary); if (matcher.matches()) { return matcher.group(1) == null ? matcher.group(2) : matcher.group(1); } else { throw new BatchDeserializerException("Invalid boundary format", BatchDeserializerException.MessageKeys.INVALID_BOUNDARY, Integer.toString(line)); } }
protected Line consumeHttpStatusLine(final List<Line> message) throws BatchDeserializerException { if (!message.isEmpty() && !"".equals(message.get(0).toString().trim())) { final Line method = message.get(0); message.remove(0); return method; } else { final int line = (!message.isEmpty()) ? message.get(0).getLineNumber() : 0; throw new BatchDeserializerException("Missing http request line", BatchDeserializerException.MessageKeys.INVALID_STATUS_LINE, "" + line); } }
public static void consumeBlankLine(final List<Line> remainingMessage, final boolean isStrict) throws BatchDeserializerException { if (!remainingMessage.isEmpty() && remainingMessage.get(0).toString().matches("\\s*\r?\n\\s*")) { remainingMessage.remove(0); } else { if (isStrict) { final int lineNumber = (!remainingMessage.isEmpty()) ? remainingMessage.get(0).getLineNumber() : 0; throw new BatchDeserializerException("Missing blank line", BatchDeserializerException.MessageKeys.MISSING_BLANK_LINE, "[None]", Integer.toString(lineNumber)); } } }
private void parseRelativeUri(final String rawUri) throws BatchDeserializerException { final Matcher relativeUriMatcher = PATTERN_RELATIVE_URI.matcher(rawUri); if (relativeUriMatcher.matches()) { buildUri(relativeUriMatcher.group(1), relativeUriMatcher.group(2)); } else { throw new BatchDeserializerException("Malformed uri", MessageKeys.INVALID_URI, Integer.toString(statusLine.getLineNumber())); } }
public static String getBoundary(final String contentType, final int line) throws BatchDeserializerException { final ContentType type = parseContentType(contentType, ContentType.MULTIPART_MIXED, line); final String boundary = type.getParameter(BOUNDARY); if (boundary == null) { throw new BatchDeserializerException("Missing boundary.", BatchDeserializerException.MessageKeys.MISSING_BOUNDARY_DELIMITER, Integer.toString(line)); } final Matcher matcher = PATTERN_BOUNDARY.matcher(boundary); if (matcher.matches()) { return matcher.group(1) == null ? matcher.group(2) : matcher.group(1); } else { throw new BatchDeserializerException("Invalid boundary format", BatchDeserializerException.MessageKeys.INVALID_BOUNDARY, Integer.toString(line)); } }
private void parseRelativeUri(final String rawUri) throws BatchDeserializerException { final Matcher relativeUriMatcher = PATTERN_RELATIVE_URI.matcher(rawUri); if (relativeUriMatcher.matches()) { buildUri(relativeUriMatcher.group(1), relativeUriMatcher.group(2)); } else { throw new BatchDeserializerException("Malformed uri", MessageKeys.INVALID_URI, Integer.toString(statusLine.getLineNumber())); } }
private HttpMethod parseMethod(final String method) throws BatchDeserializerException { try { return HttpMethod.valueOf(method.trim()); } catch (IllegalArgumentException e) { throw new BatchDeserializerException("Illegal http method", e, MessageKeys.INVALID_METHOD, Integer.toString(statusLine.getLineNumber())); } }
public void validateHttpMethod(final boolean isChangeSet) throws BatchDeserializerException { if (isChangeSet && !HTTP_CHANGE_SET_METHODS.contains(getMethod())) { throw new BatchDeserializerException("Invalid change set method", MessageKeys.INVALID_CHANGESET_METHOD, Integer.toString(statusLine.getLineNumber())); } }
private void validateChangeSetBoundary(final String changeSetBoundary, final Header header) throws BatchDeserializerException { if (changeSetBoundary.equals(boundary)) { throw new BatchDeserializerException("Change set boundary is equals to batch request boundary", BatchDeserializerException.MessageKeys.INVALID_BOUNDARY, Integer.toString(header.getHeaderField(HttpHeader.CONTENT_TYPE).getLineNumber())); } }
public void validateHttpMethod(final boolean isChangeSet) throws BatchDeserializerException { if (isChangeSet && !HTTP_CHANGE_SET_METHODS.contains(getMethod())) { throw new BatchDeserializerException("Invalid change set method", MessageKeys.INVALID_CHANGESET_METHOD, Integer.toString(statusLine.getLineNumber())); } }
private void validateChangeSetBoundary(final String changeSetBoundary, final Header header) throws BatchDeserializerException { if (changeSetBoundary.equals(boundary)) { throw new BatchDeserializerException("Change set boundary is equals to batch request boundary", BatchDeserializerException.MessageKeys.INVALID_BOUNDARY, Integer.toString(header.getHeaderField(HttpHeader.CONTENT_TYPE).getLineNumber())); } }
private void parseAbsoluteUri(final String rawUri, final String baseUri) throws BatchDeserializerException { if (rawUri.startsWith(baseUri)) { final String relativeUri = removeLeadingSlash(rawUri.substring(baseUri.length())); parseRelativeUri(relativeUri); } else { throw new BatchDeserializerException("Base uri does not match", MessageKeys.INVALID_BASE_URI, Integer.toString(statusLine.getLineNumber())); } }