/** constructor */ public UIDocActivityComposer() { addChild(new UIFormStringInput("InputDoc", "InputDoc", null)); resetValues(); }
@Override public void onPostActivity( PostContext postContext, UIComponent source, WebuiRequestContext requestContext, String postedMessage) throws Exception { if (!isDocumentReady) { requestContext .getUIApplication() .addMessage( new ApplicationMessage( "UIComposer.msg.error.Must_select_file", null, ApplicationMessage.INFO)); } else { Map<String, String> activityParams = new LinkedHashMap<String, String>(); Node node = getDocNode(REPOSITORY, WORKSPACE, documentPath); activityParams.put(UIDocActivity.DOCNAME, documentName); activityParams.put(UIDocActivity.DOCLINK, documentRefLink); activityParams.put(UIDocActivity.DOCPATH, documentPath); activityParams.put(UIDocActivity.REPOSITORY, REPOSITORY); activityParams.put(UIDocActivity.WORKSPACE, WORKSPACE); activityParams.put(UIDocActivity.MESSAGE, postedMessage); activityParams.put( BaseActivityProcessorPlugin.TEMPLATE_PARAM_TO_PROCESS, UIDocActivity.MESSAGE); if (node.getPrimaryNodeType().getName().equals(NodetypeConstant.NT_FILE)) { String activityOwnerId = UIDocActivity.getActivityOwnerId(node); DateFormat dateFormatter = null; dateFormatter = new SimpleDateFormat(ISO8601.SIMPLE_DATETIME_FORMAT); String illustrationImg = UIDocActivity.getIllustrativeImage(node); String strDateCreated = ""; if (node.hasProperty(NodetypeConstant.EXO_DATE_CREATED)) { Calendar dateCreated = node.getProperty(NodetypeConstant.EXO_DATE_CREATED).getDate(); strDateCreated = dateFormatter.format(dateCreated.getTime()); } String strLastModified = ""; if (node.hasNode(NodetypeConstant.JCR_CONTENT)) { Node contentNode = node.getNode(NodetypeConstant.JCR_CONTENT); if (contentNode.hasProperty(NodetypeConstant.JCR_LAST_MODIFIED)) { Calendar lastModified = contentNode.getProperty(NodetypeConstant.JCR_LAST_MODIFIED).getDate(); strLastModified = dateFormatter.format(lastModified.getTime()); } } activityParams.put( UIDocActivity.ID, node.isNodeType(NodetypeConstant.MIX_REFERENCEABLE) ? node.getUUID() : ""); activityParams.put(UIDocActivity.CONTENT_NAME, node.getName()); activityParams.put(UIDocActivity.AUTHOR, activityOwnerId); activityParams.put(UIDocActivity.DATE_CREATED, strDateCreated); activityParams.put(UIDocActivity.LAST_MODIFIED, strLastModified); activityParams.put(UIDocActivity.CONTENT_LINK, UIDocActivity.getContentLink(node)); activityParams.put( UIDocActivity.ID, node.isNodeType(NodetypeConstant.MIX_REFERENCEABLE) ? node.getUUID() : ""); activityParams.put(UIDocActivity.MIME_TYPE, UIDocActivity.getMimeType(node)); activityParams.put(UIDocActivity.IMAGE_PATH, illustrationImg); } if (postContext == UIComposer.PostContext.SPACE) { postActivityToSpace(source, requestContext, activityParams); } else if (postContext == UIComposer.PostContext.USER) { postActivityToUser(source, requestContext, activityParams); } } resetValues(); }
@Override public void execute(Event<UIDocActivityComposer> event) throws Exception { final UIDocActivityComposer docActivityComposer = event.getSource(); // Reset values docActivityComposer.resetValues(); }
@Override protected void onClose(Event<UIActivityComposer> event) { resetValues(); }