Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

ContentPropertyManager not working to get or set the confluence.user.site.homepage

Thomas Berger August 22, 2016

According to https://developer.atlassian.com/confdev/development-resources/confluence-architecture/confluence-internals/persistence-in-confluence

it should be possible to manipulate properties stored in the OS_PROPERTYENTRY table in the database.

https://developer.atlassian.com/static/javadoc/confluence/4.2.4/reference/com/atlassian/confluence/core/ContentPropertyManager.html

public String getStringProperty (ContentEntityObject entity, String key)

Get a string property associated with a content entity object, or null if that property is not set. String properties can not be longer than 255 characters

Parameters
entitythe entity the property is associated with
keythe key with which to look up the property

 

The 'entity_name' is stored like 'USERPROPS-userKey'

image2016-8-23 9:53:59.png

 

String userSiteHome = contentPropertyManager.getStringProperty((ContentEntityObject) user, "confluence.user.site.homepage");

I get the error message:

"com.atlassian.confluence.user.ConfluenceUserImpl cannot be cast to com.atlassian.confluence.core.ContentEntityObject"

Is there 'another' user object I should pass?

Or should I be using UserDetailsManager instead?

String userSiteHome = 
userDetailsManager.getStringProperty(user, "confluence.user.site.homepage");

This returns 'null'.

Is there a trick on how to use/initialize the UserDetailsManager?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Robert Krause
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2016

Hi @Thomas Berger,

we use the UserAccessor to get and manipulate a users homepage, where user is of type ConfluenceUser.

userAccessor.getPropertySet(user).setString(UserPreferencesKeys.PROPERTY_USER_SITE_HOMEPAGE,
      MY_SPACE_KEY);

 

Best regards,
Robert 

Thomas Berger August 23, 2016

Thanks Robert, you saved my day!

Like Lars Maehlmann likes this
TAGS
AUG Leaders

Atlassian Community Events