Follow Us on Twitter

Saving user preferences in Oracle Webcenter

by Marcel Maas on July 10, 2012 · 5 comments

That’s the requirement that arose while working on a project with Webcenter Spaces last week. Of course there are a couple of ways to do so but we did not want to maintain our own preferences database. What we really wanted to do was save these preferences in the MDS because these user preferences would generate some personalized dashboards. Also we figured since the MDS should store user personalization and customization this was the right place to save this data.

However after searching heaven, earth and google I was almost ready to give up hope. I could use user personalization but this does not give you the amount of control I would like to have. My usecase was quite simple:

A user logs in to Webcenter Spaces. On his dashboard he can click a button to edit his preferences and get a list of checkboxes for choosing categories. These checkboxes define his preferences and should be saved in the MDS.

After a last search I came across the following package:

http://docs.oracle.com/cd/E21043_01/apirefs.1111/e10686/oracle/adf/share/prefs/package-summary.html

This seemed to be exactly what I needed. It gives you the possibility to save data to a map for only the current user. All this is persisted in the MDS. This means you can use this functionality for not only Webcenter but for any application using the Oracle MDS. An example:

// First create a PreferencesFactory
// This class automatically creates a connection to the MDS Server
ADFPreferencesFactory adfp = new ADFPreferencesFactory();
// Now save a preference by adding a value to the map on the userRoot (which saves the preference only for the logged in user)
adfp.userRoot().put("ShowNews", "Yes");

Now for retrieving the preference:

// Create the preferencesFactory again
ADFPreferencesFactory adfp = new ADFPreferencesFactory();
// Get the value of the preference "ShowNews"
// When no preference (key) "ShowNews" can be found, "No" is returned as value
String pref = adfp.userRoot().get("ShowNews", "No");
// pref now has the value "Yes"

As you can see the functionality is extremely simple. At the moment you put something on the map it is immediately persisted to the MDS. The UserPreferences package has some additional functionality but I will leave it to you to try that out. Just check the API reference.

Good luck!

Saving user preferences in Oracle Webcenter, 3.3 out of 5 based on 3 ratings
Ratings:
VN:F [1.9.22_1171]
Rating: 3.3/5 (3 votes cast)

{ 4 comments… read them below or add one }

Ajay November 16, 2012 at 12:48 pm

Hi,
I tried this on a plain ADF application and i am getting the following error.
Am i missing anything.

oracle.mds.exception.ReadOnlyStoreException: MDS-01273: The operation on the resource /oracle/adf/share/prefs/data/preferences.xml failed because source metadata store mapped to the namespace / BASE DEFAULT is read only

Reply

Raj January 23, 2013 at 5:33 pm

I am too getting the same exception on plain oracle ADF application.

oracle.mds.exception.ReadOnlyStoreException: MDS-01273: The operation on the resource /oracle/adf/share/prefs/data/preferences.xml failed because source metadata store mapped to the namespace / BASE DEFAULT is read only

Any Thought ??

Reply

Chandresh Patel March 28, 2014 at 2:16 am

As described in this blog, this works for Oracle WebCenter. If you want to use this API in plain ADF application, add namespace “/oracle/adf/share/prefs” as shown in following code snippet in your adf-config.xml.

Reply

Chandresh Patel March 28, 2014 at 2:20 am

my comment did not get through properly…
namespace path=”/oracle/adf/share/prefs” metadata-store-usage=”MAR_TargetRepos”

Reply

Leave a Comment

 

{ 1 trackback }

Previous post:

Next post:

About Whitehorses
Company profile
Services
Technology

Whitehorses website

Home page
Whitebooks
Jobs

Follow us
Blog post RSS
Comment RSS
Twitter