mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
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:
@@ -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)
|
||||
{
|
||||
|
@@ -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();)
|
||||
|
@@ -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>
|
||||
|
@@ -51,6 +51,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>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
4
pom.xml
4
pom.xml
@@ -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>
|
||||
|
Reference in New Issue
Block a user