com.liferay.journal.web.internal.info.item.renderer.JournalArticleAbstractInfoItemRenderer Maven / Gradle / Ivy
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.journal.web.internal.info.item.renderer;
import com.liferay.asset.kernel.AssetRendererFactoryRegistryUtil;
import com.liferay.asset.kernel.model.AssetRendererFactory;
import com.liferay.info.item.renderer.InfoItemRenderer;
import com.liferay.journal.model.JournalArticle;
import com.liferay.portal.kernel.language.Language;
import com.liferay.portal.kernel.util.WebKeys;
import java.util.Locale;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Eudaldo Alonso
*/
@Component(
property = "service.ranking:Integer=200", service = InfoItemRenderer.class
)
public class JournalArticleAbstractInfoItemRenderer
implements InfoItemRenderer {
@Override
public String getLabel(Locale locale) {
return _language.get(locale, "default-template-shorten");
}
@Override
public void render(
JournalArticle article, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
if (!JournalArticleRendererUtil.isShowArticle(
httpServletRequest, article)) {
return;
}
try {
AssetRendererFactory> assetRendererFactory =
AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClass(
JournalArticle.class);
httpServletRequest.setAttribute(
WebKeys.ASSET_RENDERER,
assetRendererFactory.getAssetRenderer(
article.getResourcePrimKey()));
httpServletRequest.setAttribute(WebKeys.JOURNAL_ARTICLE, article);
RequestDispatcher requestDispatcher =
_servletContext.getRequestDispatcher(
"/info/item/renderer/abstract.jsp");
requestDispatcher.include(httpServletRequest, httpServletResponse);
}
catch (Exception exception) {
throw new RuntimeException(exception);
}
}
@Reference
private Language _language;
@Reference(target = "(osgi.web.symbolicname=com.liferay.journal.web)")
private ServletContext _servletContext;
}