Commit db926089 by Consultor Vertigo

ajustes para download do .docx gerado

parent e9be20d5
# Caderno Diário Oficial
Para que a biblioteca **docx4j** consiga utilizar as dependências que fazem parte do JDK, será necessário configurar o portal-ext.properties do portal para que as dependências necessárias **não** sejam consideradas como contexto do **OSGi**.
Segue abaixo a configuração a ser adicionada no portal-ext.properties (o portal precisa ser reiniciado):
```
#Possibilitar uso do javax.xml e com.sun.xml nos portlets
module.framework.properties.org.osgi.framework.bootdelegation=\
__redirected,\
com.liferay.aspectj,\
com.liferay.aspectj.*,\
com.liferay.expando.kernel.model,\
com.liferay.portal.servlet.delegate,\
com.liferay.portal.servlet.delegate*,\
com.sun.ccpp,\
com.sun.ccpp.*,\
com.sun.crypto.*,\
com.sun.image.*,\
com.sun.jmx.*,\
com.sun.jna,\
com.sun.jndi.*,\
com.sun.mail.*,\
com.sun.management.*,\
com.sun.media.*,\
com.sun.msv.*,\
com.sun.org.*,\
com.sun.syndication,\
com.sun.tools.*,\
com.sun.xml,\
com.sun.xml.*,\
com.yourkit.*,\
javax.validation,\
javax.validation.*,\
jdk.*,\
javax.xml,\
javax.xml.*,\
sun.*,\
weblogic.jndi,\
weblogic.jndi.*,\
org.w3c,\
org.w3c.*,\
org.xml.sax,\
org.xml.sax.*
```
Caso a configuração não seja aplicada ocorrerá erro como o trecho do stacktrace abaixo, ao executar funcionalidades do **docx4j**:
```
Caused by: java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.docx4j.org.apache.xalan.processor.TransformerFactoryImpl.newXMLFilter(Ljavax/xml/transform/Templates;)Lorg/xml/sax/XMLFilter;" the class loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) of the current class, org/docx4j/org/apache/xalan/processor/TransformerFactoryImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/xml/sax/XMLFilter used in the signature
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.getConstructor(Class.java:1825)
at __redirected.__TransformerFactory.<init>
```
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
<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" action="<%= submitActionURL%>" data-senna-off="true">
<div id="campo-situacao" class="campo"> <div id="campo-situacao" class="campo">
......
...@@ -226,13 +226,10 @@ public class GeraCaderno { ...@@ -226,13 +226,10 @@ public class GeraCaderno {
try { try {
templatePackage.save(exportFile); templatePackage.save(exportFile);
// PortletRequest pRequest = PortalUtil.getLiferayPortletRequest(actionRequest);
PortletResponse pResponse = PortalUtil.getLiferayPortletResponse(actionResponse); PortletResponse pResponse = PortalUtil.getLiferayPortletResponse(actionResponse);
// HttpServletRequest req = PortalUtil.getHttpServletRequest(pRequest);
HttpServletResponse res = PortalUtil.getHttpServletResponse(pResponse); HttpServletResponse res = PortalUtil.getHttpServletResponse(pResponse);
res.setHeader("Content-Disposition", "attachment; filename=" + nomeArquivo);// res.setHeader("Content-Disposition", "attachment; filename=" + nomeArquivo);//
// res.setHeader("Content-Transfer-Encoding", "binary");
res.setContentType(ContentTypes.APPLICATION_MSWORD); res.setContentType(ContentTypes.APPLICATION_MSWORD);
try (FileInputStream in = new FileInputStream(exportFile);) { try (FileInputStream in = new FileInputStream(exportFile);) {
......
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