Skip to content

Commit

Permalink
Fixed validation result format
Browse files Browse the repository at this point in the history
  • Loading branch information
irinamavrina authored and MaximPlusov committed Jul 13, 2023
1 parent 4e6fa87 commit 61c0620
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/org/verapdf/rest/resources/ValidateResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
import org.verapdf.processor.TaskType;
import org.verapdf.processor.plugins.PluginsCollectionConfig;
import org.verapdf.processor.reports.BatchSummary;
import org.verapdf.processor.reports.Reports;
import org.verapdf.processor.reports.ValidationReport;
import org.verapdf.report.HTMLReport;

/**
Expand Down Expand Up @@ -98,7 +100,7 @@ public static ComponentDetails getDetails() {
@Path("/{profileId}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public static ValidationResult validatePost(@PathParam("profileId") String profileId,
public static ValidationReport validatePost(@PathParam("profileId") String profileId,
@FormDataParam("sha1Hex") String sha1Hex,
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") final FormDataContentDisposition contentDispositionHeader)
Expand Down Expand Up @@ -178,7 +180,7 @@ public static InputStream validateHtml(@PathParam("profileId") String profileId,
@Path("/{profileId}")
@Consumes(MediaType.WILDCARD)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public static ValidationResult validatePut(@PathParam("profileId") String profileId,
public static ValidationReport validatePut(@PathParam("profileId") String profileId,
@Context HttpHeaders headers,
byte[] inFile)
throws VeraPDFException {
Expand All @@ -189,8 +191,8 @@ public static ValidationResult validatePut(@PathParam("profileId") String profil

}

private static ValidationResult validate(String profileId, String sha1Hex,
InputStream uploadedInputStream)
private static ValidationReport validate(String profileId, String sha1Hex,
InputStream uploadedInputStream)
throws VeraPDFException {
MessageDigest sha1 = getDigest();
DigestInputStream dis = new DigestInputStream(uploadedInputStream, sha1);
Expand Down Expand Up @@ -233,7 +235,8 @@ private static ValidationResult validate(String profileId, String sha1Hex,
exception.printStackTrace();
}
}
return result;

return Reports.createValidationReport(result, false);
}

private static MessageDigest getDigest() {
Expand Down

0 comments on commit 61c0620

Please sign in to comment.