diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorage.java
index 6cb49129a..67a3228a6 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorage.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorage.java
@@ -18,12 +18,6 @@ public interface FileStorage {
*/
String PROPERTY_FILE_STORAGE_BASE_DIR = "upload.directory";
- /**
- * The default implementation will use this key to ask
- * {@link ConfigurationProperties} for the maximum permissible file size.
- */
- String PROPERTY_FILE_MAXIMUM_SIZE = "file.maximum.size";
-
/**
* The default implementation will use this key to ask
* {@link ConfigurationProperties} for the default URI namespace.
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageHelper.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageHelper.java
index 0fe4897cf..9ba625165 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageHelper.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageHelper.java
@@ -21,7 +21,6 @@ import org.apache.log4j.Logger;
*
convert an ID (with namespaces) to an absolute path
* convert an ID (with namespaces) and a filename to a full path for storing
* the file
- * parse the string that specifies the maximum size of an uploaded file
*
*/
public class FileStorageHelper {
@@ -259,48 +258,4 @@ public class FileStorageHelper {
encodeName(filename));
}
- /**
- * Translate the configuration property for maximum file size from a
- * String
to a long
.
- *
- * The string must be represent a positive integer, optionally followed by
- * "K", "M", or "G" (to indicate kilobytes, megabytes, or gigabytes).
- */
- public static long parseMaximumFileSize(String fileSizeString) {
- long factor = 1L;
- String integerString;
- int shorter = fileSizeString.length() - 1;
- if (fileSizeString.endsWith("K")) {
- factor = 1024L;
- integerString = fileSizeString.substring(0, shorter);
- } else if (fileSizeString.endsWith("M")) {
- factor = 1024L * 1024L;
- integerString = fileSizeString.substring(0, shorter);
- } else if (fileSizeString.endsWith("G")) {
- factor = 1024L * 1024L * 1024L;
- integerString = fileSizeString.substring(0, shorter);
- } else {
- integerString = fileSizeString;
- }
-
- long value = 0;
- try {
- value = Long.parseLong(integerString);
-
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException(
- "Maximum file size is invalid: '" + fileSizeString
- + "'. Must be a positive integer, "
- + "optionally followed by 'K', 'M', or 'G'");
- }
-
- if (value <= 0L) {
- throw new IllegalArgumentException(
- "Maximum file size must be more than 0: '" + fileSizeString
- + "'");
- }
-
- return value * factor;
- }
-
}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageImpl.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageImpl.java
index 7a85d03d8..b9fda48da 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageImpl.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageImpl.java
@@ -34,7 +34,6 @@ public class FileStorageImpl implements FileStorage {
private final File baseDir;
private final File rootDir;
private final File namespaceFile;
- private final long maximumFileSize;
private final Map namespacesMap;
// ----------------------------------------------------------------------
@@ -53,7 +52,7 @@ public class FileStorageImpl implements FileStorage {
* missing, or if it isn't in the expected form.
*/
FileStorageImpl() throws IOException {
- this(figureBaseDir(), figureFileNamespace(), figureMaximumFileSize());
+ this(figureBaseDir(), figureFileNamespace());
}
/**
@@ -65,11 +64,9 @@ public class FileStorageImpl implements FileStorage {
* if the configuration property doesn't point to an existing,
* writeable directory.
*/
- FileStorageImpl(File baseDir, Collection namespaces,
- long maximumFileSize) throws IOException {
+ FileStorageImpl(File baseDir, Collection namespaces) throws IOException {
checkBaseDirValid(baseDir);
checkNamespacesValid(namespaces);
- checkMaximumFileSizeValid(maximumFileSize);
this.baseDir = baseDir;
this.rootDir = new File(this.baseDir, "file_storage_root");
@@ -77,8 +74,6 @@ public class FileStorageImpl implements FileStorage {
this.namespaceFile = new File(baseDir,
"file_storage_namespaces.properties");
- this.maximumFileSize = maximumFileSize;
-
if (rootDir.exists() && namespaceFile.exists()) {
this.namespacesMap = confirmNamespaces(namespaces);
} else if (!rootDir.exists() && !namespaceFile.exists()) {
@@ -97,13 +92,6 @@ public class FileStorageImpl implements FileStorage {
}
}
- private void checkMaximumFileSizeValid(long maximumFileSize) {
- if (maximumFileSize < 0) {
- throw new IllegalArgumentException(
- "Maximum file size may not be negative.");
- }
- }
-
private void checkNamespacesValid(Collection namespaces) {
if (namespaces == null) {
throw new NullPointerException("namespaces may not be null.");
@@ -185,23 +173,6 @@ public class FileStorageImpl implements FileStorage {
return Collections.singleton(fileNamespace);
}
- /**
- * Get the configuration property for the maximum file size and translate it
- * into a long integer. It must be a positive integer, optionally followed
- * by "K", "M", or "G" (to indicate kilobytes, megabytes, or gigabytes).
- */
- private static long figureMaximumFileSize() {
- String fileSizeString = ConfigurationProperties
- .getProperty(PROPERTY_FILE_MAXIMUM_SIZE);
- if (fileSizeString == null) {
- throw new IllegalArgumentException(
- "Configuration properties must contain a value for '"
- + PROPERTY_FILE_MAXIMUM_SIZE + "'");
- }
-
- return FileStorageHelper.parseMaximumFileSize(fileSizeString);
- }
-
/**
* Assign arbitrary prefixes to these namespaces.
*/
@@ -398,10 +369,6 @@ public class FileStorageImpl implements FileStorage {
byte[] buffer = new byte[4096];
int howMany;
while (-1 != (howMany = in.read(buffer))) {
- if (bytes.size() > this.maximumFileSize) {
- throw new IOException("File is too large at this ID: '"
- + id + "', file location '" + file + "'");
- }
bytes.write(buffer, 0, howMany);
}
bytes.close();
diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageFactoryTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageFactoryTest.java
index 5fafa7375..4a9ed54fe 100644
--- a/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageFactoryTest.java
+++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageFactoryTest.java
@@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.utils.filestorage;
import static edu.cornell.mannlib.vitro.webapp.utils.filestorage.FileStorageFactory.PROPERTY_IMPLEMETATION_CLASSNAME;
-import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -64,7 +63,7 @@ public class FileStorageFactoryTest extends AbstractTestClass {
@Test
public void createDefaultImplementation() throws IOException {
setConfigurationProperties(tempDir.getPath(),
- "http://vivo.myDomain.edu/individual/", "50M");
+ "http://vivo.myDomain.edu/individual/");
FileStorage fs = FileStorageFactory.getFileStorage();
assertEquals("implementation class", FileStorageImpl.class, fs
.getClass());
@@ -82,20 +81,13 @@ public class FileStorageFactoryTest extends AbstractTestClass {
@Test(expected = IllegalArgumentException.class)
public void baseDirectoryDoesntExist() throws IOException {
setConfigurationProperties("/bogus/Directory",
- "http://vivo.myDomain.edu/individual/", "50M");
+ "http://vivo.myDomain.edu/individual/");
FileStorageFactory.getFileStorage();
}
@Test(expected = IllegalArgumentException.class)
public void defaultNamespaceIsBogus() throws IOException {
- setConfigurationProperties(tempDir.getPath(), "namespace", "50M");
- FileStorageFactory.getFileStorage();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void invalidMaximumFileSize() throws IOException {
- setConfigurationProperties(tempDir.getPath(),
- "http://vivo.myDomain.edu/individual/", "50X");
+ setConfigurationProperties(tempDir.getPath(), "namespace");
FileStorageFactory.getFileStorage();
}
@@ -124,11 +116,10 @@ public class FileStorageFactoryTest extends AbstractTestClass {
// ----------------------------------------------------------------------
private void setConfigurationProperties(String baseDir,
- String defaultNamespace, String maxFileSize) {
+ String defaultNamespace) {
Map map = new HashMap();
map.put(FileStorage.PROPERTY_FILE_STORAGE_BASE_DIR, baseDir);
map.put(FileStorage.PROPERTY_DEFAULT_NAMESPACE, defaultNamespace);
- map.put(FileStorage.PROPERTY_FILE_MAXIMUM_SIZE, maxFileSize);
try {
Field f = ConfigurationProperties.class.getDeclaredField("theMap");
diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageHelperTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageHelperTest.java
index d75350dd9..1bfac7748 100644
--- a/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageHelperTest.java
+++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/filestorage/FileStorageHelperTest.java
@@ -199,41 +199,4 @@ public class FileStorageHelperTest {
assertEquals("fullPath", FULL_RESULT_PATH, actual);
}
- // ----------------------------------------------------------------------
- // parseMaximumFileSize
- // ----------------------------------------------------------------------
-
- @Test
- public void parseMaximumFileSizeBare() {
- long size = FileStorageHelper.parseMaximumFileSize("1467898");
- assertEquals("", 1467898, size);
- }
-
- @Test
- public void parseMaximumFileSizeWithSuffixes() {
- long size = FileStorageHelper.parseMaximumFileSize("152K");
- assertEquals("", 152L * 1024L, size);
-
- size = FileStorageHelper.parseMaximumFileSize("47M");
- assertEquals("", 47L * 1024L * 1024L, size);
-
- size = FileStorageHelper.parseMaximumFileSize("3G");
- assertEquals("", 3L * 1024L * 1024L * 1024L, size);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void parseMaximumFileSizeInvalidSuffix() {
- FileStorageHelper.parseMaximumFileSize("152X");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void parseMaximumFileSizeNegativeNumber() {
- FileStorageHelper.parseMaximumFileSize("-3K");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void parseMaximumFileSizeEmbeddedBadCharacter() {
- FileStorageHelper.parseMaximumFileSize("1G52K");
- }
-
}