@Override public DigitalObject getObject(String oid) throws StorageException { return storagePlugin.getObject(oid); }
@Override public void init(File jsonFile) throws PluginException { storagePlugin.init(jsonFile); }
/** * Shut down the transformer plugin */ @Override public void shutdown() throws PluginException { if (storage != null) { storage.shutdown(); } } }
/** * Gets a DigitalObject from the specified Storage instance. If the object * does not exist, this method will attempt to create it. * * @param storage a Storage instance * @param oid the object identifier to get (or create) * @return a DigitalObject * @throws StorageException if the object could not be retrieved or created */ public static DigitalObject getDigitalObject(Storage storage, String oid) throws StorageException { DigitalObject object = null; try { // try to create a new object object = storage.createObject(oid); } catch (StorageException ex) { // object exists, try and get it try { object = storage.getObject(oid); } catch (StorageException ex1) { // could not be created and not found throw new StorageException(ex1); } } return object; }
public SpringStorageWrapper() { // initialise storage system JsonSimpleConfig systemConfiguration; try { systemConfiguration = new JsonSimpleConfig(); } catch (IOException e) { throw new RuntimeException(e); } String storageType = systemConfiguration.getString( DEFAULT_STORAGE_TYPE, "storage", "type"); storagePlugin = PluginManager.getStorage(storageType); if (storagePlugin == null) { throw new RuntimeException("Storage plugin '" + storageType + "'. Ensure it is in the classpath."); } try { storagePlugin.init(systemConfiguration.toString()); log.debug("Storage service has been initialiased: {}", storagePlugin.getName()); } catch (PluginException pe) { throw new RuntimeException("Failed to initialise storage", pe); } }
/** * 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"); }
if (deleted) { log.info("Removing object {}...", oid); storage.removeObject(oid); indexer.remove(oid); indexer.annotateRemove(oid); object = storage.getObject(oid); object = conveyer.transform(object, config); indexObject(config);
@Override public void removeObject(String oid) throws StorageException { storagePlugin.removeObject(oid); }
@Override public Set<String> getObjectIdList() { return storagePlugin.getObjectIdList(); }
@Override public DigitalObject createObject(String oid) throws StorageException { // everyone can create objects return storage.createObject(oid); }
@Override public String getName() { return storage.getName() + " (secure)"; }
/** * Set the default setting */ public void setSetting() { // Get the storage type to be indexed... try { storage = PluginManager.getStorage(config.getString( DEFAULT_STORAGE_TYPE, "storage", "type")); storage.init(configFile); indexer = PluginManager.getIndexer(config.getString( DEFAULT_INDEXER_TYPE, "indexer", "type")); indexer.init(configFile); rulesList = new ArrayList<String>(); log.info("Loaded {} and {}", realStorage.getName(), indexer .getName()); } catch (Exception e) { log.error("Failed to initialise storage", e); return; } }
rulesObj = realStorage.getObject(rulesOid); rulesObj = realStorage.createObject(rulesOid); InputStream in = new FileInputStream(externalFile); Payload p = rulesObj.createStoredPayload(
@Override public void removeObject(String oid) throws StorageException { DigitalObject tempObj = getObject(oid); log.debug("Closing temp object."); tempObj.close(); log.debug("Temp object closed."); storage.removeObject(oid); }
@Override public Set<String> getObjectIdList() { // TODO Filter list depending on access return storage.getObjectIdList(); }
@Override public DigitalObject createObject(String oid) throws StorageException { return storagePlugin.createObject(oid); }
@Override public String getName() { return storagePlugin.getName(); }
/** * 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; } }
@Override public void init(String jsonString) throws PluginException { storagePlugin.init(jsonString); }
/** * Shut down the transformer plugin */ @Override public void shutdown() throws PluginException { if (storage != null) { storage.shutdown(); } } }