X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fjcr%2FJcrTestResult.java;h=e3394e05cbbda6ecbcd8c11800487512d5b86e2b;hb=2ecb1e7ce15a25ba8026b5ded625f36c1be467bd;hp=45de6597aacdfb30313a5cd88c7eb1600699e765;hpb=ac66eefd8a14c0734a978b15901e5c1ab89c1041;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/JcrTestResult.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/JcrTestResult.java index 45de6597a..e3394e05c 100644 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/JcrTestResult.java +++ b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/JcrTestResult.java @@ -127,23 +127,23 @@ public class JcrTestResult implements TestResult, SlcNames, AttachmentsEnabled { public void addResultPart(TestResultPart testResultPart) { Node node = getNode(); - + try { - - // error - if (testResultPart.getExceptionMessage() != null) - JcrUtils.discardQuietly(node.getSession()); + // error : revert all unsaved changes on the resultNode to be sure + // it is in a consistant state + if (testResultPart.getExceptionMessage() != null) + JcrUtils.discardQuietly(node.getSession()); node.getSession().save(); - + // add the new result part, retrieving status information Node resultPartNode = node.addNode(SlcNames.SLC_RESULT_PART, SlcTypes.SLC_CHECK); - resultPartNode.setProperty(SLC_SUCCESS, - testResultPart.getStatus() == TestStatus.PASSED); - // if (testResultPart.getMessage() != null) - // resultPartNode.setProperty(SLC_MESSAGE, - // testResultPart.getMessage()); - if (testResultPart.getStatus() == TestStatus.ERROR) { + resultPartNode.setProperty(SLC_SUCCESS, testResultPart.getStatus() + .equals(TestStatus.PASSED)); + if (testResultPart.getMessage() != null) + resultPartNode.setProperty(SLC_MESSAGE, + testResultPart.getMessage()); + if (testResultPart.getStatus().equals(TestStatus.ERROR)) { resultPartNode.setProperty(SLC_ERROR_MESSAGE, (testResultPart.getExceptionMessage() == null) ? "" : testResultPart.getExceptionMessage()); @@ -204,7 +204,7 @@ public class JcrTestResult implements TestResult, SlcNames, AttachmentsEnabled { node.getSession().save(); } catch (Exception e) { JcrUtils.discardUnderlyingSessionQuietly(node); - throw new SlcException("Cannot get UUID from " + node, e); + throw new SlcException("Cannot add ResultPart to node " + node, e); } }