diff --git a/iparapheur-core/src/main/java/org/adullact/iparapheur/repo/jscript/pastell/mailsec/MailsecPastellService.java b/iparapheur-core/src/main/java/org/adullact/iparapheur/repo/jscript/pastell/mailsec/MailsecPastellService.java index eb2aa68e938d90575ef62d96abcd9697f2bba40d..8cc3247c283a05b109bc6272eeb9a0740cb03d95 100644 --- a/iparapheur-core/src/main/java/org/adullact/iparapheur/repo/jscript/pastell/mailsec/MailsecPastellService.java +++ b/iparapheur-core/src/main/java/org/adullact/iparapheur/repo/jscript/pastell/mailsec/MailsecPastellService.java @@ -376,15 +376,20 @@ public class MailsecPastellService { String serverId = payload.getString(SERVER_ID_PAYLOAD); String mailId = object.getString(DOCUMENT_ID_KEY); - NodeRef parentCourant = null; + NodeRef parentCourant; if(nodeService.exists(node)) { parentCourant = nodeService.getPrimaryParent(node).getParentRef(); + } else { + parentCourant = null; } AuthenticationUtil.runAs(() -> transactionService.getRetryingTransactionHelper().doInTransaction(() -> approveMailsec(annotation, node, user, serverId, mailId)), user); if(parentCourant != null) { - corbeillesService.moveDossier(node, parentCourant, nodeService.getPrimaryParent(node).getParentRef()); + AuthenticationUtil.runAs(() -> transactionService.getRetryingTransactionHelper().doInTransaction(() -> { + corbeillesService.moveDossier(node, parentCourant, nodeService.getPrimaryParent(node).getParentRef()); + return null; + }), user); } } catch (JSONException | IOException e) { e.printStackTrace();