Teste para carregar o arquivo do template docx

parent c81646be
arguments=
auto.sync=true
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir= connection.project.dir=
eclipse.preferences.version=1 eclipse.preferences.version=1
gradle.user.home=
java.home=
jvm.arguments=-Xmx2560m
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
...@@ -92,6 +92,6 @@ repositories { ...@@ -92,6 +92,6 @@ repositories {
} }
liferay{ liferay{
liferayHome="C:/liferay-mprj-fixpack6/deploy" liferayHome="C:/Projetos/mprj/opt/deploy"
deployDir=file("${liferayHome}/") deployDir=file("${liferayHome}/")
} }
\ No newline at end of file
package mprj.doerj.caderno.util; package mprj.doerj.caderno.util;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.PortalUtil; import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.WebKeys;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -47,7 +47,7 @@ import org.w3c.dom.Element; ...@@ -47,7 +47,7 @@ import org.w3c.dom.Element;
public class GeraCaderno { public class GeraCaderno {
public static void processaCaderno(ActionRequest actionRequest,ActionResponse actionResponse,JSONArray listaConteudos,String dataDivulgacao) throws Docx4JException, JAXBException, IOException, ParseException{ public static void processaCaderno(ActionRequest actionRequest,ActionResponse actionResponse,JSONArray listaConteudos,String dataDivulgacao) throws Docx4JException, JAXBException, IOException, ParseException, PortalException{
...@@ -55,15 +55,21 @@ public class GeraCaderno { ...@@ -55,15 +55,21 @@ public class GeraCaderno {
//String pathTemplate = context.getRealPath(""); //String pathTemplate = context.getRealPath("");
InputStream templateCaderno = GeraCaderno.class.getClass().getResourceAsStream("/META-INF/resources/template/TemplateCaderno.docx"); //InputStream templateCaderno = GeraCaderno.class.getClass().getResourceAsStream("/META-INF/resources/template/TemplateCaderno.docx");
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
String templateCaderno = PortalUtil.getPortalURL(themeDisplay) + "/o/mprj.doerj.caderno/template/TemplateCaderno.docx";
String conteudo=""; String conteudo="";
String orgao=""; String orgao="";
String titulo=""; String titulo="";
PortletPreferences prefs = actionRequest.getPreferences(); PortletPreferences prefs = actionRequest.getPreferences();
CadernoUtil util = new CadernoUtil(); CadernoUtil util = new CadernoUtil();
MainDocumentPart currentDocumentPart = null; MainDocumentPart currentDocumentPart = null;
WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(new File(templateCaderno.toString()));
//System.out.println(XmlUtils.marshaltoString(templatePackage.getMainDocumentPart().getJaxbElement(), true, true)); //WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(new File(templateCaderno.toString()));
WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(new File(templateCaderno));
//System.out.println(XmlUtils.marshaltoString(templatePackage.getMainDocumentPart().getJaxbElement(), true, true));
WordprocessingMLPackage acumuladoPackage = WordprocessingMLPackage.createPackage(); WordprocessingMLPackage acumuladoPackage = WordprocessingMLPackage.createPackage();
//Preenche os dados do cabeçalho //Preenche os dados do cabeçalho
...@@ -91,80 +97,80 @@ public class GeraCaderno { ...@@ -91,80 +97,80 @@ public class GeraCaderno {
variables.put("disponibilizacao", disponibilizacao); variables.put("disponibilizacao", disponibilizacao);
variables.put("publicacao", publicacao); variables.put("publicacao", publicacao);
String PGJ = prefs.getValue("PGJConfig", StringPool.BLANK); String PGJ = prefs.getValue("PGJConfig", "");
variables.put("PGJ", PGJ); variables.put("PGJ", PGJ);
String CGMP = prefs.getValue("CGMPConfig", StringPool.BLANK); String CGMP = prefs.getValue("CGMPConfig", "");
variables.put("CGMP", CGMP); variables.put("CGMP", CGMP);
String SGJA = prefs.getValue("SGJAConfig", StringPool.BLANK); String SGJA = prefs.getValue("SGJAConfig", "");
variables.put("SGJA", SGJA); variables.put("SGJA", SGJA);
String SGJPI = prefs.getValue("SGJPIConfig", StringPool.BLANK); String SGJPI = prefs.getValue("SGJPIConfig", "");
variables.put("SGJPI", SGJPI); variables.put("SGJPI", SGJPI);
String SGJACI = prefs.getValue("SGJACIConfig", StringPool.BLANK); String SGJACI = prefs.getValue("SGJACIConfig", "");
variables.put("SGJACI", SGJACI); variables.put("SGJACI", SGJACI);
String SGJACDH = prefs.getValue("SGJACDHConfig", StringPool.BLANK); String SGJACDH = prefs.getValue("SGJACDHConfig", "");
variables.put("SGJACDH", SGJACDH); variables.put("SGJACDH", SGJACDH);
String SGJRIDP = prefs.getValue("SGJRIDPConfig", StringPool.BLANK); String SGJRIDP = prefs.getValue("SGJRIDPConfig", "");
variables.put("SGJRIDP", SGJRIDP); variables.put("SGJRIDP", SGJRIDP);
String CG = prefs.getValue("CGConfig", StringPool.BLANK); String CG = prefs.getValue("CGConfig", "");
variables.put("CG", CG); variables.put("CG", CG);
String CJ = prefs.getValue("CJConfig", StringPool.BLANK); String CJ = prefs.getValue("CJConfig", "");
variables.put("CJ", CJ); variables.put("CJ", CJ);
String AE = prefs.getValue("AEConfig", StringPool.BLANK); String AE = prefs.getValue("AEConfig", "");
variables.put("AE", AE); variables.put("AE", AE);
String CMPROCJ = prefs.getValue("CMPROCJConfig", StringPool.BLANK); String CMPROCJ = prefs.getValue("CMPROCJConfig", "");
variables.put("CMPROCJ", CMPROCJ); variables.put("CMPROCJ", CMPROCJ);
String CMPROMJ = prefs.getValue("CMPROMJConfig", StringPool.BLANK); String CMPROMJ = prefs.getValue("CMPROMJConfig", "");
variables.put("CMPROMJ", CMPROMJ); variables.put("CMPROMJ", CMPROMJ);
String CSI = prefs.getValue("CSIConfig", StringPool.BLANK); String CSI = prefs.getValue("CSIConfig", "");
variables.put("CSI", CSI); variables.put("CSI", CSI);
String CEAF = prefs.getValue("CEAFConfig", StringPool.BLANK); String CEAF = prefs.getValue("CEAFConfig", "");
variables.put("CEAF", CEAF); variables.put("CEAF", CEAF);
String OUVI = prefs.getValue("OUVIConfig", StringPool.BLANK); String OUVI = prefs.getValue("OUVIConfig", "");
variables.put("OUVI", OUVI); variables.put("OUVI", OUVI);
String SGMP = prefs.getValue("SGMPConfig", StringPool.BLANK); String SGMP = prefs.getValue("SGMPConfig", "");
variables.put("SGMP", SGMP); variables.put("SGMP", SGMP);
String AAOMC = prefs.getValue("AAOMCConfig", StringPool.BLANK); String AAOMC = prefs.getValue("AAOMCConfig", "");
variables.put("AAOMC", AAOMC); variables.put("AAOMC", AAOMC);
String ARCC = prefs.getValue("ARCCConfig", StringPool.BLANK); String ARCC = prefs.getValue("ARCCConfig", "");
variables.put("ARCC", ARCC); variables.put("ARCC", ARCC);
String GAOMC = prefs.getValue("GAOMCConfig", StringPool.BLANK); String GAOMC = prefs.getValue("GAOMCConfig", "");
variables.put("GAOMC", GAOMC); variables.put("GAOMC", GAOMC);
String ARCCRI = prefs.getValue("ARCCRIConfig", StringPool.BLANK); String ARCCRI = prefs.getValue("ARCCRIConfig", "");
variables.put("ARCCRI", ARCCRI); variables.put("ARCCRI", ARCCRI);
String AC = prefs.getValue("ACConfig", StringPool.BLANK); String AC = prefs.getValue("ACConfig", "");
variables.put("AC", AC); variables.put("AC", AC);
String ADHM = prefs.getValue("ADHMConfig", StringPool.BLANK); String ADHM = prefs.getValue("ADHMConfig", "");
variables.put("ADHM", ADHM); variables.put("ADHM", ADHM);
String ARIDP = prefs.getValue("ARIDPConfig", StringPool.BLANK); String ARIDP = prefs.getValue("ARIDPConfig", "");
variables.put("ARIDP", ARIDP); variables.put("ARIDP", ARIDP);
String AI = prefs.getValue("AIConfig", StringPool.BLANK); String AI = prefs.getValue("AIConfig", "");
variables.put("AI", AI); variables.put("AI", AI);
String AAP = prefs.getValue("AAPConfig", StringPool.BLANK); String AAP = prefs.getValue("AAPConfig", "");
variables.put("AAP", AAP); variables.put("AAP", AAP);
...@@ -198,7 +204,7 @@ public class GeraCaderno { ...@@ -198,7 +204,7 @@ public class GeraCaderno {
conteudo=util.tratarString(conteudo,"conteudo"); conteudo=util.tratarString(conteudo,"conteudo");
//AINDA NO FOI IMPLEMENTADO wordCurrentPackage = util.ConverterHTML(conteudo,orgao,titulo,actionRequest); //AINDA NO FOI IMPLEMENTADO wordCurrentPackage = util.ConverterHTML(conteudo,orgao,titulo,actionRequest);
currentDocumentPart = wordCurrentPackage.getMainDocumentPart(); currentDocumentPart = wordCurrentPackage.getMainDocumentPart();
acumuladoPackage.getMainDocumentPart().getContent().addAll(currentDocumentPart.getContent()); acumuladoPackage.getMainDocumentPart().getContent().addAll(currentDocumentPart.getContent());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment