示例#1
0
文件: Utils.java 项目: canhpv/ecms
  /**
   * Creates a restfull compliant link to the editor for editing a content, adding a content or
   * managing contents. Example : Add Content : isEditable = false, isNew = true, itemPath = the
   * parent folder path Edit Content : isEditable = true, isNew = false, itemPath = the content path
   * Manage Contents = isEditable = false, isNew = false, itemPath = the folder path
   *
   * @param itemPath
   * @param isEditable
   * @param isNew
   * @return
   */
  public static String getEditLink(String itemPath, boolean isEditable, boolean isNew) {
    PortalRequestContext pContext = Util.getPortalRequestContext();
    String backto = pContext.getRequestURI();
    WCMConfigurationService configurationService =
        Util.getUIPortalApplication().getApplicationComponent(WCMConfigurationService.class);
    String editorPageURI =
        configurationService.getRuntimeContextParam(
            isEditable || isNew
                ? WCMConfigurationService.EDITOR_PAGE_URI
                : WCMConfigurationService.SITE_EXPLORER_URI);
    UserNode editorNode = getEditorNode(editorPageURI);

    if (editorNode == null) {
      return "";
    }

    NodeURL nodeURL = pContext.createURL(NodeURL.TYPE);
    nodeURL.setNode(editorNode).setQueryParameterValue("path", itemPath);
    if (isEditable) {
      nodeURL.setQueryParameterValue("edit", "true");
    }
    if (isNew) {
      nodeURL.setQueryParameterValue("addNew", "true");
    }
    nodeURL.setQueryParameterValue(org.exoplatform.ecm.webui.utils.Utils.URL_BACKTO, backto);

    return nodeURL.toString();
  }