public Builder setContentType(MediaType mediaType) { this.headersBuilder.put(HeaderNames.CONTENT_TYPE, mediaType.toString()); return this; }
public Builder setContentType(MediaType contentType) { this.headersMap.put(HeaderNames.CONTENT_TYPE, contentType.toString()); return this; }
public Builder setContentType(MediaType mediaType) { this.headersBuilder.put(HeaderNames.CONTENT_TYPE, mediaType.toString()); return this; }
public Builder setContentType(MediaType contentType) { this.headersMap.put(HeaderNames.CONTENT_TYPE, contentType.toString()); return this; }
public void setContentType(MediaType mediaType) { headers.put(HeaderNames.CONTENT_TYPE, mediaType.toString()); }
public void setContentType(MediaType mediaType) { headers.put(HeaderNames.CONTENT_TYPE, mediaType.toString()); }
/** * Write the data for a given entity. * * @param entity The given entity. * @param entityType The entity type. * @throws XMLStreamException if unable to render the entity * @throws ODataRenderException if unable to render the entity */ public void writeData(Object entity, EntityType entityType) throws XMLStreamException, ODataRenderException { xmlWriter.writeStartElement(ODATA_CONTENT); xmlWriter.writeAttribute(TYPE, XML.toString()); xmlWriter.writeStartElement(METADATA, ODATA_PROPERTIES, ""); marshall(entity, entityType); xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); }
/** * Write the data for a given entity. * * @param entity The given entity. * @param entityType The entity type. * @throws XMLStreamException if unable to render the entity * @throws ODataRenderException if unable to render the entity */ public void writeData(Object entity, EntityType entityType) throws XMLStreamException, ODataRenderException { xmlWriter.writeStartElement(ODATA_CONTENT); xmlWriter.writeAttribute(TYPE, XML.toString()); xmlWriter.writeStartElement(METADATA, ODATA_PROPERTIES, ""); marshall(entity, entityType); xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); }
/** * Util method for first populating request properties before execution. * * @param requestProperties request properties, may be immutable. * It can be null or empty, so copying will take place, if necessary. * @param bodyLength body length * @param contentType content type * @param acceptType access type * @return populated request properties */ public static Map<String, String> populateRequestProperties( Map<String, String> requestProperties, int bodyLength, MediaType contentType, MediaType acceptType) { Map<String, String> properties; // requestProperties if (requestProperties == null || requestProperties.isEmpty()) { properties = new HashMap<>(); } else { properties = new HashMap<>(requestProperties); } if (acceptType != null) { properties.put(HeaderNames.ACCEPT, acceptType.toString()); } if (contentType != null) { properties.put(HeaderNames.CONTENT_TYPE, contentType.toString()); } if (bodyLength > -1) { properties.put(HeaderNames.CONTENT_LENGTH, String.valueOf(bodyLength)); } return properties; }
/** * Util method for first populating request properties before execution. * * @param requestProperties request properties, may be immutable. * It can be null or empty, so copying will take place, if necessary. * @param bodyLength body length * @param contentType content type * @param acceptType access type * @return populated request properties */ public static Map<String, String> populateRequestProperties( Map<String, String> requestProperties, int bodyLength, MediaType contentType, MediaType acceptType) { Map<String, String> properties; // requestProperties if (requestProperties == null || requestProperties.isEmpty()) { properties = new HashMap<>(); } else { properties = new HashMap<>(requestProperties); } if (acceptType != null) { properties.put(HeaderNames.ACCEPT, acceptType.toString()); } if (contentType != null) { properties.put(HeaderNames.CONTENT_TYPE, contentType.toString()); } if (bodyLength > -1) { properties.put(HeaderNames.CONTENT_LENGTH, String.valueOf(bodyLength)); } return properties; }
private Map<String, String> buildRenderedData(ProcessorResult result) throws ODataException { LOG.debug("Start to render the data"); Map<String, String> resultMap = new HashMap<>(); if (result.getStatus().getCode() < ODataResponse.Status.NO_CONTENT.getCode()) { String contentType = result.getHeaders().get(CONTENT_TYPE); if (!result.getHeaders().containsKey(CONTENT_TYPE) || contentType.startsWith(MediaType.ATOM_XML.toString())) { // render XML resultMap.put(FORMAT, MediaType.ATOM_XML.toString()); resultMap.put(BODY, getRenderedXML(result)); } else if (contentType.startsWith(MediaType.JSON.toString())) { // render JSON resultMap.put(FORMAT, MediaType.JSON.toString()); resultMap.put(BODY, getRenderedJSON(result)); } } else { resultMap.put(FORMAT, MediaType.HTTP.getSubType()); resultMap.put(BODY, (String) result.getData()); } return resultMap; }
private Map<String, String> buildRenderedData(ProcessorResult result) throws ODataException { LOG.debug("Start to render the data"); Map<String, String> resultMap = new HashMap<>(); if (result.getStatus().getCode() < ODataResponse.Status.NO_CONTENT.getCode()) { String contentType = result.getHeaders().get(CONTENT_TYPE); if (!result.getHeaders().containsKey(CONTENT_TYPE) || contentType.startsWith(MediaType.ATOM_XML.toString())) { // render XML resultMap.put(FORMAT, MediaType.ATOM_XML.toString()); resultMap.put(BODY, getRenderedXML(result)); } else if (contentType.startsWith(MediaType.JSON.toString())) { // render JSON resultMap.put(FORMAT, MediaType.JSON.toString()); resultMap.put(BODY, getRenderedJSON(result)); } } else { resultMap.put(FORMAT, MediaType.HTTP.getSubType()); resultMap.put(BODY, (String) result.getData()); } return resultMap; }