Properties props = object.getMetadata(); props.setProperty("render-pending", "true"); String configOid = props.getProperty("jsonConfigOid"); props.remove("userPriority"); object.close(); Payload payload = configObj.getPayload(configObj.getSourceId()); configFile = File.createTempFile("reharvest", ".json"); OutputStream out = new FileOutputStream(configFile); out.close(); payload.close(); configObj.close();
throws StorageException { List<String> plugins = new ArrayList<String>(); Properties props = object.getMetadata(); String user = props.getProperty("userPriority"); if (user != null && user.equals("true")) { log.info("User priority flag set: '{}'", object.getId()); plugins.add(CRITICAL_USER_SELECTOR); props.remove("userPriority"); object.close();
private String findTFPackageId(String storageId) throws StorageException { DigitalObject object = storage.getObject(storageId); if (object.getPayload("metadata.tfpackage") != null) { return "metadata.tfpackage"; } for (String payloadId : object.getPayloadIdList()) { if (payloadId.endsWith(".tfpackage")) { return payloadId; } } return "metadata.tfpackage"; }
public static Payload createOrUpdatePayload(DigitalObject object, String pid, InputStream in, String filePath) throws StorageException { Payload payload = null; try { if (filePath == null) { payload = object.createStoredPayload(pid, in); } else { payload = object.createLinkedPayload(pid, filePath); } } catch (StorageException ex) { try { payload = object.updatePayload(pid, in); } catch (StorageException ex1) { throw ex1; } } return payload; }
/** * Clear the render flag for objects that have finished in the tool chain * * @param oid The object to clear */ private void clearRenderFlag(String oid) { try { DigitalObject object = storage.getObject(oid); Properties props = object.getMetadata(); props.setProperty("render-pending", "false"); object.close(); } catch (StorageException ex) { log.error("Error accessing storage for '{}'", oid, ex); } }
String oid = in.getId(); Payload workflowPayload = in.getPayload("workflow.metadata"); workflow = new JsonSimple(workflowPayload.open()); workflowPayload.close(); metadata = in.getMetadata(); } catch (StorageException ex) { error("Error reading Object metadata!\nOID: '" + oid + "'", ex);
try { metadata = object.getMetadata(); String oldMod = metadata.getProperty("lastModified"); object.updatePayload(object.getSourceId(), in); object.close(); return object; metadata = object.getMetadata(); metadata.setProperty("lastModified", lastMod); metadata.setProperty("fileHash", hashFile(file)); object.close(); return object; } catch (IOException ex1) {
/** * Get the metadata properties for the indicated object. * * @param oid The object we want config for */ private Properties getObjectMetadata(String oid) { try { DigitalObject object = storage.getObject(oid); return object.getMetadata(); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); return null; } }
/** * Get a payload object in the specified Storage instance by its object ID * and the name of payload * * @param storage : Storage object * @param oid : ID of a Digital object * @param payloadName : name of payload * @return a Payload object * @throws StorageException */ public static Payload getPayload(Storage storage, String oid, String payloadName) throws StorageException { DigitalObject digitalObject = getDigitalObject(storage, oid); Payload payload = digitalObject.getPayload(payloadName); return payload; }
try { payload = object.getPayload(payloadId); } catch (IOException ex) { log.error("Error parsing existing JSON: '{}' => '{}'", object.getId(), payloadId); throw new HarvesterException( "Error parsing existing JSON: ", ex); object.updatePayload(payloadId, in); payload = object.createStoredPayload(payloadId, in);
private Properties setObjectMetadata(DigitalObject recordObject, JsonObject record, String packageType, boolean created) throws IOException, StorageException { Properties objectMetadata = recordObject.getMetadata(); objectMetadata.put("objectId", recordObject.getId()); objectMetadata.put("render-pending", "true"); objectMetadata.put("owner", "admin"); objectMetadata.setProperty("scriptType", scriptType); objectMetadata.setProperty("rulesOid", rulesObject.getId()); objectMetadata.setProperty("rulesPid", rulesObject.getSourceId()); objectMetadata.setProperty("jsonConfigOid", rulesConfigObject.getId()); objectMetadata.setProperty("jsonConfigPid", rulesConfigObject.getSourceId());
JsonSimple workflow, Properties metadata) throws TransformerException { String oid = object.getId(); String title = workflow.getString(null, Strings.NODE_FORMDATA, "title"); FedoraClient fedora = null; vitalPid = createNewObject(fedora, object.getId()); log.debug("New VITAL object created: '{}'", vitalPid); metadata.setProperty(Strings.PROP_VITAL_KEY, vitalPid); object.close(); } catch (Exception ex) { error("Failed to create object in VITAL", ex, oid, title); object.close();
Properties metadata = object.getMetadata(); configOid = metadata.getProperty("jsonConfigOid"); configPid = metadata.getProperty("jsonConfigPid"); Payload payload = object.getPayload(configPid); try { return new JsonSimple(payload.open());
/** * Build a Log entry to use in Fedora. Replace all the template placeholders * * @param object The Object being submitted * @param pid The PID in our system */ private String fedoraLogEntry(DigitalObject object, String pid) { String message = fedoraMessageTemplate.replace("[[PID]]", pid); return message.replace("[[OID]]", object.getId()); }
try { for (String payloadId : in.getPayloadIdList()) { if (payloadId.endsWith(source)) { source = payloadId; log.info("Transforming PID: " + source + " from OID: " + in.getId()); sourcePayload = in.getPayload(source); } catch (StorageException ex) { log.error("Error accessing payload in storage: " + ex); vc.put("StringEscapeUtils", StringEscapeUtils.class); vc.put("Services", scriptingServices); vc.put("oid", in.getId()); vc.put("object", in); vc.put("urlBase", urlBase + portalId);
throws Exception { File directory = new File(tmpDir, object.getId()); File target = new File(directory, pid); if (!target.exists()) { Payload payload = object.getPayload(pid); InputStream in = payload.open(); FileOutputStream out = null;
String pid = object.getSourceId(); if (pid == null) { log.error("Configuration object '()' has no SOURCE payload!", oid); payload = object.getPayload(pid); } catch (StorageException ex) { log.error("Failed to retrieve payload '{}' > '{}' from storage",
Properties props = object.getMetadata(); String indexFlag = props.getProperty("indexOnHarvest"); if (indexFlag != null) { String oid = object.getId(); sendNotification(oid, "indexStart", "Indexing '" + oid + "' started");
@Override public void removeObject(String oid) throws StorageException { // log.debug("removeObject(" + oid + ")"); File objHome = getPath(oid); if (objHome.exists()) { DigitalObject object = new FileSystemDigitalObject(objHome, oid); String[] oldManifest = {}; oldManifest = object.getPayloadIdList().toArray(oldManifest); for (String pid : oldManifest) { try { object.removePayload(pid); } catch (StorageException ex) { log.error("Error deleting payload", ex); } } try { object.close(); FileUtils.deleteDirectory(objHome); } catch (IOException ex) { throw new StorageException("Error deleting object", ex); } } else { throw new StorageException("oID '" + oid + "' doesn't exist in storage : " + objHome.getPath()); } }
/** * Save the provided object data back into storage * * @param data The data to save * @param oid The object we want it saved in */ private void saveObjectData(JsonSimple data, String oid) throws TransactionException { // Get from storage DigitalObject object = null; try { object = storage.getObject(oid); object.getPayload(DATA_PAYLOAD_ID); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); throw new TransactionException(ex); } // Store modifications String jsonString = data.toString(true); try { InputStream inStream = new ByteArrayInputStream( jsonString.getBytes("UTF-8")); object.updatePayload(DATA_PAYLOAD_ID, inStream); } catch (Exception ex) { log.error("Unable to store data '{}': ", oid, ex); throw new TransactionException(ex); } }