Added cleanup listeners. Updated Fileupload and IO dependencies to fix occassional upload problems, and improve application cleanup.

git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@2951 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2008-05-28 15:22:31 +00:00
parent 7e209122af
commit cc604e0ed3
8 changed files with 45 additions and 6 deletions

View File

@@ -507,7 +507,17 @@ public class ConfigurationManager
try
{
String configProperty = System.getProperty("dspace.configuration");
String configProperty = null;
try
{
configProperty = System.getProperty("dspace.configuration");
}
catch (SecurityException se)
{
// A security manager may stop us from accessing the system properties.
// This isn't really a fatal error though, so catch and ignore
log.warn("Unable to access system properties, ignoring.", se);
}
if (configFile != null)
{

View File

@@ -55,6 +55,8 @@ import javax.servlet.http.HttpServletRequestWrapper;
import org.apache.commons.fileupload.DiskFileUpload;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.dspace.core.ConfigurationManager;
/**
@@ -98,11 +100,15 @@ public class FileUploadRequest extends HttpServletRequestWrapper
tempDir = ConfigurationManager.getProperty("upload.temp.dir");
int maxSize = ConfigurationManager.getIntProperty("upload.max");
DiskFileUpload upload = new DiskFileUpload();
// Create a factory for disk-based file items
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(tempDir));
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
try
{
upload.setRepositoryPath(tempDir);
upload.setSizeMax(maxSize);
items = upload.parseRequest(req);
for (Iterator i = items.iterator(); i.hasNext();)

View File

@@ -124,6 +124,10 @@
<url-pattern>/view-workspaceitem</url-pattern>
</filter-mapping>
<!-- Listener to clean up Commons-FileUpload -->
<listener>
<listener-class>org.apache.commons.fileupload.servlet.FileCleanerCleanup</listener-class>
</listener>
<!-- Listener to initialise / clean up the application -->
<listener>
<listener-class>org.dspace.app.util.DSpaceContextListener</listener-class>

View File

@@ -50,7 +50,12 @@
The location of the main DSpace configuration file
</description>
</context-param>
<!-- Listener to initialise / clean up the application -->
<listener>
<listener-class>org.dspace.app.util.DSpaceContextListener</listener-class>
</listener>
<!-- DSpace configuration initialisation. This needs to be loaded before
other servlets. -->
<servlet>

View File

@@ -70,6 +70,11 @@
</description>
</context-param>
<!-- Listener to initialise / clean up the application -->
<listener>
<listener-class>org.dspace.app.util.DSpaceContextListener</listener-class>
</listener>
<!-- DSpace configuration initialisation. This needs to be loaded before
other servlets. -->
<servlet>

View File

@@ -39,6 +39,11 @@
<!-- Servlets -->
<!-- Listener to initialise / clean up the application -->
<listener>
<listener-class>org.dspace.app.util.DSpaceContextListener</listener-class>
</listener>
<!-- DSpace configuration initialisation. This needs to be loaded before
other servlets. -->
<servlet>

View File

@@ -49,6 +49,10 @@
</description>
</context-param>
<!-- Listener to clean up Commons-FileUpload -->
<listener>
<listener-class>org.apache.commons.fileupload.servlet.FileCleanerCleanup</listener-class>
</listener>
<!-- Listener to initialise / clean up the application -->
<listener>
<listener-class>org.dspace.app.util.DSpaceContextListener</listener-class>

View File

@@ -325,12 +325,12 @@
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.1.1</version>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.2</version>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>