WebCenter

What is MDS and how is it used in WebCenter

Overview
In order for Oracle WebCenter to find a way of making a generic, flexible and configurable application Oracle needed to find a way of configuring the application to behave and look different based on the needs of the customer. The changes to the system whether they are Design changes (also known as seeded customisations) or Runtime changes all use the MDS to store the customisations.

To do this Oracle created the Metadata Service. Metadata is essentially data about data, if you think of file properties in any OS, that is metadata on the file itself.

So, WebCenter uses this metadata store to keep track of all of the system changes and also any tweaks that the user can make to their pages as well. It provides a very flexible mechanism to have a single product that can behave and look different user to user and company to company.

The data can either be stored on the file system or in a database. Oracle recommend that you use a relational database rather than the file system.

Accessing the data
To be able to gain access to the metadata or to upload changes you can use the WLST shell. You’ll need to connect to your server and then from there you can run the commands importMetadata and exportMetadata.

Here are a few example commands to get you going.

– Connect to wlst using the command
– $MIDDLEWARE_HOME/Oracle_WC1/common/bin/wlst.sh
– connect(“weblogic”, “welcome1”, “127.0.0.1:7001”)

To export the data from the meta data store execute the following command in the wlst shell.
– exportMetadata(application=’webcenter’,server=’WC_Spaces1′,toLocation=’/home/oracle/mdssys.zip’,docs=’/mdssys/**’);
– To delete meta data from the store execute the following command in the wlst shell.
– deleteMetadata(application=’webcenter’,server=’WC_Spaces1′,docs=’/mdssys/**’);

To import meta data into the store call the following function:
– importMetadata(application=’webcenter’,server=’WC_Spaces1′,fromLocation=’/home/oracle/file.zip’);

Adding Edit Capability to WebCenter Profile page

In my previous post about being able to update user profiles programmatically it assumed that the user had the capability to edit the profile.

There were some additional configuration steps required to be able to get this to work in a controlled way which are explained below. The easy way would be to add the “Manage People Connections” permission to the “Authenticated-User” role, however, this gives more capability that we really want. The steps below are aimed at only enabling edit capability.

Adding general permission to the authenticated-user role
1. Login to WebCenter using weblogic
2. Click Administration then click Security
3. Scroll right on the Roles table (note you have to scroll to the bottom first to see the scrollbar)
4. The Authenticated-User role in the table should be on the right hand side. Enable “Update People Connections Data” and then click Apply at the top of the page.

Enable the application policy
1. Login to Enterprise Manager
2. Navigate to Farm_base_domain->Weblogic Domain->base_domain
3. Right click on base_domain and then select Security->Application Policies.
4. Search for the right policy using the details:
a. Application Stripe: webcenter
b. Principal Type: Application Role
c. Name (Includes): authenicated
5. Select Principal “authenticated-user” and click Edit
6. In the Permissions section click the Add button.
7. Select “oracle.webcenter.peopleconnections.profile.security.ProfilePermission” from the Permission Class dropdown.
8. Enter “/oracle/webcenter/peopleconnections/profile/s8bba98ff_4cbb_40b8_beee_296c916a23ed/.*” in the Resource Name section and click the blue search arrow button.
9. Select the line that has the “Edit” Permission Action
10. Click Continue then OK

Updating a user’s WebCenter Profile programmatically

There are many details stored in a user’s profile and sometimes it needs to be controlled what is updated and how. This means that using the standard edit capability in the WebCenter profile screen isn’t possible.

To get around this you can create a custom taskflow that that permits and validates the changes to the profile. The challenge that I found when working on this was how to get the user’s profile, update it and get WebCenter to invalidate the cached profile object that it had stored.

Whilst hunting through the APIs I found a WCUserProfile class that looked like it fitted my needs and also it had a save(); method on the object. I had a go at retrieving the profile and updating it then calling save(); and it worked.


  private void updateAndSaveUserProfileChanges(String username) throws ProfileException {
    WCUserProfile userProfile = this.userProfileManager.getProfileForUpdate(username);
    userProfile.setFirstName("John");
    userProfile.setLastName("Smith");
    userProfile.setBusinessEmail("john.smith@somewhere.com");
    userProfile.save();
  }

Note that getProfileForUpdate was used to get the WCUserProfile object, there is another getProfile command without the update. I opted for the getProfileForUpdate because I was updating it but the JavaDoc wasn’t too helpful I found.

The one thing I haven’t solved with this change is the About screen in WebCenter still has cached content in the user’s session. Logging out and back in clears this and the About page in the User’s Profile then shows the updated information.

Where to find GenericConstants.AM_REQUEST_TOKEN_IDENTIFIER when creating a custom login page for Oracle WebCenter

Whilst working on creating a custom login screen for Oracle WebCenter I came across something in the instructions that was assumed and undocumented.

In the guide Developing Custom Pages it contains the code below:

String reqToken = request.getParameter(GenericConstants.AM_REQUEST_TOKEN_IDENTIFIER);

<%
if(reqToken != null && reqToken.length() > 0) {%>
<input type="hidden" name="" value="">
<%
}%>

However, I couldn’t find the location of GenericConstants.AM_REQUEST_TOKEN_IDENTIFIER anywhere, google searches returned nothing of any use. Hence why I’m sharing this.

The jar that you need to include in your project is bizarrely only available on the target OAM server! If you search for utilities.jar which on our server was located at $MIDDLEWARE_HOME/user_projects/domains/OAMDomain/servers/oam_server1/tmp/_WL_user/oam_server_11.1.2.0.0/88g74i/APP-INF/lib

Bits of this path will be different on your system beacause of how your domain is configured, however, you should roughly have the structure.

Copy the utilities.jar to your projects lib folder and include it in the JDeveloper libraries for your custom login page project. You should then have access to these pre-defined Strings.

“Development Lifecycle for Taskflows in WebCenter Portal” whitepaper guidance notes

Whilst following the white paper from Oracle on the “Development lifecycle in Oracle WebCenter Portal” I came across a significant issue for new users of WebCenter which was a missing project for the tutorial.

It stated in the introduction that there are applications shipped with the whitepaper but I couldn’t find them and neither could Oracle Support. To get going in the meantime I created my own “GenericWebService” project that satisfied the requirements of the tutorial. This is available here.

Alternatively, follow the steps below to create it yourself.

Missing connection.xml file
Section 3a: Create a Web Service Proxy Facade – On page 28 the whitepaper says to update the connection.xml file with the contents in yellow in the page above. However, for my application that I had created I didn’t have a connection.xml file for some reason. To resolve this I closed the GenericServiceConsumer application, went to the GenericServiceConsumer\.adf\META-INF folder and created a new file called connection.xml. On re-opening the GenericServiceConsumer project the file was then available and I could paste the conents below into it.

<?xml version = '1.0' encoding = 'UTF-8'?>
<References xmlns="http://xmlns.oracle.com/adf/jndi">
  <Reference name="GenericUserWebServiceConnection"
             className="oracle.adf.model.connection.webservice.impl.WebServiceConnectionImpl"
             manageInOracleEnterpriseManager="true" deployable="true" xmlns="">
    <Factory className="oracle.adf.model.connection.webservice.api.WebServiceConnectionFactory"/>
    <RefAddresses>
      <XmlRefAddr addrType="WebServiceConnection">
        <Contents>
          <wsconnection description="http://localhost:7101/GenericWebService-UserWebService-context-root/UserServiceWS?WSDL"
                        service="{http://oracle.com/}UserServicePort"/>
        </Contents>
      </XmlRefAddr>
    </RefAddresses>
  </Reference>
</References>

Nullpointer Exception
I also had a nullpointer exception thrown when I first started up the taskflow in the JSF page. This was probably because of the home made web service project that I created above. It wasn’t a SOAP based web service and therefore the URL was wrong in the connection.xml file.

You will notice that mine above contains the URL http://localhost:7101/GenericWebService-UserWebService-context-root/UserServiceWS?WSDL whereas the whitepaper’s URL is http://localhost:8888/GenericWebService-UserWebService-context-root/UserServiceSoap12HttpPort?WSDL

Proxy Server pitfalls with JDeveloper!

If you are using JDeveloper with a proxy server then you may already be familiar that you need to go into Tools->Preferences->Web Browser and Proxy to setup your proxy server. For me this is required so that I can download extensions into JDeveloper.

I then began to have issues when I was trying to setup my JDeveloper connection to my VM application server that hosts WebCenter. I filled all of the details out correctly however, the connection test output returned failure when testing JSR-160. See output below.

Testing JSR-160 Runtime … failed.
Cannot establish connection.
Testing JSR-160 DomainRuntime … skipped.
Testing JSR-88 … skipped.
Testing JSR-88-LOCAL … skipped.
Testing JNDI … skipped.
Testing JSR-160 Edit … skipped.
Testing HTTP … success.
Testing Server MBeans Model … skipped.

This issue was down to the proxy server settings. I attempted to configure the proxy settings in JDeveloper to ignore my VM, so it didn’t go through the proxy server, I tried disabling the proxy server. Neither of these worked.

What I needed to do was disable the proxy server settings in JDeveloper and then restart it! Only once I had restarted did the disabling of the proxy work.

The downside of JDeveloper here, is I now need to turn the proxy settings on whenever I need to download/check the extensions but then disable it whenever I need to deploy to my VM Application Server!

Customising WebCenter Portal Spaces

This post is aimed at providing a summary of what is required and what is available when developers want to customise their WebCenter Portal: Spaces application (Renamed to WebCenter Portal from 11.1.1.8). It doesn’t go into detail, however, does provide useful links to the Oracle documentation on where to go for further details.

There are a couple of options available to developers if they want to customise Spaces within WebCenter.

  • Browser – If adding spaces, tweaking/selecting templates customising portals, spaces and pages with respect to content.
  • JDeveloper – If you want to deploy additional shared libraries, include custom code or tasksflows. You can also edit skins, page templates and navigations in JDeveloper too.
  • In order to customise any Spaces in JDeveloper you’ll need to download the DesignWebCenterSpaces project available here for version 11.1.1.6. This consists of a JDeveloper application which contains two projects “WebCenterSpacesExtensionLibrary” and “WebCenterSpacesResources”.

    WebCenterSpacesExtensionLibrary (11.1.1.6)
    On the Weblogic server there is already an empty extended.spaces.webapp.war and the WebCenterSpacesExtensionLibrary project in this application allows the developer to add and build a new extended.spaces.webapp.war.

    WebCenterSpacesExtensionLibrary (11.1.1.8)
    There is a zip file in this page that you’ll need for customising skins and page templates. Search for DesignWebCenterSpaces_11.1.1.8.0.zip download that and open the application in JDeveloper to get going.

    This project essentially contains a weblogic.xml that you can insert the shared library declarations into.

    Creating your own extended.spaces.webapp.war informs WebCenter Portal: Spaces that you are deploying customisations that the server needs to make available.

    Important Note – It is best practice to deploy your extended.spaces.webapp.war in addition to the one that comes with the server. As long as the version in the Manifest.MF file in the war is greater then this will take precedence. Keeping the original ensures that if needed you can go back to the base configuration.

    WebCenterSpacesResources
    This project contains resource customisations, e.g. custom skins, page templates, page styles, navigations etc. It provides a single project that enables the developer to customise the look and feel of Spaces and allows you to make these changes from within JDeveloper. As a starting point you can export your existing application to get it’s templates and then make incremental changes to that rather than trying to start from scratch.