Commit e9be20d5 by Consultor Vertigo

ajustes nas dependências após avançar na geração do docx.

parent d381a7e0
/META-INF/ /META-INF/
/content/
/mprj/ /mprj/
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<form id="<portlet:namespace />formDO" name="<portlet:namespace />formDO" method="POST" enctype="multipart/form-data" action="<%= submitActionURL%>" > <form id="<portlet:namespace />formDO" name="<portlet:namespace />formDO" method="POST" action="<%= submitActionURL%>" data-senna-off="true">
<div id="campo-situacao" class="campo"> <div id="campo-situacao" class="campo">
<label><liferay-ui:message key="admin.form.editar.situacao"/></label> <label><liferay-ui:message key="admin.form.editar.situacao"/></label>
......
...@@ -13,9 +13,6 @@ Export-Package: mprj.doerj.caderno.constants ...@@ -13,9 +13,6 @@ Export-Package: mprj.doerj.caderno.constants
-includeresource: \ -includeresource: \
@commons-lang3-3.11.jar,\ @commons-lang3-3.11.jar,\
@json-20200518.jar,\ @json-20200518.jar,\
@docx4j-core-8.0.0.jar,\
@docx4j-6.1.2.jar,\
@docx4j-ImportXHTML-8.0.0.jar,\
@failureaccess-1.0.1.jar,\ @failureaccess-1.0.1.jar,\
@error_prone_annotations-2.4.0.jar,\ @error_prone_annotations-2.4.0.jar,\
@lorem-2.1.jar,\ @lorem-2.1.jar,\
...@@ -56,13 +53,18 @@ Export-Package: mprj.doerj.caderno.constants ...@@ -56,13 +53,18 @@ Export-Package: mprj.doerj.caderno.constants
@dom-2.3.0-jaxb-1.0.6.jar,\ @dom-2.3.0-jaxb-1.0.6.jar,\
@slf4j-log4j12-1.7.25.jar,\ @slf4j-log4j12-1.7.25.jar,\
@slf4j-api-1.7.26.jar,\ @slf4j-api-1.7.26.jar,\
@docx4j-MOXy-JAXBContext-6.0.0.jar,\ @docx4j-core-8.1.0.jar,\
@org.eclipse.persistence.core-*.jar,\ @docx4j-6.1.2.jar,\
@org.eclipse.persistence.asm-*.jar,\ @docx4j-ImportXHTML-8.0.0.jar,\
@org.eclipse.persistence.moxy-*.jar,\ @docx4j-JAXB-ReferenceImpl-*.jar,\
@docx4j-openxml-objects-*.jar,\
@xmlgraphics-commons-*.jar,\ @xmlgraphics-commons-*.jar,\
@xalan-*.jar,\ @xalan-2.7.2.jar,\
@serializer-*.jar @xalan-interpretive-*.jar,\
@xalan-metainf-*.jar,\
@xalan-serializer-*.jar,\
@serializer-*.jar,\
@jaxb-runtime-*.jar
Import-Package: \ Import-Package: \
...@@ -83,6 +85,7 @@ Import-Package: \ ...@@ -83,6 +85,7 @@ Import-Package: \
!com.sun.codemodel.*,\ !com.sun.codemodel.*,\
!com.sun.org.apache.*,\ !com.sun.org.apache.*,\
!com.sun.tools.xjc.*,\ !com.sun.tools.xjc.*,\
!com.sun.istack.*,\
!com.zaxxer.*,\ !com.zaxxer.*,\
!javax.activation.*,\ !javax.activation.*,\
!javax.faces.*,\ !javax.faces.*,\
...@@ -105,11 +108,14 @@ Import-Package: \ ...@@ -105,11 +108,14 @@ Import-Package: \
!org.checkerframework.*,\ !org.checkerframework.*,\
!org.codehaus.jackson.*,\ !org.codehaus.jackson.*,\
!org.docx4j.org.xhtmlrenderer.*,\ !org.docx4j.org.xhtmlrenderer.*,\
!org.apache.xalan.transformer.*,\
!org.jvnet.*,\
!javax.enterprise.*,\ !javax.enterprise.*,\
!javax.persistence.*,\ !javax.persistence.*,\
!javax.resource.*,\ !javax.resource.*,\
!org.eclipse.persistence.jpa.*,\ !org.eclipse.persistence.jpa.*,\
!org.eclipse.persistence.internal.libraries.antlr.runtime.*,\ !org.eclipse.persistence.internal.libraries.antlr.runtime.*,\
!org.eclipse.persistence.oxm.*,\
!org.joda.*,\ !org.joda.*,\
!org.plutext.jaxb.svg11.*,\ !org.plutext.jaxb.svg11.*,\
!org.tukaani.*,\ !org.tukaani.*,\
......
...@@ -39,9 +39,6 @@ dependencies { ...@@ -39,9 +39,6 @@ dependencies {
compileOnly group: 'biz.aQute.bnd', name: 'bndlib', version: '2.4.0' compileOnly group: 'biz.aQute.bnd', name: 'bndlib', version: '2.4.0'
compileOnly group: 'com.caucho', name: 'burlap', version: '2.1.12' compileOnly group: 'com.caucho', name: 'burlap', version: '2.1.12'
compileOnly group: 'org.docx4j', name: 'docx4j-ImportXHTML', version: '8.0.0'
compileOnly group: 'org.docx4j', name: 'docx4j', version: '6.1.2'
compileOnly group: 'org.docx4j', name: 'docx4j-MOXy-JAXBContext', version: '6.0.0'
compileOnly group: 'com.google.guava', name: 'failureaccess', version: '1.0.1' compileOnly group: 'com.google.guava', name: 'failureaccess', version: '1.0.1'
compileOnly group: 'com.google.errorprone', name: 'error_prone_annotations', version: '2.4.0' compileOnly group: 'com.google.errorprone', name: 'error_prone_annotations', version: '2.4.0'
compileOnly group: 'com.google.guava', name: 'guava-concurrent', version: 'r03' compileOnly group: 'com.google.guava', name: 'guava-concurrent', version: 'r03'
...@@ -83,10 +80,20 @@ dependencies { ...@@ -83,10 +80,20 @@ dependencies {
compileOnly group: 'org.eclipse.persistence', name: 'org.eclipse.persistence.core', version: '2.7.7' compileOnly group: 'org.eclipse.persistence', name: 'org.eclipse.persistence.core', version: '2.7.7'
compileOnly group: 'org.eclipse.persistence', name: 'org.eclipse.persistence.asm', version: '2.7.7' compileOnly group: 'org.eclipse.persistence', name: 'org.eclipse.persistence.asm', version: '2.7.7'
compileOnly group: 'org.apache.xmlgraphics', name: 'xmlgraphics-commons', version: '2.4' compileOnly group: 'org.apache.xmlgraphics', name: 'xmlgraphics-commons', version: '2.4'
compileOnly group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.2'
compileOnly group: 'xalan', name: 'xalan', version: '2.7.2' compileOnly group: 'xalan', name: 'xalan', version: '2.7.2'
compileOnly group: 'xalan', name: 'serializer', version: '2.7.2' compileOnly group: 'xalan', name: 'serializer', version: '2.7.2'
compileOnly group: 'org.docx4j', name: 'docx4j-ImportXHTML', version: '8.0.0'
compileOnly group: 'org.docx4j', name: 'docx4j', version: '6.1.2'
compileOnly group: 'org.docx4j', name: 'docx4j-JAXB-ReferenceImpl', version: '8.1.0'
compileOnly group: 'org.docx4j', name: 'docx4j-openxml-objects', version: '8.1.0'
compileOnly group: 'org.docx4j.org.apache', name: 'xalan-serializer', version: '8.0.0' compileOnly group: 'org.docx4j.org.apache', name: 'xalan-serializer', version: '8.0.0'
compileOnly group: 'org.docx4j.org.apache', name: 'xalan-interpretive', version: '8.0.0' compileOnly group: 'org.docx4j.org.apache', name: 'xalan-interpretive', version: '8.0.0'
compileOnly group: 'org.docx4j.org.apache', name: 'xalan-metainf', version: '8.0.0'
cssBuilder group: "com.liferay", name: "com.liferay.css.builder", version: "3.0.2" cssBuilder group: "com.liferay", name: "com.liferay.css.builder", version: "3.0.2"
} }
......
...@@ -62,7 +62,7 @@ property = { "com.liferay.portlet.display-category=category.sample", ...@@ -62,7 +62,7 @@ property = { "com.liferay.portlet.display-category=category.sample",
"com.liferay.portlet.preferences-owned-by-group=true", "com.liferay.portlet.preferences-owned-by-group=true",
"com.liferay.portlet.add-default-resource=true", "com.liferay.portlet.add-default-resource=true",
"com.liferay.portlet.css-class-wrapper=mprj-doerj-materia-web", "com.liferay.portlet.css-class-wrapper=mprj-doerj-materia-web",
"javax.portlet.display-name=Gesto de Matrias do Dirio Oficial", "javax.portlet.display-name=Gest�o de Mat�rias do Di�rio Oficial",
"javax.portlet.expiration-cache=0", "javax.portlet.expiration-cache=0",
"javax.portlet.init-param.portlet-title-based-navigation=true", "javax.portlet.init-param.portlet-title-based-navigation=true",
"javax.portlet.init-param.template-path=/", "javax.portlet.init-param.template-path=/",
...@@ -129,11 +129,8 @@ public class MprjDoerjCadernoPortlet extends MVCPortlet { ...@@ -129,11 +129,8 @@ public class MprjDoerjCadernoPortlet extends MVCPortlet {
public void geraCaderno(ActionRequest actionRequest, ActionResponse actionResponse)throws Exception { public void geraCaderno(ActionRequest actionRequest, ActionResponse actionResponse)throws Exception {
UploadPortletRequest uploadRequest=PortalUtil.getUploadPortletRequest(actionRequest); String dataDivulgacao = ParamUtil.getString(actionRequest, "dataP");
ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY); String idStatus = ParamUtil.getString(actionRequest, "situacao");
String dataDivulgacao = ParamUtil.getString(uploadRequest, "dataP");
String idStatus = ParamUtil.getString(uploadRequest, "situacao");
JSONArray listaConteudos = new JSONArray(); JSONArray listaConteudos = new JSONArray();
RestServices rest = new RestServices(); RestServices rest = new RestServices();
...@@ -141,7 +138,6 @@ public class MprjDoerjCadernoPortlet extends MVCPortlet { ...@@ -141,7 +138,6 @@ public class MprjDoerjCadernoPortlet extends MVCPortlet {
listaConteudos = rest.getRest(dataDivulgacaoRest,idStatus,actionRequest); listaConteudos = rest.getRest(dataDivulgacaoRest,idStatus,actionRequest);
SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE);
if(!mensagensDeErro(listaConteudos, dataDivulgacao, actionRequest)){ if(!mensagensDeErro(listaConteudos, dataDivulgacao, actionRequest)){
GeraCaderno caderno = new GeraCaderno(); GeraCaderno caderno = new GeraCaderno();
......
...@@ -2,6 +2,7 @@ package mprj.doerj.caderno.util; ...@@ -2,6 +2,7 @@ package mprj.doerj.caderno.util;
import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.theme.ThemeDisplay; import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.PortalUtil; import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.kernel.util.WebKeys;
...@@ -17,9 +18,7 @@ import javax.portlet.ActionRequest; ...@@ -17,9 +18,7 @@ import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse; import javax.portlet.ActionResponse;
import javax.portlet.PortletContext; import javax.portlet.PortletContext;
import javax.portlet.PortletPreferences; import javax.portlet.PortletPreferences;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse; import javax.portlet.PortletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
...@@ -217,30 +216,44 @@ public class GeraCaderno { ...@@ -217,30 +216,44 @@ public class GeraCaderno {
//File exportFile = new File("C:/Users/diogo.souza/Documents/Caderno DO/testeDoc4JNovo.docx"); //File exportFile = new File("C:/Users/diogo.souza/Documents/Caderno DO/testeDoc4JNovo.docx");
String dataNomeArquivo = dataDivulgacao.replace("/", "-"); String dataNomeArquivo = dataDivulgacao.replace("/", "-");
String nomeArquivo="caderno_doerj_" + dataNomeArquivo + ".docx"; String nomeArquivo="caderno_doerj_" + dataNomeArquivo + ".docx";
InputStream nomeArquivoInputStream = GeraCaderno.class.getClass().getResourceAsStream("/META-INF/resources/template/"+nomeArquivo);
File exportFile = new File(nomeArquivoInputStream.toString());
templatePackage.save(exportFile);
PortletRequest pRequest = PortalUtil.getLiferayPortletRequest(actionRequest); // InputStream nomeArquivoInputStream = getClass().getResourceAsStream("/META-INF/resources/template/"+nomeArquivo);
PortletResponse pResponse = PortalUtil.getLiferayPortletResponse(actionResponse); // File exportFile = new File(nomeArquivoInputStream.toString());
HttpServletRequest req = PortalUtil.getHttpServletRequest(pRequest); //cria o arquivo temporário que será utilizado na resposta da requisição
HttpServletResponse res = PortalUtil.getHttpServletResponse(pResponse); File exportFile = File.createTempFile("caderno_doerj_tmp_", ".docx");
res.setHeader("Content-Disposition", "attachment; filename="+nomeArquivo + ".docx");//
res.setHeader("Content-Transfer-Encoding", "binary"); try {
res.setContentType("application/force-download"); templatePackage.save(exportFile);
FileInputStream in = new FileInputStream(exportFile); // PortletRequest pRequest = PortalUtil.getLiferayPortletRequest(actionRequest);
OutputStream out = res.getOutputStream(); PortletResponse pResponse = PortalUtil.getLiferayPortletResponse(actionResponse);
byte[] buffer = new byte[4096]; // HttpServletRequest req = PortalUtil.getHttpServletRequest(pRequest);
HttpServletResponse res = PortalUtil.getHttpServletResponse(pResponse);
int numBytesRead; res.setHeader("Content-Disposition", "attachment; filename=" + nomeArquivo);//
while ((numBytesRead = in.read(buffer)) > 0) { // res.setHeader("Content-Transfer-Encoding", "binary");
out.write(buffer, 0, numBytesRead); res.setContentType(ContentTypes.APPLICATION_MSWORD);
}
try (FileInputStream in = new FileInputStream(exportFile);) {
res.flushBuffer(); OutputStream out = res.getOutputStream();
byte[] buffer = new byte[4096];
int numBytesRead;
while ((numBytesRead = in.read(buffer)) > 0) {
out.write(buffer, 0, numBytesRead);
}
out.flush();
res.flushBuffer();
}
}
finally {
exportFile.delete();
}
} }
......
...@@ -43,9 +43,7 @@ ...@@ -43,9 +43,7 @@
<portlet:param name="mvcPath" value="/view.jsp"/> <portlet:param name="mvcPath" value="/view.jsp"/>
</portlet:actionURL> </portlet:actionURL>
<form id="<portlet:namespace />formDO" name="<portlet:namespace />formDO" method="POST" action="<%= submitActionURL%>" data-senna-off="true">
<form id="<portlet:namespace />formDO" name="<portlet:namespace />formDO" method="POST" enctype="multipart/form-data" action="<%= submitActionURL%>" >
<div id="campo-situacao" class="campo"> <div id="campo-situacao" class="campo">
<label><liferay-ui:message key="admin.form.editar.situacao"/></label> <label><liferay-ui:message key="admin.form.editar.situacao"/></label>
......
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