You are here

Working with Customization Classes in WebCenter

In WebCenter each customization that you do is stored in a layer in the MDS. This is nicely explained in the ADF Documentation: http://docs.oracle.com/cd/E16764_01/web.1111/b31974/customize.htm

WebCenter uses this functionality quite heavily. Almost everything you do at runtime is stored as such a layer on top of your basic application.

Most people who have been working with WebCenter for a while understand this part but not many people know or understand how to manipulate the layer selection. You can control in which layer those customizations are stored or which layer to display depending on your own business logic.

It will become more clear with an easy example. Suppose I have a page in my application and I want to provide each department of my company with a different view of that page. This can be achieved by providing them each their own page but it would be easier to manage if you have a single page and apply a different layer depending on the department.

When an administrator of the HR department makes changes to the page, they will only be affected for the members of the HR group. If an admin of the Finance group makes changes to the same page, they will only be visible for the members of the finance group.

This can be achieved by implementing a customization class. By default a WebCenter application has been configured to use a layer called Site. It is using a customization class that always returns Site as value for the layer.

You can check this out by opening the adf-config and check the MDS Configuration:

Notice that the Customization Class is SiteCC.

When we run the application and make a customization like adding a taskflow to a page, we will be able to find out the name of the layer by browsing to the MDS folder. When working with the integrated environment in JDeveloper, the MDS is file based and not DB bases so we can easily examine it.

You can find the location of the MDS by opening the Application Properties. Under Run select MDS and copy the Default Location:

Paste this in explorer to open the MDS directory

The last part of the directory contains the layer name and value. In our case this comes from the SiteCC class defined in the MDS Configuration.

We will now create a custom class that will select a different layer depend on business logic. Afterwards we can examine the MDS another time to see that there are separate folders for different layer values.

You can download the application here.

I have added a few users and groups to make the use case more clear:

hrAdmin/welcome1 is the administrator for the HR group
hrUser/welcome1 is a member of the HR group
finAdmin/welcome1 is the administrator for the finance group
finUser/welcome1 is a member of the finance group

Finance and HR are also two Application Roles.

When you create a customization class, you have to create a java class that extends the CustomizationClass. You need to implement 3 methods:

  • CacheHint getCacheHint()
  • String getName() this will return the name of the layer that should be used
  • String[] getValue(RestrictedSession restrictedSession,MetadataObject metadataObject) contains the logic to determine the value for the layer.

In this example the layer will be called department and the getValue will determine the value of that layer.

The logic is contained in the getValue method:

  1.     public String[] getValue(RestrictedSession restrictedSession,
  2.                         MetadataObject metadataObject) {
  3.         FacesContext ctx = FacesContext.getCurrentInstance();
  4.         ExternalContext eCtx = ctx.getExternalContext();
  5.         if(eCtx.isUserInRole("Finance")){
  6.            layerName = "finance";
  7.         }
  8.         if(eCtx.isUserInRole("HR")){
  9.             layerName = "hr";
  10.         }
  11.          String[] layers = {layerName};
  12.         return layers;    
  13. }

This will check which role the user is in and selects the role.

Then we have to replace the SiteCC with our class in the MDS Configuration:

The next thing we need to do is to let the application know which layer we will be assigning.
This can be done by clicking on the Configure Design Time Customization Layer Values:

The first time, JDeveloper will ask you to create the file. Just press OK and then it will open the CustomizationLayerValues.xml file

Notice that there is a layer called Site available. This is the one used by the SiteCC.

The layer we are going to use is the department layer (returned by the getName() method) so we have to add the layer and provide the possible values:

This is done by adding following to the file:

  1.   <cust-layer name="department" id-prefix="r">
  2.     <cust-layer-value value="finance" display-name="Finance" id-prefix="1"/>
  3.     <cust-layer-value value="hr" display-name="HR" id-prefix="2"/>
  4.   </cust-layer>

By now you should understand the difference between layer name and layer value.

When we run the application and make some customizations with both users we will notice that both layers will be created in the MDS:

Notice how the department is the name of the layer and the values of the layer are each a subdirectory of the layer.

That's how you can create your own layers and select them based upon some business logic.

The most important part to remember is that you have to specify a layer name and layer value. If the layer name or value does not exist in the CustomLayerValues.xml, it will not work and a default layer will be used.

