/**
* OpenCPS is the open source Core Public Services software
* Copyright (C) 2016-present OpenCPS community

* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.

* This program 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 Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/

package org.opencps.jasperreport.compile;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;

import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;

import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRReport;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;

/**
 * @author trungnt
 */
public class JRReportTemplate extends JasperReport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public JRReportTemplate(
	    JRReport report, String compilerClass, Serializable compileData,
	    JRExpressionCollector expressionCollector, String compileNameSuffix) {
		super(
		    report, compilerClass, compileData, expressionCollector, compileNameSuffix);

	}

	public JRReportTemplate(
	    JRReport report, String compilerClass, Serializable compileData,
	    JRBaseObjectFactory factory, String compileNameSuffix) {
		super(
		    report, compilerClass, compileData, factory, compileNameSuffix);

	}

	public static JRReportTemplate compile(String jrxmlTemplate) {

		JRReportTemplate reportTemplate = null;
		try {
			InputStream isTemplate = new ByteArrayInputStream(jrxmlTemplate
			    .getBytes(StandardCharsets.UTF_8));
			reportTemplate = (JRReportTemplate) JasperCompileManager
			    .compileReport(isTemplate);

		}
		catch (Exception e) {
			_log
			    .error(e);
		}

		return reportTemplate;
	}

	private static Log _log = LogFactoryUtil
	    .getLog(JRReportTemplate.class);
}

@@ -931,96 +931,48 @@
 ort 
-com.liferay.portal.kernel.log.Log;%0Aimport com.liferay.portal.kernel.log.LogFactoryUtil;%0A
+net.sf.jasperreports.engine.JRException;
 %0Aimp
@@ -1963,63 +1963,36 @@
 ate)
- %7B%0A%0A%09%09JRReportTemplate reportTemplate = null;%0A%09%09try %7B%0A%09
+%0A%09    throws JRException %7B%0A%0A
 %09%09In
@@ -2055,17 +2055,16 @@
 plate%0A%09%09
-%09
     .get
@@ -2097,17 +2097,33 @@
 _8));%0A%09%09
-%09
+JRReportTemplate 
 reportTe
@@ -2130,16 +2130,22 @@
 mplate =
+%0A%09%09   
  (JRRepo
@@ -2179,17 +2179,20 @@
 nager%0A%09%09
-%09
+    
     .com
@@ -2222,172 +2222,33 @@
 %0A%0A%09%09
-%7D%0A%09%09catch (Exception e) %7B%0A%09%09%09_log%0A%09%09%09    .error(e);%0A%09%09%7D%0A%0A%09%09return reportTemplate;%0A%09%7D%0A%0A%09private static Log _log = LogFactoryUtil%0A%09    .getLog(JRReportTemplate.class);
+return reportTemplate;%0A%09%7D%0A
 %0A%7D%0A

Edit method compile template Throws JRException