public void setRange(String rangeRequest) throws ServerException { if(rangeRequest != null && !rangeRequest.isEmpty() && !m_gotStream){ try{ ByteRangeInputStream range = new ByteRangeInputStream(m_stream, m_size, rangeRequest); setStream(range); m_size = range.length; m_httpStatus = HttpStatus.SC_PARTIAL_CONTENT; setContentRange(range.contentRange); } catch (IOException e) { throw new StreamIOException(e.getMessage(),e); } catch (IndexOutOfBoundsException e) { throw new RangeNotSatisfiableException(e.getMessage()); } } } /**
logger.error(re.getMessage(), re); throw re;
} else if (response.getStatusCode() == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { response.close(); throw new RangeNotSatisfiableException("External URL datastream request returned 416 Range Not Satisfiable"); } else { if (headOnly) { logger.error(re.getMessage(), re); throw re; } catch (Exception e) {
} else if (response.getStatusCode() == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { response.close(); throw new RangeNotSatisfiableException("External URL datastream request returned 416 Range Not Satisfiable"); } else { if (headOnly) { logger.error(re.getMessage(), re); throw re; } catch (Exception e) {
public void setRange(String rangeRequest) throws ServerException { if(rangeRequest != null && !rangeRequest.isEmpty() && !m_gotStream){ try{ ByteRangeInputStream range = new ByteRangeInputStream(m_stream, m_size, rangeRequest); setStream(range); m_size = range.length; m_httpStatus = HttpStatus.SC_PARTIAL_CONTENT; setContentRange(range.contentRange); } catch (IOException e) { throw new StreamIOException(e.getMessage(),e); } catch (IndexOutOfBoundsException e) { throw new RangeNotSatisfiableException(e.getMessage()); } } } /**
logger.error(re.getMessage(), re); throw re;
@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()); }