List of usage examples for org.springframework.dao OptimisticLockingFailureException getMessage
@Override
@Nullable
public String getMessage()
From source file:org.terasoluna.gfw.functionaltest.app.exceptionhandling.ExceptionHandlingController.java
@ExceptionHandler(OptimisticLockingFailureException.class) @ResponseStatus(HttpStatus.CONFLICT)//from w w w . j av a 2 s . co m public ModelAndView handleException(OptimisticLockingFailureException e) { ExtendedModelMap modelMap = new ExtendedModelMap(); modelMap.addAttribute("exceptionMessage", e.getMessage()); return new ModelAndView("exceptionhandling/exceptionHandler", modelMap); }
From source file:org.cloudfoundry.identity.uaa.scim.endpoints.ScimUserEndpoints.java
@RequestMapping(value = "/Users/{userId}", method = RequestMethod.PUT) @ResponseBody/* w ww . ja v a 2 s .c o m*/ public ScimUser updateUser(@RequestBody ScimUser user, @PathVariable String userId, @RequestHeader(value = "If-Match", required = false, defaultValue = "NaN") String etag, HttpServletRequest request, HttpServletResponse httpServletResponse) { checkIsEditAllowed(user.getOrigin(), request); if (etag.equals("NaN")) { throw new ScimException("Missing If-Match for PUT", HttpStatus.BAD_REQUEST); } int version = getVersion(userId, etag); user.setVersion(version); try { ScimUser updated = dao.update(userId, user); scimUpdates.incrementAndGet(); ScimUser scimUser = syncApprovals(syncGroups(updated)); addETagHeader(httpServletResponse, scimUser); return scimUser; } catch (OptimisticLockingFailureException e) { throw new ScimResourceConflictException(e.getMessage()); } }
From source file:org.cloudfoundry.identity.uaa.scim.ScimUserEndpoints.java
@RequestMapping(value = "/User/{userId}", method = RequestMethod.PUT) @ResponseBody/*from w w w. j av a 2 s . c o m*/ public ScimUser updateUser(@RequestBody ScimUser user, @PathVariable String userId, @RequestHeader(value = "If-Match", required = false, defaultValue = "NaN") String etag) { if (etag.equals("NaN")) { throw new ScimException("Missing If-Match for PUT", HttpStatus.BAD_REQUEST); } int version = getVersion(userId, etag); user.setVersion(version); try { return dao.updateUser(userId, user); } catch (OptimisticLockingFailureException e) { throw new ScimException(e.getMessage(), HttpStatus.CONFLICT); } }
From source file:org.kuali.kfs.module.bc.document.service.impl.BudgetDocumentServiceImpl.java
/** * Runs validation and persists a document to the database. * /*from w ww . j a v a 2s. com*/ * @param document * @param event * @throws WorkflowException * @throws ValidationException */ @Transactional public void validateAndPersistDocument(Document document, KualiDocumentEvent event) throws ValidationException { if (document == null) { LOG.error("document passed to validateAndPersist was null"); throw new IllegalArgumentException("invalid (null) document"); } LOG.info("validating and preparing to persist document " + document.getDocumentNumber()); // runs business rules event.validate() and creates rule instance and runs rule method recursively document.validateBusinessRules(event); // calls overriden method for specific document for anything that needs to happen before the save // currently nothing for BC document document.prepareForSave(event); // save the document to the database try { LOG.info("storing document " + document.getDocumentNumber()); documentDao.save(document); } catch (OptimisticLockingFailureException e) { LOG.error("exception encountered on store of document " + e.getMessage()); throw e; } document.postProcessSave(event); }
From source file:org.kuali.kra.service.impl.KraDocumentServiceImpl.java
@Override public void validateAndPersistDocument(Document document, KualiDocumentEvent event) throws WorkflowException, ValidationException { if (document == null) { LOG.error("document passed to validateAndPersist was null"); throw new IllegalArgumentException("invalid (null) document"); }//w ww . jav a 2 s. co m if (LOG.isInfoEnabled()) { LOG.info("validating and preparing to persist document " + document.getDocumentNumber()); } document.validateBusinessRules(event); document.prepareForSave(event); // save the document try { if (LOG.isInfoEnabled()) { LOG.info("storing document " + document.getDocumentNumber()); } if (document instanceof CommitteeDocument) { Committee committee = ((CommitteeDocument) document).getCommittee(); ((CommitteeDocument) document).setCommitteeList(new ArrayList()); getDocumentDao().save(document); ((CommitteeDocument) document).getCommitteeList().add(committee); if (event instanceof RouteDocumentEvent) { getDocumentDao().save(document); } } else { getDocumentDao().save(document); } } catch (OptimisticLockingFailureException e) { LOG.error("exception encountered on store of document " + e.getMessage()); throw e; } document.postProcessSave(event); }
From source file:org.kuali.rice.krad.service.impl.DocumentServiceImpl.java
/** * Validates and persists a document.//from w ww. j a va2s . c o m */ @Override public Document validateAndPersistDocument(Document document, DocumentEvent event) throws ValidationException { if (document == null) { LOG.error("document passed to validateAndPersist was null"); throw new IllegalArgumentException("invalid (null) document"); } if (LOG.isDebugEnabled()) { LOG.debug("validating and preparing to persist document " + document.getDocumentNumber()); } document.validateBusinessRules(event); document.prepareForSave(event); // save the document Document savedDocument = null; try { if (LOG.isInfoEnabled()) { LOG.info("storing document " + document.getDocumentNumber()); } savedDocument = getLegacyDataAdapter().saveDocument(document); savedDocument.processAfterRetrieve(); // Need to preserve the workflow document header, which just got left behind savedDocument.getDocumentHeader() .setWorkflowDocument(document.getDocumentHeader().getWorkflowDocument()); } catch (OptimisticLockingFailureException e) { LOG.error("exception encountered on store of document " + e.getMessage()); throw e; } boolean notesSaved = saveDocumentNotes(savedDocument); if (!notesSaved) { if (LOG.isInfoEnabled()) { LOG.info( "Notes not saved during validateAndPersistDocument, likely means that note save needs to be deferred because note target is not ready."); } } savedDocument.postProcessSave(event); return savedDocument; }