[ 
https://issues.apache.org/jira/browse/OAK-3228?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15162979#comment-15162979
 ] 

angela edited comment on OAK-3228 at 2/24/16 1:29 PM:
------------------------------------------------------

[~kwin], no unfortunately not. but if you say

{quote}
the group which was just being created in the same session
{quote}

this is something quite different than the sling-based test above illustrates. 
the test in the description first saves the changes with session A and then 
uses session B to retrieve the changes. my test-case reflects the latter... the 
former case (same session without calling save) is expected to not work IMO 
because the principal manager performs a query by principal name, which will 
IMO should only find persisted data (but i am not a query expert)

anyway: if it was crucial to have the fixed in the 1.2 branch, we would need to 
invest a bit more time to identify which exact modification changed the 
behavior (may this wasn't even intended). from an Oak point of view it was 
therefore crucial to have the exact steps on how to reproduce it with Oak 
version xyz. Adobe AEM comes with a different configuration setup and different 
query indices which might result in Oak issues being resolved works-for-me 
though an issue is effectively present in the Adobe product. 


was (Author: anchela):
[~kwin], no unfortunately not. but if you say

{quote}
the group which was just being created in the same session
{quote}

this is something quite different than the sling-based test above illustrates. 
the test in the description first saves the changes with session A and then 
uses session B to retrieve the changes. my test-case reflects the latter... the 
former case (same session without calling save) is expected to not work IMO 
because the principal manager performs a query by principal name, which will 
IMO should only find persisted data (but i am not a query expert)

anyway: if it was crucial to have the fixed in the 1.2 branch, we would need to 
invest a bit more time to identify which exact modification changed the 
behavior (may this wasn't even intended). from an Oak point of view it was 
therefore crucial to have a the exact steps on how to reproduce it with Oak 
version xyz. Adobe AEM comes with a different configuration setup and different 
query indices which might result in Oak issues being resolved works-for-me 
though an issue is effectively present in the Adobe product. 

> Delayed visibility of new groups when using PrincipalManager 
> -------------------------------------------------------------
>
>                 Key: OAK-3228
>                 URL: https://issues.apache.org/jira/browse/OAK-3228
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: jcr
>    Affects Versions: 1.2.2
>            Reporter: Georg Henzler
>         Attachments: OAK-3228_testcase.patch
>
>
> PrincipalManager does not show groups that were just created (this is causing 
> problems in our code). As workaround we use now 
> UserManager.getAuthorizable().getPrincipal() which curiously works 
> immediately after saving a group. Also it does not seem to be an index 
> problem, as a query {{SELECT * FROM [rep:Authorizable] WHERE 
> [rep:principalName] = "mygroup"}} also immediately shows a new group.
> See the following servlet snippet for easy reproduction:
> {code}
> ...
> @SlingServlet(paths = "/bin/CreateGroupAndRetrievePrincipal", methods = "GET")
> public class CreateGroupAndRetrievePrincipalServlet extends 
> SlingSafeMethodsServlet {
>     private static final long serialVersionUID = 1L;
>     private static final Logger LOG = 
> LoggerFactory.getLogger(CreateGroupAndRetrievePrincipalServlet.class);
>     @Reference
>     private SlingRepository repository;
>     @Override
>     @SuppressWarnings("deprecation")
>     protected void doGet(final SlingHttpServletRequest request, final 
> SlingHttpServletResponse response) throws ServletException,
>             IOException {
>         response.setContentType("text/plain");
>         PrintWriter out = response.getWriter();
>         final String groupName = request.getParameter("g");
>         LOG.debug("test");
>         Session session = null;
>         try {
>             session = repository.loginAdministrative(null);
>             UserManager usermanager = ((JackrabbitSession) 
> session).getUserManager();
>             Group newGroup = usermanager.createGroup(new 
> java.security.Principal() {
>                 @Override
>                 public String getName() {
>                     return groupName;
>                 }
>             }, "principaltest");
>             out.println("Created Group " + newGroup);
>             session.save();
>         } catch (Exception e) {
>             throw new ServletException(e.getMessage(), e);
>         } finally {
>             if (session != null) {
>                 session.logout();
>                 session = null;
>             }
>         }
>         out.println();
>         try {
>             session = repository.loginAdministrative(null);
>             // No 1: PrincipalManager
>             PrincipalManager principalManager = ((JackrabbitSession) 
> session).getPrincipalManager();
>             Principal principal = principalManager.getPrincipal(groupName);
>             out.println("PrincipalManager: principal: " + principal);
>             // No 2: UserManager
>             UserManager usermanager = ((JackrabbitSession) 
> session).getUserManager();
>             Authorizable authorizable = 
> usermanager.getAuthorizable(groupName);
>             out.println("UserManager: authorizable: " + authorizable);
>             // No 3: query
>             QueryManager queryManager = 
> session.getWorkspace().getQueryManager();
>             final Query query = queryManager.createQuery("SELECT * FROM 
> [rep:Authorizable] WHERE [rep:principalName] = \"" + groupName
>                     + "\"", Query.JCR_SQL2);
>             QueryResult result = query.execute();
>             NodeIterator nodes = result.getNodes();
>             if (!nodes.hasNext()) {
>                 out.println("QUERY: group not found: " + groupName);
>             }
>             while (nodes.hasNext()) {
>                 Node resultNode = (Node) nodes.next();
>                 out.println("QUERY: node " + resultNode.getPath() + " 
> property rep:principalName="
>                         + 
> resultNode.getProperty("rep:principalName").getString());
>             }
>             query.execute();
>         } catch (Exception e) {
>             throw new ServletException(e.getMessage(), e);
>         } finally {
>             if (session != null) {
>                 session.logout();
>                 session = null;
>             }
>         }
>     }
> }
> {code}
> returns (using AEM 6.1)
> {code}
> Created Group Group 'my-test-group'
> PrincipalManager: principal: null
> UserManager: authorizable: Group 'my-test-group'
> QUERY: node /home/groups/principaltest/qb2WDGrrC0q9bE8jaObH property 
> rep:principalName=my-test-group
> {code}
> Potentially the problem is that the principal manager holds its own session 
> (even though it was retrieved by {{((JackrabbitSession) 
> session).getPrincipalManager()}}) and the refresh behaviour of sessions 
> (http://jackrabbit.apache.org/oak/docs/dos_and_donts.html)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to