protected boolean isPrivateLayout(String name, String primKey) throws Exception {

    if (!name.equals(Layout.class.getName())) {
      return false;
    }

    long plid = GetterUtil.getLong(primKey);

    Layout layout = LayoutLocalServiceUtil.getLayout(plid);

    if (layout.isPublicLayout() || layout.isTypeControlPanel()) {
      return false;
    }

    return true;
  }
Exemple #2
0
  /**
   * The search redirection.
   *
   * @return an empty string.
   */
  public String search() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Object responseObject = facesContext.getExternalContext().getResponse();

    if (responseObject != null && responseObject instanceof ActionResponse) {
      ActionResponse actionResponse = (ActionResponse) responseObject;

      Query query = new Query();
      query.getTags().add(selectedTag);
      actionResponse.setEvent(
          new QName("http://fokus.fraunhofer.de/odplatform", "querydatasets"), query);

      String location = LiferayFacesContext.getInstance().getThemeDisplay().getPortalURL();
      Layout layout = LiferayFacesContext.getInstance().getThemeDisplay().getLayout();

      try {
        if (layout.isPublicLayout()) {
          location +=
              LiferayFacesContext.getInstance().getThemeDisplay().getPathFriendlyURLPublic();
        }

        location +=
            layout.hasScopeGroup()
                ? layout.getScopeGroup().getFriendlyURL()
                : layout.getGroup().getFriendlyURL();
        location += "/suchen";
      } catch (PortalException e) {
        e.printStackTrace();
      } catch (SystemException e) {
        e.printStackTrace();
      }

      try {
        facesContext.getExternalContext().redirect(location);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return "";
  }
Exemple #3
0
  public static WikiNode getFirstVisibleNode(PortletRequest portletRequest)
      throws PortalException, SystemException {

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

    WikiNode node = null;

    int nodesCount = WikiNodeLocalServiceUtil.getNodesCount(themeDisplay.getScopeGroupId());

    if (nodesCount == 0) {
      Layout layout = themeDisplay.getLayout();

      ServiceContext serviceContext =
          ServiceContextFactory.getInstance(WikiNode.class.getName(), portletRequest);

      serviceContext.setAddCommunityPermissions(true);

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

      node = WikiNodeLocalServiceUtil.addDefaultNode(themeDisplay.getUserId(), serviceContext);
    } else {
      node = WikiUtil.getFirstNode(portletRequest);

      if (node == null) {
        throw new PrincipalException();
      }

      return node;
    }

    portletRequest.setAttribute(WebKeys.WIKI_NODE, node);

    return node;
  }
Exemple #4
0
  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);
  }
  /**
   * Submit.
   *
   * @return the string
   */
  public void submit() {
    // Query q = new Query();
    // q.setSearchterm(query);

    ThemeDisplay themeDisplay = LiferayFacesContext.getInstance().getThemeDisplay();
    Layout layout = themeDisplay.getLayout();
    String currentPage = layout.getFriendlyURL();

    FacesContext facesContext = FacesContext.getCurrentInstance();
    Object responseObject = facesContext.getExternalContext().getResponse();
    if (responseObject != null && responseObject instanceof ActionResponse) {
      ActionResponse actionResponse = (ActionResponse) responseObject;
      // actionResponse.setEvent(new
      // QName("http://fokus.fraunhofer.de/odplatform", "querydatasets"),
      // q);

      if (query != null && !query.isEmpty()) {
        log.info("searching for '{}'", query);
        // String escapedQuery = StringEscapeUtils.escapeHtml(query);
        String escapedQuery = StringUtils.escapeColonString(query);
        // msg 8:5.2014 actionResponse.setRenderParameter("searchterm",
        // query);
        escapedQuery = StringUtils.removeBlankStrings(query);
        log.info("escapedQuery:" + escapedQuery);
        actionResponse.setRenderParameter("searchterm", escapedQuery);
      } else {
        actionResponse.removePublicRenderParameter("searchterm");
      }

      actionResponse.removePublicRenderParameter("searchcategory");
    }

    // if (currentPage.equals("/home")) {
    String location = themeDisplay.getPortalURL();
    if (layout.isPublicLayout()) {
      location += themeDisplay.getPathFriendlyURLPublic();
    }

    try {
      location +=
          layout.hasScopeGroup()
              ? layout.getScopeGroup().getFriendlyURL()
              : layout.getGroup().getFriendlyURL();
      if (currentPage.equals("/home")) {
        location += "/suchen";
      } else {
        location += layout.getFriendlyURL();
      }
    } catch (PortalException e) {
      log.error("add group to url", e);
    } catch (SystemException e) {
      log.error("add group to url", e);
    }

    try {
      facesContext.getExternalContext().redirect(location);
    } catch (IOException e) {
      log.error("redirect to result page", e);
    }
    // }

  }