{"id":37701,"date":"2014-04-10T05:55:42","date_gmt":"2014-04-10T12:55:42","guid":{"rendered":"http:\/\/localhost\/exoblog\/?p=6872"},"modified":"2023-06-05T16:49:09","modified_gmt":"2023-06-05T14:49:09","slug":"customize-platform-activity-stream-content","status":"publish","type":"post","link":"https:\/\/www.exoplatform.com\/blog\/customize-platform-activity-stream-content\/","title":{"rendered":"How to Customize Your Platform Activity Stream Content"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>The Activity Stream (AS) is the most recognizable social feature of eXo Platform. AS gives you updates of the activities of your connections and spaces. It is also the place to share your work, your stuff or even just your mood.<\/p>\n<p>By using the event listener mechanism, AS automatically publishes activities like user profile updates, document updates, relationship updates and space updates.<\/p>\n<p><!--more--><\/p>\n<p><a href=\"\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-6873\" alt=\"1-Activity-Stream\" src=\"\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream.png\" width=\"650\" srcset=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream.png 975w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream-300x239.png 300w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream-768x613.png 768w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream-593x473.png 593w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream-411x328.png 411w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream-296x236.png 296w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream-164x131.png 164w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream-100x80.png 100w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/04\/1-Activity-Stream-38x30.png 38w\" sizes=\"(max-width: 975px) 100vw, 975px\" \/><\/a><\/p>\n<p>In some cases, you might want to remove such default activities from AS or implement customized actions based on dedicated activities. In this tutorial, you will see how to remove the activities for space leaving and space joining by overriding the <b>SpaceActivityPublisher<\/b> listener.<\/p>\n<h2>How a listener works<\/h2>\n<p>Listeners are registered with the main services. Every time the main service is running and fires a registered event, listeners will be called.<\/p>\n<pre class=\"lang:default decode:true \" >&lt;component&gt;\n\t&lt;key&gt;org.exoplatform.social.core.space.spi.SpaceService&lt;\/key&gt;\n\t&lt;type&gt;org.exoplatform.social.core.space.impl.SpaceServiceImpl&lt;\/type&gt;\t\n\u2026\u2026\u2026\u2026\u2026\u2026      \t\n  \t&lt;component-plugin&gt;\n    \t\t&lt;name&gt;SpaceActivityPublisher&lt;\/name&gt;\n    \t\t&lt;set-method&gt;addSpaceListener&lt;\/set-method&gt;\n    \t\t&lt;type&gt;org.exoplatform.social.core.application.SpaceActivityPublisher&lt;\/type&gt;\n  \t&lt;\/component-plugin&gt;   \t\t\n\u2026\u2026\u2026\u2026\u2026\u2026\n  &lt;\/component&gt;<\/pre>\n<p>The above configuration can be found in <b>social-extension.war<\/b>: <span class=\"navCode\">\/WEB-INF\/conf\/social-extension\/social\/core-configuration.xml<\/span><\/p>\n<p><b>SpaceActivityPublisher<\/b> implements the <b>SpaceLifeCycleListener<\/b> interface and it is registered with <b>SpaceService <\/b>as a listener. It listens to most space-related activities, such as when a space is created, a space is removed, space settings change or someone leaves or joins a space, and it publishes them as social activities on AS.<\/p>\n<p>If you would like to remove all space-related activities from AS, just simply comment out the component plugin config of <b>SpaceActivityPublisher<\/b>. This will disable the <b>SpaceActivityPublisher<\/b> listener. If you want to remove just the activities for when someone leaves or joins a space, as seeing such activities can sometimes be annoying, then you have to override <b>SpaceActivityPublisher<\/b> with your own implementation. To do so, you need to create an extension project, which can override the default components or default configuration of eXo Platform. Please find details for how to create an extension project <a href=\"https:\/\/docs.exoplatform.org\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<h2>Override a listener<\/h2>\n<p>We will create a sub-class of <b>SpaceActivityPublisher<\/b> called <b>CustomSpaceActivityPublisher<\/b> in our extension project. In this class, we inherit all the methods of <b>SpaceActivityPublisher<\/b>, and only override the <i>joined(SpaceLifeCycleEvent event)<\/i> and <i>left(SpaceLifeCycleEvent event)<\/i> methods so that no action is taken for the events when a member joins or leaves.<\/p>\n<pre class=\"lang:default decode:true \" >public class CustomSpaceActivityPublisher extends SpaceActivityPublisher {\n  public CustomSpaceActivityPublisher(InitParams params,\n  \tActivityManager activityManager, IdentityManager identityManager) {\n\tsuper(params, activityManager, identityManager);\n\t\/\/ TODO Auto-generated constructor stub\n  }\n\n  \/**\n   * {@inheritDoc}\n   *\/\n  @Override\n  public void joined(SpaceLifeCycleEvent event) {\n   \/\/Do nothing\n  }\n\n  \/**\n   * {@inheritDoc}\n   *\/\n  @Override\n  public void left(SpaceLifeCycleEvent event) {\n\t\/\/Do nothing\n  }\n}<\/pre>\n<h2>Override a configuration<\/h2>\n<p>As mentioned above, the configuration needed to register <b>SpaceActivityPublisher<\/b> listener with <b>SpaceService<\/b> is in <b>social-extension.war:<\/b> <span class=\"navCode\">\/WEB-INF\/conf\/social-extension\/social\/core-configuration.xml<\/span><\/p>\n<p>We copy this configuration file into our extension project and update the configuration as follows:<\/p>\n<pre class=\"lang:default decode:true \" >&lt;component-plugin&gt;\n\t&lt;name&gt;SpaceActivityPublisher&lt;\/name&gt;\n\t&lt;set-method&gt;addSpaceListener&lt;\/set-method&gt;\n\t&lt;type&gt;org.exoplatform.customization.listener.CustomSpaceActivityPublisher&lt;\/type&gt;\n&lt;\/component-plugin&gt;<\/pre>\n<p>This registers our new sub-class as the listener for <b>SpaceService<\/b>. Remember that to override the existing <b>core-configuration.xml<\/b> of <b>social-extension.war<\/b>, we have to put our configuration file in the same path as the original one.<\/p>\n<p><b><i>* Important note:<\/i><\/b> <i>We cannot just add the above listener registration to the existing <b>core-configuration.xml<\/b>. We have to override the existing <b>core-configuration.xml<\/b> with the new one in our extension project. This is to avoid a registration conflict.<\/i><\/p>\n<h2>Launching customization<\/h2>\n<p>Now you are ready to deploy your extension project. The source code of a sample extension project can be found <a href=\"https:\/\/github.com\/exo-addons\/resource-center\/tree\/master\/sample-activity-stream-customization\" target=\"_blank\" rel=\"noopener\">here<\/a>. After you have built this extension project using Maven, simply copy the .war files to <span class=\"navCode\">$TomcatHome\/webapps<\/span> and copy the .jar files to <span class=\"navCode\">$TomcatHome\/lib<\/span> then start your Tomcat instance.<\/p>\n<h2>Going further<\/h2>\n<p>Customization can do more than removing unwanted activities from AS. You can override any method of the existing listener for the expected behavior. Besides <b>SpaceActivityPublisher<\/b>, there are a number of <a href=\"https:\/\/docs.exoplatform.org\/\" target=\"_blank\" rel=\"noopener\">overridable components<\/a> supported by eXo Platform.<\/p>\n<p>You can download the <a href=\"https:\/\/github.com\/exo-addons\/resource-center\/tree\/master\/sample-activity-stream-customization\" target=\"_blank\" rel=\"noopener\">Sample extension project<\/a>.<\/p>\n<p><a href=\"https:\/\/community.exoplatform.com\/portal\/dw\/\" target=\"_blank\" rel=\"noopener\"><b>Join the eXo tribe<\/b><\/a><b> by registering for the community and access tutorials, support, and downloads!<\/b><\/p>\n<p><!--begin adv-events--><\/p>\n<div class=\"adv-events\" style=\"background: #476fad; padding: 30px 20px; color: white; border-radius: 3px;\">\n<div class=\"media\">\n<div class=\"pull-right\"><a href=\"#\"><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-6587 alignright\" alt=\"make-the-most-out-of-eXo-platform4\" src=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/02\/how-to-make-the-most-of-eXo-platform41.png\" width=\"161\" height=\"85\" \/><br \/>\n<\/a><\/div>\n<div class=\"media-body\">\n<h4 class=\"media-heading\">Make the most out of eXo Platform 4<\/h4>\n<p>Register to the next webinar and get a complete overview of what you can do with eXo Platform 4. <strong><a href=\"https:\/\/www.exoplatform.com\/contact-us\/\">Reserve your seat now!<\/a><\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!--end adv-events--><\/p>\n","protected":false},"excerpt":{"rendered":"Overview The Activity Stream (AS) is the most recognizable social feature of eXo Platform. AS gives you updates of the activities of your connections and spaces. It is also the place to share your work, your stuff or even just your mood. By using the event listener mechanism, AS automatically publishes activities like user profile [&hellip;]","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[699],"tags":[],"lang":"en","translations":{"en":37701},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/posts\/37701"}],"collection":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/comments?post=37701"}],"version-history":[{"count":0,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/posts\/37701\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/media?parent=37701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/categories?post=37701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/tags?post=37701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}