Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
doerj-caderno-dxp-7.2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
diogo.souza
doerj-caderno-dxp-7.2
Commits
e9be20d5
Commit
e9be20d5
authored
Oct 20, 2020
by
Consultor Vertigo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajustes nas dependências após avançar na geração do docx.
parent
d381a7e0
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
53 additions
and
34 deletions
+53
-34
.gitignore
bin/main/.gitignore
+0
-1
view.jsp
bin/main/META-INF/resources/view.jsp
+1
-1
MprjDoerjCadernoPortlet.class
.../mprj/doerj/caderno/portlet/MprjDoerjCadernoPortlet.class
+0
-0
GeraCaderno.class
bin/main/mprj/doerj/caderno/util/GeraCaderno.class
+0
-0
bnd.bnd
bnd.bnd
+15
-9
build.gradle
build.gradle
+10
-3
MprjDoerjCadernoPortlet.java
...a/mprj/doerj/caderno/portlet/MprjDoerjCadernoPortlet.java
+3
-7
GeraCaderno.java
src/main/java/mprj/doerj/caderno/util/GeraCaderno.java
+23
-10
view.jsp
src/main/resources/META-INF/resources/view.jsp
+1
-3
No files found.
bin/main/.gitignore
View file @
e9be20d5
/META-INF/
/content/
/mprj/
bin/main/META-INF/resources/view.jsp
View file @
e9be20d5
...
...
@@ -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>
...
...
bin/main/mprj/doerj/caderno/portlet/MprjDoerjCadernoPortlet.class
View file @
e9be20d5
No preview for this file type
bin/main/mprj/doerj/caderno/util/GeraCaderno.class
View file @
e9be20d5
No preview for this file type
bnd.bnd
View file @
e9be20d5
...
...
@@ -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.*,\
...
...
build.gradle
View file @
e9be20d5
...
...
@@ -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"
}
...
...
src/main/java/mprj/doerj/caderno/portlet/MprjDoerjCadernoPortlet.java
View file @
e9be20d5
...
...
@@ -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=Gest
o de Matrias do Di
rio 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
();
...
...
src/main/java/mprj/doerj/caderno/util/GeraCaderno.java
View file @
e9be20d5
...
...
@@ -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
());
// 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
);
//
PortletRequest pRequest = PortalUtil.getLiferayPortletRequest(actionRequest);
PortletResponse
pResponse
=
PortalUtil
.
getLiferayPortletResponse
(
actionResponse
);
HttpServletRequest
req
=
PortalUtil
.
getHttpServletRequest
(
pRequest
);
//
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"
);
res
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
nomeArquivo
);
//
//
res.setHeader("Content-Transfer-Encoding", "binary");
res
.
setContentType
(
ContentTypes
.
APPLICATION_MSWORD
);
FileInputStream
in
=
new
FileInputStream
(
exportFile
);
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
();
}
}
...
...
src/main/resources/META-INF/resources/view.jsp
View file @
e9be20d5
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment