コード例 #1
0
  @Override
  public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    Portlet portlet = _portletLocalService.getPortletById(portletDisplay.getId());

    PortletURL portletURL =
        PortletURLFactoryUtil.create(
            portletRequest,
            PortletProviderUtil.getPortletId(
                DDMStructure.class.getName(), PortletProvider.Action.VIEW),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/view.jsp");
    portletURL.setParameter("backURL", themeDisplay.getURLCurrent());
    portletURL.setParameter("groupId", String.valueOf(themeDisplay.getScopeGroupId()));
    portletURL.setParameter("refererPortletName", DLPortletKeys.DOCUMENT_LIBRARY);
    portletURL.setParameter("refererWebDAVToken", WebDAVUtil.getStorageToken(portlet));
    portletURL.setParameter("showAncestorScopes", Boolean.TRUE.toString());
    portletURL.setParameter("showManageTemplates", Boolean.FALSE.toString());

    return portletURL.toString();
  }
コード例 #2
0
  protected void addPublicSite(
      long companyId, long defaultUserId, List<LayoutSetPrototype> layoutSetPrototypes)
      throws Exception {

    ResourceBundle resourceBundle =
        ResourceBundle.getBundle("content.Language", LocaleUtil.getDefault());

    LayoutSet layoutSet =
        DefaultLayoutSetPrototypesUtil.addLayoutSetPrototype(
            companyId,
            defaultUserId,
            LanguageUtil.get(resourceBundle, "layout-set-prototype-community-site-title"),
            LanguageUtil.get(resourceBundle, "layout-set-prototype-community-site-description"),
            layoutSetPrototypes);

    if (layoutSet == null) {
      return;
    }

    // Home layout

    Layout layout =
        DefaultLayoutPrototypesUtil.addLayout(layoutSet, "home", "/home", "2_columns_iii");
    String portletId =
        PortletProviderUtil.getPortletId(MBMessage.class.getName(), PortletProvider.Action.EDIT);

    DefaultLayoutPrototypesUtil.addPortletId(layout, portletId, "column-1");

    DefaultLayoutPrototypesUtil.addPortletId(
        layout, UserStatisticsPortletKeys.USER_STATISTICS, "column-2");

    // Wiki layout

    DefaultLayoutPrototypesUtil.addLayout(layoutSet, "wiki", "/wiki", "2_columns_iii");
  }
コード例 #3
0
  @Override
  public PortletURL getViewContentURL(HttpServletRequest request, String className, long classPK)
      throws PortalException {

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

    String portletId =
        PortletProviderUtil.getPortletId(TrashEntry.class.getName(), PortletProvider.Action.VIEW);

    if (!themeDisplay.isSignedIn()
        || !isTrashEnabled(themeDisplay.getScopeGroupId())
        || !PortletPermissionUtil.hasControlPanelAccessPermission(
            themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), portletId)) {

      return null;
    }

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

    if (trashHandler.isInTrashContainer(classPK)) {
      TrashEntry trashEntry = trashHandler.getTrashEntry(classPK);

      className = trashEntry.getClassName();
      classPK = trashEntry.getClassPK();

      trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);
    }

    TrashRenderer trashRenderer = trashHandler.getTrashRenderer(classPK);

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

    PortletURL portletURL =
        PortalUtil.getControlPanelPortletURL(request, portletId, PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/view_content.jsp");
    portletURL.setParameter("redirect", themeDisplay.getURLCurrent());

    TrashEntry trashEntry = TrashEntryLocalServiceUtil.getEntry(className, classPK);

    if (trashEntry.getRootEntry() != null) {
      portletURL.setParameter("className", className);
      portletURL.setParameter("classPK", String.valueOf(classPK));
    } else {
      portletURL.setParameter("trashEntryId", String.valueOf(trashEntry.getEntryId()));
    }

    portletURL.setParameter("showAssetMetadata", Boolean.TRUE.toString());

    return portletURL;
  }
コード例 #4
0
  /** @deprecated As of 7.0.0, with no direct replacement */
  @Deprecated
  @JSON(include = false)
  public PortletURL getURLPageSettings() {
    if (_urlPageSettings == null) {
      String portletId =
          PortletProviderUtil.getPortletId(Layout.class.getName(), PortletProvider.Action.EDIT);

      _urlPageSettings =
          PortalUtil.getControlPanelPortletURL(
              getRequest(), portletId, PortletRequest.RENDER_PHASE);
    }

    return _urlPageSettings;
  }
