Esempio n. 1
0
  @Override
  public PortletURL getViewContentURL(HttpServletRequest request, long trashEntryId)
      throws PortalException {

    TrashEntry trashEntry = TrashEntryLocalServiceUtil.fetchEntry(trashEntryId);

    return getViewContentURL(request, trashEntry.getClassName(), trashEntry.getClassPK());
  }
Esempio n. 2
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;
  }