if (dso.getType() == Constants.ITEM)
{
Item item = (Item) dso;
new DSpace().getEventService().fireEvent(
new UsageEvent(
UsageEvent.Action.VIEW,
request,
context,
dso));
// Only use last-modified if this is an anonymous access
// - caching content that may be generated under authorisation
// is a security problem
if (context.getCurrentUser() == null)
{
response.setDateHeader("Last-Modified", item
.getLastModified().getTime());
// Check for if-modified-since header
long modSince = request.getDateHeader("If-Modified-Since");
if (modSince != -1 && item.getLastModified().getTime() < modSince)
{
// Item has not been modified since requested date,
// hence bitstream has not; return 304
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
}
else
{
// Display the item page
displayItem(context, request, response, item, handle);
}
}
else
{
// Display the item page
displayItem(context, request, response, item, handle);
}
}
else if (dso.getType() == Constants.COLLECTION)
{
Collection c = (Collection) dso;
new DSpace().getEventService().fireEvent(
new UsageEvent(
UsageEvent.Action.VIEW,
request,
context,
dso));
//UsageEvent ue = new UsageEvent();
//ue.fire(request, context, AbstractUsageEvent.VIEW,
// Constants.COLLECTION, dso.getID());
// Store collection location in request
request.setAttribute("dspace.collection", c);
/*
* Find the "parent" community the collection, mainly for
* "breadcrumbs" FIXME: At the moment, just grab the first community
* the collection is in. This should probably be more context
* sensitive when we have multiple inclusion.
*/
Community[] parents = c.getCommunities();
request.setAttribute("dspace.community", parents[0]);
/*
* Find all the "parent" communities for the collection for
* "breadcrumbs"
*/
request.setAttribute("dspace.communities", getParents(parents[0],
true));
// home page, or forward to another page?
if ((extraPathInfo == null) || (extraPathInfo.equals("/")))
{
collectionHome(context, request, response, parents[0], c);
}
else
{
// Forward to another servlet
request.getRequestDispatcher(extraPathInfo).forward(request,
response);
}
}
else if (dso.getType() == Constants.COMMUNITY)
{
Community c = (Community) dso;
new DSpace().getEventService().fireEvent(
new UsageEvent(
UsageEvent.Action.VIEW,
request,
context,
dso));