コード例 #5
0
  @JSON(include = false)
  public PortletURL getURLMyAccount() {
    if (_urlMyAccount == null) {
      String portletId =
          PortletProviderUtil.getPortletId(
              PortalMyAccountApplicationType.MyAccount.CLASS_NAME, PortletProvider.Action.VIEW);

      _urlMyAccount =
          PortalUtil.getControlPanelPortletURL(
              getRequest(), portletId, PortletRequest.RENDER_PHASE);
    }

    return _urlMyAccount;
  }
コード例 #6
0
ファイル: RuntimeTag.java プロジェクト: jpince/liferay-portal
  public static void doTag(
      String portletProviderClassName,
      PortletProvider.Action portletProviderAction,
      String instanceId,
      String queryString,
      String defaultPreferences,
      boolean persistSettings,
      PageContext pageContext,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String portletId =
        PortletProviderUtil.getPortletId(portletProviderClassName, portletProviderAction);

    if (Validator.isNotNull(portletId)) {
      doTag(
          portletId,
          instanceId,
          queryString,
          _SETTINGS_SCOPE_DEFAULT,
          defaultPreferences,
          persistSettings,
          pageContext,
          request,
          response);
    } else {
      ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

      Layout layout = themeDisplay.getLayout();

      if (!layout.isTypeControlPanel()
          && !LayoutPermissionUtil.contains(
              themeDisplay.getPermissionChecker(), layout, ActionKeys.UPDATE)) {

        return;
      }

      String errorMessage =
          LanguageUtil.format(
              request,
              "an-app-that-can-x-x-belongs-here",
              new Object[] {portletProviderAction.name(), portletProviderClassName},
              false);

      request.setAttribute("liferay-portlet:runtime:errorMessage", errorMessage);

      PortalIncludeUtil.include(pageContext, _ERROR_PAGE);
    }
  }
コード例 #7
0
  public static List<BreadcrumbEntry> getPortletBreadcrumbEntries(HttpServletRequest request) {

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String name = WebKeys.PORTLET_BREADCRUMBS;

    List<BreadcrumbEntry> breadcrumbEntries = (List<BreadcrumbEntry>) request.getAttribute(name);

    if (Validator.isNotNull(portletDisplay.getId())
        && !portletDisplay.isFocused()
        && !Validator.equals(
            portletDisplay.getId(),
            PortletProviderUtil.getPortletId(
                BreadcrumbEntry.class.getName(), PortletProvider.Action.VIEW))) {

      name = name.concat(StringPool.UNDERLINE.concat(portletDisplay.getId()));

      List<BreadcrumbEntry> portletBreadcrumbEntries =
          (List<BreadcrumbEntry>) request.getAttribute(name);

      if (portletBreadcrumbEntries != null) {
        breadcrumbEntries = portletBreadcrumbEntries;
      }
    }

    if (breadcrumbEntries == null) {
      return Collections.emptyList();
    }

    for (int i = 0; i < breadcrumbEntries.size() - 1; i++) {
      BreadcrumbEntry portletBreadcrumbEntry = breadcrumbEntries.get(i);

      String url = portletBreadcrumbEntry.getURL();

      if (Validator.isNotNull(url) && !CookieKeys.hasSessionId(request)) {
        HttpSession session = request.getSession();

        portletBreadcrumbEntry.setURL(PortalUtil.getURLWithSessionId(url, session.getId()));
      }
    }

    return breadcrumbEntries;
  }
