Skip to content

Commit

Permalink
#137 ProcessRestController retry on InvalidDocumentVersionException
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Feb 16, 2017
1 parent 33427ad commit fbcb815
Showing 1 changed file with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
Expand Down Expand Up @@ -109,15 +109,15 @@ public JSONProcessInstance createInstanceFromRequest(
)
{
userSession.assertLoggedIn();

final ProcessInfo processInfo = createProcessInfo(adProcessId, request);

return Execution.callInNewExecution("pinstance.create", () -> {
final ProcessInstance processInstance = instancesRepository.createNewProcessInstance(processInfo);
return JSONProcessInstance.of(processInstance, newJsonOpts());
});
}

private ProcessInfo createProcessInfo(final int adProcessId, final JSONCreateProcessInstanceRequest request)
{
// Validate request's AD_Process_ID
Expand Down Expand Up @@ -213,20 +213,22 @@ public List<JSONDocument> processParametersChangeEvents(
{
userSession.assertLoggedIn();

return Execution.callInNewExecution("pinstance.processParametersChangeEvents", () -> {
final ProcessInstance processInstance = instancesRepository.getProcessInstanceForWriting(pinstanceId);
return Execution.prepareNewExecution()
.retryOnVersionError(3)
.execute(() -> {
final ProcessInstance processInstance = instancesRepository.getProcessInstanceForWriting(pinstanceId);

//
// Apply changes
processInstance.processParameterValueChanges(events, REASON_Value_DirectSetFromCommitAPI);
//
// Apply changes
processInstance.processParameterValueChanges(events, REASON_Value_DirectSetFromCommitAPI);

// Push back the changed document
instancesRepository.checkin(processInstance);
// Push back the changed document
instancesRepository.checkin(processInstance);

//
// Return the changes
return JSONDocument.ofEvents(Execution.getCurrentDocumentChangesCollector(), newJsonOpts());
});
//
// Return the changes
return JSONDocument.ofEvents(Execution.getCurrentDocumentChangesCollector(), newJsonOpts());
});
}

@RequestMapping(value = "/{processId}/{pinstanceId}/start", method = RequestMethod.GET)
Expand Down Expand Up @@ -268,7 +270,7 @@ public ResponseEntity<byte[]> getReport(
headers.setContentType(MediaType.parseMediaType(reportContentType));
headers.set(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + reportFilenameEffective + "\"");
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
final ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(reportData, headers, HttpStatus.OK);
final ResponseEntity<byte[]> response = new ResponseEntity<>(reportData, headers, HttpStatus.OK);
return response;
}

Expand Down

0 comments on commit fbcb815

Please sign in to comment.