コード例 #1
0
  @Override
  protected void extendUIActivity(BaseUIActivity uiActivity, ExoSocialActivity activity) {
    UIDocActivity docActivity = (UIDocActivity) uiActivity;
    //
    if (activity.getTemplateParams() == null) {
      saveToNewDataFormat(activity);
    }
    //
    Map<String, String> activityParams = activity.getTemplateParams();
    docActivity.docLink = activityParams.get(UIDocActivity.DOCLINK);
    docActivity.docName = activityParams.get(UIDocActivity.DOCNAME);
    docActivity.message = activityParams.get(UIDocActivity.MESSAGE);
    docActivity.docPath = activityParams.get(UIDocActivity.DOCPATH);
    docActivity.repository = activityParams.get(UIDocActivity.REPOSITORY);
    docActivity.workspace = activityParams.get(UIDocActivity.WORKSPACE);

    // escape node name for special characters
    docActivity.docPath = escapeIllegalJcrCharsOnNodeName(docActivity.docPath);
  }
コード例 #2
0
  @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();
  }