ActivityService - Alfresco Content Services - 23.4 - 23.4 - Ready - Alfresco - external

Alfresco Content Services

Platform
Alfresco
Product
Alfresco Content Services
Release
23.4
License

The ActivityService is responsible for generating activity feeds for each member of a Share site. The activities generated include such events as a document was added, a document was previewed, the wiki was updated.

What is an activity?

  • Activity represents an action that has taken place within a client interface (app/tool)
  • Activity is typically initiated by the app/tool/component/service on behalf of a user (it is not necessarily initiated by the underlying repository)
  • Activity is of a given/named type specified by the app/tool (for example document added)
  • Activity is performed at a particular point in time (post date)
  • Activity may have associated data dependent on type of activity
  • Activity may be performed within a given site/network context
  • Activity may be performed within a given app/tool context
  • Activity may be sensitive, that is, associated with data that is permission controlled, therefore, the activity itself may be permission controlled (can or can’t be read)
  • Activity may be rendered into one or more UI views (activity summary)

Activities may be raised by one or more Content Services applications. The posted activity must have a uniquely named activity type.

Examples of activity types include:

  • Added, updated, and deleted documents
  • Triggered on versioning
  • Includes changes to metadata (explicitly denoted in feed)
  • Does not include updates to tags
  • Uploaded and expanded ZIP
  • Added and deleted folders
  • Added and removed members (person joined/left site)
  • User role changes (change of user role for a site)
  • New comments (on any artifact in a site, including documents, blog entries, and so on.)
  • Workflow-generated activities (requires explicit posting via customizing workflow definition)
  • Added, updated, and deleted events (calendar entries)
  • Published, updated, and deleted wiki pages
  • Published, updated, and deleted blog entries
  • Blog entry published to external blog engine

Sample code showing posting an activity:

privatevoidpostActivityUpdated(NodeRef nodeRef){
    SiteInfo siteInfo = serviceRegistry.getSiteService().getSite(nodeRef);
    String jsonActivityData = "";

    try {
        JSONWriter jsonWriter = new JSONStringer().object();
        jsonWriter.key("title").value((Object)serviceRegistry.getNodeService().getProperty(
                nodeRef, ContentModel.PROP_NAME).toString());
        jsonWriter.key("nodeRef").value((Object)nodeRef.toString());
        StringBuilder sb = new StringBuilder("document-details?nodeRef=");
        sb.append(URLEncoder.encode(nodeRef.toString(), "UTF-8"));
        jsonWriter.key("page").value((Object)sb.toString());
        jsonActivityData = jsonWriter.endObject().toString();
    }
    catch (Exception e) {
        thrownew RuntimeException(e);
    }

    FileInfo fileInfo = serviceRegistry.getFileFolderService().getFileInfo(nodeRef);
    serviceRegistry.getActivityService().postActivity("org.alfresco.documentlibrary.file-updated", 
        siteInfo == null ? null : siteInfo.getShortName(), siteInfo == null ? null : "documentLibrary", 
        jsonActivityData, null, fileInfo);
}