You can of course add some business logic to the getName method so you are not limited to a single layer. You can make it as complex as you want but remember that this method is called quite often so it is important to keep the logic fast and performing!

Category: 

Comments

hi yannick
when i tried to run the sample of this application i got this exception:
===============================================
ARNING: Failed to get MDS path for namespace [null], due to: oracle.mds.config.MDSConfigurationException
oracle.mds.config.MDSConfigurationException: MDS-00035: cannot load the class: com.im.wcp.portal.DepartmentCC.
at oracle.mds.config.CustConfig.getCustClassList(CustConfig.java:365)
at oracle.mds.config.CustConfig.loadFromBean(CustConfig.java:277)
at oracle.mds.config.CustConfig.(CustConfig.java:242)
at oracle.mds.config.MDSConfig.loadFromBean(MDSConfig.java:701)
at oracle.mds.config.MDSConfig.loadFromElement(MDSConfig.java:764)
at oracle.mds.config.MDSConfig.(MDSConfig.java:515)
at oracle.webcenter.dt.utils.MDSUtil.getMDSPathForNS(MDSUtil.java:194)
at oracle.adfdtinternal.model.portlet.mds.PortletMarPlugin.getAdditionalDocumentsToInclude(PortletMarPlugin.java:354)
at oracle.mds.internal.dt.packaging.MDSMarDeployer.getPlugInDocs(MDSMarDeployer.java:551)
at oracle.mds.internal.dt.packaging.MDSMarDeployer.deployImpl(MDSMarDeployer.java:247)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:457)
at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:217)
at oracle.jdevimpl.deploy.common.ModulePackagerImpl.deployProfiles(ModulePackagerImpl.java:86)
at oracle.jdeveloper.deploy.common.ModulePackager.deployProfiles(ModulePackager.java:63)
at oracle.jdeveloper.deploy.common.ModulePackager.deployImpl(ModulePackager.java:52)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:457)
at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:217)
at oracle.jdevimpl.runner.adrs.AdrsStarter$7$1.run(AdrsStarter.java:1774)
Nov 20, 2012 12:15:54 PM oracle.webcenter.dt.utils.MDSUtil getMDSPathForNS
WARNING: Failed to get MDS path for namespace [null], due to: oracle.mds.config.MDSConfigurationException
oracle.mds.config.MDSConfigurationException: MDS-00035: cannot load the class: com.im.wcp.portal.DepartmentCC.
at oracle.mds.config.CustConfig.getCustClassList(CustConfig.java:365)
at oracle.mds.config.CustConfig.loadFromBean(CustConfig.java:277)
at oracle.mds.config.CustConfig.(CustConfig.java:242)
at oracle.mds.config.MDSConfig.loadFromBean(MDSConfig.java:701)
at oracle.mds.config.MDSConfig.loadFromElement(MDSConfig.java:764)
at oracle.mds.config.MDSConfig.(MDSConfig.java:515)
at oracle.webcenter.dt.utils.MDSUtil.getMDSPathForNS(MDSUtil.java:194)
at oracle.webcenter.internal.dt.packaging.WebCenterMARPlugin.getAdditionalDocumentsToInclude(WebCenterMARPlugin.java:86)
at oracle.mds.internal.dt.packaging.MDSMarDeployer.getPlugInDocs(MDSMarDeployer.java:551)
at oracle.mds.internal.dt.packaging.MDSMarDeployer.deployImpl(MDSMarDeployer.java:247)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:457)
at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:217)
at oracle.jdevimpl.deploy.common.ModulePackagerImpl.deployProfiles(ModulePackagerImpl.java:86)
at oracle.jdeveloper.deploy.common.ModulePackager.deployProfiles(ModulePackager.java:63)
at oracle.jdeveloper.deploy.common.ModulePackager.deployImpl(ModulePackager.java:52)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:457)
at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:217)
at oracle.jdevimpl.runner.adrs.AdrsStarter$7$1.run(AdrsStarter.java:1774)

==================================================
any suggestions
best regards

Is the class valid? You usually get this problem when there is a problem in the CC class.
If it's valid try to clean the project by clicking on Build => Clean All and then rerun the app.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer