Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
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 2d17df61
authored
Jan 12, 2015
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lippusydeemit toimii, vielä pitää fixata multibuggagesearch
1 parent
1cc321e8
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
188 additions
and
16 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/util/MailMessage.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BarcodeBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/MailMessageBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/TicketBean.java
code/moya-web/WebContent/place/myEtickets.xhtml
code/moya-web/WebContent/resources/cditools/infoview/usermultisearch.xhtml
code/moya-web/WebContent/resources/templates/infoview/template.xhtml
code/moya-web/WebContent/resources/templates/primelayout/template.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/eticket/EticketView.java
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n.properties
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
code/moya-beans-client/ejbModule/fi/codecrew/moya/util/MailMessage.java
View file @
2d17df6
...
...
@@ -20,6 +20,8 @@ package fi.codecrew.moya.util;
import
java.io.Serializable
;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.mail.internet.InternetAddress
;
...
...
@@ -29,7 +31,7 @@ public class MailMessage implements Serializable {
/**
*
*/
private
static
final
long
serialVersionUID
=
-
476946839485040710
7
L
;
private
static
final
long
serialVersionUID
=
-
476946839485040710
9
L
;
private
static
final
String
DEFAULT_MAIL_CHARSET
=
"ISO-8859-1"
;
...
...
@@ -41,6 +43,8 @@ public class MailMessage implements Serializable {
private
String
message
;
private
String
charset
=
DEFAULT_MAIL_CHARSET
;
private
List
<
MailMessageAttachment
>
attachmentList
;
public
InternetAddress
getTo
()
throws
UnsupportedEncodingException
{
return
new
InternetAddress
(
toAddress
,
toName
,
getCharset
());
}
...
...
@@ -117,6 +121,14 @@ public class MailMessage implements Serializable {
return
charset
;
}
public
List
<
MailMessageAttachment
>
getAttachmentList
()
{
return
attachmentList
;
}
public
void
setAttachmentList
(
List
<
MailMessageAttachment
>
attachmentList
)
{
this
.
attachmentList
=
attachmentList
;
}
public
void
setTo
(
User
user
)
{
setToName
(
user
.
getWholeName
());
setToAddress
(
user
.
getEmail
());
...
...
@@ -127,4 +139,11 @@ public class MailMessage implements Serializable {
public
String
toString
()
{
return
new
StringBuilder
(
"fi.codecrew.moya.util.MailMessage[to="
).
append
(
toAddress
).
append
(
"]"
).
toString
();
}
public
void
addAttachment
(
MailMessageAttachment
attachment
)
{
if
(
attachmentList
==
null
)
attachmentList
=
new
ArrayList
<>();
attachmentList
.
add
(
attachment
);
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BarcodeBean.java
View file @
2d17df6
...
...
@@ -51,7 +51,9 @@ public class BarcodeBean implements BarcodeBeanLocal {
private
static
final
String
PRINTED_CARD_TEXTCODEPREFIX
=
"10"
;
private
static
final
String
PLACE_TEXTCODEPREFIX
=
"11"
;
private
static
final
String
EVENTUSER_TEXTCODEPREFIX
=
"12"
;
// DO NOT ACCIDENTLY ADD '=' -char to this list
private
static
final
String
TEXTCODE_CHARACTER_MAP
=
"23456789ABCDEFGHJKLMNPQRSTUVWXYZ"
;
private
static
final
int
TEXTCODE_ROTATE_COUNT
=
500
;
...
...
@@ -105,6 +107,11 @@ public class BarcodeBean implements BarcodeBeanLocal {
@Override
public
EventUser
getUserFromLongTextCode
(
String
textcode
)
{
// check if it is some url
if
(
textcode
.
lastIndexOf
(
"="
)
>
6
)
{
textcode
=
textcode
.
substring
(
textcode
.
lastIndexOf
(
"="
)+
1
);
}
return
getUserFromTextCode
(
textcode
,
38
,
16
);
}
...
...
@@ -331,11 +338,16 @@ public class BarcodeBean implements BarcodeBeanLocal {
// try if it is our Eticket -code
EventUser
user
=
getUserFromTextCode
(
barcode
);
logger
.
info
(
"Found maybe some nice user {}"
,
user
);
if
(
user
!=
null
)
return
user
;
// not eticket, then there is our other eticket, the one sent via email.
user
=
getUserFromLongTextCode
(
barcode
);
if
(
user
!=
null
)
return
user
;
}
catch
(
NumberFormatException
x
)
{
}
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/MailMessageBean.java
View file @
2d17df6
...
...
@@ -20,6 +20,7 @@ package fi.codecrew.moya.beans;
import
java.io.UnsupportedEncodingException
;
import
javax.activation.DataHandler
;
import
javax.annotation.Resource
;
import
javax.ejb.ActivationConfigProperty
;
import
javax.ejb.MessageDriven
;
...
...
@@ -27,12 +28,14 @@ import javax.jms.JMSException;
import
javax.jms.Message
;
import
javax.jms.MessageListener
;
import
javax.jms.ObjectMessage
;
import
javax.mail.MessagingException
;
import
javax.mail.Session
;
import
javax.mail.Transport
;
import
javax.mail.*
;
import
javax.mail.internet.MimeBodyPart
;
import
javax.mail.internet.MimeMessage
;
import
javax.mail.internet.MimeMessage.RecipientType
;
import
javax.mail.internet.MimeMultipart
;
import
javax.mail.util.ByteArrayDataSource
;
import
fi.codecrew.moya.util.MailMessageAttachment
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -75,7 +78,16 @@ public class MailMessageBean implements MessageListener {
mailmsg
=
(
MailMessage
)
((
ObjectMessage
)
message
).
getObject
();
logger
.
debug
(
"Got message {}"
,
mailmsg
.
getToName
());
if
(
BortalLocalContextHolder
.
isInDevelopmentMode
())
{
// MERGEREQUESTIN TARKASTAJA!
// MERGEREQUESTIN TARKASTAJA!
// MERGEREQUESTIN TARKASTAJA!
// MERGEREQUESTIN TARKASTAJA!
// MERGEREQUESTIN TARKASTAJA!
// MERGEREQUESTIN TARKASTAJA!
// MERGEREQUESTIN TARKASTAJA!
// MERGEREQUESTIN TARKASTAJA!
// Jos unohan tän falsen tähän alle, niin ulise TKffTK:lle kovasti :)
if
(
false
&&
BortalLocalContextHolder
.
isInDevelopmentMode
())
{
String
dmessage
=
" To: "
+
mailmsg
.
getTo
()
+
"\n Subject: "
+
mailmsg
.
getSubject
()
+
"\n Text: "
...
...
@@ -85,11 +97,27 @@ public class MailMessageBean implements MessageListener {
}
else
{
MimeMessage
msg
=
new
MimeMessage
(
mailSession
);
MimeMultipart
multipart
=
new
MimeMultipart
();
MimeBodyPart
contentPart
=
new
MimeBodyPart
();
contentPart
.
setText
(
mailmsg
.
getMessage
(),
mailmsg
.
getCharset
());
multipart
.
addBodyPart
(
contentPart
);
// Add attachments, if any
if
(
mailmsg
.
getAttachmentList
()
!=
null
&&
mailmsg
.
getAttachmentList
().
size
()
>
0
)
{
for
(
MailMessageAttachment
attachment
:
mailmsg
.
getAttachmentList
())
{
MimeBodyPart
mimeAttachment
=
new
MimeBodyPart
();
mimeAttachment
.
setFileName
(
attachment
.
getName
());
mimeAttachment
.
setDataHandler
(
new
DataHandler
(
new
ByteArrayDataSource
(
attachment
.
getData
(),
attachment
.
getMimeType
())));
multipart
.
addBodyPart
(
mimeAttachment
);
}
}
msg
.
setSubject
(
mailmsg
.
getSubject
());
msg
.
setFrom
(
mailmsg
.
getFrom
());
msg
.
setRecipient
(
RecipientType
.
TO
,
mailmsg
.
getTo
());
msg
.
setText
(
mailmsg
.
getMessage
(),
mailmsg
.
getCharset
());
msg
.
setContent
(
multipart
);
Transport
.
send
(
msg
);
}
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/TicketBean.java
View file @
2d17df6
...
...
@@ -18,6 +18,7 @@
*/
package
fi
.
codecrew
.
moya
.
beans
;
import
com.pdfjet.*
;
import
fi.codecrew.moya.enums.apps.MapPermission
;
import
fi.codecrew.moya.enums.apps.SpecialPermission
;
...
...
@@ -26,8 +27,12 @@ import fi.codecrew.moya.facade.GroupMembershipFacade;
import
fi.codecrew.moya.facade.PlaceGroupFacade
;
import
fi.codecrew.moya.model.*
;
import
fi.codecrew.moya.util.MailMessage
;
import
fi.codecrew.moya.util.MailMessageAttachment
;
import
fi.codecrew.moya.utilities.BarcodeUtils
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventType
;
import
net.glxn.qrgen.*
;
import
net.glxn.qrgen.QRCode
;
import
net.glxn.qrgen.image.ImageType
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -36,6 +41,8 @@ import javax.annotation.security.RolesAllowed;
import
javax.ejb.EJB
;
import
javax.ejb.EJBAccessException
;
import
javax.ejb.Stateless
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.OutputStream
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
...
...
@@ -72,6 +79,7 @@ public class TicketBean implements TicketBeanLocal {
@EJB
private
UtilBean
utilBean
;
/**
* Default constructor.
*/
...
...
@@ -112,6 +120,8 @@ public class TicketBean implements TicketBeanLocal {
@Override
public
void
sendTicketEmail
(
EventUser
user
,
String
url
)
{
String
token
=
barcodeBean
.
getUserLongTextCode
(
user
);
MailMessage
msg
=
new
MailMessage
();
...
...
@@ -120,12 +130,99 @@ public class TicketBean implements TicketBeanLocal {
String
formatUrl
=
MessageFormat
.
format
(
url
,
token
);
logger
.
info
(
"Sending eticket url {}"
,
formatUrl
);
// ByteArrayOutputStream codeStream = QRCode.from(formatUrl).to(ImageType.PNG).withCharset("UTF-8").withSize(250, 250).stream();
MailMessageAttachment
attachment
=
new
MailMessageAttachment
(
"eticket.pdf"
,
getTicketPdf
(
user
,
formatUrl
),
"application/pdf"
);
msg
.
addAttachment
(
attachment
);
msg
.
setMessage
(
MessageFormat
.
format
(
eventbean
.
getPropertyString
(
LanEventPropertyKey
.
ETICKETMAIL_CONTENT
),
formatUrl
,
user
.
getUser
().
getWholeName
()));
msg
.
setToAddress
(
user
.
getEmail
());
utilBean
.
sendMail
(
msg
);
}
private
byte
[]
getTicketPdf
(
EventUser
user
,
String
codetext
)
{
PDF
pdf
=
null
;
try
{
ByteArrayOutputStream
ostream
=
new
ByteArrayOutputStream
();
pdf
=
new
PDF
(
ostream
);
Font
smallfont
=
new
Font
(
pdf
,
CoreFont
.
HELVETICA
);
smallfont
.
setSize
(
10
);
Font
font
=
new
Font
(
pdf
,
CoreFont
.
HELVETICA
);
font
.
setSize
(
15
);
Font
titlefont
=
new
Font
(
pdf
,
CoreFont
.
HELVETICA
);
titlefont
.
setSize
(
25
);
TextLine
textLine
=
null
;
// new float[]{420.0F, 595.0F};
Page
page
=
new
Page
(
pdf
,
A5
.
PORTRAIT
);
// topic
textLine
=
new
TextLine
(
titlefont
,
eventbean
.
getCurrentEvent
().
getName
());
textLine
.
setPosition
(
210
-(
textLine
.
getWidth
()/
2
),
30
);
textLine
.
setColor
(
0x333333
);
textLine
.
drawOn
(
page
);
// eventuser info
textLine
=
new
TextLine
(
font
,
user
.
getWholeName
()
+
" ("
+
user
.
getLogin
()+
")"
);
textLine
.
setPosition
(
210
-(
textLine
.
getWidth
()/
2
),
50
);
textLine
.
setColor
(
0x333333
);
textLine
.
drawOn
(
page
);
// QRCode
// you can add also something like:
QRCode
code
=
QRCode
.
from
(
codetext
).
to
(
ImageType
.
PNG
).
withSize
(
300
,
300
);
ByteArrayInputStream
istream
=
new
ByteArrayInputStream
(
code
.
stream
().
toByteArray
());
Image
image
=
new
Image
(
pdf
,
istream
,
com
.
pdfjet
.
ImageType
.
PNG
);
image
.
setPosition
(
60
,
50
);
image
.
drawOn
(
page
);
// Text under code //
textLine
=
new
TextLine
(
smallfont
,
"Show this ticket on event door,"
);
textLine
.
setPosition
(
210
-(
textLine
.
getWidth
()/
2
),
330
);
textLine
.
setColor
(
0x333333
);
textLine
.
drawOn
(
page
);
textLine
=
new
TextLine
(
smallfont
,
"or you can transfer it to phone by scanning it with mobile phone."
);
textLine
.
setPosition
(
210
-(
textLine
.
getWidth
()/
2
),
340
);
textLine
.
setColor
(
0x333333
);
textLine
.
drawOn
(
page
);
// placecodes
int
y
=
370
;
for
(
GroupMembership
gm
:
findMembershipPrintlistForUser
(
user
))
{
String
rowInfo
=
gm
.
getPlaceReservation
().
getProduct
().
getName
()
+
": "
+
gm
.
getPlaceReservation
().
getName
();
textLine
=
new
TextLine
(
font
,
rowInfo
);
textLine
.
setPosition
(
210
-(
textLine
.
getWidth
()/
2
),
y
);
textLine
.
setColor
(
0x333333
);
textLine
.
drawOn
(
page
);
y
+=
17
;
}
pdf
.
flush
();
return
ostream
.
toByteArray
();
}
catch
(
Exception
e
)
{
// ^ kuka prkl implementoi jutukkeen joka sanoo heittävänsä "Exceptionin", ton pitäis olla laitonta
throw
new
RuntimeException
(
e
);
}
}
}
...
...
code/moya-web/WebContent/place/myEtickets.xhtml
View file @
2d17df6
...
...
@@ -23,9 +23,11 @@
<p:printer
target=
"eticketpanel"
/>
</p:commandButton>
<p:commandButton
update=
":messages"
icon=
"ui-icon-mail-closed"
value=
"#{i18n['etickets.sendAsMail']}"
actionListener=
"#{eticketView.sendAsMail}"
/><br/><br/><br/>
<p:commandButton
id=
"sendeticketbutton"
update=
"sentmessagepanel"
icon=
"ui-icon-mail-closed"
value=
"#{i18n['etickets.sendAsMail']}"
actionListener=
"#{eticketView.sendAsMail}"
/><br/>
<p:outputPanel
id=
"sentmessagepanel"
>
<p:outputLabel
rendered=
"#{eticketView.sent}"
for=
"sendeticketbutton"
id=
"eticketSended"
styleClass=
"success"
value=
"#{i18n['etickets.mailSended']}"
/><br
/><br/><br/>
</p:outputPanel>
<p:outputPanel
id=
"eticketpanel"
>
<p:fieldset
legend=
"#{i18n['etickets.eticketcode']}"
style=
"width: 250px; "
>
...
...
code/moya-web/WebContent/resources/cditools/infoview/usermultisearch.xhtml
View file @
2d17df6
...
...
@@ -26,7 +26,7 @@
});
</h:outputScript>
<p:autoComplete
immediate=
"true"
widgetVar=
"usermultisearch"
styleClass=
"usermultisearch"
id=
"acsb"
value=
"#{infoView.multiSearchUser}"
completeMethod=
"#{infoView.matchMulti}"
converter=
"#{eventUserCodeFinderConverter}"
var=
"usrx"
itemLabel=
"#{usrx.shortUserDescriptor}"
itemValue=
"#{usrx}"
>
<p:autoComplete
widgetVar=
"usermultisearch"
styleClass=
"usermultisearch"
id=
"acsb"
value=
"#{infoView.multiSearchUser}"
completeMethod=
"#{infoView.matchMulti}"
converter=
"#{eventUserCodeFinderConverter}"
var=
"usrx"
itemLabel=
"#{usrx.shortUserDescriptor}"
itemValue=
"#{usrx}"
>
<p:ajax
event=
"itemSelect"
listener=
"#{cardlessIncomingView.changeUser}"
/>
</p:autoComplete>
<p:watermark
for=
"acsb"
value=
"#{i18n['infoview.multisearch']}"
/>
...
...
code/moya-web/WebContent/resources/templates/infoview/template.xhtml
View file @
2d17df6
...
...
@@ -69,7 +69,7 @@
<div
class=
"clearfix"
></div>
<div>
<div
style=
"margin-left: 10px;"
>
<ui:insert
name=
"content"
/>
</div>
...
...
code/moya-web/WebContent/resources/templates/primelayout/template.xhtml
View file @
2d17df6
...
...
@@ -194,9 +194,6 @@
<ui:insert
name=
"title"
/>
<p:menubar
rendered=
"#{primeMenuView.hasSecondaryMenu}"
model=
"#{primeMenuView.secondaryMenuModel}"
/>
<h:form
id=
"messages"
>
<p:growl
id=
"growl"
showDetail=
"true"
widgetVar=
"messages_growl"
/>
</h:form>
<ui:insert
name=
"edittab"
/>
...
...
@@ -223,7 +220,14 @@
</p:layout>
<h:form
id=
"messages"
>
<p:growl
id=
"growl"
showDetail=
"true"
sticky=
"true"
widgetVar=
"messages_growl"
/>
</h:form>
<h:form>
<!-- <p:growl id="growl" showDetail="true" sticky="true" autoUpdate="true" /> -->
<p:confirmDialog
global=
"true"
showEffect=
"fade"
hideEffect=
"explode"
>
<p:commandButton
value=
"Yes"
type=
"button"
styleClass=
"ui-confirmdialog-yes"
icon=
"ui-icon-check"
/>
<p:commandButton
value=
"No"
type=
"button"
styleClass=
"ui-confirmdialog-no"
icon=
"ui-icon-close"
/>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/eticket/EticketView.java
View file @
2d17df6
...
...
@@ -115,6 +115,8 @@ public class EticketView extends GenericCDIView {
public
void
sendAsMail
()
{
ticketBean
.
sendTicketEmail
(
userView
.
getSelectedUser
(),
getTicketUrl
());
addFaceMessage
(
"etickets.mailSended"
);
sent
=
true
;
}
...
...
@@ -141,6 +143,11 @@ public class EticketView extends GenericCDIView {
return
path
.
toString
();
}
boolean
sent
=
false
;
public
boolean
isSent
()
{
return
sent
;
}
}
...
...
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n.properties
View file @
2d17df6
...
...
@@ -486,3 +486,4 @@ user.invalidLoginCredentials=
barcodeReader.readBarcode
=
Lue viivakoodi
incomingflow.allGiven
=
Merkitty {0} lippu(a) annetuksi.
reader.noReader
=
Ei valittua lukijaa
etickets.mailSended
=
Lippu l
\u
00E4hetetty s
\u
00E4hk
\u
00F6postiisi
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
View file @
2d17df6
...
...
@@ -1701,3 +1701,4 @@ submenu.info.cardlessIncoming=Incoming
incomingFlow.count
=
Count
incomingflow.allGiven
=
Marked {0} tickets given.
reader.noReader
=
No selected reader
etickets.mailSended
=
Ticket has been sended to your email
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
View file @
2d17df6
...
...
@@ -1685,3 +1685,4 @@ submenu.info.cardlessIncoming=Sis\u00E4\u00E4ntulo
incomingFlow.count
=
M
\u
00E4
\u
00E4r
\u
00E4
incomingflow.allGiven
=
Merkitty {0} lippu(a) annetuksi.
reader.noReader
=
Ei valittua lukijaa
etickets.mailSended
=
Lippu l
\u
00E4hetetty s
\u
00E4hk
\u
00F6postiisi
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