@Override public DigitalObject getObject(String oid) throws StorageException { return storagePlugin.getObject(oid); }
/** * Start to run the indexing */ public void run() { DateFormat df = new SimpleDateFormat(DATETIME_FORMAT); String now = df.format(new Date()); long start = System.currentTimeMillis(); log.info("Started at " + now); rulesFile = new File(configFile.getParentFile(), config.getString( null, "indexer", "script", "rules")); log.debug("rulesFile=" + rulesFile); // Check storage for our rules file String rulesOid = rulesFile.getAbsolutePath(); updateRules(rulesOid); // List all the DigitalObjects in the storages Set<String> objectIdList = realStorage.getObjectIdList(); for (String objectId : objectIdList) { try { DigitalObject object = realStorage.getObject(objectId); processObject(object, rulesOid, config.getObject("indexer", "params"), false); } catch (StorageException ex) { log.error("Error getting rules file", ex); } catch (IOException ex) { log.error("Error Processing object", ex); } } log.info("Completed in " + ((System.currentTimeMillis() - start) / 1000.0) + " seconds"); }
/** * Retrieve an object from storage and return once instantiated. * * @param oid The ID of the object to retrieve * @param DigitalObject An instantiated object */ private DigitalObject getObjectFromStorage(String oid) { try { return storage.getObject(oid); } catch (StorageException ex) { log.error("Error accessing OID: '{}'", oid, ex); return null; } }
/** * 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 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; } }
/** * Retrieve a Payload from storage * * @param oid The Object ID of the object in storage * @param pid The Payload ID in the object * @return Payload An instantiated Payload Object, or null for errors */ private Payload getPayload(String oid, String pid) { // Get the object from storage DigitalObject digitalObject = null; try { digitalObject = storage.getObject(oid); } catch (StorageException ex) { log.error("Retrieving OID '{}' failed!: ", oid, ex); return null; } // Return the payload... if it exists try { return digitalObject.getPayload(pid); } catch (StorageException ex) { return null; } }
/** * Retrieve the metadata properties from storage for the request OID. * * @param oid The Object ID of the object in storage * @return Properties An instantiated Properties Object, or null for errors */ private Properties getMetadata(String oid) { // Get the object from storage DigitalObject digitalObject = null; try { digitalObject = storage.getObject(oid); } catch (StorageException ex) { log.error("Retrieving OID '{}' failed!: ", oid, ex); return null; } // Retrieve the key/value metadata list try { return digitalObject.getMetadata(); } catch (StorageException ex) { log.error("Retrieving metadata for OID '{}' failed!: ", oid, ex); return null; } }
/** * 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); } }
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"; }
/** * 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); } }
/** * Set the render flag for objects that are starting in the tool chain * * @param oid * The object to set */ private void setRenderFlag(String oid) { try { DigitalObject object = storage.getObject(oid); Properties props = object.getMetadata(); props.setProperty("render-pending", "true"); object.close(); } catch (StorageException ex) { log.error("Error accessing storage for '{}'", oid, ex); } }
/** * Set the render flag for objects that are starting in the tool chain * * @param oid The object to set */ private void setRenderFlag(String oid) { try { DigitalObject object = storage.getObject(oid); Properties props = object.getMetadata(); props.setProperty("render-pending", "true"); object.close(); } catch (StorageException ex) { log.error("Error accessing storage for '{}'", oid, ex); } }
@Override public DigitalObject getObject(String oid) throws StorageException { DigitalObject obj = storage.getObject(oid); if (isAccessAllowed(obj)) { return obj; } throw new StorageException("Access denied"); }
/** * Indexing single object * * TODO: Might let the user to fill in form in the portal regards to which * rules to be used * * @param objectId Object Id to be indexed */ public void indexObject(String objectId) { DigitalObject object = null; try { object = realStorage.getObject(objectId); } catch (StorageException ex) { log.error("Error getting object", ex); } try { Properties sofMeta = object.getMetadata(); String rulesOid = sofMeta.getProperty("rulesOid"); if (!rulesList.contains(rulesOid)) { updateRules(rulesOid); rulesList.add(rulesOid); } processObject(object, rulesOid, null, true); } catch (StorageException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
DigitalObject object = storage.getObject(oid);
DigitalObject object = storage.getObject(oid); payload = getDataPayload(object); } catch (StorageException ex) {
/** * Index a specific payload * * @param oid : The identifier of the payload's object * @param pid : The identifier of the payload * @throws IndexerException if there were errors during indexing */ @Override public void index(String oid, String pid) throws IndexerException { try { DigitalObject object = storage.getObject(oid); Payload payload = object.getPayload(pid); index(object, payload); } catch (StorageException ex) { throw new IndexerException(ex); } }
/** * Index an annotation * * @param oid : The identifier of the annotation's object * @param pid : The identifier of the annotation * @throws IndexerException if there were errors during indexing */ @Override public void annotate(String oid, String pid) throws IndexerException { // At this stage this is identical to the 'index()' method // above, but there may be changes at a later date. try { DigitalObject object = storage.getObject(oid); Payload payload = object.getPayload(pid); annotate(object, payload); } catch (StorageException ex) { throw new IndexerException(ex); } }
/** * Index an object and all of its payloads * * @param oid : The identifier of the object * @throws IndexerException if there were errors during indexing */ @Override public void index(String oid) throws IndexerException { try { DigitalObject object = storage.getObject(oid); // Some workflow actions create payloads, so we can't iterate // directly against the object. String[] oldManifest = {}; oldManifest = object.getPayloadIdList().toArray(oldManifest); for (String payloadId : oldManifest) { Payload payload = object.getPayload(payloadId); index(object, payload); } } catch (StorageException ex) { throw new IndexerException(ex); } }
/** * 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); getDataPayload(object); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); throw new TransactionException(ex); } // Store modifications String jsonString = data.toString(true); try { updateDataPayload(object, jsonString); } catch (Exception ex) { log.error("Unable to store data '{}': ", oid, ex); throw new TransactionException(ex); } }