private void initialiseKeyMap() { Map authorizedKeyMap = new HashMap(); if (clients != null) { for (Object client : clients) { JsonObject clientObject = (JsonObject) client; authorizedKeyMap.put((String) clientObject.get("apiKey"), (String) clientObject.get("username")); } } this.authorizedKeyMap = Collections.synchronizedMap(authorizedKeyMap); }
private void processDatastream(DigitalObject recordObject, JsonObject datastream) throws StorageException { String datastreamId = (String) datastream.get("datastream_id"); String contents = (String) datastream.get("contents"); StorageUtils.createOrUpdatePayload(recordObject, datastreamId, IOUtils.toInputStream(contents), "utf-8"); }
/** * Get a list of strings found on the specified node * * @param json object to retrieve from * @param field The field that has the list * @return List<String> The resulting list */ public static List<String> getStringList(JsonObject json, String field) { List<String> response = new LinkedList<String>(); Object object = json.get(field); if (object instanceof JSONArray) { return getStringList((JSONArray) object); } return response; }
public JsonObject findJsonObjectWithKey(String keyName) { Object[] reportCriteriaOptions = reportCriteriaOptionsJson.getArray( "results").toArray(); for (Object object : reportCriteriaOptions) { JsonObject jsonObject = (JsonObject) object; if (keyName.equals(jsonObject.get("key"))) { return jsonObject; } } return null; }
private void processJsonObjectToProperties(JsonObject jsonObject, String parentKey, Properties properties) { for (Object o : jsonObject.keySet()) { String key = (String) o; Object value = jsonObject.get(key); if (value instanceof String) { properties.put(parentKey + "." + key, value); } else if (value instanceof JsonObject) { processJsonObjectToProperties((JsonObject) value, parentKey + "." + key, properties); } } } }
/** * Generate an order to add a message to the System's audit log * * @param response The response to add an order to * @param oid The object ID we are logging * @param message The message we want to log */ private void audit(JsonSimple response, String oid, String message) { JsonObject order = newSubscription(response, oid); JsonObject messageObject = (JsonObject) order.get("message"); messageObject.put("eventType", message); }
/** * Generate an order to add a message to the System's audit log * * @param response * The response to add an order to * @param oid * The object ID we are logging * @param message * The message we want to log */ private void audit(JsonSimple response, String oid, String message) { JsonObject order = newSubscription(response, oid); JsonObject messageObject = (JsonObject) order.get("message"); messageObject.put("eventType", message); }
/** * Return the List of SolrFacet objects from this result set. * * @return List<SolrFacet> : The list of facets */ public Map<String, SolrFacet> getFacets() { if (facets == null) { facets = new LinkedHashMap<String, SolrFacet>(); JsonObject object = getObject("facet_counts", "facet_fields"); if (object == null) { return null; } for (Object key : object.keySet()) { Object value = object.get(key); if (value instanceof JSONArray) { facets.put((String) key, new SolrFacet((String) key, (JSONArray) value)); } } } return facets; }
/** * <p> * Take all of the JsonObjects found in a JsonObject, wrap them in * JsonSimple objects, then add to a Java Map and return. * </p> * * All entries found that are not JsonObjects are ignored. * * @return String : The JSON String */ public static Map<String, JsonSimple> toJavaMap(JsonObject object) { Map<String, JsonSimple> response = new LinkedHashMap<String, JsonSimple>(); if (object != null && !object.isEmpty()) { for (Object key : object.keySet()) { Object child = object.get(key); if (child != null && child instanceof JsonObject) { response.put((String) key, new JsonSimple((JsonObject) child)); } } } return response; }
public void setConfig(JsonSimpleConfig config) throws IOException { // Get the basics file_path = config.getString(null, "roles", "internal", "path"); loadRoles(); JSONArray roleJsonArray = (JSONArray)config.getObject("roles", "internal").get("defaultRoles"); if(roleJsonArray != null) { defaultRoles = Arrays.copyOf(roleJsonArray.toArray(), roleJsonArray.size(), String[].class); } }
/** * Retrieve the given node from the provided object. * * @param path : An array of indeterminate length to use as the path * @return JsonObject : The JSON representation */ private Object getNode(Object object, Object path) { if (isArray(object)) { try { return ((JSONArray) object).get((Integer) path); } catch(ArrayIndexOutOfBoundsException ex) { return null; } } if (isObject(object)) { return ((JsonObject) object).get(path); } return null; }
/** * Generate an order to send an email to the intended recipient * * @param response The response to add an order to * @param message The message we want to send */ private void email(JsonSimple response, String oid, String text) { JsonObject object = newMessage(response, EmailNotificationConsumer.LISTENER_ID); JsonObject message = (JsonObject) object.get("message"); message.put("to", emailAddress); message.put("body", text); message.put("oid", oid); }
/** * Generate an order to send an email to the intended recipient * * @param response * The response to add an order to * @param message * The message we want to send */ private void email(JsonSimple response, String oid, String text) { JsonObject object = newMessage(response, EmailNotificationConsumer.LISTENER_ID); JsonObject message = (JsonObject) object.get("message"); message.put("to", emailAddress); message.put("body", text); message.put("oid", oid); }
public boolean move(String id, String destination) { // Find our nodes JsonObject toRemove = getWritableParent(id); JsonObject toMove = getWritableNode(destination); // Confirm validity of request if (toRemove == null || toMove == null) { return false; } // Now actually move it toMove.put(id, toRemove.get(id)); toRemove.remove(id); // Update metadata getNode(id).setParentKey(destination); return true; }