@Override
  public PortletURL getURLAdd(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long classTypeId)
      throws PortalException {

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

    CalendarResource calendarResource =
        CalendarResourceUtil.getScopeGroupCalendarResource(
            liferayPortletRequest, themeDisplay.getScopeGroupId());

    if (calendarResource == null) {
      return null;
    }

    PortletURL portletURL =
        PortalUtil.getControlPanelPortletURL(
            liferayPortletRequest, CalendarPortletKeys.CALENDAR, PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/edit_calendar_booking.jsp");

    Calendar calendar = calendarResource.getDefaultCalendar();

    portletURL.setParameter("calendarId", String.valueOf(calendar.getCalendarId()));

    return portletURL;
  }
  @Override
  public String getURLViewInContext(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      String noSuchEntryRedirect)
      throws Exception {

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

    Layout layout = themeDisplay.getLayout();

    if (Validator.isNotNull(_article.getLayoutUuid())) {
      layout =
          LayoutLocalServiceUtil.getLayoutByUuidAndCompanyId(
              _article.getLayoutUuid(), _article.getCompanyId());
    }

    String portletId = (String) liferayPortletRequest.getAttribute(WebKeys.PORTLET_ID);

    PortletPreferences portletSetup =
        PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout, portletId);

    String linkToLayoutUuid =
        GetterUtil.getString(portletSetup.getValue("portletSetupLinkToLayoutUuid", null));

    if (Validator.isNotNull(_article.getLayoutUuid()) && Validator.isNull(linkToLayoutUuid)) {

      Group group = themeDisplay.getScopeGroup();

      if (group.getGroupId() != _article.getGroupId()) {
        group = GroupLocalServiceUtil.getGroup(_article.getGroupId());
      }

      String groupFriendlyURL =
          PortalUtil.getGroupFriendlyURL(group, layout.isPrivateLayout(), themeDisplay);

      return PortalUtil.addPreservedParameters(
          themeDisplay,
          groupFriendlyURL
              .concat(JournalArticleConstants.CANONICAL_URL_SEPARATOR)
              .concat(_article.getUrlTitle()));
    }

    List<Long> hitLayoutIds =
        JournalContentSearchLocalServiceUtil.getLayoutIds(
            _article.getGroupId(), layout.isPrivateLayout(), _article.getArticleId());

    if (!hitLayoutIds.isEmpty()) {
      Long hitLayoutId = hitLayoutIds.get(0);

      Layout hitLayout =
          LayoutLocalServiceUtil.getLayout(
              _article.getGroupId(), layout.isPrivateLayout(), hitLayoutId.longValue());

      return PortalUtil.getLayoutURL(hitLayout, themeDisplay);
    }

    return noSuchEntryRedirect;
  }
  @Override
  public String getURLViewInContext(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      String noSuchEntryRedirect) {

    try {
      ThemeDisplay themeDisplay =
          (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);

      User user = themeDisplay.getUser();

      long portletPlid =
          PortalUtil.getPlidFromPortletId(user.getGroupId(), true, PortletKeys.TASKS);

      PortletURL portletURL =
          PortletURLFactoryUtil.create(
              liferayPortletRequest, PortletKeys.TASKS, portletPlid, PortletRequest.RENDER_PHASE);

      portletURL.setParameter("mvcPath", "/tasks/view.jsp");

      return portletURL.toString();
    } catch (Exception e) {
    }

    return null;
  }
  @Override
  public PortletURL getURLAdd(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse)
      throws PortalException, SystemException {

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

    if (!AdminPermission.contains(
        themeDisplay.getPermissionChecker(),
        themeDisplay.getScopeGroupId(),
        ActionKeys.ADD_KB_ARTICLE)) {

      return null;
    }

    PortletURL portletURL =
        PortletURLFactoryUtil.create(
            liferayPortletRequest,
            PortletKeys.KNOWLEDGE_BASE_ADMIN,
            getControlPanelPlid(themeDisplay),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/admin/edit_article.jsp");

    return portletURL;
  }
  @Override
  public String getIconPath(LiferayPortletRequest liferayPortletRequest) {
    ThemeDisplay themeDisplay =
        (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    return getIconPath(themeDisplay);
  }
Пример #6
0
  public EntriesChecker(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) {

    super(liferayPortletResponse);

    _journalDisplayContext =
        new JournalDisplayContext(
            PortalUtil.getHttpServletRequest(liferayPortletRequest),
            liferayPortletRequest,
            liferayPortletResponse,
            liferayPortletRequest.getPreferences());

    _liferayPortletResponse = liferayPortletResponse;

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

    _permissionChecker = themeDisplay.getPermissionChecker();
  }
Пример #7
0
  public EntriesChecker(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) {

    super(liferayPortletResponse);

    _liferayPortletResponse = liferayPortletResponse;

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

    _permissionChecker = themeDisplay.getPermissionChecker();
  }
  public String getURLViewInContext(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      String noSuchEntryRedirect) {

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

    return themeDisplay.getPortalURL()
        + themeDisplay.getPathMain()
        + "/blogs/find_entry?noSuchEntryRedirect="
        + HttpUtil.encodeURL(noSuchEntryRedirect)
        + "&entryId="
        + _entry.getEntryId();
  }
  protected void postProcessAuthFailure(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    LiferayPortletRequest liferayPortletRequest =
        PortalUtil.getLiferayPortletRequest(actionRequest);

    String portletName = liferayPortletRequest.getPortletName();

    Layout layout = (Layout) actionRequest.getAttribute(WebKeys.LAYOUT);

    PortletURL portletURL =
        new PortletURLImpl(
            actionRequest, portletName, layout.getPlid(), PortletRequest.RENDER_PHASE);

    portletURL.setParameter("saveLastPath", Boolean.FALSE.toString());

    String redirect = ParamUtil.getString(actionRequest, "redirect");

    if (Validator.isNotNull(redirect)) {
      portletURL.setParameter("redirect", redirect);
    }

    String login = ParamUtil.getString(actionRequest, "login");

    if (Validator.isNotNull(login)) {
      portletURL.setParameter("login", login);
    }

    if (portletName.equals(LoginPortletKeys.LOGIN)) {
      portletURL.setWindowState(WindowState.MAXIMIZED);
    } else {
      portletURL.setWindowState(actionRequest.getWindowState());
    }

    actionResponse.sendRedirect(portletURL.toString());
  }
  @Override
  public String getURLViewInContext(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      String noSuchEntryRedirect) {

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

    try {
      return _user.getDisplayURL(themeDisplay);
    } catch (Exception e) {
    }

    return noSuchEntryRedirect;
  }
  @Override
  public PortletURL getURLEdit(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse)
      throws Exception {

    HttpServletRequest request = liferayPortletRequest.getHttpServletRequest();

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

    PortletURL editPortletURL =
        PortletURLFactoryUtil.create(
            request,
            PortletKeys.MESSAGE_BOARDS,
            getControlPanelPlid(themeDisplay),
            PortletRequest.RENDER_PHASE);

    editPortletURL.setParameter("struts_action", "/message_boards/edit_discussion");
    editPortletURL.setParameter("commentId", String.valueOf(_message.getMessageId()));

    return editPortletURL;
  }
  @Override
  public String getURLViewInContext(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      String noSuchEntryRedirect) {

    try {
      ThemeDisplay themeDisplay =
          (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);

      User user = themeDisplay.getUser();

      long portletPlid =
          PortalUtil.getPlidFromPortletId(user.getGroupId(), true, "1_WAR_microblogsportlet");

      PortletURL portletURL =
          PortletURLFactoryUtil.create(
              liferayPortletRequest,
              "1_WAR_microblogsportlet",
              portletPlid,
              PortletRequest.RENDER_PHASE);

      portletURL.setParameter("mvcPath", "/microblogs/view.jsp");

      long microblogsEntryId = _entry.getMicroblogsEntryId();

      if (_entry.getReceiverMicroblogsEntryId() > 0) {
        microblogsEntryId = _entry.getReceiverMicroblogsEntryId();
      }

      portletURL.setParameter("receiverMicroblogsEntryId", String.valueOf(microblogsEntryId));

      return portletURL.toString();
    } catch (Exception e) {
    }

    return null;
  }
Пример #13
0
  /**
   * @deprecated As of 7.0.0, replaced by {@link #getAddPortletURLs(LiferayPortletRequest,
   *     LiferayPortletResponse, long, long[], long[], long[], String[], String)}
   */
  @Deprecated
  public static Map<String, PortletURL> getAddPortletURLs(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long[] classNameIds,
      long[] classTypeIds,
      long[] allAssetCategoryIds,
      String[] allAssetTagNames,
      String redirect)
      throws Exception {

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

    return getAddPortletURLs(
        liferayPortletRequest,
        liferayPortletResponse,
        themeDisplay.getScopeGroupId(),
        classNameIds,
        classTypeIds,
        allAssetCategoryIds,
        allAssetTagNames,
        redirect);
  }
Пример #14
0
  public static Map<String, PortletURL> getAddPortletURLs(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long groupId,
      long[] classNameIds,
      long[] classTypeIds,
      long[] allAssetCategoryIds,
      String[] allAssetTagNames,
      String redirect)
      throws Exception {

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

    Map<String, PortletURL> addPortletURLs =
        new TreeMap<>(new ModelResourceComparator(themeDisplay.getLocale()));

    for (long classNameId : classNameIds) {
      String className = PortalUtil.getClassName(classNameId);

      AssetRendererFactory<?> assetRendererFactory =
          AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(className);

      if (Validator.isNull(assetRendererFactory.getPortletId())) {
        continue;
      }

      Portlet portlet =
          PortletLocalServiceUtil.getPortletById(
              themeDisplay.getCompanyId(), assetRendererFactory.getPortletId());

      if (!portlet.isActive()) {
        continue;
      }

      ClassTypeReader classTypeReader = assetRendererFactory.getClassTypeReader();

      List<ClassType> classTypes =
          classTypeReader.getAvailableClassTypes(
              PortalUtil.getCurrentAndAncestorSiteGroupIds(themeDisplay.getScopeGroupId()),
              themeDisplay.getLocale());

      if ((classTypeIds.length == 0) || classTypes.isEmpty()) {
        PortletURL addPortletURL =
            getAddPortletURL(
                liferayPortletRequest,
                liferayPortletResponse,
                groupId,
                className,
                0,
                allAssetCategoryIds,
                allAssetTagNames,
                redirect);

        if (addPortletURL != null) {
          addPortletURLs.put(className, addPortletURL);
        }
      }

      for (ClassType classType : classTypes) {
        long classTypeId = classType.getClassTypeId();

        if (ArrayUtil.contains(classTypeIds, classTypeId) || (classTypeIds.length == 0)) {

          PortletURL addPortletURL =
              getAddPortletURL(
                  liferayPortletRequest,
                  liferayPortletResponse,
                  groupId,
                  className,
                  classTypeId,
                  allAssetCategoryIds,
                  allAssetTagNames,
                  redirect);

          if (addPortletURL != null) {
            String mesage = className + CLASSNAME_SEPARATOR + classType.getName();

            addPortletURLs.put(mesage, addPortletURL);
          }
        }
      }
    }

    return addPortletURLs;
  }
Пример #15
0
  public static PortletURL getAddPortletURL(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long groupId,
      String className,
      long classTypeId,
      long[] allAssetCategoryIds,
      String[] allAssetTagNames,
      String redirect)
      throws Exception {

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

    AssetRendererFactory<?> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(className);

    if ((assetRendererFactory == null)
        || !assetRendererFactory.hasAddPermission(
            themeDisplay.getPermissionChecker(), groupId, classTypeId)) {

      return null;
    }

    PortletURL addPortletURL =
        assetRendererFactory.getURLAdd(liferayPortletRequest, liferayPortletResponse, classTypeId);

    if (addPortletURL == null) {
      return null;
    }

    if (redirect != null) {
      addPortletURL.setParameter("redirect", redirect);
    }

    String referringPortletResource = ParamUtil.getString(liferayPortletRequest, "portletResource");

    if (Validator.isNotNull(referringPortletResource)) {
      addPortletURL.setParameter("referringPortletResource", referringPortletResource);
    } else {
      PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

      addPortletURL.setParameter("referringPortletResource", portletDisplay.getId());

      if (allAssetCategoryIds != null) {
        Map<Long, String> assetVocabularyAssetCategoryIds = new HashMap<>();

        for (long assetCategoryId : allAssetCategoryIds) {
          AssetCategory assetCategory =
              AssetCategoryLocalServiceUtil.fetchAssetCategory(assetCategoryId);

          if (assetCategory == null) {
            continue;
          }

          long assetVocabularyId = assetCategory.getVocabularyId();

          if (assetVocabularyAssetCategoryIds.containsKey(assetVocabularyId)) {

            String assetCategoryIds = assetVocabularyAssetCategoryIds.get(assetVocabularyId);

            assetVocabularyAssetCategoryIds.put(
                assetVocabularyId, assetCategoryIds + StringPool.COMMA + assetCategoryId);
          } else {
            assetVocabularyAssetCategoryIds.put(assetVocabularyId, String.valueOf(assetCategoryId));
          }
        }

        for (Map.Entry<Long, String> entry : assetVocabularyAssetCategoryIds.entrySet()) {

          long assetVocabularyId = entry.getKey();
          String assetCategoryIds = entry.getValue();

          addPortletURL.setParameter("assetCategoryIds_" + assetVocabularyId, assetCategoryIds);
        }
      }

      if (allAssetTagNames != null) {
        addPortletURL.setParameter("assetTagNames", StringUtil.merge(allAssetTagNames));
      }
    }

    addPortletURL.setPortletMode(PortletMode.VIEW);
    addPortletURL.setWindowState(LiferayWindowState.POP_UP);

    return addPortletURL;
  }