Extending WPC Content Handling 
The IWPCContentHandling interface provides the following content handling capabilities:
Notification on content modifications
For more information, see Updating Page Status On Modification of Existing Content.
Handling of a pending approval request
To handle a pending approval request, you use one of the following methods to either approve or reject the request:
public Map<String, String> approve(IUser user, String objectID) throws ApprovalException;
public Map<String, String> reject(IUser user, String objectID) throws ApprovalException;
The following examples demonstrate how to approve a request, and how to approve a request and send a notification to the initiator of the request.
Example
// Approve a request String pageID = "MainPage"; // ID of page to approve IUser approverUser = "A123456"; // User who approves the request IWPCContentHandling contentHandling = (IWPCContentHandling) PortalRuntime.getRuntimeResources().getService(IWPCContentHandling.KEY); contentHandling.approve(approverUser, pageID);
Example
// Approve a request, and send notification to the author who initiated the request
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
.
.
.
String pageID = "MainPage"; // ID of page to approve
IUser approverUser = "A123456"; // User who approves the request
.
.
.
IWPCContentHandling contentHandling = (IWPCContentHandling) PortalRuntime.getRuntimeResources().getService(IWPCContentHandling.KEY);
{ //Approval
Map <String, Object> approved_notificationParams = null;
try {
// Trigger the 'approve' method in the IWPCContentHandling service
approved_notificationParams = contentHandling.approve(approverUser, pageID);
// The page has been approved
// Use the notification parameters to notify the author, using the custom notification mechanism
}
catch (ApprovalException e) {
response.write("<br>An error occurred. ApprovalException was caught while trying to approve " +
"the object with the following ID: " + pageID + ".<br>");
return;
}
response.write("<br>Page has been approved.<br>");
// Navigate to the custom notification component, using the response object
triggerNavigation(response, approved_notificationParams);
return;
}
}
// Notification
private void triggerNavigation(IPortalComponentResponse response, Map <String, Object> approvedNotificationParams) {
String url = null;
Object messageType = approvedNotificationParams.get(NotificationConstants.PropertyKeys.MESSAGE_TYPE);
Object to = approvedNotificationParams.get(NotificationConstants.PropertyKeys.TO);
Object from = approvedNotificationParams.get(NotificationConstants.PropertyKeys.FROM);
Object cc = approvedNotificationParams.get(NotificationConstants.PropertyKeys.CC_RECIPIENTS);
Object objectName = approvedNotificationParams.get(NotificationConstants.PropertyKeys.OBJECT_NAME);
Object objectDesigntimeID = approvedNotificationParams.get(NotificationConstants.PropertyKeys.OBJECT_ID_DESIGNTIME);
Object objectLink = approvedNotificationParams.get(NotificationConstants.PropertyKeys.OBJECT_LINK);
Object versionDescription = approvedNotificationParams.get(NotificationConstants.PropertyKeys.VERSION_DESCRIPTION);
// Standard nagivation-mode parameter, to determine the type of navigation to perform to the custom notification component
// The default value 3 opens a new headerless window
Object navMode = approvedNotificationParams.get("NavMode");
navMode = (navMode == null) ? "3" : navMode;
url = approvedNotificationParams.get("handlerID").toString() + '?';
url = url + NotificationConstants.PropertyKeys.MESSAGE_TYPE + "=" + URLEncoder.encode(messageType.toString());
url = url + '&' + NotificationConstants.PropertyKeys.TO + "=" + URLEncoder.encode(to.toString());
url = url + '&' + NotificationConstants.PropertyKeys.FROM + "=" + URLEncoder.encode(from.toString());
url = url + '&' + NotificationConstants.PropertyKeys.OBJECT_NAME + "=" + URLEncoder.encode(objectName.toString());
url = url + '&' + NotificationConstants.PropertyKeys.OBJECT_ID_DESIGNTIME + "=" + URLEncoder.encode(objectDesigntimeID.toString());
url = url + '&' + NotificationConstants.PropertyKeys.OBJECT_LINK + "=" + URLEncoder.encode(objectLink.toString());
if ((cc != null) && (!cc.equals("")))
url = url + '&' + NotificationConstants.PropertyKeys.CC_RECIPIENTS + "=" + URLEncoder.encode(cc.toString());
if ((versionDescription != null) && (!versionDescription.equals("")))
url = url + '&' + NotificationConstants.PropertyKeys.VERSION_DESCRIPTION + "=" + URLEncoder.encode(versionDescription.toString());
// Adding JavaScript to the response, to trigger an EPCM navigation event.
// Navigates to the custom notification component using the notification parameters
response.write("<script language='javascript'>" +
"EPCM.doNavigate('" + url + "','" + navMode + "','','','','','','');" +
"<script>");
}