/** * replace into low-level store content of Fedora object already in lowlevel store * * @return */ public final long replace(String pid, InputStream content, Map<String, String> hints) throws LowlevelStorageException { String filePath; File file = null; try { filePath = pathRegistry.get(pid); } catch (ObjectNotInLowlevelStorageException ffff) { LowlevelStorageException noPath = new LowlevelStorageException(false, "pid " + pid + " not in registry", ffff); throw noPath; } if (filePath == null || filePath.equals("")) { // guard against registry // implementation LowlevelStorageException nullPath = new LowlevelStorageException(true, "pid " + pid + " not in registry"); throw nullPath; } try { file = new File(filePath); } catch (Exception eFile) { // purposefully general catch-all LowlevelStorageException newFile = new LowlevelStorageException(true, "couldn't make new File for " + filePath, eFile); throw newFile; } long result = fileSystem.rewrite(file, content); if (hints != null && hints.containsKey(IrodsLowlevelStorageModule.STORAGE_LEVEL_HINT)) { fileSystem.setStorageLevel(file, hints.get(IrodsLowlevelStorageModule.STORAGE_LEVEL_HINT)); } return result; }
/** remove Fedora object from low-level store */ public final void remove(String pid) throws LowlevelStorageException { String filePath; File file = null; try { filePath = pathRegistry.get(pid); } catch (ObjectNotInLowlevelStorageException eReg) { throw eReg; } if (filePath == null || filePath.equals("")) { // guard against registry // implementation LowlevelStorageException nullPath = new LowlevelStorageException(true, "null path from registry for pid " + pid); throw nullPath; } try { file = new File(filePath); } catch (Exception eFile) { // purposefully general catch-all LowlevelStorageException newFile = new LowlevelStorageException(true, "couldn't make File for " + filePath, eFile); throw newFile; } pathRegistry.remove(pid); fileSystem.delete(file); }
/** get content of Fedora object from low-level store */ public final InputStream retrieve(String pid) throws LowlevelStorageException { String filePath = this.getIrodsPath(pid); File file; try { filePath = this.getIrodsPath(pid); } catch (ObjectNotInLowlevelStorageException eReg) { throw eReg; } if (filePath == null || filePath.equals("")) { // guard against registry // implementation LowlevelStorageException nullPath = new LowlevelStorageException(true, "null path from registry for pid " + pid); throw nullPath; } try { file = new File(filePath); } catch (Exception eFile) { // purposefully general catch-all LowlevelStorageException newFile = new LowlevelStorageException(true, "couldn't make File for " + filePath, eFile); throw newFile; } return fileSystem.read(file); }
public IRODSQueryResultSet getMetadata(String pid) throws LowlevelStorageException { String filePath; filePath = pathRegistry.get(pid); if (filePath == null || filePath.equals("")) { // guard against registry // implementation LowlevelStorageException nullPath = new LowlevelStorageException(true, "null path from registry for pid " + pid); throw nullPath; } return fileSystem.getMetadata(filePath); }
/** * add to lowlevel store content of Fedora object not already in lowlevel store * * @return */ public final long add(String pid, InputStream content, Map<String, String> hints) throws LowlevelStorageException { String filePath; File file = null; try { // check that object is not already in store filePath = pathRegistry.get(pid); ObjectAlreadyInLowlevelStorageException already = new ObjectAlreadyInLowlevelStorageException("" + pid); throw already; } catch (ObjectNotInLowlevelStorageException not) { // OK: keep going } filePath = pathAlgorithm.get(pid); if (filePath == null || filePath.equals("")) { // guard against // algorithm // implementation LowlevelStorageException nullPath = new LowlevelStorageException(true, "null path from algorithm for pid " + pid); throw nullPath; } try { file = new File(filePath); } catch (Exception eFile) { // purposefully general catch-all LowlevelStorageException newFile = new LowlevelStorageException(true, "couldn't make File for " + filePath, eFile); throw newFile; } long size = fileSystem.write(file, content); if (hints != null && hints.containsKey(IrodsLowlevelStorageModule.STORAGE_LEVEL_HINT)) { fileSystem.setStorageLevel(file, hints.get(IrodsLowlevelStorageModule.STORAGE_LEVEL_HINT)); } pathRegistry.put(pid, filePath); irodsPathCache.put(pid, filePath); return size; }