List of usage examples for com.liferay.portal.kernel.util ContentTypes TEXT_CSS_UTF8
String TEXT_CSS_UTF8
To view the source code for com.liferay.portal.kernel.util ContentTypes TEXT_CSS_UTF8.
Click Source Link
From source file:com.liferay.portlet.journal.action.GetTemplateAction.java
License:Open Source License
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {// w w w . jav a 2 s .c om long groupId = ParamUtil.getLong(request, "groupId"); String templateId = getTemplateId(request); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Map<String, String> tokens = JournalUtil.getTokens(groupId, themeDisplay); tokens.put("template_id", templateId); String languageId = LanguageUtil.getLanguageId(request); boolean transform = ParamUtil.getBoolean(request, "transform", true); JournalTemplate template = JournalTemplateServiceUtil.getTemplate(groupId, templateId, true); String script = JournalUtil.getTemplateScript(template, tokens, languageId, transform); String extension = JournalTemplateConstants.LANG_TYPE_VM; if (template.getLangType() != null) { extension = template.getLangType(); } String fileName = null; byte[] bytes = script.getBytes(); String contentType = ContentTypes.TEXT_PLAIN_UTF8; if (Validator.equals(extension, JournalTemplateConstants.LANG_TYPE_CSS)) { contentType = ContentTypes.TEXT_CSS_UTF8; } else if (Validator.equals(extension, JournalTemplateConstants.LANG_TYPE_XSL)) { contentType = ContentTypes.TEXT_XML_UTF8; } ServletResponseUtil.sendFile(request, response, fileName, bytes, contentType); return null; } catch (Exception e) { PortalUtil.sendError(e, request, response); return null; } }