Commit e9be20d5 by Consultor Vertigo

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

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