diff --git a/src/main/java/org/verapdf/rest/resources/ValidateResource.java b/src/main/java/org/verapdf/rest/resources/ValidateResource.java index f0108ea..a087354 100644 --- a/src/main/java/org/verapdf/rest/resources/ValidateResource.java +++ b/src/main/java/org/verapdf/rest/resources/ValidateResource.java @@ -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 Carl Wilson */ 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,