@Override public String get(String pid) throws LowlevelStorageException { String result; try { result = hashtable.get(pid); } catch (Exception e) { throw new LowlevelStorageException(true, "SimplePathRegistry.get(" + pid + ")", e); } if (null == result || 0 == result.length()) { throw new ObjectNotInLowlevelStorageException("SimplePathRegistry.get(" + pid + "): object not found"); } return result; }
@Override public String get(String pid) throws LowlevelStorageException { String result; try { result = hashtable.get(pid); } catch (Exception e) { throw new LowlevelStorageException(true, "SimplePathRegistry.get(" + pid + ")", e); } if (null == result || 0 == result.length()) { throw new ObjectNotInLowlevelStorageException("SimplePathRegistry.get(" + pid + "): object not found"); } return result; }
private void ensureSingleUpdate(Statement statement) throws ObjectNotInLowlevelStorageException, LowlevelStorageInconsistencyException, LowlevelStorageException { try{ int updateCount = statement.getUpdateCount(); if (updateCount == 0) { throw new ObjectNotInLowlevelStorageException("Object not found in low-level storage: -no- rows updated in db registry"); } if (updateCount > 1) { throw new LowlevelStorageInconsistencyException("-multiple- rows updated in db registry"); } } catch (SQLException e1) { throw new LowlevelStorageException(true, "sql failurex (exec)", e1); } }
private void ensureSingleUpdate(Statement statement) throws ObjectNotInLowlevelStorageException, LowlevelStorageInconsistencyException, LowlevelStorageException { try{ int updateCount = statement.getUpdateCount(); if (updateCount == 0) { throw new ObjectNotInLowlevelStorageException("Object not found in low-level storage: -no- rows updated in db registry"); } if (updateCount > 1) { throw new LowlevelStorageInconsistencyException("-multiple- rows updated in db registry"); } } catch (SQLException e1) { throw new LowlevelStorageException(true, "sql failurex (exec)", e1); } }
@Override public void remove(String pid) throws ObjectNotInLowlevelStorageException, LowlevelStorageInconsistencyException, LowlevelStorageException { try { executeUpdate(deleteByIdQuery, pid); } catch (ObjectNotInLowlevelStorageException e1) { throw new ObjectNotInLowlevelStorageException("[" + pid + "] not in db registry to delete", e1); } catch (LowlevelStorageInconsistencyException e2) { throw new LowlevelStorageInconsistencyException("[" + pid + "] deleted from db registry -multiple- times", e2); } }
@Override public void remove(String pid) throws ObjectNotInLowlevelStorageException, LowlevelStorageInconsistencyException, LowlevelStorageException { try { executeUpdate(deleteByIdQuery, pid); } catch (ObjectNotInLowlevelStorageException e1) { throw new ObjectNotInLowlevelStorageException("[" + pid + "] not in db registry to delete", e1); } catch (LowlevelStorageInconsistencyException e2) { throw new LowlevelStorageInconsistencyException("[" + pid + "] deleted from db registry -multiple- times", e2); } }
"token", "path"}, new String[] {pid, path}, "token"); } catch (SQLException e1) { throw new ObjectNotInLowlevelStorageException("put into db registry failed for [" + pid + "]", e1);
"token", "path"}, new String[] {pid, path}, "token"); } catch (SQLException e1) { throw new ObjectNotInLowlevelStorageException("put into db registry failed for [" + pid + "]", e1);
private static long getSize(BlobStore store, String key) throws ObjectNotInLowlevelStorageException { BlobStoreConnection connection = null; boolean successful = false; try { URI blobId = getBlobId(key); connection = getConnection(store, null); Blob blob = getBlob(connection, blobId, null); return blob.getSize(); } catch (MissingBlobException e) { throw new ObjectNotInLowlevelStorageException("Object not found in low-level storage: " + key); } catch (IOException e) { // should never happen throw new RuntimeException("Error reading blob size: " +e.getMessage(), e); } finally { if (!successful) { closeConnection(connection); } } }
private static long getSize(BlobStore store, String key) throws ObjectNotInLowlevelStorageException { BlobStoreConnection connection = null; boolean successful = false; try { URI blobId = getBlobId(key); connection = getConnection(store, null); Blob blob = getBlob(connection, blobId, null); return blob.getSize(); } catch (MissingBlobException e) { throw new ObjectNotInLowlevelStorageException("Object not found in low-level storage: " + key); } catch (IOException e) { // should never happen throw new RuntimeException("Error reading blob size: " +e.getMessage(), e); } finally { if (!successful) { closeConnection(connection); } } }
throw new ObjectNotInLowlevelStorageException("no path in db registry for [" + pid + "]");
throw new ObjectNotInLowlevelStorageException("no path in db registry for [" + pid + "]");
private static InputStream retrieve(BlobStore store, String key) throws ObjectNotInLowlevelStorageException { BlobStoreConnection connection = null; InputStream content = null; boolean successful = false; try { URI blobId = getBlobId(key); connection = getConnection(store, null); Blob blob = getBlob(connection, blobId, null); content = openInputStream(blob); successful = true; return new ConnectionClosingInputStream(connection, content); } catch (MissingBlobException e) { throw new ObjectNotInLowlevelStorageException("Object not found in low-level storage: " + key); } finally { if (!successful) { IOUtils.closeQuietly(content); closeConnection(connection); } } }
private static InputStream retrieve(BlobStore store, String key) throws ObjectNotInLowlevelStorageException { BlobStoreConnection connection = null; InputStream content = null; boolean successful = false; try { URI blobId = getBlobId(key); connection = getConnection(store, null); Blob blob = getBlob(connection, blobId, null); content = openInputStream(blob); successful = true; return new ConnectionClosingInputStream(connection, content); } catch (MissingBlobException e) { throw new ObjectNotInLowlevelStorageException("Object not found in low-level storage: " + key); } finally { if (!successful) { IOUtils.closeQuietly(content); closeConnection(connection); } } }
private static void remove(BlobStore store, String key) throws ObjectNotInLowlevelStorageException { BlobStoreConnection connection = null; try { URI blobId = getBlobId(key); connection = getConnection(store, null); Blob blob = getBlob(connection, blobId, null); if (exists(blob)) { delete(blob); } else { throw new ObjectNotInLowlevelStorageException("Object not found in low-level storage: " + key); } } finally { closeConnection(connection); } }
private static void remove(BlobStore store, String key) throws ObjectNotInLowlevelStorageException { BlobStoreConnection connection = null; try { URI blobId = getBlobId(key); connection = getConnection(store, null); Blob blob = getBlob(connection, blobId, null); if (exists(blob)) { delete(blob); } else { throw new ObjectNotInLowlevelStorageException("Object not found in low-level storage: " + key); } } finally { closeConnection(connection); } }
throw new ObjectNotInLowlevelStorageException("Object not found in low-level storage: " + key);
throw new ObjectNotInLowlevelStorageException("Object not found in low-level storage: " + key);
@Test public void testExceptionResponses() throws Exception { Response output = null; output = test.handleException(new ObjectNotFoundException("This is testing exception handling"), false); assertEquals(HttpStatus.SC_NOT_FOUND, output.getStatus()); output = test.handleException(new ObjectNotInLowlevelStorageException("This is testing exception handling"), false); assertEquals(HttpStatus.SC_NOT_FOUND, output.getStatus()); output = test.handleException(new DatastreamNotFoundException("This is testing exception handling"), false); assertEquals(HttpStatus.SC_NOT_FOUND, output.getStatus()); output = test.handleException(new ObjectLockedException("This is testing exception handling"), false); assertEquals(HttpStatus.SC_CONFLICT, output.getStatus()); output = test.handleException(new DatastreamLockedException("This is testing exception handling"), false); assertEquals(HttpStatus.SC_CONFLICT, output.getStatus()); output = test.handleException(new RangeNotSatisfiableException("This is testing exception handling"), false); assertEquals(HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE, output.getStatus()); }