Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Write problem in publish with valid user

Avatar

Level 2

First a little background on the problem.
There is some data (on page nodes) that gets updated every now an then when a page is requested. A WCMUsePojo calls a service that updates the data, 2 components use that data and I have a really weird behavior, let's say the first class calls the service, that one would update the nodes (I see no errors) and return the data, the second one would not update because it doesn't need to, it just reads from the nodes. Here comes the weird part, the second class read data that was not actually written to the nodes, my best guess is that that data lived in the session only for some reason, I tried committing with both resourceResolver and saving the session which do not return errors. Another doubt that I have is that maybe that data can only be read by the same user that wrote in the nodes?, if that is a possibility (I ignore if that's possible but I'm exploring all ideas) can I create some kind of user that can write for all kinds of user to read?

Thanks for reading, sorry for the long post

1 Accepted Solution

Avatar

Correct answer by
Level 2

Closing this down I found the issue.
The problem was that the Node I was modifying was not obtained with the resource resolver of the user with write privileges. It was a Node obtained in the Use class and that did not work.

View solution in original post

4 Replies

Avatar

Level 10

As long as a session user has permission to read data from a particular path, user should be able to read without any issue

Can you share code snippet you are using to save data into repository.

Avatar

Level 2

I'll try to give a short version of the code:

@Reference
ResourceResolverFactory resourceResolverFactory;


//with that we get the service resource resolver and the session
ResourceResolver resolver = resourceResolverFactory.getServiceResourceResolver("someservice"));
Session session = resolver.adaptTo(Session.class);

//and then the data writing

someNode.setProperty("Some property","Some value");

// I have tried with both resolver.commit() and session.save()

resolver.commit();
session.save();
resolver.commit();

session.close();

Thats the gist of it, but the property set is actually not persisted, I can see the old value on the CRX

Avatar

Correct answer by
Level 2

Closing this down I found the issue.
The problem was that the Node I was modifying was not obtained with the resource resolver of the user with write privileges. It was a Node obtained in the Use class and that did not work.

Avatar

Level 10

Thank you for posting the issue.