@Override
  public String getTitle(long classPK, Locale locale) {
    try {
      AssetRenderer<?> assetRenderer = getAssetRenderer(classPK);

      if (assetRenderer != null) {
        return assetRenderer.getTitle(locale);
      }
    } catch (Exception e) {
      if (_log.isWarnEnabled()) {
        _log.warn(e, e);
      }
    }

    return null;
  }
  @Override
  public String getSummary(
      long classPK, PortletRequest portletRequest, PortletResponse portletResponse) {

    try {
      AssetRenderer<?> assetRenderer = getAssetRenderer(classPK);

      if (assetRenderer != null) {
        return assetRenderer.getSummary(portletRequest, portletResponse);
      }
    } catch (Exception e) {
      if (_log.isWarnEnabled()) {
        _log.warn(e, e);
      }
    }

    return null;
  }
  @Override
  public boolean include(
      long classPK, HttpServletRequest request, HttpServletResponse response, String template) {

    try {
      AssetRenderer<?> assetRenderer = getAssetRenderer(classPK);

      if (assetRenderer != null) {
        return assetRenderer.include(request, response, template);
      }
    } catch (Exception e) {
      if (_log.isWarnEnabled()) {
        _log.warn(e, e);
      }
    }

    return false;
  }
  @Override
  public PortletURL getURLViewDiffs(
      long classPK,
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse) {

    try {
      AssetRenderer<?> assetRenderer = getAssetRenderer(classPK);

      if (assetRenderer != null) {
        return assetRenderer.getURLViewDiffs(liferayPortletRequest, liferayPortletResponse);
      }
    } catch (Exception e) {
      if (_log.isWarnEnabled()) {
        _log.warn(e, e);
      }
    }

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

    try {
      AssetRenderer<?> assetRenderer = getAssetRenderer(classPK);

      if (assetRenderer != null) {
        return assetRenderer.getURLViewInContext(
            liferayPortletRequest, liferayPortletResponse, noSuchEntryRedirect);
      }
    } catch (Exception e) {
      if (_log.isWarnEnabled()) {
        _log.warn(e, e);
      }
    }

    return null;
  }
예제 #6
0
  public String[] getExtensions(AssetRenderer<?> assetRenderer) {
    final String[] supportedConversions = assetRenderer.getSupportedConversions();

    if (supportedConversions == null) {
      return getExtensions();
    }

    return ArrayUtil.filter(
        getExtensions(),
        new PredicateFilter<String>() {

          @Override
          public boolean filter(String extension) {
            return ArrayUtil.contains(supportedConversions, extension);
          }
        });
  }
예제 #7
0
  public static String getSearchResultViewURL(
      RenderRequest renderRequest,
      RenderResponse renderResponse,
      String className,
      long classPK,
      boolean viewInContext,
      String currentURL)
      throws Exception {

    try {
      PortletURL viewContentURL = renderResponse.createRenderURL();

      viewContentURL.setParameter("mvcPath", "/view_content.jsp");
      viewContentURL.setParameter("redirect", currentURL);
      viewContentURL.setPortletMode(PortletMode.VIEW);
      viewContentURL.setWindowState(WindowState.MAXIMIZED);

      if (Validator.isNull(className) || (classPK <= 0)) {
        return viewContentURL.toString();
      }

      AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(className, classPK);

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

      if (assetRendererFactory == null) {
        return viewContentURL.toString();
      }

      viewContentURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId()));
      viewContentURL.setParameter("type", assetRendererFactory.getType());

      if (viewInContext) {
        String viewFullContentURLString = viewContentURL.toString();

        viewFullContentURLString =
            HttpUtil.setParameter(viewFullContentURLString, "redirect", currentURL);

        AssetRenderer<?> assetRenderer = assetRendererFactory.getAssetRenderer(classPK);

        String viewURL =
            assetRenderer.getURLViewInContext(
                (LiferayPortletRequest) renderRequest,
                (LiferayPortletResponse) renderResponse,
                viewFullContentURLString);

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

        return AssetUtil.checkViewURL(assetEntry, viewInContext, viewURL, currentURL, themeDisplay);
      }

      return viewContentURL.toString();
    } catch (Exception e) {
      _log.error(
          "Unable to get search result  view URL for class "
              + className
              + " with primary key "
              + classPK,
          e);

      return "";
    }
  }