Right now our code uses 2 ways to find out if we should display hidden documents for the current user:
- In most places: `Integer preference = userPreferencesSource.getProperty(“displayHiddenDocuments”, Integer.class);``
- In one place:
Object displayHiddenDocuments = documentAccessBridge.getProperty(parameters.user, userClass, "displayHiddenDocuments");. Note: this is needed because we don’t look for the current user’s preference but for a given user.
This is really not nice because it’s code duplication and it makes it harder to maintain it than it should. It also doesn’t follow the SOC principle (Separation of Concerns).
I’m thus proposing to add a new
Yes, I know that XWikiUser is in the
com.xpn package and old, and we need a new proper User interface in the newer
xwiki-platform-user-api module. However that’s harder to do and will take more time. I still think that doing what I propose is going in the right direction and will make it easier to switch from XWikiUser to any future User class.
PS: I think having a
UserPreferencesConfigurationSource was actually a bad idea, because it’s too low level and doesn’t offer a nice typed API. Thus I think we should deprecate and legacify
UserPreferencesConfigurationSource at some point. It becomes a liability since code can directly use it instead of going through XWikiUser. For example Simon recently added a
XWikiUser#isDisabled() method but nothing prevents code from using directly
UserPreferencesConfigurationSource and to check the “active” xproperty’s value. And yes, I know it’s possible to use the
XWikiDocument API too to access a User profile’s properties too so that’s also a liability but this one is harder to remove