SF patch #1517488 Access Bitstreams in Withdrawn Items SF bug #1408373

git-svn-id: http://scm.dspace.org/svn/repo/trunk@1591 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Claudia Juergen
2006-09-04 12:07:12 +00:00
parent c6e5a20b15
commit 9a7155e9b5
2 changed files with 35 additions and 20 deletions

View File

@@ -29,6 +29,7 @@
(Claudia Juergen) (Claudia Juergen)
- SF patch #1514965 fixes SF bug #1505422. fix typo in SQL for item mapper - SF patch #1514965 fixes SF bug #1505422. fix typo in SQL for item mapper
- SF patch #1516988 Deleting owner of mapped items SF bug #1196724 - SF patch #1516988 Deleting owner of mapped items SF bug #1196724
- SF patch #1517488 Access Bitstreams in Withdrawn Items SF bug #1408373
(Richard Jones) (Richard Jones)
- SF bug #1515075. minor build file fix to copy correct config file - SF bug #1515075. minor build file fix to copy correct config file

View File

@@ -77,6 +77,7 @@ public class BitstreamServlet extends DSpaceServlet
SQLException, AuthorizeException SQLException, AuthorizeException
{ {
Bitstream bitstream = null; Bitstream bitstream = null;
boolean isWithdrawn = false;
// Get the ID from the URL // Get the ID from the URL
String idString = request.getPathInfo(); String idString = request.getPathInfo();
@@ -132,6 +133,9 @@ public class BitstreamServlet extends DSpaceServlet
return; return;
} }
// determine whether the item the bitstream belongs to has been withdrawn
isWithdrawn = item.isWithdrawn();
int sid = Integer.parseInt(sequence); int sid = Integer.parseInt(sequence);
boolean found = false; boolean found = false;
@@ -157,34 +161,44 @@ public class BitstreamServlet extends DSpaceServlet
} }
} }
// Did we get a bitstream? if (!isWithdrawn)
if (bitstream != null)
{ {
log.info(LogManager.getHeader(context, "view_bitstream", // Did we get a bitstream?
if (bitstream != null)
{
log.info(LogManager.getHeader(context, "view_bitstream",
"bitstream_id=" + bitstream.getID())); "bitstream_id=" + bitstream.getID()));
// Set the response MIME type // Set the response MIME type
response.setContentType(bitstream.getFormat().getMIMEType()); response.setContentType(bitstream.getFormat().getMIMEType());
// Response length // Response length
response.setHeader("Content-Length", String.valueOf(bitstream response.setHeader("Content-Length", String.valueOf(bitstream
.getSize())); .getSize()));
// Pipe the bits // Pipe the bits
InputStream is = bitstream.retrieve(); InputStream is = bitstream.retrieve();
Utils.bufferedCopy(is, response.getOutputStream()); Utils.bufferedCopy(is, response.getOutputStream());
is.close(); is.close();
response.getOutputStream().flush(); response.getOutputStream().flush();
}
// display the tombstone instead of the bitstream if the item is withdrawn
else
{
// No bitstream - we got an invalid ID
log.info(LogManager.getHeader(context, "view_bitstream",
"invalid_bitstream_id=" + idString));
JSPManager.showInvalidIDError(request, response, idString,
Constants.BITSTREAM);
}
} }
else else
{ {
// No bitstream - we got an invalid ID log.info(LogManager.getHeader(context, "view_bitstream", "item has been withdrawn"));
log.info(LogManager.getHeader(context, "view_bitstream", JSPManager.showJSP(request, response, "/tombstone.jsp");
"invalid_bitstream_id=" + idString));
JSPManager.showInvalidIDError(request, response, idString,
Constants.BITSTREAM);
} }
} }
} }