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); } } } }
/** * Add a new document into the buffer, and check if submission is required * * @param document : The Solr document to add to the buffer. */ private void addToBuffer(String index, String document) { JsonObject message = new JsonObject(); message.put("event", "index"); message.put("index", index); message.put("document", document); sendToIndex(message.toString()); }
public boolean delete(String id) { JsonObject toRemove = getWritableParent(id); // Confirm validity of request if (toRemove == null) { return false; } toRemove.remove(id); return true; }
protected JsonObject getSuccessResponse(String oid) { JsonObject jsonObject = new JsonObject(); jsonObject.put("code", 200); if (oid != null) { jsonObject.put("oid", oid); } return jsonObject; }
/** * 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); }
Object movedNode = toRemove.get(id); toRemove.remove(id); JsonObject newMap = new JsonObject(); for (Object objKey : toMove.keySet()) { String key = (String) objKey; if (key.equals(destination)) { newMap.put(objKey, toMove.get(objKey)); newMap.put(id, movedNode); } else { newMap.put(objKey, toMove.get(objKey)); toMove.clear(); toMove.putAll(newMap);
order.put("forceCommit", true); if (quickIndex) { JsonObject order = newIndex(response, oid); order.put("forceCommit", true); JsonObject audit = (JsonObject) order.get("message"); audit.putAll(message.getJsonObject()); JsonObject audit = (JsonObject) order.get("message"); audit.putAll(message.getJsonObject()); order.put("forceCommit", true); return response; message.getJsonObject().put("oid", oid);
/** * Set the description for this manifest * * @param description : The new description */ public void setDescription(String description) { getJsonObject().put("description", description); }
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; }
/** * <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; }
/** * Generate orders for the list of normal transformers scheduled to execute * on the tool chain * * @param message The incoming message, which contains the tool chain config * for this object * @param response The response to edit * @param oid The object to schedule for clearing */ private void scheduleTransformers(JsonSimple message, JsonSimple response) { String oid = message.getString(null, "oid"); List<String> list = message.getStringList( "transformer", "metadata"); if (list != null && !list.isEmpty()) { for (String id : list) { JsonObject order = newTransform(response, id, oid); // Add item config to message... if it exists JsonObject itemConfig = message.getObject( "transformerOverrides", id); if (itemConfig != null) { JsonObject config = (JsonObject) order.get("config"); config.putAll(itemConfig); } } } }
((JsonObject) relation).put("oid", relatedOid); saveData = true; if (curatedPid != null && (updatingById || updatingByOid)) { log.debug("Updating..."); ((JsonObject) relation).put("isCurated", true); ((JsonObject) relation).put("curatedPid", curatedPid); saveData = true; task.remove("oid"); task.put("identifier", relatedId); task.put("task", "curation-request"); JsonObject relObject = new JsonObject(); relObject.put("identifier", thisPid); relObject.put("curatedPid", thisPid); relObject.put("broker", brokerUrl); relObject.put("isCurated", true); relObject.put("relationship", reverseRelationship); relObject.put("oid", thisOid); task.put("relationships", newRelations); JsonObject msgResponse = new JsonObject(); msgResponse.put("broker", brokerUrl); msgResponse.put("oid", thisOid); msgResponse.put("task", "curation-pending");
JsonObject data = new JsonObject(); for (int index = 0; index < columns.length; index++) { String field = dataFields.get(index); data.put(field, list); data.put(field, value); log.debug(data.toJSONString()); JsonObject meta = new JsonObject(); meta.put("dc.identifier", idPrefix + recordId);
/** * To delete object processing from queue * * @param oid Object id * @param jsonFile Configuration file * @throws MessagingException if the message could not be sent */ private void queueDelete(String oid, File jsonFile) throws MessagingException { try { JsonObject json = new JsonSimple(jsonFile).getJsonObject(); json.put("oid", oid); json.put("deleted", "true"); messaging.queueMessage(toolChainEntry, json.toString()); } catch (IOException ioe) { log.error("Failed to parse message: {}", ioe.getMessage()); throw new MessagingException(ioe); } }
@SuppressWarnings("unchecked") @ApiOperation(value = "get information about the ReDBox instance", tags = "info") @ApiResponses({ @ApiResponse(code = 200, message = "The datastreams are listed"), @ApiResponse(code = 500, message = "Server configuration not found", response = IOException.class) }) @Get("json") public String getServerInformation() throws IOException{ JsonObject responseObject = getSuccessResponse(null); JsonSimpleConfig config = new JsonSimpleConfig(); responseObject.put("institution", config.getString(null, "identity","institution")); responseObject.put("applicationVersion", config.getString(null, "redbox.version.string")); JSONArray packageTypes = new JSONArray(); if ("mint".equals(config.getString(null, "system"))) { packageTypes.addAll(getPackageTypesFromFileSystem()); } else { JsonObject packageTypesObject = config.getObject("portal", "packageTypes"); packageTypes.addAll(packageTypesObject.keySet()); } responseObject.put("packageTypes", packageTypes); return new JsonSimple(responseObject).toString(true); }
/** * Generates the report specific query from parameters */ @Override public String getQueryAsString() { String query = ""; JsonObject queryFilters = config.getObject("query", "filter"); String[] keyArray = Arrays.copyOf( new ArrayList<Object>(queryFilters.keySet()).toArray(), queryFilters.keySet().size(), String[].class); List<String> keys = Arrays.asList(keyArray); java.util.Collections.sort(keys); query += processDateCriteria(queryFilters); query += processShowCriteria(queryFilters); return query; }
/** * Wrap a JsonObject in this class * * @param newJsonObject : The JsonObject to wrap */ public JsonSimple(JsonObject newJsonObject) { substitueProperties = true; if (newJsonObject == null) { newJsonObject = new JsonObject(); } jsonObject = newJsonObject; }