Saturday, March 5, 2016

Automatic approval of assets

Oracle WebCenter Sites allows to schedule a publishing event called as Scheduled Publishing so that content gets published to target system automatically, if approved. Furthermore, with respect to publishing, WebCenter Sites also provides custom hooks like publish event listener (for auditing purposes), writing custom transporter (multi-destination publishing), email on completion of content's life cycle via workflow step or condition, etc. But it lacks one very important feature i.e. automatic approval of content.

In nearly all enterprise-level Oracle WebCenter Sites projects, it is very common to have following architectural design:
Description of Figure 1-10 follows
                                                              WebCenter Sites Systems

where each system has its own database, application server and web server (if applicable). One of the systems, Testing system, is an optional system usually installed for quality assurance. Content is synchronized between each system by means of Publishing (generally RealTime Publishing is used). But problem with having Test system is that authors/content editors do not usually approve and/or publish content from Management System but they want their content to be present in Testing System for testing site before go-live. And thus, this is where automatic approval of content can be very helpful for clients.

General steps:
1. Create one user with highest privileges on the source system (usually batchuser should be enough but having a separate user will not hurt). Although this is very easy task but needs to be taken care while creating such user as its credential should not be exposed to any other users who have access to Admin UI and/or Support Tools because these users can view/download the properties files and know password if not encrypted. To overcome this problem, use OOTB WebCenter Sites's utility program: PropertyEditor (both windows and unix version are available) which is shipped with WebCenter Sites; to save the password as encrypted (Check Sites Internal Security). Usually, it is better to create one site-specific/project-specific property file for e.g. [sitename/projectname]_Properties.ini file and add username & password. This property file should be placed in same folder where futuretense.ini file resides.

2. Write a custom utility which searches for held, new and edited assets which are required to be approved to target system. As it is considered that automatic publishing event is already set for publishing assets from source to target system, utility just needs to find and approve those assets. To implement this functionality, basic steps would be as followed:
  • Create a CSElement from Admin UI or developer tools in Eclipse, say, for e.g. ApproveAssetsEvent
  • Create a SiteEntry in SiteCatalog table using Sites Explorer (erstwhile Content Server Explorer) with same name i.e. ApproveAssetsEvent where sscache and cscache should be false. Important: Name should be same and should be created from Sites Explorer as there is one bug where in if SiteEntry is created from Admin UI, it fails to run the associated CSElement via System Events.
  • Following sample code snippet should be helpful in writing this utility:


3. Add an entry in SystemEvents table via Sites Explorer with following:
  • eventname: ApproveAssetsEvent
  • type: 1
  • enabled: 1 (1 for enabling and 0 for disabling)
  • times: add time as mentioned in guide (Time format: hours:minutes:seconds weekdays/days of month/months of year)
  • target: ContentServer
  • params: pagename=ApproveAssetsEvent&target=12345 (where 12345 is Target System Id) 
That's it!! By implementing this solution, editors can now create their content in management system without worrying about approving it to Test System and thus, save time. Also, one can add logs within code for debugging purposes or can create & update some custom table to maintain approval history or can output the results in some file for reviewing later.

Summary:
  1. Create CSElement + SiteEntry or Template which lists the assets for approval and approves them for scheduled publishing.
  2. Add the entry in SystemEvents table using SitesExplorer.
  3. If there is too much activity on management system and depending upon how complex operations will take place in approve assets' element, custom event can be performance intensive and thus, it is better to schedule it when there is no or very less editorial activity. Usually scheduling to approve assets at the end of the day should be ideal time but obviously differs from project to project.
  4. Additionally one can off-load all events in SystemEvents table if you have clustered installation; by setting cs.eventhost to the cluster node which will act as event host and by setting cs.batchhost property which will act as batch host.
  5. Take care to set time of this custom approval event which doesn't clash with scheduled publishing event.
Disclaimer: This post does not provides full implementation rather just an idea on how to develop such solution. Please note, the code and the configurations posted are not official recommendation and should be used at sole's discretion with proper testing before deploying on live WebCenter Sites systems.

No comments:

Post a Comment

A simple code compare functionality

One of the most important aspect of any development cycle is deployment and while deployment, it is very important to note the changes don...