Skip to content

Commit

Permalink
Store the value as binary when the size is too big
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Castelo committed May 29, 2024
1 parent 8adc66f commit 78a91cb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/src/main/java/de/valtech/aecu/core/history/HistoryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
import de.valtech.aecu.core.service.HistoryEntryImpl;

import javax.jcr.Binary;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
import javax.jcr.ValueFactory;

/**
Expand Down Expand Up @@ -374,11 +374,13 @@ private void saveExecutionResultInHistory(ExecutionResult result, String path, R
values.put(ATTR_RUN_OUTPUT, result.getOutput());
} else {
try {
ValueFactory factory = resolver.adaptTo(Session.class).getValueFactory();
Node node = entry.adaptTo(Node.class);
Session session = node.getSession();
ValueFactory factory = session.getValueFactory();
InputStream is = new ByteArrayInputStream(result.getOutput().getBytes());
Binary binary = factory.createBinary(is);
Value value = factory.createValue(binary);
values.put(ATTR_RUN_OUTPUT, value);
node.setProperty(ATTR_RUN_OUTPUT, binary);
session.save();
} catch (RepositoryException e) {
LOG.error("Not able to save the output of the script as binary on the History node [{}]", entry.getPath());
}
Expand Down

0 comments on commit 78a91cb

Please sign in to comment.