@Override public void setFromJSON(String json) throws JsonException { id = SerializationUtils.fromJson(json); }
public static AbstractProcessStage fromJsonString(String json) throws JsonException, ClassNotFoundException, InstantiationException, IllegalAccessException, InitFailedException, RequiredArgumentMissingException { Map<String, Object> properties = SerializationUtils.fromJson(json); return fromMap(properties); }
@Override public void setFromJSON(String json) throws JsonException { id = toObjectId(SerializationUtils.fromJson(json)); }
public static MongoDocumentID getDocumentID(String json) throws JsonException { return getDocumentID(SerializationUtils.fromJson(json)); }
public static ObjectId getObjectId(String json) throws JsonException { return toObjectId(SerializationUtils.fromJson(json)); }
private static Map<String, Object> readPropertiesFile(String filename) { String json = ""; try { json = readFileAsString(filename); } catch (IOException e) { System.err.println("Property file " + filename + " could not be read"); System.exit(-1); } try { return SerializationUtils.fromJson(json); } catch (JsonException e) { System.err.println("Property file " + filename + " is not well formed json"); System.exit(-1); } return null; }
@SuppressWarnings({ "unchecked" }) @Override public void fromJson(String json) throws JsonException{ try { Map<String, Object> queryObject = (Map<String, Object>) SerializationUtils.fromJson(json); if(queryObject.containsKey("equals")) { equals = (Map<String, Object>) queryObject.get("equals"); } if(queryObject.containsKey("notEquals")) { notEquals = (Map<String, Object>) queryObject.get("notEquals"); } if(queryObject.containsKey("exists")) { exists = (Map<String, Boolean>) queryObject.get("exists"); } if(queryObject.containsKey("touched")) { touched = (Map<String, Boolean>) queryObject.get("touched"); } if(queryObject.containsKey("action")) { action = Action.valueOf((String)queryObject.get("action")); } } catch(JsonParseException jse) { throw new JsonException(jse); } }
@SuppressWarnings("unchecked") @Override public final void fromJson(String json) throws JsonException { try { Map<String, Object> m = SerializationUtils.fromJson(json); if(m.containsKey(ID_KEY)) { documentMap.put(ID_KEY, m.get(ID_KEY)); } if(m.containsKey(ACTION_KEY) && m.get(ACTION_KEY)!=null) { documentMap.put(ACTION_KEY, Action.valueOf((String)m.get(ACTION_KEY))); } if(m.containsKey(METADATA_KEY)) { Map<String, Object> metadata = (Map<String, Object>) m.get(METADATA_KEY); for(Map.Entry<String, Object> e : metadata.entrySet()) { putMetadataField(e.getKey(), metadata.get(e.getKey())); } } if(m.containsKey(CONTENTS_KEY)) { Map<String, Object> content = (Map<String, Object>) m.get(CONTENTS_KEY); for(Map.Entry<String, Object> e : content.entrySet()) { putContentField(e.getKey(), content.get(e.getKey())); } } } catch(JsonParseException e) { internalLogger.error("Caught JsonParseException, throwing JsonException"); throw new JsonException(e); } }
@SuppressWarnings("unchecked") private DocumentFile<T> getDocumentFile(HttpRequest request) throws ParseException, IOException, JsonException { HttpEntity requestEntity = ((HttpEntityEnclosingRequest) request).getEntity(); String requestContent = EntityUtils.toString(requestEntity, "UTF-8"); Object o = SerializationUtils.fromJson(requestContent); if(!(o instanceof Map)) { return null; } Map<String, Object> map = (Map<String, Object>) o; DocumentID<T> id = io.toDocumentId(map.get("documentId")); String fileName = (String) map.get("fileName"); Date d = (Date) map.get("uploadDate"); String encoding = (String) map.get("encoding"); String mimetype = (String) map.get("mimetype"); String savedByStage = (String) map.get("savedByStage"); InputStream is; if(encoding == null) { is = new ByteArrayInputStream(Base64.decodeBase64(((String)map.get("stream")).getBytes("UTF-8"))); } else { is = new ByteArrayInputStream(Base64.decodeBase64(((String)map.get("stream")).getBytes(encoding))); } DocumentFile<T> df = new DocumentFile<T>(id, fileName, is, savedByStage, d); df.setEncoding(encoding); df.setMimetype(mimetype); return df; }
public final void fromJson(String json) throws JsonException { try { Map<String, Object> queryObject = (Map<String, Object>) SerializationUtils.fromJson(json); if(queryObject.containsKey("equals")) { for (Entry<String, Object> entry : ((Map<String, Object>) queryObject.get("equals")).entrySet()) {