private static void updateMainActivity( ActivityManager activityManager, Node contentNode, ExoSocialActivity activity) { Map<String, String> activityParams = activity.getTemplateParams(); String state; String nodeTitle; String nodeType = null; String nodeIconName = null; String documentTypeLabel; String currentVersion = null; TemplateService templateService = WCMCoreUtils.getService(TemplateService.class); try { nodeType = contentNode.getPrimaryNodeType().getName(); documentTypeLabel = templateService.getTemplateLabel(nodeType); } catch (Exception e) { documentTypeLabel = ""; } try { nodeTitle = org.exoplatform.ecm.webui.utils.Utils.getTitle(contentNode); } catch (Exception e1) { nodeTitle = ""; } try { state = contentNode.hasProperty(CURRENT_STATE_PROP) ? contentNode.getProperty(CURRENT_STATE_PROP).getValue().getString() : ""; } catch (Exception e) { state = ""; } try { currentVersion = contentNode.getBaseVersion().getName(); // TODO Must improve this hardcode later, need specification if (currentVersion.contains("jcr:rootVersion")) currentVersion = "0"; } catch (Exception e) { currentVersion = ""; } activityParams.put(ContentUIActivity.STATE, state); activityParams.put(ContentUIActivity.DOCUMENT_TYPE_LABEL, documentTypeLabel); activityParams.put(ContentUIActivity.DOCUMENT_TITLE, nodeTitle); activityParams.put(ContentUIActivity.DOCUMENT_VERSION, currentVersion); String summary = getSummary(contentNode); summary = getFirstSummaryLines(summary, MAX_SUMMARY_LINES_COUNT); activityParams.put(ContentUIActivity.DOCUMENT_SUMMARY, summary); activity.setTemplateParams(activityParams); activityManager.updateActivity(activity); }
public String getVersionNumber(Node node) throws RepositoryException { if (!Utils.isVersionable(node)) return "-"; return node.getBaseVersion().getName(); }