Example usage for org.apache.http.entity ContentType APPLICATION_JSON

List of usage examples for org.apache.http.entity ContentType APPLICATION_JSON

Introduction

In this page you can find the example usage for org.apache.http.entity ContentType APPLICATION_JSON.

Prototype

ContentType APPLICATION_JSON

To view the source code for org.apache.http.entity ContentType APPLICATION_JSON.

Click Source Link

Usage

From source file:org.kitodo.data.elasticsearch.MockEntity.java

public static HashMap<Integer, HttpEntity> createEntities() {
    HashMap<Integer, HttpEntity> documents = new HashMap<>();

    String jsonString = "{\"title\":\"Batch1\",\"type\":\"LOGISTIC\",\"amount\":2,\"processes\":[{\"id\":\"1\"},{\"id\":\"2\"}]}";
    HttpEntity entity = new NStringEntity(jsonString, ContentType.APPLICATION_JSON);
    documents.put(1, entity);/*ww w  . ja v  a 2 s  .  com*/

    jsonString = "{\"title\":\"Sort\",\"type\":\"null\",\"amount\":4,\"processes\":[]}";
    entity = new NStringEntity(jsonString, ContentType.APPLICATION_JSON);
    documents.put(2, entity);

    jsonString = "{\"title\":\"Batch2\",\"type\":\"null\",\"amount\":0,\"processes\":[]}";
    entity = new NStringEntity(jsonString, ContentType.APPLICATION_JSON);
    documents.put(3, entity);

    jsonString = "{\"title\":\"Order\",\"type\":\"null\",\"amount\":2,\"processes\":[]}";
    entity = new NStringEntity(jsonString, ContentType.APPLICATION_JSON);
    documents.put(4, entity);

    return documents;
}

From source file:org.stem.api.BaseHttpClient.java

protected static void setHeaders(AbstractHttpMessage request) {
    request.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
    request.addHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_JSON.toString());
}

From source file:org.kitodo.data.elasticsearch.index.type.DocketType.java

@SuppressWarnings("unchecked")
@Override/*from w w  w .j a  v a  2  s .  co m*/
public HttpEntity createDocument(Docket docket) {

    JSONObject docketObject = new JSONObject();
    docketObject.put("title", docket.getTitle());
    docketObject.put("file", docket.getFile());

    return new NStringEntity(docketObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:org.kitodo.data.elasticsearch.index.type.FilterType.java

@SuppressWarnings("unchecked")
@Override//from   w w  w .  j  av  a  2s. c om
public HttpEntity createDocument(Filter filter) {

    JSONObject propertyObject = new JSONObject();
    propertyObject.put("value", filter.getValue());
    Integer user = filter.getUser() != null ? filter.getUser().getId() : null;
    propertyObject.put("user", user);

    return new NStringEntity(propertyObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:com.vmware.photon.controller.api.client.resource.ApiBase.java

public static StringEntity serializeObjectAsJson(Object o) throws JsonProcessingException {
    String payload = objectMapper.writeValueAsString(o);

    return new StringEntity(payload, ContentType.APPLICATION_JSON);
}

From source file:org.kitodo.data.elasticsearch.index.type.UserGroupType.java

@SuppressWarnings("unchecked")
@Override// w w  w .ja  v  a 2  s  .c  o m
public HttpEntity createDocument(UserGroup userGroup) {

    JSONObject userGroupObject = new JSONObject();
    userGroupObject.put("title", userGroup.getTitle());
    userGroupObject.put("permission", userGroup.getPermission());
    userGroupObject.put("users", addObjectRelation(userGroup.getUsers()));

    return new NStringEntity(userGroupObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:org.kitodo.data.elasticsearch.index.type.BatchType.java

@SuppressWarnings("unchecked")
@Override/*from w  w  w . ja  va  2 s  .  co m*/
public HttpEntity createDocument(Batch batch) {

    JSONObject batchObject = new JSONObject();
    batchObject.put("title", batch.getTitle());
    String type = batch.getType() != null ? batch.getType().toString() : null;
    batchObject.put("type", type);
    batchObject.put("processes", addObjectRelation(batch.getProcesses()));

    return new NStringEntity(batchObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:org.kitodo.data.index.elasticsearch.type.DocketType.java

@SuppressWarnings("unchecked")
@Override/*from  www.  j a v a2  s  .co  m*/
public HttpEntity createDocument(Docket docket) {

    LinkedHashMap<String, String> orderedDocketMap = new LinkedHashMap<>();
    orderedDocketMap.put("name", docket.getName());
    orderedDocketMap.put("file", docket.getFile());
    JSONObject docketObject = new JSONObject(orderedDocketMap);

    return new NStringEntity(docketObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:org.kitodo.data.elasticsearch.index.type.RulesetType.java

@SuppressWarnings("unchecked")
@Override//from   ww w  .j  a  v a  2s  . co m
public HttpEntity createDocument(Ruleset ruleset) {

    JSONObject rulesetObject = new JSONObject();
    rulesetObject.put("title", ruleset.getTitle());
    rulesetObject.put("file", ruleset.getFile());
    rulesetObject.put("orderMetadataByRuleset", ruleset.isOrderMetadataByRuleset());
    rulesetObject.put("fileContent", "");

    return new NStringEntity(rulesetObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:org.kitodo.data.elasticsearch.index.type.WorkpieceType.java

@SuppressWarnings("unchecked")
@Override// w w  w  .  jav  a  2s .  com
public HttpEntity createDocument(Workpiece workpiece) {

    JSONObject workpieceObject = new JSONObject();
    Integer process = workpiece.getProcess() != null ? workpiece.getProcess().getId() : null;
    workpieceObject.put("process", process);
    workpieceObject.put("properties", addObjectRelation(workpiece.getProperties()));

    return new NStringEntity(workpieceObject.toJSONString(), ContentType.APPLICATION_JSON);
}