コード例 #1
0
ファイル: ActionUtil.java プロジェクト: feniix/as7liferay
  public static WikiNode getNode(PortletRequest portletRequest) throws Exception {

    HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest);

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    long nodeId = ParamUtil.getLong(request, "nodeId");
    String nodeName = ParamUtil.getString(request, "nodeName");

    WikiNode node = null;

    try {
      if (nodeId > 0) {
        node = WikiNodeServiceUtil.getNode(nodeId);
      } else if (Validator.isNotNull(nodeName)) {
        node = WikiNodeServiceUtil.getNode(themeDisplay.getScopeGroupId(), nodeName);
      } else {
        throw new NoSuchNodeException();
      }
    } catch (NoSuchNodeException nsne) {
      node = ActionUtil.getFirstVisibleNode(portletRequest);
    }

    request.setAttribute(WebKeys.WIKI_NODE, node);

    return node;
  }
コード例 #2
0
  protected void validateNode(ActionRequest actionRequest) throws Exception {
    long selNodeId = GetterUtil.getLong(getParameter(actionRequest, "selNodeId"));

    try {
      WikiNodeServiceUtil.getNode(selNodeId);
    } catch (NoSuchNodeException nsne) {
      SessionErrors.add(actionRequest, nsne.getClass());
    }
  }
コード例 #3
0
ファイル: ActionUtil.java プロジェクト: feniix/as7liferay
  public static void getPage(HttpServletRequest request) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    long nodeId = ParamUtil.getLong(request, "nodeId");
    String title = ParamUtil.getString(request, "title");
    double version = ParamUtil.getDouble(request, "version");

    WikiNode node = null;

    try {
      if (nodeId > 0) {
        node = WikiNodeServiceUtil.getNode(nodeId);
      }
    } catch (NoSuchNodeException nsne) {
    }

    if (node == null) {
      node = (WikiNode) request.getAttribute(WebKeys.WIKI_NODE);

      if (node != null) {
        nodeId = node.getNodeId();
      }
    }

    if (Validator.isNull(title)) {
      title = WikiPageConstants.FRONT_PAGE;
    }

    WikiPage page = null;

    try {
      page = WikiPageServiceUtil.getPage(nodeId, title, version);
    } catch (NoSuchPageException nspe) {
      if (title.equals(WikiPageConstants.FRONT_PAGE) && (version == 0)) {
        long userId = PortalUtil.getUserId(request);

        if (userId == 0) {
          long companyId = PortalUtil.getCompanyId(request);

          userId = UserLocalServiceUtil.getDefaultUserId(companyId);
        }

        ServiceContext serviceContext = new ServiceContext();

        Layout layout = themeDisplay.getLayout();

        serviceContext.setAddCommunityPermissions(true);

        if (layout.isPublicLayout()) {
          serviceContext.setAddGuestPermissions(true);
        } else {
          serviceContext.setAddGuestPermissions(false);
        }

        boolean workflowEnabled = WorkflowThreadLocal.isEnabled();

        try {
          WorkflowThreadLocal.setEnabled(false);

          page =
              WikiPageLocalServiceUtil.addPage(
                  userId, nodeId, title, null, WikiPageConstants.NEW, true, serviceContext);
        } finally {
          WorkflowThreadLocal.setEnabled(workflowEnabled);
        }
      } else {
        throw nspe;
      }
    }

    request.setAttribute(WebKeys.WIKI_PAGE, page);
  }