Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Minor change to Config.java for use in derived datastores. Added method
getStringValue, changed getLongValue to take property name, not value.
  • Loading branch information
terrischwartz committed Jun 27, 2016
1 parent 30e01ed commit 7ba7803
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/main/java/org/tus/servlet/upload/Config.java
Expand Up @@ -62,13 +62,13 @@ private void init(Properties properties) throws ServletException
uploadFolder = (tmp == null)? UPLOAD_FOLDER : tmp;
validateFolder(uploadFolder);

l = getLongValue(properties.getProperty("maxFileSize"));
l = getLongValue("maxFileSize");
maxSize = (l == null) ? MAX_SIZE : l;

l = getLongValue(properties.getProperty("maxStorage"));
l = getLongValue("maxStorage");
maxStorage = (l == null) ? MAX_STORAGE : l;

l = getLongValue(properties.getProperty("maxRequest"));
l = getLongValue("maxRequest");
maxRequest = (l == null) ? MAX_REQUEST : l;

datastoreProvider = properties.getProperty("datastoreProvider");
Expand Down Expand Up @@ -136,22 +136,28 @@ protected void validateFolder(String folder) throws ServletException
}
}

protected Long getLongValue(String text) throws ServletException
public String getStringValue(String name) throws ServletException
{
return allProperties.getProperty(name);
}

public Long getLongValue(String name) throws ServletException
{
String msg;
if (text == null)
String value = allProperties.getProperty(name);
if (value == null)
{
return null;
}
Long value = null;
Long longValue = null;
try
{
value = new Long(text);
return value;
longValue = new Long(value);
return longValue;
}
catch(NumberFormatException ne)
{
msg = "Parameter must be a long. Error parsing: " + text;
msg = "Parameter must be a long. Error parsing: " + value;
throw new ServletException(msg);
}
}
Expand Down

0 comments on commit 7ba7803

Please sign in to comment.