Create custom activity in WebCenter Activity Stream

person Bijeshfolder_openOracle, WebCenteraccess_time January 30, 2015

WebCenter provides an out-of-the-box activity stream that is leveraged to log user activities like add documents, posting messages, modifying space/portal settings, etc. The Activity Stream module also exposes an API that may be used to add custom activity events to the stream.

I couldn’t find a single source for all the information about publishing custom activities and so I decided to log my experience using the APIs. The post also includes sample code for publishing an activity.

At a high level, these are the steps

  1. Define a service via service-definition.xml. The main details include
    • A unique serviceId
    • resource bundle for the activity message, etc.
    • activity types
    • object types
    • resource view and resource mini view if applicable
  2. Java code to use the ActivityStreamingService and associated API to publish the event
  3. Deploy to  WebCenter Portal as an ADF Library Jar within a shared library

The sample demonstrates publishing a “Create purchase order” activity to the stream. The README file and the screenshots should give an idea of the what and the how. Here’s a peak at the code

    1. service-definition.xml
<?xml version="1.0" encoding="utf-8" ?>
<definitions xmlns="">
 <service-definition id="com.uxcredrock.purchaseorder" version="">
                                 preferredHeight="400" preferredWidth="640"/>
     <name>Purchase Order Viewer</name>
     <description>Purchase Order Viewer</description>
         <generic-activity-category name="CREATE">
             <activity-type name="createPO" displayName="Create Purchase Order"
         <object-type name="purchaseOrder" displayName="Purchase Order"
                 description="Purchase Order"/>
    1. Instantiate and use ActivityStreamingService API
ActivityStreamingService service = 
//requires the GUID of the user in WebCenter Portal
ActivityActor actor = service.createActor(userGUID); 
ServiceObjectType objectType =  service.findObjectType(serviceId, "purchaseOrder");
ActivityObject activityObject = service.createObject(purchaseOrderId
                                                   , objectType
                                                   , purchaseOrderSummary);
ActivityType activityType = service.findActivityType(serviceId, activityTypeName);
ActivityElement  activityElement = 
                                                      , serviceContext.getScope(), serviceId
                                                      , activityType , activityActors
                                                      , activityObjects, ActivityPermission.SHARED
                                                      , new Date());

The source code is here: ActivityStreamingSample.7z

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>