List of usage examples for org.apache.http.nio.entity NStringEntity NStringEntity
public NStringEntity(final String s, String charset) throws UnsupportedEncodingException
From source file:org.kitodo.data.index.elasticsearch.RestClientImplementationTest.java
private static HashMap<Integer, HttpEntity> createEntities() { HashMap<Integer, HttpEntity> documents = new HashMap<>(); String jsonString = "{\"title\":\"Batch1\",\"type\":\"LOGISTIC\",\"processes\":[{\"id\":\"1\"},{\"id\":\"2\"}]}"; HttpEntity entity = new NStringEntity(jsonString, ContentType.APPLICATION_JSON); documents.put(1, entity);/* www.j a va 2 s . c o m*/ jsonString = "{\"title\":\"Batch2\",\"type\":\"null\",\"processes\":[]}"; entity = new NStringEntity(jsonString, ContentType.APPLICATION_JSON); documents.put(2, entity); return documents; }
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);/*from ww w. j a v a 2 s. c o m*/ 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.kitodo.data.elasticsearch.index.type.DocketType.java
@SuppressWarnings("unchecked") @Override//w w w.jav a2s.c om 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 ava 2s .c o m 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:org.kitodo.data.elasticsearch.index.type.UserGroupType.java
@SuppressWarnings("unchecked") @Override/*from w w w . ja va 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.index.elasticsearch.type.DocketType.java
@SuppressWarnings("unchecked") @Override//from ww w. jav a 2s . c o 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.BatchType.java
@SuppressWarnings("unchecked") @Override/*from w ww. j a va2 s . c o 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.elasticsearch.index.type.RulesetType.java
@SuppressWarnings("unchecked") @Override//from w w w.j a v a2 s. c om 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/*from w w w . j a v a 2s . c o m*/ 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); }
From source file:org.kitodo.data.elasticsearch.index.type.TemplateType.java
@SuppressWarnings("unchecked") @Override//from w w w. ja v a 2 s. com public HttpEntity createDocument(Template template) { JSONObject templateObject = new JSONObject(); templateObject.put("origin", template.getOrigin()); Integer process = template.getProcess() != null ? template.getProcess().getId() : null; templateObject.put("process", process); templateObject.put("properties", addObjectRelation(template.getProperties())); return new NStringEntity(templateObject.toJSONString(), ContentType.APPLICATION_JSON); }