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:
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:
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:
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!