Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 12aab1d0
authored
Sep 01, 2013
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fileuploading fix..
1 parent
f942451c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
22 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardPrintBean.java
code/MoyaWeb/WebContent/index.xhtml
code/MoyaWeb/src/fi/codecrew/moya/servlet/FileDownloadServlet.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/organisation/EventPropertyView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardPrintBean.java
View file @
12aab1d
...
@@ -234,6 +234,9 @@ public class CardPrintBean implements CardPrintBeanLocal {
...
@@ -234,6 +234,9 @@ public class CardPrintBean implements CardPrintBeanLocal {
@Override
@Override
public
byte
[]
constructPNG
(
PrintedCard
card
)
throws
Exception
{
public
byte
[]
constructPNG
(
PrintedCard
card
)
throws
Exception
{
if
(
card
==
null
)
{
return
null
;
}
card
=
printedCardFacade
.
reload
(
card
);
card
=
printedCardFacade
.
reload
(
card
);
// logger.info("Printing card tpl {} with template image {}",
// logger.info("Printing card tpl {} with template image {}",
...
...
code/MoyaWeb/WebContent/index.xhtml
View file @
12aab1d
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
>
<h:head>
<h:head>
<meta
http-equiv=
"refresh"
content=
"1;url=frontpage.jsf"
/>
<meta
http-equiv=
"refresh"
content=
"1;url=
#{request.contextPath}/
frontpage.jsf"
/>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
window
.
location
.
href
=
"frontpage.jsf"
window
.
location
.
href
=
"
#{request.contextPath}/
frontpage.jsf"
</script>
</script>
<title></title>
<title></title>
</h:head>
</h:head>
<h:body>
<h:body>
Redirecting to
<a
href=
"frontpage.jsf"
>
Frontpage
</a>
Redirecting to
<a
href=
"
#{request.contextPath}/
frontpage.jsf"
>
Frontpage
</a>
</h:body>
</h:body>
</html>
</html>
\ No newline at end of file
code/MoyaWeb/src/fi/codecrew/moya/servlet/FileDownloadServlet.java
View file @
12aab1d
...
@@ -44,13 +44,12 @@ public class FileDownloadServlet extends GenericImageServlet {
...
@@ -44,13 +44,12 @@ public class FileDownloadServlet extends GenericImageServlet {
@EJB
@EJB
private
transient
UserBeanLocal
userbean
;
private
transient
UserBeanLocal
userbean
;
@EJB
@EJB
private
transient
CardTemplateBeanLocal
cardbean
;
private
transient
CardTemplateBeanLocal
cardbean
;
@EJB
@EJB
private
transient
CardPrintBeanLocal
cardprint
;
private
transient
CardPrintBeanLocal
cardprint
;
@EJB
@EJB
private
transient
PermissionBeanLocal
permbean
;
private
transient
PermissionBeanLocal
permbean
;
...
@@ -61,19 +60,13 @@ public class FileDownloadServlet extends GenericImageServlet {
...
@@ -61,19 +60,13 @@ public class FileDownloadServlet extends GenericImageServlet {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FileDownloadServlet
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FileDownloadServlet
.
class
);
/**
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
* response)
*/
*/
private
static
final
Pattern
URLPATTERN
=
Pattern
.
compile
(
"([^./]+)"
);
private
static
final
Pattern
URLPATTERN
=
Pattern
.
compile
(
"([^./]+)"
);
/**
/**
* Usage MoyaWeb/dydata/format/
* Usage MoyaWeb/dydata/format/ possible formats logo userimage/<eventuserid>.jpg cardtemplate/<cardtemplateid>.png usercard/
* possible formats
* logo
* userimage/<eventuserid>.jpg
* cardtemplate/<cardtemplateid>.png
* usercard/
*/
*/
@Override
@Override
protected
ImageMover
getImagedata
()
{
protected
ImageMover
getImagedata
()
{
...
@@ -135,28 +128,25 @@ public class FileDownloadServlet extends GenericImageServlet {
...
@@ -135,28 +128,25 @@ public class FileDownloadServlet extends GenericImageServlet {
}
}
}
}
}
else
if
(
urlparts
.
get
(
0
).
equals
(
"usercard"
)
&&
urlparts
.
size
()
>
2
)
}
else
if
(
urlparts
.
get
(
0
).
equals
(
"usercard"
)
&&
urlparts
.
size
()
>
2
)
{
{
int
userid
=
Integer
.
parseInt
(
urlparts
.
get
(
1
));
int
userid
=
Integer
.
parseInt
(
urlparts
.
get
(
1
));
EventUser
usr
=
userbean
.
findByUserId
(
userid
);
EventUser
usr
=
userbean
.
findByUserId
(
userid
);
logger
.
info
(
"Trying to print usercard for user {}"
,
usr
);
logger
.
info
(
"Trying to print usercard for user {}"
,
usr
);
if
(
usr
!=
null
)
{
if
(
usr
!=
null
)
{
PrintedCard
card
=
cardbean
.
checkPrintedCard
(
usr
);
PrintedCard
card
=
cardbean
.
checkPrintedCard
(
usr
);
try
{
try
{
byte
[]
img
=
cardprint
.
constructPNG
(
card
);
byte
[]
img
=
cardprint
.
constructPNG
(
card
);
if
(
img
.
length
>
0
)
if
(
img
!=
null
&&
img
.
length
>
0
)
{
{
ret
.
setData
(
img
);
ret
.
setData
(
img
);
ret
.
setImagetype
(
"image/png"
);
ret
.
setImagetype
(
"image/png"
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
logger
.
warn
(
"Error generating image"
,
e
);
e
.
printStackTrace
();
}
}
}
}
}
}
if
(
ret
.
getImagetype
()
==
null
)
{
if
(
ret
.
getImagetype
()
==
null
)
{
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/organisation/EventPropertyView.java
View file @
12aab1d
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
organisation
;
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
organisation
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
...
@@ -136,6 +137,23 @@ public class EventPropertyView extends GenericCDIView {
...
@@ -136,6 +137,23 @@ public class EventPropertyView extends GenericCDIView {
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
;
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
)
{
super
.
addFaceMessage
(
"eventProperty.errorUploadingFile"
);
return
null
;
}
property
.
setByteValue
(
file
.
getContents
());
property
.
setByteValue
(
file
.
getContents
());
property
.
setByteMime
(
file
.
getContentType
());
property
.
setByteMime
(
file
.
getContentType
());
}
}
...
...
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