/** * Get JSON text from the Representation entity * @param entity json * @return String or null */ private String getJSONText(JsonRepresentation entity) { try { return entity.getText(); } catch (Exception e) { return null; } } }
/** * Get JSON text from the Representation entity * @param entity json * @return String or null */ private String getJSONText(JsonRepresentation entity) { try { return entity.getText(); } catch (Exception e) { return null; } } }
/** * Get JSON text from the Representation entity * @param entity json * @return String or null */ private String getJSONText(JsonRepresentation entity) { try { return entity.getText(); } catch (Exception e) { return null; } } }
/** * Get JSON text from the Representation entity * @param entity json * @return String or null */ private String getJSONText(JsonRepresentation entity) { try { return entity.getText(); } catch (Exception e) { return null; } } }
@ApiOperation(value = "updates the record's Object Metadata", tags="objectmeta") @ApiImplicitParams({ @ApiImplicitParam(name = "skipReindex", value="Skip the reindex process. Useful if you are batching many changes to a ReDBox object at once.", required = false, allowMultiple = false, defaultValue = "false", dataType = "string") }) @ApiResponses({ @ApiResponse(code = 200, message = "The object metadata is updated"), @ApiResponse(code = 500, message = "General Error", response = Exception.class) }) @Post("json") public String updateMetadataResource(JsonRepresentation data) throws IOException, PluginException, MessagingException { Storage storage = (Storage) ApplicationContextProvider.getApplicationContext().getBean("fascinatorStorage"); String oid = getAttribute("oid"); JsonSimple metadataJson = new JsonSimple(data.getText()); JsonObject metadataObject = metadataJson.getJsonObject(); DigitalObject digitalObject = StorageUtils.getDigitalObject(storage, oid); Properties metadata = digitalObject.getMetadata(); for (Object key : metadataObject.keySet()) { metadata.setProperty((String) key, (String) metadataObject.get(key)); } ByteArrayOutputStream output = new ByteArrayOutputStream(); metadata.store(output, null); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); StorageUtils.createOrUpdatePayload(digitalObject, "TF-OBJ-META", input); reindex(oid); return getSuccessResponseString(oid); }
JsonSimple metadataJson = new JsonSimple(data.getText());
@ApiOperation(value = "Queues a message on the specified message queue", tags = "messaging") @ApiResponses({ @ApiResponse(code = 200, message = "The record's metadata is updated"), @ApiResponse(code = 500, message = "General Error", response = Exception.class) }) @Post("json") public String sendMessageToQueue(JsonRepresentation data) throws IOException, MessagingException { MessagingServices ms = MessagingServices.getInstance(); String messageQueue = getAttribute("messageQueue"); String message = data.getText(); ms.queueMessage(messageQueue, message); return getSuccessResponseString(null); }
@ApiOperation(value = "updates the record's metadata", tags = "recordmeta") @ApiImplicitParams({ @ApiImplicitParam(name = "skipReindex", value = "Skip the reindex process. Useful if you are batching many changes to a ReDBox object at once.", required = false, allowMultiple = false, defaultValue = "false", dataType = "string") }) @ApiResponses({ @ApiResponse(code = 200, message = "The record's metadata is updated"), @ApiResponse(code = 500, message = "General Error", response = Exception.class) }) @Post("json") public String updateMetadataResource(JsonRepresentation data) throws IOException, PluginException, MessagingException { JsonSimpleConfig config = new JsonSimpleConfig(); Storage storage = (Storage) ApplicationContextProvider.getApplicationContext().getBean("fascinatorStorage"); String oid = getAttribute("oid"); JsonSimple metadataJson = new JsonSimple(data.getText()); DigitalObject digitalObject = StorageUtils.getDigitalObject(storage, oid); String payloadId; if ("mint".equals(config.getString(null, "system"))) { payloadId = "metadata.json"; } else { payloadId = findTfPackagePayload(digitalObject); } StorageUtils.createOrUpdatePayload(digitalObject, payloadId, IOUtils.toInputStream(metadataJson.toString(true), "UTF-8")); reindex(oid); return getSuccessResponseString(oid); }
@ApiOperation(value = "create a new ReDBox Object", tags = "object") @ApiImplicitParams({ @ApiImplicitParam(name = "skipReindex", value = "Skip the reindex process. Useful if you are batching many changes to a ReDBox object at once.", required = false, allowMultiple = false, dataType = "boolean"), @ApiImplicitParam(name = "oid", value = "The desired object identifier. If not supplied, one will be randomly generated", required = false, allowMultiple = false, dataType = "string") }) @ApiResponses({ @ApiResponse(code = 200, message = "An object is created"), @ApiResponse(code = 500, message = "General Error", response = Exception.class) }) @Post("json") public String harvestObjects(JsonRepresentation data) throws IOException, PluginException, MessagingException { JsonObject responseJsonObject = new JsonObject(); String packageType = getAttribute("packageType"); JSONArray responses = new JSONArray(); JsonSimple batchJson = new JsonSimple(data.getText()); JSONArray recordsArray = batchJson.getArray("records"); for (Object recordObject : recordsArray) { JsonObject processResult = processRecord((JsonObject) recordObject, packageType); try { responses.add(processResult); } catch (Exception e) { log.error("Error processing record in harvest", e); JsonObject responseObject = new JsonObject(); responseObject.put("status", "error"); responseObject.put("reason", ExceptionUtils.getStackTrace(e)); responses.add(responseObject); } } responseJsonObject.put("results", responses); return new JsonSimple(responseJsonObject).toString(); }