Is there a way to make the following code atomic (transactional)? | Community
Skip to main content
LinearGradient
Level 6
October 16, 2015
Solved

Is there a way to make the following code atomic (transactional)?

  • October 16, 2015
  • 3 replies
  • 1044 views

Hi,

Is there a way to make code similar to what follows transactional:

UserManager userManager = ...; //  org.apache.jackrabbit.api.security.user.UserManager userManager.createUser(...); userManager.createGroup(...); updateGroupService.updateGroup(...) // org.apache.sling.jackrabbit.usermanager.UpdateGroup AccessControlUtil.replaceAccessControlEntry(...) JcrResourceUtil.createPath(...) JcrUtil.copy(...)

Basically:

  • We create a user,
  • A group,
  • Assign the user to the group,
  • Add permissions to the group,
  • Create a folder (e.g. /content/foo/bar/baz)
  • Copy some content from some folder in JCR to /content/foo/bar/baz

At the moment one or more of ceateUser, createGroup, updateGroup, replaceAccessControlEntry commit their changes even before explicitly calling save() on the current request's session.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

Hi,

On the Jackrabbit wiki [1] there's a reference to the chapter 8.1 of the JCR specification, see also [2]. To be honest, I never played with transactions on JR.

Jörg

 

[1] http://jackrabbit.apache.org/frequently-asked-questions.html

[2] http://www.day.com/maven/jcr/2.0/21_Transactions.html

3 replies

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Hi,

On the Jackrabbit wiki [1] there's a reference to the chapter 8.1 of the JCR specification, see also [2]. To be honest, I never played with transactions on JR.

Jörg

 

[1] http://jackrabbit.apache.org/frequently-asked-questions.html

[2] http://www.day.com/maven/jcr/2.0/21_Transactions.html

Adobe Employee
October 16, 2015

Hi,

Is the UserManager you are using in "autosave" [0] mode? If autosave mode is on session.save() is called for you and could explain the results you are seeing.

Will

[0] http://jackrabbit.apache.org/api/2.4/org/apache/jackrabbit/api/security/user/UserManager.html#isAutoSave()

LinearGradient
Level 6
October 16, 2015

Hi Will,

That almost worked until I hit this roadblock: http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__azkh-hi_when_i_runth.html

Do you know if there's a way to work around that? IMHO, looks like a bug in Jackrabbit/Sling.

Thanks.