[MGNLUI-2981] NPE is logged when adding new favorite entry and user is not superuser Created: 06/Jun/14  Updated: 09/Feb/17  Resolved: 23/May/16

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 5.3.12, 5.4.3
Fix Version/s: 5.3.15, 5.4.7, 5.5

Type: Bug Priority: Major
Reporter: Milan Divilek Assignee: Hieu Nguyen Duc
Resolution: Fixed Votes: 2
Labels: None
Remaining Estimate: 0d
Time Spent: 5d 6.5h
Original Estimate: 4d

Attachments: PNG File grantAclForSecurityBase.png    
Issue Links:
causality
caused by MGNLUI-1374 Trying to r/w profiles workspace as a... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Release notes required:
Yes
Date of First Response:
Sprint: Saigon 45
Story Points: 3

 Description   

Steps to reproduce:

  1. Log in as eric
  2. Open pages app and select "article" page
  3. Switch to Favorites
  4. Click to "Add new" and then "Add"
  5. New entry is correctly added, but in log you can find NPE
2014-06-06 11:15:05,936 ERROR .ui.admincentral.shellapp.favorites.FavoritesEntry: Failed to create an itemId from an AbstractJcrNodeAdapter
java.lang.NullPointerException
	at info.magnolia.ui.admincentral.shellapp.favorites.FavoritesEntry.createItemdId(FavoritesEntry.java:325)
	at info.magnolia.ui.admincentral.shellapp.favorites.FavoritesEntry.<init>(FavoritesEntry.java:94)
	at info.magnolia.ui.admincentral.shellapp.favorites.FavoritesViewImpl.init(FavoritesViewImpl.java:159)
	at info.magnolia.ui.admincentral.shellapp.favorites.FavoritesPresenter.initializeView(FavoritesPresenter.java:285)
	at info.magnolia.ui.admincentral.shellapp.favorites.FavoritesPresenter.start(FavoritesPresenter.java:82)
	at info.magnolia.ui.admincentral.shellapp.favorites.FavoritesShellApp.start(FavoritesShellApp.java:60)
	at info.magnolia.ui.admincentral.shellapp.ShellAppController$ShellAppContextImpl.start(ShellAppController.java:157)
	at info.magnolia.ui.admincentral.shellapp.ShellAppController.addShellApp(ShellAppController.java:90)
	at info.magnolia.ui.admincentral.AdmincentralPresenter.<init>(AdmincentralPresenter.java:75)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at info.magnolia.objectfactory.ObjectManufacturer.newInstance(ObjectManufacturer.java:109)
	at info.magnolia.objectfactory.ObjectManufacturer.newInstance(ObjectManufacturer.java:79)
	at info.magnolia.objectfactory.guice.GuiceComponentProvider.newInstanceWithParameterResolvers(GuiceComponentProvider.java:121)
	at info.magnolia.objectfactory.guice.GuiceComponentProvider.newInstance(GuiceComponentProvider.java:107)
	at info.magnolia.ui.admincentral.AdmincentralUI.init(AdmincentralUI.java:120)
	at com.vaadin.ui.UI.doInit(UI.java:610)
	at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:223)
	at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:73)
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1371)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
	at info.magnolia.ui.admincentral.AdmincentralVaadinServlet.service(AdmincentralVaadinServlet.java:131)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at info.magnolia.cms.filters.ServletDispatchingFilter.doFilter(ServletDispatchingFilter.java:147)
	at info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:90)
	at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:80)
	at info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:82)

Solution

Get item id for FavoritesEntry using AbstractJcrNodeAdapter#getItemId()



 Comments   
Comment by Magnolia International [ 23/Sep/14 ]

Seeing this on 5.3.2 when favorite is created, and every time the owner of that favorite logs in

Comment by Tomáš Gregovský [ 24/Sep/14 ]

same on corporate website 5.3.2
error doesn't show when superuser do this

Comment by Michiel Meeuwissen [ 11/Jan/16 ]

We see this issue too. It seems that every attempt to make a favorite results in rubbish in our logs.

Comment by Hieu Nguyen Duc [ 28/Apr/16 ]

1) The cause is JcrItemUtil#getJcrItem() can't get item from UUID so it throws ItemNotFoundException.

2) Solution: Get item id for FavoritesEntry using another way

id = nodeAdapter.getItemId().getUuid();
Comment by Hieu Nguyen Duc [ 09/May/16 ]

The root cause is user "eric" doesn't have permission on "profiles" workspace.

Because:

  • User "eric" is a member of "travel-demo-editors".
  • "travel-demo-editors" is granted role "security-base".

This is what I've tried:

  • Create an ACL rule for role "security-base" on "/eric/favorites/bookmarks" like the below picture.
  • Login as "eric" and add a favorite.
    => It works fine with no exception logged.

But we need a way to set the path for every user respectively.
For example: If current user is "peter", the path should be "/peter/favorites/bookmarks" and so on...

Comment by Hieu Nguyen Duc [ 13/May/16 ]

I've thought out a solution that we could create a task to set permissions on "/<user>/favorites/bookmarks" of "profiles" workspace for existing users.
When a new user is created, we also do the same thing.
mgeljic What do you think about it?

Comment by Mikaël Geljić [ 20/May/16 ]

So after further consideration, as much as we (w/ apchelintcev) would like to see proper profiles ACLs happening, it's a longer shot with should be estimated and prioritized if we really wanted to (see linked concept for preferences and user profile).
For now, we don't change the current approach (favs are 'managed' in system ctx), and the original fix does the trick.

Generated at Mon Feb 12 09:02:03 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.