|
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-21 13:52:34
|
Revision: 499
http://sword-app.svn.sourceforge.net/sword-app/?rev=499&view=rev
Author: richard-jones
Date: 2012-04-21 13:52:27 +0000 (Sat, 21 Apr 2012)
Log Message:
-----------
File cleanup enhancements
Previously, in the case of an error, file cleanup wasn't successful. This update adds calls to the cleanup operation in more places, enhances the cleanup process, and fixes a bug in the SwordAPIEndpoint which caused the cleanup not to function correctly
Modified Paths:
--------------
JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java
JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java
JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java
JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java
Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java
===================================================================
--- JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java 2012-04-20 15:02:55 UTC (rev 498)
+++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java 2012-04-21 13:52:27 UTC (rev 499)
@@ -198,6 +198,9 @@
}
catch (SwordError se)
{
+ // get rid of any temp files used
+ this.cleanup(deposit);
+
this.swordError(req, resp, se);
}
catch (SwordServerException e)
@@ -210,6 +213,9 @@
}
catch (SwordAuthException e)
{
+ // get rid of any temp files used
+ this.cleanup(deposit);
+
// authentication actually failed at the server end; not a SwordError, but
// need to throw a 403 Forbidden
resp.sendError(403);
Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java
===================================================================
--- JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java 2012-04-20 15:02:55 UTC (rev 498)
+++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java 2012-04-21 13:52:27 UTC (rev 499)
@@ -262,6 +262,9 @@
}
catch (SwordError se)
{
+ // get rid of any temp files used
+ this.cleanup(deposit);
+
this.swordError(req, resp, se);
}
catch (SwordServerException e)
@@ -274,6 +277,9 @@
}
catch (SwordAuthException e)
{
+ // get rid of any temp files used
+ this.cleanup(deposit);
+
// authentication actually failed at the server end; not a SwordError, but
// need to throw a 403 Forbidden
resp.sendError(403);
@@ -391,6 +397,9 @@
}
catch (SwordError se)
{
+ // get rid of any temp files used
+ this.cleanup(deposit);
+
this.swordError(req, resp, se);
}
catch (SwordServerException e)
@@ -403,6 +412,9 @@
}
catch (SwordAuthException e)
{
+ // get rid of any temp files used
+ this.cleanup(deposit);
+
// authentication actually failed at the server end; not a SwordError, but
// need to throw a 403 Forbidden
resp.sendError(403);
Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java
===================================================================
--- JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java 2012-04-20 15:02:55 UTC (rev 498)
+++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java 2012-04-21 13:52:27 UTC (rev 499)
@@ -176,6 +176,9 @@
}
catch (SwordError se)
{
+ // get rid of any temp files used
+ this.cleanup(deposit);
+
this.swordError(req, resp, se);
}
catch (SwordServerException e)
@@ -184,6 +187,9 @@
}
catch (SwordAuthException e)
{
+ // get rid of any temp files used
+ this.cleanup(deposit);
+
// authentication actually failed at the server end; not a SwordError, but
// need to throw a 403 Forbidden
resp.sendError(403);
@@ -270,8 +276,10 @@
}
catch (SwordError se)
{
+ // get rid of any temp files used
+ this.cleanup(deposit);
+
this.swordError(req, resp, se);
- return;
}
catch (SwordServerException e)
{
@@ -279,6 +287,9 @@
}
catch (SwordAuthException e)
{
+ // get rid of any temp files used
+ this.cleanup(deposit);
+
// authentication actually failed at the server end; not a SwordError, but
// need to throw a 403 Forbidden
resp.sendError(403);
Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java
===================================================================
--- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-20 15:02:55 UTC (rev 498)
+++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-21 13:52:27 UTC (rev 499)
@@ -161,7 +161,10 @@
// Check the size is OK
File file = new File(filename);
- long fLength = file.length() / 1024; // in kilobytes
+ // Set the file to be deposited
+ deposit.setFile(file);
+
+ long fLength = file.length() / 1024; // in kilobytes
if ((config.getMaxUploadSize() != -1) && (fLength > config.getMaxUploadSize()))
{
String msg = "The uploaded file exceeded the maximum file size this server will accept (the file is " +
@@ -184,11 +187,6 @@
String msg = "The received MD5 checksum for the deposited file did not match the checksum sent by the deposit client";
throw new SwordError(UriRegistry.ERROR_CHECKSUM_MISMATCH, msg);
}
- else
- {
- // Set the file to be deposited
- deposit.setFile(file);
- }
log.debug("Package temporarily stored as: " + filename);
}
catch (NoSuchAlgorithmException e)
@@ -271,6 +269,7 @@
}
tmp.delete();
+ deposit.setFile(null);
}
protected Element getGenerator(SwordConfiguration config)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|