-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8425d9d
commit 39573d0
Showing
1 changed file
with
12 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,10 +13,11 @@ | |
import java.security.DigestInputStream; | ||
import java.security.MessageDigest; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import javax.ws.rs.BadRequestException; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.DefaultValue; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.HeaderParam; | ||
import javax.ws.rs.InternalServerErrorException; | ||
|
@@ -61,6 +62,9 @@ | |
* @author <a href="mailto:[email protected]">Carl Wilson</a> | ||
*/ | ||
public class ValidateResource { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(ValidateResource.class.getCanonicalName()); | ||
|
||
private static final String PARAM_PROFILE_DESC = "the String id of the PDF Specification to validate against. " + | ||
"Possible values: auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1, ua2, wt1a or wt1r. " + | ||
"Selecting 'auto' allows the validator to detect and apply the appropriate specification from the PDF metadata."; | ||
|
@@ -152,7 +156,13 @@ public static Response validate( | |
} | ||
|
||
public static void setMaxFileSize(Integer maxFileSize) { | ||
ValidateResource.maxFileSize = maxFileSize; | ||
int maxValue = Integer.MAX_VALUE / CONVERTER_MB_TO_B; | ||
if (maxFileSize < maxValue && maxFileSize > 0) { | ||
maxValue = maxFileSize; | ||
} else { | ||
LOGGER.log(Level.WARNING, "Incorrect value of maxFileSize parameter. maxFileSize set to " + maxValue); | ||
} | ||
ValidateResource.maxFileSize = maxValue; | ||
} | ||
|
||
private static InputStream validateFile(InputStream uploadedInputStream, | ||
|