Skip to content

Commit

Permalink
Merge pull request #497 from liimaorg/rescopy_autoflush
Browse files Browse the repository at this point in the history
Persist resource copy result before permission check
  • Loading branch information
yvespp authored Jul 11, 2019
2 parents 893712c + 4ed4e99 commit e8e4325
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,11 @@ protected CopyResourceResult doCopyResourceAndSave(CopyUnit copyUnit) throws For

// do save
if (copyUnit.getResult().isSuccess()) {
// check if only decorable fields on resource changed when changing owner is different from resource owner
foreignableService.verifyEditableByOwner(copyUnit.getActingOwner(), targetHashCodeBeforeChange, copyUnit.getTargetResource());
auditService.storeIdInThreadLocalForAuditLog(copyUnit.getTargetResource());
// persist before permission check to avoid TransientPropertyValueException when JPA tries to auto flush
entityManager.persist(copyUnit.getTargetResource());
// check if only decorable fields on resource changed when changing owner is different from resource owner
foreignableService.verifyEditableByOwner(copyUnit.getActingOwner(), targetHashCodeBeforeChange, copyUnit.getTargetResource());
}
copyUnit.getResult().setTargetResource(copyUnit.getTargetResource());
return copyUnit.getResult();
Expand Down

0 comments on commit e8e4325

Please sign in to comment.