com.liferay.journal.web.internal.info.item.renderer.JournalArticleTitleInfoItemRenderer 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.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 Pavel Savinov
*/
@Component(
property = "service.ranking:Integer=150", service = InfoItemRenderer.class
)
public class JournalArticleTitleInfoItemRenderer
implements InfoItemRenderer {
@Override
public String getLabel(Locale locale) {
return _language.get(locale, "title");
}
@Override
public void render(
JournalArticle article, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
if (!JournalArticleRendererUtil.isShowArticle(
httpServletRequest, article)) {
return;
}
try {
httpServletRequest.setAttribute(WebKeys.JOURNAL_ARTICLE, article);
RequestDispatcher requestDispatcher =
_servletContext.getRequestDispatcher(
"/info/item/renderer/title.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;
}