In nearly all enterprise-level Oracle WebCenter Sites projects, it is very common to have following architectural design:

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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters<%@page import="java.util.Date" %><%@ taglib prefix="cs" uri="futuretense_cs/ftcs1_0.tld" %><%@ taglib prefix="asset" uri="futuretense_cs/asset.tld" %><%@ taglib prefix="usermanager" uri="futuretense_cs/usermanager.tld" %><%@ taglib prefix="ics" uri="futuretense_cs/ics.tld" %><%@ taglib prefix="render" uri="futuretense_cs/render.tld" %><%@ page import="COM.FutureTense.Interfaces.*, COM.FutureTense.Util.ftMessage, COM.FutureTense.Util.ftErrors" %><cs:ftcs><%-- /** * @author: fatwiredev * * Sample utility element to approve article assets of AviSports site to target system * */ --%><ics:if condition='<%=ics.GetVar("eid")!=null%>'><ics:then><render:logdep cid='<%=ics.GetVar("eid")%>' c="CSElement"/></ics:then></ics:if> <ics:logmsg msg='<%= "Starting Approval Event at: " + new Date().toString() %>' name="com.avisports.assets.approval.event" severity="DEBUG"/> <ics:getproperty name="xcelerate.batchuser" file="futuretense_xcel.ini" output="batchusername"/> <ics:getproperty name="xcelerate.batchpass" file="futuretense_xcel.ini" output="batchpassword"/> <usermanager:loginuser username='<%=ics.GetVar("batchusername")%>' password='<%=ics.GetVar("batchpassword")%>' varname="loggedIn" /> <ics:if condition='<%="true".equalsIgnoreCase(ics.GetVar("loggedIn")) && ics.GetErrno() == 0%>'><ics:then><% String sql = "Select id as assetid, 'AVIArticle' as assettype from AVIArticle where status!='VO'"; //Optimize query to fetch only those assets which require approval like held assets, new assets and edited assets which are not approved+published %><ics:sql listname="listToApprove" sql="<%= sql %>" table="AVIArticle"/> <ics:if condition='<%= ics.GetList("listToApprove") != null && ics.GetList("listToApprove").hasData() %>'><ics:then> <ics:logmsg msg='Trying to approve all article assets' name="com.avisports.assets.approval.event" severity="INFO"/> <%-- Set the following required variables list -- IList of assets to be approved recursive -- (boolean) approve dependencies or not force -- (boolean) force approval or not target -- target id which would be set while adding entry in SystemEvents table dryrun -- whether this is a dry run or a real approval --%> <ics:setvar name="list" value="listToApprove"/> <ics:setvar name="recursive" value="true"/> <ics:setvar name="force" value="false"/> <ics:setvar name="dry" value="false"/> <ics:setvar name="target" value="<%= ics.GetVar("target") %>"/> <%-- Call the OOTB provided WCS element which approves list of assets. Note: The behavior of this element may differ and/or can change in different version of Oracle WebCenter Sites. It is better to create your own element, then copy & paste the code and make changes as required to avoid any issues in event of upgrade. --%> <render:callelement elementname="OpenMarket/Xcelerate/PrologActions/Publish/AdvPub/ApproveAssets" scoped="global"/> <ics:if condition='<%= Integer.valueOf(ics.GetVar("errno")) == 0 %>'><ics:then> <ics:logmsg msg='Successfully approved assets' name="com.avisports.assets.approval.event" severity="INFO"/> <%-- Following can be helpful to maintain the logs for past approvals: 1. Add logs within code for debugging purposes which show up in sites.log file 2. Maintain a simple custom table to check approval history 3. Output the results with status in some file for reviewing later. --%> </ics:then><ics:else> <ics:logmsg msg='<%= "Error while approving assets: " + ics.GetErrno() %>' name="com.avisports.assets.approval.event" severity="ERROR"/> <%-- Email or log error info in some file for reviewing later --%> <ics:clearerrno/> </ics:else></ics:if> </ics:then></ics:if> </ics:then><ics:else> <ics:logmsg msg='<%= "Error while logging using batch user: " + ics.GetErrno() %>' name="com.avisports.assets.approval.event" severity="ERROR"/> </ics:else></ics:if> <usermanager:logout/> <ics:logmsg msg='<%= "Finished Custom Approval Event at: " + new Date().toString() %>' name="com.avisports.assets.approval.event" severity="DEBUG"/> </cs:ftcs>
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)
Summary:
- Create CSElement + SiteEntry or Template which lists the assets for approval and approves them for scheduled publishing.
- Add the entry in SystemEvents table using SitesExplorer.
- 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.
- 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.
- Take care to set time of this custom approval event which doesn't clash with scheduled publishing event.
No comments:
Post a Comment