mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-23 09:53:09 +00:00
Checking in HTMLSupport
git-svn-id: http://scm.dspace.org/svn/repo/trunk@763 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -202,7 +202,8 @@ CREATE TABLE Bundle
|
||||
(
|
||||
bundle_id INTEGER PRIMARY KEY,
|
||||
mets_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
||||
name VARCHAR(16) -- ORIGINAL | THUMBNAIL | TEXT
|
||||
name VARCHAR(16) -- ORIGINAL | THUMBNAIL | TEXT,
|
||||
primary_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id)
|
||||
);
|
||||
|
||||
-------------------------------------------------------
|
||||
|
@@ -260,6 +260,11 @@
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>html</servlet-name>
|
||||
<servlet-class>org.dspace.app.webui.servlet.HTMLServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>retrieve</servlet-name>
|
||||
<servlet-class>org.dspace.app.webui.servlet.RetrieveServlet</servlet-class>
|
||||
@@ -408,6 +413,11 @@
|
||||
<url-pattern>/register</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>html</servlet-name>
|
||||
<url-pattern>/html/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>retrieve</servlet-name>
|
||||
<url-pattern>/retrieve/*</url-pattern>
|
||||
|
@@ -57,6 +57,7 @@
|
||||
<%@ page import="org.dspace.app.webui.util.SubmissionInfo" %>
|
||||
<%@ page import="org.dspace.content.Bitstream" %>
|
||||
<%@ page import="org.dspace.content.BitstreamFormat" %>
|
||||
<%@ page import="org.dspace.content.Bundle" %>
|
||||
|
||||
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
|
||||
|
||||
@@ -69,7 +70,7 @@
|
||||
boolean showChecksums = ((Boolean) request.getAttribute("show.checksums")).booleanValue();
|
||||
%>
|
||||
|
||||
<dspace:layout locbar="off" navbar="off" title="Uploaded Files" nocache="true">
|
||||
<dspace:layout locbar="off" navbar="off" title="Uploaded Files">
|
||||
|
||||
<form action="<%= request.getContextPath() %>/submit" method=post>
|
||||
|
||||
@@ -92,6 +93,7 @@
|
||||
|
||||
<table class="miscTable" align=center>
|
||||
<tr>
|
||||
<th class="oddRowEvenCol">Primary<br>bitstream</th>
|
||||
<th class="oddRowOddCol">File</th>
|
||||
<th class="oddRowEvenCol">Size</th>
|
||||
<th class="oddRowOddCol">Description</th>
|
||||
@@ -120,6 +122,11 @@
|
||||
String row = "even";
|
||||
|
||||
Bitstream[] bitstreams = si.submission.getItem().getNonInternalBitstreams();
|
||||
Bundle[] bundles = null;
|
||||
|
||||
if (bitstreams[0] != null) {
|
||||
bundles = bitstreams[0].getBundles();
|
||||
}
|
||||
|
||||
for (int i = 0; i < bitstreams.length; i++)
|
||||
{
|
||||
@@ -141,6 +148,14 @@
|
||||
String supportLevelLink = "/help/formats.html#" + supportLevel;
|
||||
%>
|
||||
<tr>
|
||||
<td class="<%= row %>RowEvenCol" align="center">
|
||||
<input type="radio" name="primary_bitstream_id" value=<%= bitstreams[i].getID() %>
|
||||
<% if (bundles[0] != null) {
|
||||
if (bundles[0].getPrimaryBitstreamID() == bitstreams[i].getID()) { %>
|
||||
<%="checked" %>
|
||||
<% }
|
||||
} %> >
|
||||
</td>
|
||||
<td class="<%= row %>RowOddCol"><A HREF="<%= request.getContextPath() %>/retrieve/<%= bitstreams[i].getID() %>/<%= java.net.URLEncoder.encode(bitstreams[i].getName()) %>" target="_blank"><%= bitstreams[i].getName() %></A></td>
|
||||
<td class="<%= row %>RowEvenCol"><%= bitstreams[i].getSize() %> bytes</td>
|
||||
<td class="<%= row %>RowOddCol">
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -440,6 +440,23 @@ public class ItemTag extends TagSupport
|
||||
{
|
||||
// if item contains multiple non-license bundles, display bitstream description
|
||||
boolean multiFile = (bundles.length > 2);
|
||||
boolean html = false;
|
||||
Bitstream primaryBitstream = null;
|
||||
|
||||
// check if primary bitstream is html
|
||||
Bundle[] bunds = item.getBundles("ORIGINAL");
|
||||
if (bunds[0] != null)
|
||||
{
|
||||
Bitstream[] bits = bunds[0].getBitstreams();
|
||||
for (int i = 0; i < bits.length && !html; i++)
|
||||
{
|
||||
if (bits[i].getID() == bunds[0].getPrimaryBitstreamID())
|
||||
{
|
||||
html = bits[i].getFormat().getMIMEType().equals("text/html");
|
||||
primaryBitstream = bits[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.println("<table cellpadding=6><tr><th class=\"standard\">File</th>");
|
||||
if (multiFile)
|
||||
@@ -448,6 +465,30 @@ public class ItemTag extends TagSupport
|
||||
}
|
||||
out.println("<th class=\"standard\">Size</th class=\"standard\"><th class=\"standard\">Format</th></tr>");
|
||||
|
||||
// if primary bitstream is html, display a link for only that one to HTMLServlet
|
||||
if (html)
|
||||
{
|
||||
out.print("<tr><td class=\"standard\">");
|
||||
out.print(primaryBitstream.getName());
|
||||
if (multiFile)
|
||||
{
|
||||
out.print("</td><td class=\"standard\">");
|
||||
String desc = primaryBitstream.getDescription();
|
||||
out.print(desc != null ? desc : "");
|
||||
}
|
||||
out.print("</td><td class=\"standard\">");
|
||||
out.print(primaryBitstream.getSize() / 1024);
|
||||
out.print("Kb</td><td class=\"standard\">");
|
||||
out.print(primaryBitstream.getFormatDescription());
|
||||
out.print("</td><td class=\"standard\"><A TARGET=_blank HREF=\"");
|
||||
out.print(request.getContextPath());
|
||||
out.print("/html/");
|
||||
out.print(item.getHandle() + "/");
|
||||
out.print(URLEncoder.encode(primaryBitstream.getName()));
|
||||
out.print("\">View/Open</A></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < bundles.length; i++)
|
||||
{
|
||||
Bitstream[] bitstreams = bundles[i].getBitstreams();
|
||||
@@ -478,9 +519,11 @@ public class ItemTag extends TagSupport
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
out.println("</table>");
|
||||
}
|
||||
|
||||
out.println("</td></tr></table>");
|
||||
}
|
||||
}
|
||||
|
||||
|
196
dspace/src/org/dspace/app/webui/servlet/HTMLServlet.java
Normal file
196
dspace/src/org/dspace/app/webui/servlet/HTMLServlet.java
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* RetrieveServlet.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
package org.dspace.app.webui.servlet;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
import java.sql.SQLException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.webui.util.JSPManager;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.AuthorizeManager;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.handle.HandleManager;
|
||||
|
||||
/**
|
||||
* Servlet for HTML bitstream support.
|
||||
* <P>
|
||||
* <code>/html/handle/filename</code>
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class HTMLServlet extends DSpaceServlet
|
||||
{
|
||||
/** log4j category */
|
||||
private static Logger log = Logger.getLogger(HTMLServlet.class);
|
||||
|
||||
|
||||
protected void doDSGet(Context context,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
Bitstream bitstream = null;
|
||||
|
||||
// Get the ID from the URL
|
||||
String idString = request.getPathInfo();
|
||||
String filename = "";
|
||||
String handle = "";
|
||||
|
||||
if (idString != null)
|
||||
{
|
||||
|
||||
// Remove leading slash
|
||||
if (idString.startsWith("/"))
|
||||
{
|
||||
idString = idString.substring(1);
|
||||
}
|
||||
|
||||
// Get filename
|
||||
int slashIndex = idString.lastIndexOf('/');
|
||||
if (slashIndex != -1)
|
||||
{
|
||||
filename = idString.substring(slashIndex + 1);
|
||||
filename = URLDecoder.decode(filename);
|
||||
handle = idString.substring(0, slashIndex);
|
||||
}
|
||||
|
||||
// If there's still a second slash, remove it and anything after it,
|
||||
// it might be a relative directory name
|
||||
slashIndex = handle.indexOf('/');
|
||||
slashIndex = handle.indexOf('/', slashIndex + 1);
|
||||
if (slashIndex != -1)
|
||||
{
|
||||
handle = handle.substring(0, slashIndex);
|
||||
}
|
||||
|
||||
|
||||
// Find the corresponding bitstream
|
||||
try
|
||||
{
|
||||
boolean found = false;
|
||||
|
||||
Item item = (Item) HandleManager.resolveToObject(context, handle);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
log.info(LogManager.getHeader(context,
|
||||
"invalid_id",
|
||||
"path=" + handle));
|
||||
JSPManager.showInvalidIDError(request, response, handle, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
Bundle[] bundles = item.getBundles();
|
||||
for (int i = 0; i < bundles.length; i++) {
|
||||
Bitstream[] bitstreams = bundles[i].getBitstreams();
|
||||
if (!found) {
|
||||
for (int k = 0; k < bitstreams.length; k++) {
|
||||
if (filename.equals(bitstreams[k].getName())) {
|
||||
bitstream = bitstreams[k];
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//bitstream = Bitstream.find(context, id);
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
// Invalid ID - this will be dealt with below
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Did we get a bitstream?
|
||||
if (bitstream != null)
|
||||
{
|
||||
|
||||
log.info(LogManager.getHeader(context,
|
||||
"view_bitstream",
|
||||
"bitstream_id=" + bitstream.getID()));
|
||||
|
||||
// Set the response MIME type
|
||||
response.setContentType(bitstream.getFormat().getMIMEType());
|
||||
|
||||
// Response length
|
||||
response.setHeader("Content-Length",
|
||||
String.valueOf(bitstream.getSize()));
|
||||
|
||||
// Pipe the bits
|
||||
InputStream is = bitstream.retrieve();
|
||||
|
||||
Utils.bufferedCopy(is, response.getOutputStream());
|
||||
is.close();
|
||||
response.getOutputStream().flush();
|
||||
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -81,7 +81,6 @@ import org.dspace.eperson.EPerson;
|
||||
import org.dspace.workflow.WorkflowItem;
|
||||
import org.dspace.workflow.WorkflowManager;
|
||||
|
||||
|
||||
/**
|
||||
* Submission servlet for DSpace. Handles the initial submission of items, as
|
||||
* well as the editing of items further down the line.
|
||||
@@ -1257,12 +1256,30 @@ public class SubmitServlet extends DSpaceServlet
|
||||
{
|
||||
// Finished the uploading of files
|
||||
// FIXME Validation check here
|
||||
|
||||
// set primary bitstream
|
||||
if (request.getParameter("primary_bitstream_id") != null)
|
||||
{
|
||||
Bundle[] bundles = item.getBundles();
|
||||
bundles[0].setPrimaryBitstreamID(new Integer(request.getParameter("primary_bitstream_id")).intValue());
|
||||
bundles[0].update();
|
||||
}
|
||||
|
||||
userHasReached(subInfo, REVIEW_SUBMISSION);
|
||||
doStep(context, request, response, subInfo, REVIEW_SUBMISSION);
|
||||
context.complete();
|
||||
}
|
||||
else if (buttonPressed.equals("submit_more"))
|
||||
{
|
||||
// set primary bitstream
|
||||
if (request.getParameter("primary_bitstream_id") != null)
|
||||
{
|
||||
Bundle[] bundles = item.getBundles();
|
||||
bundles[0].setPrimaryBitstreamID(new Integer(request.getParameter("primary_bitstream_id")).intValue());
|
||||
bundles[0].update();
|
||||
context.commit();
|
||||
}
|
||||
|
||||
// Upload another file
|
||||
request.setAttribute("submission.info", subInfo);
|
||||
JSPManager.showJSP(request, response, "/submit/choose-file.jsp");
|
||||
|
@@ -85,7 +85,6 @@ public class Bundle extends DSpaceObject
|
||||
/** The bitstreams in this bundle */
|
||||
private List bitstreams;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a bundle object with the given table row
|
||||
*
|
||||
@@ -238,6 +237,30 @@ public class Bundle extends DSpaceObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the primary bitstream ID of the bundle
|
||||
*
|
||||
* @return primary bitstream ID
|
||||
* or -1 if not set
|
||||
*/
|
||||
public int getPrimaryBitstreamID()
|
||||
{
|
||||
return bundleRow.getIntColumn("primary_bitstream_id");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the primary bitstream ID of the bundle
|
||||
*
|
||||
* @param bitstreamID int ID of primary bitstream
|
||||
* (e.g. index html file)
|
||||
*/
|
||||
public void setPrimaryBitstreamID(int bitstreamID)
|
||||
{
|
||||
bundleRow.setColumn("primary_bitstream_id", bitstreamID);
|
||||
}
|
||||
|
||||
|
||||
public String getHandle()
|
||||
{
|
||||
// No Handles for bundles
|
||||
|
Reference in New Issue
Block a user