コード例 #8
0
  private String _getOnclickMethod() {
    String imageEditorPortletId =
        PortletProviderUtil.getPortletId(Image.class.getName(), PortletProvider.Action.EDIT);

    PortletURL imageEditorURL =
        PortletURLFactoryUtil.create(_request, imageEditorPortletId, PortletRequest.RENDER_PHASE);

    imageEditorURL.setParameter("mvcRenderCommandName", "/image_editor/view");

    try {
      imageEditorURL.setWindowState(LiferayWindowState.POP_UP);
    } catch (Exception e) {
      throw new SystemException("Unable to set window state", e);
    }

    LiferayPortletResponse liferayPortletResponse = _getLiferayPortletResponse();

    PortletURL editURL = liferayPortletResponse.createActionURL();

    editURL.setParameter(
        ActionRequest.ACTION_NAME, "/document_library/edit_file_entry_with_image_editor");

    editURL.setParameter("fileEntryId", String.valueOf(_fileEntry.getFileEntryId()));

    String fileEntryPreviewURL =
        DLUtil.getPreviewURL(_fileEntry, _fileVersion, _themeDisplay, StringPool.BLANK);

    StringBundler sb = new StringBundler(10);

    sb.append(liferayPortletResponse.getNamespace());
    sb.append("editWithImageEditor('");
    sb.append(imageEditorURL.toString());
    sb.append("', '");
    sb.append(editURL.toString());
    sb.append("', '");
    sb.append(_fileEntry.getFileName());
    sb.append("', '");
    sb.append(fileEntryPreviewURL);
    sb.append("');");

    return sb.toString();
  }
コード例 #9
0
  @Override
  public PortletURL getViewURL(HttpServletRequest request) throws PortalException {

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

    String portletId =
        PortletProviderUtil.getPortletId(TrashEntry.class.getName(), PortletProvider.Action.VIEW);

    if (!themeDisplay.isSignedIn()
        || !isTrashEnabled(themeDisplay.getScopeGroupId())
        || !PortletPermissionUtil.hasControlPanelAccessPermission(
            themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), portletId)) {

      return null;
    }

    PortletURL portletURL =
        PortalUtil.getControlPanelPortletURL(request, portletId, PortletRequest.RENDER_PHASE);

    portletURL.setParameter("redirect", themeDisplay.getURLCurrent());

    return portletURL;
  }
コード例 #10
0
  public static String getURL(
      HttpServletRequest request,
      ThemeDisplay themeDisplay,
      AssetRendererFactory assetRendererFactory,
      AssetRenderer assetRenderer)
      throws Exception {

    long classPK = assetRenderer.getClassPK();
    String className = assetRendererFactory.getClassName();
    String portletId = PortletProviderUtil.getPortletId(className, PortletProvider.Action.VIEW);

    PortletURL portletURL = null;

    if (className.equals(BlogsEntry.class.getName())) {
      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("mvcRenderCommandName", "/blogs/view_entry");
      portletURL.setParameter("entryId", String.valueOf(classPK));
    } else if (className.equals(JournalArticle.class.getName())) {
      JournalArticle journalArticle = JournalArticleLocalServiceUtil.getLatestArticle(classPK);

      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("struts_action", "/journal_content/view");
      portletURL.setParameter("groupId", String.valueOf(journalArticle.getGroupId()));
      portletURL.setParameter("articleId", journalArticle.getArticleId());
    } else if (className.equals(KBArticle.class.getName())) {
      portletURL =
          PortletURLFactoryUtil.create(
              request,
              PortletKeys.KNOWLEDGE_BASE_ARTICLE_DEFAULT_INSTANCE,
              themeDisplay.getPlid(),
              PortletRequest.RENDER_PHASE);

      portletURL.setParameter("mvcPath", "/article/view_article.jsp");
      portletURL.setParameter("resourcePrimKey", String.valueOf(classPK));
    } else if (className.equals(MBMessage.class.getName())) {
      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("struts_action", "/message_boards/view_message");
      portletURL.setParameter("messageId", String.valueOf(classPK));
    } else if (className.equals(WikiPage.class.getName())) {
      WikiPage wikiPage = WikiPageLocalServiceUtil.getPage(classPK);

      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("struts_action", "/wiki/view");
      portletURL.setParameter("nodeId", String.valueOf(wikiPage.getNodeId()));
      portletURL.setParameter("title", wikiPage.getTitle());
    }

    String currentURL = PortalUtil.getCurrentURL(request);

    if (portletURL == null) {
      return currentURL;
    }

    portletURL.setWindowState(WindowState.MAXIMIZED);
    portletURL.setPortletMode(PortletMode.VIEW);

    portletURL.setParameter("returnToFullPageURL", currentURL);

    return portletURL.toString();
  }