UISharedFileBuilder extends BaseUIActivityBuilder { @Override protected void extendUIActivity(BaseUIActivity uiActivity, ExoSocialActivity activity) { FileUIActivity fileActivity = (FileUIActivity) uiActivity; String nodeUUID = ""; String workspaceName = ""; if (activity.getTemplateParams() != null) { fileActivity.setUIActivityData(activity.getTemplateParams()); nodeUUID = activity.getTemplateParams().get(ContentUIActivity.NODE_UUID); workspaceName = activity.getTemplateParams().get(ContentUIActivity.WORKSPACE); } fileActivity.setMessage(activity.getTitle()); if (StringUtils.isNotBlank(activity.getTitle())) { fileActivity.setActivityTitle(activity.getTitle().replace("</br></br>", "")); } try { ManageableRepository manageRepo = WCMCoreUtils.getRepository(); if(StringUtils.isEmpty(workspaceName)) workspaceName = manageRepo.getConfiguration().getDefaultWorkspaceName(); SessionProvider sessionProvider = WCMCoreUtils.getSystemSessionProvider(); TrashService trashService = WCMCoreUtils.getService(TrashService.class); Node currentNode = sessionProvider.getSession(workspaceName, manageRepo).getNodeByUUID(nodeUUID); if(trashService.isInTrash(currentNode)) { org.exoplatform.wcm.ext.component.activity.listener.Utils.deleteFileActivity(currentNode); } fileActivity.setContentNode(currentNode, 0); } catch (ItemNotFoundException infe){ LOG.error("Item not found. Activity will be deleted ", infe); ActivityManager activityManager = WCMCoreUtils.getService(ActivityManager.class); activityManager.deleteActivity(activity); } catch (RepositoryException re) { if(LOG.isErrorEnabled()) LOG.error("Can not get the repository. ", re); } }    }
@Test public void testExtendUIActivity() throws Exception { String activityTitle = "Test"; UISharedFileBuilder uiSharedFileBuilder = new UISharedFileBuilder(); FileUIActivity fileUIActivity = new FileUIActivity(); ExoSocialActivity activity = new ExoSocialActivityImpl(); activity.setTitle(activityTitle); try { uiSharedFileBuilder.extendUIActivity(fileUIActivity, activity); } catch (Exception e) { LOG.error("Can not get the repository. "); } assertEquals(activityTitle, fileUIActivity.getMessage()); assertEquals(activityTitle, fileUIActivity.getActivityTitle()); }