Skip to content

Commit

Permalink
Bug fix attachment ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
georgweiss committed Aug 15, 2023
1 parent cd30d46 commit fd5ecf8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/java/org/phoebus/olog/LogResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,20 @@ public Log createLog(@RequestHeader(value = OLOG_CLIENT_INFO_HEADER, required =
Log newLogEntry = createLog(clientInfo, markup, inReplyTo, logEntry, principal);

if (files != null) {
Iterator<Attachment> attachmentIterator = logEntry.getAttachments().iterator();
for (int i = 0; i < files.length; i++) {
Attachment attachment = attachmentIterator.next();
String originalFileName = files[i].getOriginalFilename();
Optional<Attachment> attachment =
logEntry.getAttachments().stream()
.filter(a -> a.getFilename() != null && a.getFilename().equals(originalFileName)).findFirst();
if(attachment.isEmpty()){ // Should not happen if client behaves correctly
logger.log(Level.WARNING, "File " + originalFileName + " not matched with attachment meta-data");
continue;
}
uploadAttachment(Long.toString(newLogEntry.getId()),
files[i],
files[i].getOriginalFilename(),
attachment.getId(),
attachment.getFileMetadataDescription());
originalFileName,
attachment.get().getId(),
attachment.get().getFileMetadataDescription());
}
}

Expand Down

0 comments on commit fd5ecf8

Please sign in to comment.