Commit b9e4f189 authored by shake's avatar shake
Browse files

Fixed 2 bugs in retrieve servlet - One which cause an exception when multiple...

Fixed 2 bugs in retrieve servlet - One which cause an exception when multiple collections had the same name, and another which caused a 403 forbidden when proxy data was set to true.

git-svn-id: https://subversion.umiacs.umd.edu/ace/trunk@188 f1b3a171-7291-4a19-a512-95ad0ad9394a
parent 19f8769f
......@@ -66,7 +66,7 @@ public final class RetrieveItemServlet extends EntityManagerServlet {
Collection coll;
MonitoredItem item = null;
String urlPath;
String collection;
Long collection;
String collectionPath = null;
......@@ -77,21 +77,22 @@ public final class RetrieveItemServlet extends EntityManagerServlet {
urlPath = request.getPathInfo().substring(1);
if ( urlPath.contains("/") ) {
collection = urlPath.substring(0, urlPath.indexOf("/"));
collectionPath = urlPath.substring(collection.length());
collection =
Long.parseLong(urlPath.substring(0, urlPath.indexOf("/")));
collectionPath = urlPath.substring(collection.toString().length());
} else {
collection = urlPath;
collection = Long.parseLong(urlPath);
}
LOG.trace("Looking up item, collection: " + collection + " path: " + collectionPath);
if ( (coll = resolveCollection(collection, em)) == null ) {
if ( (coll = em.find(Collection.class, collection)) == null ) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
if (SettingsUtil.getBoolean(coll, ConfigConstants.ATTR_PROXY_DATA)) {
// if ( !coll.isProxyData() ) {
if (!SettingsUtil.getBoolean(coll, ConfigConstants.ATTR_PROXY_DATA)) {
//if ( !coll.isProxyData() ) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
......@@ -119,19 +120,6 @@ public final class RetrieveItemServlet extends EntityManagerServlet {
}
private Collection resolveCollection( String collection, EntityManager em ) {
Query q = em.createNamedQuery("Collection.getCollectionByName");
q.setParameter("name", collection);
try {
return (Collection) q.getSingleResult();
} catch ( NoResultException nre ) {
LOG.info("Attempt to access non-existent collection: " + collection);
return null;
}
}
private void writeItemToResponse( HttpServletResponse response,
String collectionPath, Collection coll, EntityManager em ) throws IOException {
DigestInputStream dis = null;
......
......@@ -201,7 +201,6 @@ public final class AuditThread extends Thread implements CancelCallback {
}
*
*/
System.out.println(!auditOnly);
if( !auditOnly ) {
fallback = !openIms();
if ( !fallback ) {
......
......@@ -166,7 +166,7 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library.
</m:Auth>
<m:Auth role="Download Item">
<c:if test="${selectedFile.root.parentCollection.settings['proxy.data']}">
<a href="Path/${selectedFile.root.parentCollection.name}${selectedFile.root.path}">Download Item</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="Path/${selectedFile.root.parentCollection.id}${selectedFile.root.path}">Download Item</a>&nbsp;&nbsp;&nbsp;&nbsp;
</c:if>
</m:Auth>
<m:Auth role="Show Duplicates">
......
......@@ -43,8 +43,8 @@
<c:forEach items="${results.ingestedItems}" var="entry">
<p class="collName">Collection: ${entry.key.name}</p>
<div class="ingestContent">
<c:forEach items="${entry.value}" var="what">
<li>${what}</li>
<c:forEach items="${entry.value}" var="token">
<li>${token}</li>
</c:forEach>
</div>
</c:forEach>
......
......@@ -11,7 +11,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>System Settings</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment