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=
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 {
}
liferay{
liferayHome="C:/liferay-mprj-fixpack6/deploy"
liferayHome="C:/Projetos/mprj/opt/deploy"
deployDir=file("${liferayHome}/")
}
\ No newline at end of file
package mprj.doerj.caderno.rest;
import com.liferay.portal.kernel.util.StringPool;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
......@@ -11,6 +9,7 @@ import javax.portlet.PortletPreferences;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
......@@ -24,13 +23,16 @@ public class RestServices {
PortletPreferences prefs = actionRequest.getPreferences();
String urlOrgao = prefs.getValue("urlOrgao", StringPool.BLANK);
String urlOrgao = prefs.getValue("urlOrgao", "");
final String baseUrl = urlOrgao + dataDivulgacao + "/" + idStatus;
URI uri = new URI(baseUrl);
//RestTemplate restTemplate = new RestTemplate();
RestTemplate restTemp = new RestTemplate();
ResponseEntity<String> result = restTemp.getForEntity(uri, String.class);
//ResponseEntity<String> result = restTemp.getForEntity(uri, String.class);
ResponseEntity<String> result = new ResponseEntity<String>("{\"Materias\":{\"materia\":[{\"CONTEUDO\":\"<p class=&quot;western&quot; style=&quot;margin&ndash;top:0cm;margin&ndash;right:0cm;margin&ndash;bottom:7.5pt;margin&ndash;left:0cm&quot;><span style=&quot;font&ndash;size:13.5pt;color:#222222;background:white&quot;>O MINISTÉRIO PÚBLICO DO ESTADO DO RIO DE JANEIRO, através da 2</span><span style=&quot;font&ndash;size:10.0pt;color:#222222;background:white&quot;>a</span><span style=&quot;font&ndash;size:13.5pt;color:#222222;background:white&quot;>&nbsp;Promotoria de Justiça Criminal de Angra dos Reis, vem COMUNICAR aos investigados CLAUDINEI JUNIOR DE OLIVEIRA,&nbsp;identidade nº 30939776&ndash;8</span><span style=&quot;font&ndash;size:13.5pt;color:black;background:white&quot;>,</span><span style=&quot;font&ndash;size:13.5pt;color:#222222;background:white&quot;>&nbsp;e JESUS GOMES DA SILVA, identidade&nbsp;</span><span new=&quot;&quot; roman=&quot;&quot; times=&quot;&quot;><span helvetica=&quot;&quot; style=&quot;font&ndash;size:10.5pt;font&ndash;family:&quot;>nº 34357883&ndash;7,</span></span><span style=&quot;font&ndash;size:13.5pt;color:#222222;background:white&quot;>&nbsp;que, nos autos do Procedimento nº&nbsp;</span><span style=&quot;font&ndash;size:13.5pt;color:black;background:white&quot;>0006428&ndash;91.20202.8.19.0066</span><span style=&quot;font&ndash;size:13.5pt;color:#222222;background:white&quot;>, houve recusa, por ausência de requisitos legais, de formulação de Proposta de Acordo de Não Persecução Penal, para os fins previstos no § 14 do artigo 28&ndash;A, do Código de Processo Penal.&nbsp;</span><span helvetica=&quot;&quot; style=&quot;font&ndash;size:10.5pt;font&ndash;family:&quot;><o:p></o:p></span></p>\\n\\n<p class=&quot;western&quot; style=&quot;margin&ndash;top:0cm;margin&ndash;right:0cm;margin&ndash;bottom:7.5pt;margin&ndash;left:0cm;font&ndash;variant&ndash;ligatures: normal;font&ndash;variant&ndash;caps: normal;orphans: 2;text&ndash;align:start;widows: 2;&ndash;webkit&ndash;text&ndash;stroke&ndash;width: 0px;text&ndash;decoration&ndash;style: initial;text&ndash;decoration&ndash;color: initial;word&ndash;spacing:0px&quot;><span helvetica=&quot;&quot; style=&quot;font&ndash;size:10.5pt;font&ndash;family:&quot;><o:p>&nbsp;</o:p></span></p>\\n\\n<p class=&quot;western&quot; style=&quot;margin&ndash;top:0cm;margin&ndash;right:0cm;margin&ndash;bottom:7.5pt;margin&ndash;left:0cm;font&ndash;variant&ndash;ligatures: normal;font&ndash;variant&ndash;caps: normal;orphans: 2;text&ndash;align:start;widows: 2;&ndash;webkit&ndash;text&ndash;stroke&ndash;width: 0px;text&ndash;decoration&ndash;style: initial;text&ndash;decoration&ndash;color: initial;word&ndash;spacing:0px&quot;><span style=&quot;font&ndash;size:13.5pt;color:black&quot;>Ficam os investigados, ainda, a contar desta publicação, cientificados da fluência do prazo previsto no artigo 6º, da Resolução GPGJ/CGMP Nº 20, de 23 de janeiro de 2020.</span><span helvetica=&quot;&quot; style=&quot;font&ndash;size:10.5pt;font&ndash;family:&quot;><o:p></o:p></span></p>\",\"IDMATERIA\":42456,\"ORGAO\":\"GERÊNCIA DE PORTAL E PROGRAMAÇÃO VISUAL\",\"NOME\":\"Decisão da Comissão de Concurso\",\"POSICAO\":10},{\"CONTEUDO\":\"<table align=&quot;center&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>\\n\\t<tbody>\\n\\t\\t<tr>\\n\\t\\t\\t<td style=&quot;width:653px;&quot;>\\n\\t\\t\\t<p align=&quot;center&quot;>&nbsp;</p>\\n\\n\\t\\t\\t<p align=&quot;center&quot;><strong><u>AGENDA IERBB/MPRJ</u></strong></p>\\n\\n\\t\\t\\t<p align=&quot;center&quot;><strong>Período de 08 a 22.06.2020</strong></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;>O <strong>INSTITUTO DE EDUCAÇÃO ROBERTO BERNARDES BARROSO (IERBB/MPRJ)</strong> INFORMA aos membros e servidores do MPRJ o lançamento de <strong>novos vídeos e episódios de <em>podcasts, </em></strong>bem como os <strong>cursos e palestras com inscrições abertas</strong>.</p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>WEBINARS</strong></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><em>Palestras que ocorrem em um único dia por meio das ferramentas de videoconferência, substituindo os eventos presenciais.</em></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;19/06 &ndash;&nbsp;</strong><a href=&quot;https://ierbb.mprj.mp.br/ci/2020_06_19_WebinarMinistro.pdf&quot; target=&quot;_blank&quot;>Ministério Público, Pandemia e Decisões Judiciais &ndash; Ministro Luís Roberto Barroso.</a></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>IERBB CONECTA</strong></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><em>Série de Seminários on&ndash;line promovidos pelo IERBB/MPRJ que ocorrem durante a semana, sempre às 14h30min.</em></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;08/06</strong>&nbsp;&ndash;&nbsp;<a href=&quot;https://ierbb.mprj.mp.br/ci/2020_06_08_Conecta.pdf&quot; target=&quot;_blank&quot;>Lei 13431/17 &ndash; Lei da escuta protegida de crianças e adolescentes. Discussão jurídica e fundamentos das. técnicas de coleta de testemunho</a></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;09/06</strong>&nbsp;&ndash;&nbsp;<a href=&quot;https://ierbb.mprj.mp.br/ci/2020_06_09_Conecta.pdf&quot; target=&quot;_blank&quot;>A experiência dos Centros de Atendimento Integrado (CAACs) e do atendimento especial de crianças e adolescentes no Estado do Rio de Janeiro.</a></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;10/06</strong>&nbsp;&ndash;&nbsp;<a href=&quot;https://ierbb.mprj.mp.br/ci/2020_06_10_Conecta.pdf&quot; target=&quot;_blank&quot;>O Ministério Público na defesa da igualdade racial</a></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;17/06</strong>&nbsp;&ndash;&nbsp;<a href=&quot;https://ierbb.mprj.mp.br/ci/2020_06_17_Conecta.pdf&quot; target=&quot;_blank&quot;>União Estável e União Civil: um diálogo Brasil&ndash;Portugal</a></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;18/06</strong>&nbsp;&ndash;&nbsp;<a href=&quot;https://ierbb.mprj.mp.br/ci/2020_06_18_Conecta.pdf&quot; target=&quot;_blank&quot;>Edificando o Controle Interno</a></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;22/06</strong>&nbsp;&ndash;&nbsp;<a href=&quot;https://ierbb.mprj.mp.br/ci/2020_06_22_Conecta.pdf&quot; target=&quot;_blank&quot;>Atuação do MP em saúde mental e o projeto &quot;Saúde Mental é Mais Legal&quot;</a></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>CURSOS DE CAPACITAÇAO</strong></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><em>Cursos com aulas regulares com temas inerentes às atividades fim e meio do ministério público, onde é necessária a participação em 75% das aulas para obtenção de certificado.</em></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;16/06 &ndash;&nbsp;</strong><a href=&quot;https://ierbb.mprj.mp.br/ci/2020_06_16_IRDR.pdf&quot; target=&quot;_blank&quot;>Curso de julgamentos repetitivos e a atuação do MPRJ: IRDR sob a perspectiva das funções institucionais do ministério</a></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>IERBB CAST</strong></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><em>O Podcast do IERBB/MPRJ. Episódios com convidados especialistas em diversos temas relativos à atuação do Ministério Público na sociedade. Disponível no site do IERBB, Spotify e no Soundcloud.</em></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;08/06</strong>&nbsp;&ndash; Temas Relevantes sobre Crimes Sexuais &ndash; Roberta La Place.</p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;15/06</strong>&nbsp;&ndash; A importância da representação institucional do Ministério Público &ndash; Jarbas Soares Júnior</p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>IERBB IDEIAS</strong></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><em>Vídeos curtos com reflexões, propostas e novos olhares sobre o mundo e a vida em sociedade, feitos por especialistas em diversos temas. Disponibilizamos em nosso site, canal no YouTube e Facebook</em></p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;12/06</strong>&nbsp;&ndash; As 7 Lições para um Mundo Pós&ndash;Pandêmico &ndash; André Bello</p>\\n\\n\\t\\t\\t<p style=&quot;margin&ndash;left:14.2pt;&quot;><strong>&ndash;&nbsp;19/06</strong>&nbsp;&ndash; A vida das crianças na pandemia &ndash; Angela Borba</p>\\n\\t\\t\\t</td>\\n\\t\\t</tr>\\n\\t</tbody>\\n</table>\\n\\n<div style=&quot;clear:both;&quot;>&nbsp;</div>\",\"IDMATERIA\":42455,\"ORGAO\":\"GERÊNCIA DE PORTAL E PROGRAMAÇÃO VISUAL\",\"NOME\":\"Edital-Pauta do Órgão Especial do Colégio de Procuradores de Justiça\",\"POSICAO\":500}]}}", HttpStatus.OK);
JSONObject obj = new JSONObject(result.getBody());
......
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.StringPool;
import com.liferay.portal.kernel.util.WebKeys;
import java.io.File;
import java.io.FileInputStream;
......@@ -47,7 +47,7 @@ import org.w3c.dom.Element;
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 {
//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 orgao="";
String titulo="";
PortletPreferences prefs = actionRequest.getPreferences();
CadernoUtil util = new CadernoUtil();
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();
//Preenche os dados do cabeçalho
......@@ -91,80 +97,80 @@ public class GeraCaderno {
variables.put("disponibilizacao", disponibilizacao);
variables.put("publicacao", publicacao);
String PGJ = prefs.getValue("PGJConfig", StringPool.BLANK);
String PGJ = prefs.getValue("PGJConfig", "");
variables.put("PGJ", PGJ);
String CGMP = prefs.getValue("CGMPConfig", StringPool.BLANK);
String CGMP = prefs.getValue("CGMPConfig", "");
variables.put("CGMP", CGMP);
String SGJA = prefs.getValue("SGJAConfig", StringPool.BLANK);
String SGJA = prefs.getValue("SGJAConfig", "");
variables.put("SGJA", SGJA);
String SGJPI = prefs.getValue("SGJPIConfig", StringPool.BLANK);
String SGJPI = prefs.getValue("SGJPIConfig", "");
variables.put("SGJPI", SGJPI);
String SGJACI = prefs.getValue("SGJACIConfig", StringPool.BLANK);
String SGJACI = prefs.getValue("SGJACIConfig", "");
variables.put("SGJACI", SGJACI);
String SGJACDH = prefs.getValue("SGJACDHConfig", StringPool.BLANK);
String SGJACDH = prefs.getValue("SGJACDHConfig", "");
variables.put("SGJACDH", SGJACDH);
String SGJRIDP = prefs.getValue("SGJRIDPConfig", StringPool.BLANK);
String SGJRIDP = prefs.getValue("SGJRIDPConfig", "");
variables.put("SGJRIDP", SGJRIDP);
String CG = prefs.getValue("CGConfig", StringPool.BLANK);
String CG = prefs.getValue("CGConfig", "");
variables.put("CG", CG);
String CJ = prefs.getValue("CJConfig", StringPool.BLANK);
String CJ = prefs.getValue("CJConfig", "");
variables.put("CJ", CJ);
String AE = prefs.getValue("AEConfig", StringPool.BLANK);
String AE = prefs.getValue("AEConfig", "");
variables.put("AE", AE);
String CMPROCJ = prefs.getValue("CMPROCJConfig", StringPool.BLANK);
String CMPROCJ = prefs.getValue("CMPROCJConfig", "");
variables.put("CMPROCJ", CMPROCJ);
String CMPROMJ = prefs.getValue("CMPROMJConfig", StringPool.BLANK);
String CMPROMJ = prefs.getValue("CMPROMJConfig", "");
variables.put("CMPROMJ", CMPROMJ);
String CSI = prefs.getValue("CSIConfig", StringPool.BLANK);
String CSI = prefs.getValue("CSIConfig", "");
variables.put("CSI", CSI);
String CEAF = prefs.getValue("CEAFConfig", StringPool.BLANK);
String CEAF = prefs.getValue("CEAFConfig", "");
variables.put("CEAF", CEAF);
String OUVI = prefs.getValue("OUVIConfig", StringPool.BLANK);
String OUVI = prefs.getValue("OUVIConfig", "");
variables.put("OUVI", OUVI);
String SGMP = prefs.getValue("SGMPConfig", StringPool.BLANK);
String SGMP = prefs.getValue("SGMPConfig", "");
variables.put("SGMP", SGMP);
String AAOMC = prefs.getValue("AAOMCConfig", StringPool.BLANK);
String AAOMC = prefs.getValue("AAOMCConfig", "");
variables.put("AAOMC", AAOMC);
String ARCC = prefs.getValue("ARCCConfig", StringPool.BLANK);
String ARCC = prefs.getValue("ARCCConfig", "");
variables.put("ARCC", ARCC);
String GAOMC = prefs.getValue("GAOMCConfig", StringPool.BLANK);
String GAOMC = prefs.getValue("GAOMCConfig", "");
variables.put("GAOMC", GAOMC);
String ARCCRI = prefs.getValue("ARCCRIConfig", StringPool.BLANK);
String ARCCRI = prefs.getValue("ARCCRIConfig", "");
variables.put("ARCCRI", ARCCRI);
String AC = prefs.getValue("ACConfig", StringPool.BLANK);
String AC = prefs.getValue("ACConfig", "");
variables.put("AC", AC);
String ADHM = prefs.getValue("ADHMConfig", StringPool.BLANK);
String ADHM = prefs.getValue("ADHMConfig", "");
variables.put("ADHM", ADHM);
String ARIDP = prefs.getValue("ARIDPConfig", StringPool.BLANK);
String ARIDP = prefs.getValue("ARIDPConfig", "");
variables.put("ARIDP", ARIDP);
String AI = prefs.getValue("AIConfig", StringPool.BLANK);
String AI = prefs.getValue("AIConfig", "");
variables.put("AI", AI);
String AAP = prefs.getValue("AAPConfig", StringPool.BLANK);
String AAP = prefs.getValue("AAPConfig", "");
variables.put("AAP", AAP);
......@@ -198,7 +204,7 @@ public class GeraCaderno {
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();
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