bossenti commented on code in PR #2522:
URL: https://github.com/apache/streampipes/pull/2522#discussion_r1519243060
##########
streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/file/FileManager.java:
##########
@@ -104,6 +107,17 @@ public static InputStream cleanFile(InputStream
fileInputStream, String filetype
return fileInputStream;
}
+ public static boolean checkFileContentChanged(String filename, String hash)
throws IOException {
+ var fileHash = getFileHash(filename);
+ return !fileHash.equals(hash);
+ }
+
+ private static String getFileHash(String filename) throws IOException {
Review Comment:
This is required to be the same implementation as in `FileProtocolUtils`.
Do you see a way where we can define the method only once?
If this is not possible, I would like to some notes that make this
interdependence explicit.
##########
streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java:
##########
@@ -139,4 +139,24 @@ public ResponseEntity<List<String>>
getAllOriginalFilenames() {
.toLowerCase())
.toList());
}
+
+ @GetMapping(
+ path = "/{filename}/checkFileContentChanged/{hash}",
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_READ_FILE_PRIVILEGE)
+ public ResponseEntity<Boolean> checkFileContentChanged(
+ @PathVariable(value = "filename") String filename,
+ @PathVariable(value = "hash") String hash
+ ) {
+ try {
+ return ok(FileManager.checkFileContentChanged(filename, hash));
+ } catch (IOException e) {
+ throw new SpMessageException(
+ org.springframework.http.HttpStatus.NOT_FOUND,
Review Comment:
Is there a reason why you don't import `HttpStatus`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]