Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c3cf8a7b
authored
Jun 05, 2018
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branches 'findbugs-fixes' and 'maven-fix' into massmerge4
3 parents
2894fcba
9091cd98
8914d19b
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
88 additions
and
148 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/ApiApplicationBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beanutil/PdfPrinter.java
code/moya-beans/pom.xml
code/moya-database/pom.xml
code/moya-parent/pom.xml
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/GitRepositoryState.java
code/moya-web/WebContent/WEB-INF/web.xml
code/moya-web/pom.xml
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/MapManageView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/organisation/EventPropertyView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/CardView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/ImportView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/voting/CompoView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/voting/VotingCompoAddEntryView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/FileUploadUtils.java
code/pom.xml
code/moya-beans/ejbModule/fi/codecrew/moya/beans/ApiApplicationBean.java
View file @
c3cf8a7
...
@@ -88,7 +88,7 @@ public class ApiApplicationBean implements ApiApplicationBeanLocal {
...
@@ -88,7 +88,7 @@ public class ApiApplicationBean implements ApiApplicationBeanLocal {
String
authname
=
permissionBean
.
getCurrentUser
().
getLogin
()
+
"_"
+
application
.
getName
()
+
"_"
+
currevent
.
getId
()
+
"_"
+
currevent
.
getName
();
String
authname
=
permissionBean
.
getCurrentUser
().
getLogin
()
+
"_"
+
application
.
getName
()
+
"_"
+
currevent
.
getId
()
+
"_"
+
currevent
.
getName
();
// Replace all non-valid characters with '_'
// Replace all non-valid characters with '_'
authname
.
replaceAll
(
"[^a-zA-Z0-9._]"
,
"_"
);
authname
=
authname
.
replaceAll
(
"[^a-zA-Z0-9._]"
,
"_"
);
// Ensure authname is unique;
// Ensure authname is unique;
final
String
origAuthname
=
authname
;
final
String
origAuthname
=
authname
;
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beanutil/PdfPrinter.java
View file @
c3cf8a7
...
@@ -47,8 +47,8 @@ public class PdfPrinter {
...
@@ -47,8 +47,8 @@ public class PdfPrinter {
}
}
private
static
final
String
fontname
=
CoreFont
.
HELVETICA
;
private
static
final
CoreFont
fontname
=
CoreFont
.
HELVETICA
;
private
static
final
String
boldfontname
=
CoreFont
.
HELVETICA_BOLD
;
private
static
final
CoreFont
boldfontname
=
CoreFont
.
HELVETICA_BOLD
;
private
static
final
String
EURO
=
" EUR"
;
private
static
final
String
EURO
=
" EUR"
;
// Legacy y-coordinater reverse constant
// Legacy y-coordinater reverse constant
private
static
final
double
INVERT
=
840
;
private
static
final
double
INVERT
=
840
;
...
...
code/moya-beans/pom.xml
View file @
c3cf8a7
...
@@ -32,22 +32,11 @@
...
@@ -32,22 +32,11 @@
<version>
1.2-SNAPSHOT
</version>
<version>
1.2-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
fi.codecrew.moya
</groupId>
<groupId>
fi.codecrew.moya
</groupId>
<artifactId>
moya-authmodule-client
</artifactId>
<artifactId>
moya-authmodule-client
</artifactId>
<version>
1.2-SNAPSHOT
</version>
<version>
1.2-SNAPSHOT
</version>
</dependency>
</dependency>
<!-- <dependency> <groupId>javax.ejb</groupId> <artifactId>javax.ejb-api</artifactId>
<version>3.2</version> <scope>test</scope> </dependency> -->
<dependency>
<groupId>
org.glassfish.main.extras
</groupId>
<artifactId>
glassfish-embedded-web
</artifactId>
<version>
4.1
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<parent>
<parent>
<groupId>
fi.codecrew.moya
</groupId>
<groupId>
fi.codecrew.moya
</groupId>
...
...
code/moya-database/pom.xml
View file @
c3cf8a7
...
@@ -7,6 +7,10 @@
...
@@ -7,6 +7,10 @@
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${compiler-plugin-version}
</version>
<configuration>
<useIncrementalCompilation>
false
</useIncrementalCompilation>
</configuration>
<executions>
<executions>
<execution>
<execution>
<id>
generate-entity-metamodel
</id>
<id>
generate-entity-metamodel
</id>
...
@@ -35,13 +39,6 @@
...
@@ -35,13 +39,6 @@
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<useIncrementalCompilation>
false
</useIncrementalCompilation>
</configuration>
</plugin>
</plugins>
</plugins>
</build>
</build>
<dependencies>
<dependencies>
...
...
code/moya-parent/pom.xml
View file @
c3cf8a7
...
@@ -50,9 +50,9 @@
...
@@ -50,9 +50,9 @@
<version>
1.5.9
</version>
<version>
1.5.9
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
fi.iudex.pdfjet
</groupId>
<groupId>
fi.iudex.
com.
pdfjet
</groupId>
<artifactId>
pdfjet
</artifactId>
<artifactId>
pdfjet
</artifactId>
<version>
0.0.0-2013-08-19
</version>
<version>
2017.04.09-1
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
net.glxn
</groupId>
<groupId>
net.glxn
</groupId>
...
@@ -122,13 +122,6 @@
...
@@ -122,13 +122,6 @@
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.glassfish
</groupId>
<artifactId>
javax.json
</artifactId>
<version>
1.0
</version>
<type>
jar
</type>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<artifactId>
slf4j-api
</artifactId>
<version>
${slf4j.version}
</version>
<version>
${slf4j.version}
</version>
...
@@ -169,15 +162,9 @@
...
@@ -169,15 +162,9 @@
<version>
${swagger.version}
</version>
<version>
${swagger.version}
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
javax.ws.rs
</groupId>
<groupId>
fish.payara.extras
</groupId>
<artifactId>
javax.ws.rs-api
</artifactId>
<artifactId>
payara-embedded-all
</artifactId>
<version>
2.0.1
</version>
<version>
${payara.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.glassfish.jersey.containers
</groupId>
<artifactId>
jersey-container-servlet
</artifactId>
<version>
2.17
</version>
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
<!-- These are required for findbugs annotations-->
<!-- These are required for findbugs annotations-->
...
...
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/GitRepositoryState.java
View file @
c3cf8a7
...
@@ -41,8 +41,9 @@ public class GitRepositoryState {
...
@@ -41,8 +41,9 @@ public class GitRepositoryState {
private
GitRepositoryState
()
{
private
GitRepositoryState
()
{
logger
.
info
(
"Initializing git status"
);
logger
.
info
(
"Initializing git status"
);
this
.
properties
=
new
Properties
();
this
.
properties
=
new
Properties
();
InputStream
resource
=
null
;
try
{
try
{
InputStream
resource
=
getClass
().
getResourceAsStream
(
"/git.properties"
);
resource
=
getClass
().
getResourceAsStream
(
"/git.properties"
);
if
(
resource
==
null
)
{
if
(
resource
==
null
)
{
logger
.
warn
(
"Resource not found!"
);
logger
.
warn
(
"Resource not found!"
);
...
@@ -53,6 +54,14 @@ public class GitRepositoryState {
...
@@ -53,6 +54,14 @@ public class GitRepositoryState {
logger
.
info
(
"Git keys:"
,
this
.
properties
.
keys
());
logger
.
info
(
"Git keys:"
,
this
.
properties
.
keys
());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error initializing git proerties"
,
e
);
logger
.
warn
(
"Error initializing git proerties"
,
e
);
}
finally
{
if
(
resource
!=
null
)
{
try
{
resource
.
close
();
}
catch
(
IOException
e
)
{
// Error clsoing resource in finally.. Eat the error.
}
}
}
}
}
}
...
...
code/moya-web/WebContent/WEB-INF/web.xml
View file @
c3cf8a7
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<web-app
xmlns=
"http://xmlns.jcp.org/xml/ns/javaee"
xmlns=
"http://xmlns.jcp.org/xml/ns/javaee"
xmlns:web=
"http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version=
"3.1"
>
version=
"3.1"
>
<display-name>
MoyaWeb
</display-name>
<display-name>
MoyaWeb
</display-name>
<context-param>
<context-param>
...
...
code/moya-web/pom.xml
View file @
c3cf8a7
...
@@ -40,25 +40,12 @@
...
@@ -40,25 +40,12 @@
<artifactId>
all-themes
</artifactId>
<artifactId>
all-themes
</artifactId>
<version>
${primefaces.themeversion}
</version>
<version>
${primefaces.themeversion}
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
fi.codecrew.moya
</groupId>
<groupId>
fi.codecrew.moya
</groupId>
<artifactId>
moya-restpojo
</artifactId>
<artifactId>
moya-restpojo
</artifactId>
<version>
1.2.4
</version>
<version>
1.2.4
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.glassfish.jersey.media
</groupId>
<artifactId>
jersey-media-multipart
</artifactId>
<version>
2.16
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.glassfish.jersey.core
</groupId>
<artifactId>
jersey-server
</artifactId>
<version>
2.16
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.ocpsoft.rewrite
</groupId>
<groupId>
org.ocpsoft.rewrite
</groupId>
<artifactId>
rewrite-servlet
</artifactId>
<artifactId>
rewrite-servlet
</artifactId>
<version>
${rewriteservlet.version}
</version>
<version>
${rewriteservlet.version}
</version>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/MapManageView.java
View file @
c3cf8a7
...
@@ -32,6 +32,7 @@ import javax.faces.event.ActionEvent;
...
@@ -32,6 +32,7 @@ import javax.faces.event.ActionEvent;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.web.helpers.FileUploadUtils
;
import
org.primefaces.model.DefaultStreamedContent
;
import
org.primefaces.model.DefaultStreamedContent
;
import
org.primefaces.model.StreamedContent
;
import
org.primefaces.model.StreamedContent
;
import
org.primefaces.model.UploadedFile
;
import
org.primefaces.model.UploadedFile
;
...
@@ -130,16 +131,11 @@ public class MapManageView extends GenericCDIView {
...
@@ -130,16 +131,11 @@ public class MapManageView extends GenericCDIView {
public
String
submitBg
()
{
public
String
submitBg
()
{
byte
[]
bytes
=
bgFile
.
getContents
();
byte
[]
bytes
=
FileUploadUtils
.
getFileContents
(
bgFile
);
if
(
bytes
==
null
&&
bgFile
.
getSize
()
>
0
)
{
if
(
bytes
==
null
||
bytes
.
length
==
0
)
{
bytes
=
new
byte
[(
int
)
bgFile
.
getSize
()];
try
{
bgFile
.
getInputstream
().
read
(
bytes
);
}
catch
(
IOException
e
)
{
super
.
addFaceMessage
(
"mapManage.errorUploadingBackground"
);
super
.
addFaceMessage
(
"mapManage.errorUploadingBackground"
);
return
null
;
return
null
;
}
}
}
map
.
setMapData
(
bytes
);
map
.
setMapData
(
bytes
);
map
.
setMimeType
(
bgFile
.
getContentType
());
map
.
setMimeType
(
bgFile
.
getContentType
());
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/organisation/EventPropertyView.java
View file @
c3cf8a7
...
@@ -29,6 +29,7 @@ import javax.faces.model.ListDataModel;
...
@@ -29,6 +29,7 @@ import javax.faces.model.ListDataModel;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.web.helpers.FileUploadUtils
;
import
org.primefaces.model.UploadedFile
;
import
org.primefaces.model.UploadedFile
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -131,20 +132,9 @@ public class EventPropertyView extends GenericCDIView {
...
@@ -131,20 +132,9 @@ public class EventPropertyView extends GenericCDIView {
public
String
savePrivateProperty
()
{
public
String
savePrivateProperty
()
{
logger
.
info
(
"Saving property {}, eventorg {}, key {}"
,
new
Object
[]{
privateProperty
.
getEvent
(),
privateProperty
.
getEventorg
(),
privateProperty
.
getKey
()});
logger
.
info
(
"Saving property {}, eventorg {}, key {}"
,
new
Object
[]{
privateProperty
.
getEvent
(),
privateProperty
.
getEventorg
(),
privateProperty
.
getKey
()});
if
(
privateProperty
.
getKey
().
isData
()
&&
file
!=
null
)
{
if
(
privateProperty
.
getKey
().
isData
()
&&
file
!=
null
)
{
byte
[]
contents
=
null
;
byte
[]
contents
=
FileUploadUtils
.
getFileContents
(
file
);
if
(
file
.
getContents
()
!=
null
)
{
contents
=
file
.
getContents
();
}
else
{
contents
=
new
byte
[(
int
)
file
.
getSize
()];
try
{
file
.
getInputstream
().
read
(
contents
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error reading file from stream"
,
e
);
contents
=
null
;
}
}
if
(
contents
==
null
)
{
if
(
contents
==
null
||
contents
.
length
==
0
)
{
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
return
null
;
return
null
;
}
}
...
@@ -187,20 +177,9 @@ public class EventPropertyView extends GenericCDIView {
...
@@ -187,20 +177,9 @@ public class EventPropertyView extends GenericCDIView {
logger
.
debug
(
"Is data: {} File {}"
,
property
.
getKey
().
isData
(),
file
);
logger
.
debug
(
"Is data: {} File {}"
,
property
.
getKey
().
isData
(),
file
);
if
(
property
.
getKey
().
isData
()
&&
file
!=
null
)
{
if
(
property
.
getKey
().
isData
()
&&
file
!=
null
)
{
logger
.
info
(
"saving data values type: {}, length {}"
,
file
.
getContentType
(),
file
.
getSize
());
logger
.
info
(
"saving data values type: {}, length {}"
,
file
.
getContentType
(),
file
.
getSize
());
byte
[]
contents
=
null
;
byte
[]
contents
=
FileUploadUtils
.
getFileContents
(
file
);
if
(
file
.
getContents
()
!=
null
)
{
contents
=
file
.
getContents
();
}
else
{
contents
=
new
byte
[(
int
)
file
.
getSize
()];
try
{
file
.
getInputstream
().
read
(
contents
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error reading file from stream"
,
e
);
contents
=
null
;
}
}
if
(
contents
==
null
)
{
if
(
contents
==
null
||
contents
.
length
==
0
)
{
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
return
null
;
return
null
;
}
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/CardView.java
View file @
c3cf8a7
...
@@ -27,6 +27,7 @@ import javax.enterprise.context.ConversationScoped;
...
@@ -27,6 +27,7 @@ import javax.enterprise.context.ConversationScoped;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.web.helpers.FileUploadUtils
;
import
org.primefaces.model.UploadedFile
;
import
org.primefaces.model.UploadedFile
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -95,20 +96,9 @@ public class CardView extends GenericCDIView {
...
@@ -95,20 +96,9 @@ public class CardView extends GenericCDIView {
try
{
try
{
logger
.
info
(
"Templateimage: {}"
,
getTemplateImage
());
logger
.
info
(
"Templateimage: {}"
,
getTemplateImage
());
byte
[]
contents
=
null
;
byte
[]
contents
=
null
;
UploadedFile
file
=
getTemplateImage
();
contents
=
FileUploadUtils
.
getFileContents
(
getTemplateImage
());
if
(
file
.
getContents
()
!=
null
)
{
contents
=
file
.
getContents
();
}
else
{
contents
=
new
byte
[(
int
)
file
.
getSize
()];
try
{
file
.
getInputstream
().
read
(
contents
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error reading file from stream"
,
e
);
contents
=
null
;
}
}
if
(
contents
==
null
)
{
if
(
contents
==
null
||
contents
.
length
==
0
)
{
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
return
null
;
return
null
;
}
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/ImportView.java
View file @
c3cf8a7
...
@@ -27,6 +27,7 @@ import javax.ejb.EJB;
...
@@ -27,6 +27,7 @@ import javax.ejb.EJB;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.web.helpers.FileUploadUtils
;
import
org.primefaces.model.UploadedFile
;
import
org.primefaces.model.UploadedFile
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -82,19 +83,10 @@ public class ImportView extends GenericCDIView {
...
@@ -82,19 +83,10 @@ public class ImportView extends GenericCDIView {
{
{
ArrayList
<
ImportWrapper
>
ret
=
new
ArrayList
<
ImportWrapper
>();
ArrayList
<
ImportWrapper
>
ret
=
new
ArrayList
<
ImportWrapper
>();
byte
[]
bytes
=
file
.
getContents
();
byte
[]
bytes
=
FileUploadUtils
.
getFileContents
(
file
);
if
(
bytes
==
null
&&
file
.
getSize
()
>
0
)
{
bytes
=
new
byte
[(
int
)
file
.
getSize
()];
try
{
file
.
getInputstream
().
read
(
bytes
);
}
catch
(
IOException
e
)
{
super
.
addFaceMessage
(
"import.erroruploading"
);
return
null
;
}
}
if
(
bytes
==
null
)
{
if
(
bytes
==
null
||
bytes
.
length
==
0
)
{
super
.
addFaceMessage
(
"import.erroruploading"
);
return
null
;
return
null
;
}
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/voting/CompoView.java
View file @
c3cf8a7
...
@@ -26,6 +26,7 @@ import javax.enterprise.inject.Produces;
...
@@ -26,6 +26,7 @@ import javax.enterprise.inject.Produces;
import
javax.faces.model.ListDataModel
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.web.helpers.FileUploadUtils
;
import
org.primefaces.event.RateEvent
;
import
org.primefaces.event.RateEvent
;
import
org.primefaces.model.UploadedFile
;
import
org.primefaces.model.UploadedFile
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -169,23 +170,9 @@ public class CompoView extends GenericCDIView {
...
@@ -169,23 +170,9 @@ public class CompoView extends GenericCDIView {
return
null
;
return
null
;
}
}
byte
[]
contents
=
null
;
byte
[]
contents
=
FileUploadUtils
.
getFileContents
(
file
);
if
(
file
.
getContents
()
!=
null
)
{
contents
=
file
.
getContents
();
logger
.
info
(
"Got file contents from .confents()"
);
}
else
{
contents
=
new
byte
[(
int
)
file
.
getSize
()];
logger
.
info
(
"Read {} bytes from stream in file {}"
,
file
.
getSize
(),
file
.
getFileName
());
try
{
file
.
getInputstream
().
read
(
contents
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error reading file from stream"
,
e
);
contents
=
null
;
}
}
if
(
contents
==
null
)
if
(
contents
==
null
||
contents
.
length
==
0
)
{
{
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
return
null
;
return
null
;
}
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/voting/VotingCompoAddEntryView.java
View file @
c3cf8a7
...
@@ -25,6 +25,7 @@ import javax.enterprise.context.RequestScoped;
...
@@ -25,6 +25,7 @@ import javax.enterprise.context.RequestScoped;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
fi.codecrew.moya.web.helpers.FileUploadUtils
;
import
org.primefaces.model.UploadedFile
;
import
org.primefaces.model.UploadedFile
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -108,27 +109,14 @@ public class VotingCompoAddEntryView extends GenericCDIView {
...
@@ -108,27 +109,14 @@ public class VotingCompoAddEntryView extends GenericCDIView {
UploadedFile
file
=
getUploadedFile
();
UploadedFile
file
=
getUploadedFile
();
if
(
file
==
null
)
if
(
file
==
null
)
{
{
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
return
null
;
return
null
;
}
}
byte
[]
contents
=
null
;
byte
[]
contents
=
FileUploadUtils
.
getFileContents
(
file
);
if
(
file
.
getContents
()
!=
null
)
{
contents
=
file
.
getContents
();
}
else
{
contents
=
new
byte
[(
int
)
file
.
getSize
()];
try
{
file
.
getInputstream
().
read
(
contents
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error reading file from stream"
,
e
);
contents
=
null
;
}
}
if
(
contents
==
null
)
if
(
contents
==
null
||
contents
.
length
==
0
)
{
{
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
super
.
addFaceMessage
(
"compo.fileuploadFailed"
);
return
null
;
return
null
;
}
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/FileUploadUtils.java
0 → 100644
View file @
c3cf8a7
package
fi
.
codecrew
.
moya
.
web
.
helpers
;
import
org.apache.commons.io.IOUtils
;
import
org.primefaces.model.UploadedFile
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
class
FileUploadUtils
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FileUploadUtils
.
class
);
public
static
byte
[]
getFileContents
(
UploadedFile
file
)
{
if
(
file
.
getContents
()
!=
null
)
{
return
file
.
getContents
();
}
else
{
InputStream
istream
=
null
;
try
{
istream
=
file
.
getInputstream
();
return
IOUtils
.
toByteArray
(
istream
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error reading file from stream"
,
e
);
}
finally
{
if
(
istream
!=
null
)
{
try
{
istream
.
close
();
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Error closing UploadFile inputstream"
);
}
}
}
}
return
null
;
}
}
code/pom.xml
View file @
c3cf8a7
...
@@ -31,10 +31,10 @@
...
@@ -31,10 +31,10 @@
<!-- EJB spec version -->
<!-- EJB spec version -->
<ejb-spec-version>
3.2
</ejb-spec-version>
<ejb-spec-version>
3.2
</ejb-spec-version>
<swagger.version>
1.5.
13
</swagger.version>
<swagger.version>
1.5.
20
</swagger.version>
<slf4j.version>
1.7.25
</slf4j.version>
<slf4j.version>
1.7.25
</slf4j.version>
<logback.version>
1.2.3
</logback.version>
<logback.version>
1.2.3
</logback.version>
<testng.version>
6.14.
2
</testng.version>
<testng.version>
6.14.
3
</testng.version>
<findbugs.version>
3.0.1
</findbugs.version>
<findbugs.version>
3.0.1
</findbugs.version>
<findbugs-maven.version>
3.0.5
</findbugs-maven.version>
<findbugs-maven.version>
3.0.5
</findbugs-maven.version>
<javamelody.version>
1.70.0
</javamelody.version>
<javamelody.version>
1.70.0
</javamelody.version>
...
@@ -44,12 +44,13 @@
...
@@ -44,12 +44,13 @@
<primefaces.extensions>
6.0.0
</primefaces.extensions>
<primefaces.extensions>
6.0.0
</primefaces.extensions>
<jodatime.version>
2.9.9
</jodatime.version>
<jodatime.version>
2.9.9
</jodatime.version>
<rewriteservlet.version>
3.4.
1
.Final
</rewriteservlet.version>
<rewriteservlet.version>
3.4.
2
.Final
</rewriteservlet.version>
<iudex.standalone>
1.0.23
</iudex.standalone>
<iudex.standalone>
1.0.23
</iudex.standalone>
<js.node.version>
v8.6.0
</js.node.version>
<js.node.version>
v8.6.0
</js.node.version>
<js.npm.version>
5.6.0
</js.npm.version>
<js.npm.version>
5.6.0
</js.npm.version>
<eirslett.frontend.version>
1.4
</eirslett.frontend.version>
<eirslett.frontend.version>
1.4
</eirslett.frontend.version>
<payara.version>
4.1.2.181
</payara.version>
</properties>
</properties>
<url>
http://codecrew.fi
</url>
<url>
http://codecrew.fi
</url>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment