Skip to content

Commit

Permalink
Changed implementation of PWC search for a document.
Browse files Browse the repository at this point in the history
  • Loading branch information
mspasiano committed Aug 13, 2023
1 parent 755c2ab commit 74c25de
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;

@Repository
public class ProtocolRepository {
Expand Down Expand Up @@ -81,12 +82,16 @@ public String getProtocol(boolean checkout) {

public void updateDocument(Session session, String content, String checkinMessage) {
Document document = (Document) session.getObjectByPath(protocolPath);
if (!document.getVersionLabel().equalsIgnoreCase(PWC))
document = document.getAllVersions()
.stream()
.filter(x -> x.getVersionLabel().equalsIgnoreCase(PWC))
.findFirst()
.get();
if (!document.getVersionLabel().equalsIgnoreCase(PWC)) {
document = Optional.ofNullable(document)
.flatMap(document1 -> Optional.ofNullable(document1.getVersionSeriesId()))
.map(s -> s.concat(";"))
.map(s -> s.concat(PWC))
.flatMap(s -> Optional.ofNullable(session.getObject(s)))
.filter(Document.class::isInstance)
.map(Document.class::cast)
.orElse(document);
}
String name = document.getName();
String mimeType = document.getContentStreamMimeType();
ContentStreamImpl cs = new ContentStreamImpl(name, mimeType, content);
Expand Down

0 comments on commit 74c25de

Please sign in to comment.