public static boolean isODataIEEE754Compatible(final ContentType contentType) { return Boolean.TRUE.toString().equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_IEEE754_COMPATIBLE)); } }
public static boolean isODataIEEE754Compatible(final ContentType contentType) { return Boolean.TRUE.toString().equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_IEEE754_COMPATIBLE)); } }
public static boolean isODataMetadataNone(final ContentType contentType) { return contentType.isCompatible(ContentType.APPLICATION_JSON) && ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); }
public static boolean isODataMetadataFull(final ContentType contentType) { return contentType.isCompatible(ContentType.APPLICATION_JSON) && ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); }
private boolean isODataMetadataNone() { return contentType.isCompatible(ContentType.APPLICATION_JSON) && ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); }
private boolean isODataMetadataFull() { return contentType.isCompatible(ContentType.APPLICATION_JSON) && ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); } }
private boolean isODataMetadataFull() { return contentType.isCompatible(ContentType.APPLICATION_JSON) && ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); } }
public static boolean isODataMetadataFull(final ContentType contentType) { return contentType.isCompatible(ContentType.APPLICATION_JSON) && ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); }
private boolean isODataMetadataNone() { return contentType.isCompatible(ContentType.APPLICATION_JSON) && ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); }
public static boolean isODataMetadataNone(final ContentType contentType) { return contentType.isCompatible(ContentType.APPLICATION_JSON) && ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase( contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)); }
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)); } }
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 updateCurrentCharset(final String currentLine) { if (currentLine != null) { if (currentLine.startsWith(HttpHeader.CONTENT_TYPE)) { final ContentType contentType = ContentType.parse( currentLine.substring(HttpHeader.CONTENT_TYPE.length() + 1, currentLine.length() - 2).trim()); if (contentType != null) { final String charsetString = contentType.getParameter(ContentType.PARAMETER_CHARSET); currentCharset = charsetString == null ? contentType.isCompatible(ContentType.APPLICATION_JSON) || contentType.getSubtype().contains("xml") ? Charset.forName("UTF-8") : DEFAULT_CHARSET : Charset.forName(charsetString); final String boundary = contentType.getParameter(BOUNDARY); if (boundary != null) { currentBoundary = DOUBLE_DASH + boundary; } } } else if (CRLF.equals(currentLine)) { readState.foundLinebreak(); } else if (isBoundary(currentLine)) { readState.foundBoundary(); } } }
private void updateCurrentCharset(final String currentLine) { if (currentLine != null) { if (currentLine.startsWith(HttpHeader.CONTENT_TYPE)) { final ContentType contentType = ContentType.parse( currentLine.substring(HttpHeader.CONTENT_TYPE.length() + 1, currentLine.length() - 2).trim()); if (contentType != null) { final String charsetString = contentType.getParameter(ContentType.PARAMETER_CHARSET); currentCharset = charsetString == null ? contentType.isCompatible(ContentType.APPLICATION_JSON) || contentType.getSubtype().contains("xml") ? Charset.forName("UTF-8") : DEFAULT_CHARSET : Charset.forName(charsetString); final String boundary = contentType.getParameter(BOUNDARY); if (boundary != null) { currentBoundary = DOUBLE_DASH + boundary; } } } else if (CRLF.equals(currentLine)) { readState.foundLinebreak(); } else if (isBoundary(currentLine)) { readState.foundBoundary(); } } }
private Charset getCharset(final BatchQueryOperation operation) { final ContentType contentType = ContentType.parse(operation.getHeaders().getHeader(HttpHeader.CONTENT_TYPE)); if (contentType != null) { final String charsetValue = contentType.getParameter(ContentType.PARAMETER_CHARSET); if (charsetValue == null) { if (contentType.isCompatible(ContentType.APPLICATION_JSON) || contentType.getSubtype().contains("xml")) { return Charset.forName("UTF-8"); } } else { return Charset.forName(charsetValue); } } return Charset.forName("ISO-8859-1"); }
private Charset getCharset(final BatchQueryOperation operation) { final ContentType contentType = ContentType.parse(operation.getHeaders().getHeader(HttpHeader.CONTENT_TYPE)); if (contentType != null) { final String charsetValue = contentType.getParameter(ContentType.PARAMETER_CHARSET); if (charsetValue == null) { if (contentType.isCompatible(ContentType.APPLICATION_JSON) || contentType.getSubtype().contains("xml")) { return Charset.forName("UTF-8"); } } else { return Charset.forName(charsetValue); } } return Charset.forName("ISO-8859-1"); }
@Override public ODataSerializer createSerializer(final ContentType contentType) throws SerializerException { ODataSerializer serializer = null; if (contentType.isCompatible(ContentType.APPLICATION_JSON)) { final String metadata = contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA); if (metadata == null || ContentType.VALUE_ODATA_METADATA_MINIMAL.equalsIgnoreCase(metadata) || ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase(metadata) || ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase(metadata)) { serializer = new ODataJsonSerializer(contentType, new Constantsv00()); } } else if (contentType.isCompatible(ContentType.APPLICATION_XML) || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) { serializer = new ODataXmlSerializer(); } if (serializer == null) { throw new SerializerException("Unsupported format: " + contentType.toContentTypeString(), SerializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString()); } else { return serializer; } }
@Override public ODataSerializer createSerializer(final ContentType contentType) throws SerializerException { ODataSerializer serializer = null; if (contentType.isCompatible(ContentType.APPLICATION_JSON)) { final String metadata = contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA); if (metadata == null || ContentType.VALUE_ODATA_METADATA_MINIMAL.equalsIgnoreCase(metadata) || ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase(metadata) || ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase(metadata)) { serializer = new ODataJsonSerializer(contentType, new Constantsv00()); } } else if (contentType.isCompatible(ContentType.APPLICATION_XML) || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) { serializer = new ODataXmlSerializer(); } if (serializer == null) { throw new SerializerException("Unsupported format: " + contentType.toContentTypeString(), SerializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString()); } else { return serializer; } }
@Override public ODataSerializer createSerializer(final ContentType contentType, final List<String> versions) throws SerializerException { ODataSerializer serializer = null; IConstants constants = new Constantsv00(); if(versions!=null && versions.size()>0 && getMaxVersion(versions)>4){ constants = new Constantsv01() ; } if (contentType.isCompatible(ContentType.APPLICATION_JSON)) { final String metadata = contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA); if (metadata == null || ContentType.VALUE_ODATA_METADATA_MINIMAL.equalsIgnoreCase(metadata) || ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase(metadata) || ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase(metadata)) { serializer = new ODataJsonSerializer(contentType, constants); } } else if (contentType.isCompatible(ContentType.APPLICATION_XML) || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) { serializer = new ODataXmlSerializer(); } if (serializer == null) { throw new SerializerException("Unsupported format: " + contentType.toContentTypeString(), SerializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString()); } else { return serializer; } }
@Override public ODataSerializer createSerializer(final ContentType contentType, final List<String> versions) throws SerializerException { ODataSerializer serializer = null; IConstants constants = new Constantsv00(); if(versions!=null && versions.size()>0 && getMaxVersion(versions)>4){ constants = new Constantsv01() ; } if (contentType.isCompatible(ContentType.APPLICATION_JSON)) { final String metadata = contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA); if (metadata == null || ContentType.VALUE_ODATA_METADATA_MINIMAL.equalsIgnoreCase(metadata) || ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase(metadata) || ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase(metadata)) { serializer = new ODataJsonSerializer(contentType, constants); } } else if (contentType.isCompatible(ContentType.APPLICATION_XML) || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) { serializer = new ODataXmlSerializer(); } if (serializer == null) { throw new SerializerException("Unsupported format: " + contentType.toContentTypeString(), SerializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString()); } else { return serializer; } }