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 998d70a9
authored
May 11, 2013
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added printing rest
1 parent
f9a2e134
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
274 additions
and
104 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardPrintBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardTemplateBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PrintedCardBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/PrintedCardFacade.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/CardPrintBeanLocal.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/CardTemplateBeanLocal.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/EventBeanLocal.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/PrintedCardBeanLocal.java
code/MoyaUtilities/src/fi/codecrew/moya/enums/CardState.java
code/MoyaWeb/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
code/MoyaWeb/.settings/org.eclipse.wst.common.project.facet.core.xml
code/MoyaWeb/WebContent/WEB-INF/web.xml
code/MoyaWeb/src/fi/codecrew/moya/rest/PrinterRestView.java
code/MoyaWeb/src/fi/codecrew/moya/rest/pojo/PrintedCardRestPojo.java
code/MoyaWeb/src/fi/codecrew/moya/servlet/FileDownloadServlet.java
code/MoyaWeb/src/fi/codecrew/moya/servlet/UserPngImageServlet.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardPrintBean.java
View file @
998d70a
...
...
@@ -35,6 +35,7 @@ import com.pdfjet.TextLine;
import
fi.codecrew.moya.facade.CardTemplateFacade
;
import
fi.codecrew.moya.facade.EventUserFacade
;
import
fi.codecrew.moya.facade.PrintedCardFacade
;
import
fi.codecrew.moya.facade.UserFacade
;
import
fi.codecrew.moya.model.CardTemplate
;
import
fi.codecrew.moya.model.EventUser
;
...
...
@@ -61,6 +62,8 @@ public class CardPrintBean implements CardPrintBeanLocal {
private
UserFacade
userfacade
;
@EJB
private
BarcodeBean
barcodeBean
;
@EJB
private
PrintedCardFacade
printedCardFacade
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CardPrintBean
.
class
);
/**
...
...
@@ -225,10 +228,12 @@ public class CardPrintBean implements CardPrintBeanLocal {
}
@Override
public
byte
[]
constructPNG
(
EventUser
user
)
throws
Exception
{
public
byte
[]
constructPNG
(
PrintedCard
card
)
throws
Exception
{
PrintedCard
card
=
cardTemplateBean
.
checkPrintedCard
(
user
);
logger
.
info
(
"Printing card {}"
,
card
);
card
=
printedCardFacade
.
reload
(
card
);
// logger.info("Printing card tpl {} with template image {}",
// card.getTemplate(), card.getTemplate().getImage());
EventUser
user
=
card
.
getUser
();
BufferedImage
face
=
ImageIO
.
read
(
new
ByteArrayInputStream
(
user
.
getUser
().
getCurrentImage
().
getImageData
()));
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardTemplateBean.java
View file @
998d70a
...
...
@@ -17,6 +17,7 @@ import javax.imageio.ImageIO;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.enums.CardState
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.facade.CardTemplateFacade
;
import
fi.codecrew.moya.facade.EventUserFacade
;
...
...
@@ -250,4 +251,24 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
public
List
<
CardTemplate
>
findAll
()
{
return
cdFacade
.
findAll
();
}
// TODO: Laita takaisin kun rest-kutsut authaa. -- tuomari
// @RolesAllowed(UserPermission.S_WRITE_ROLES)
@Override
public
PrintedCard
saveCard
(
PrintedCard
card
)
{
return
printedcardfacade
.
merge
(
card
);
}
@Override
// TODO: Laita takaisin kun rest-kutsut authaa. -- tuomari
// @RolesAllowed(UserPermission.S_WRITE_ROLES)
public
PrintedCard
findCard
(
Integer
id
)
{
return
printedcardfacade
.
find
(
id
);
}
@Override
public
List
<
PrintedCard
>
getCardsByState
(
CardState
...
state
)
{
return
printedcardfacade
.
findByState
(
state
);
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PrintedCardBean.java
deleted
100644 → 0
View file @
f9a2e13
package
fi
.
codecrew
.
moya
.
beans
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.RolesAllowed
;
import
javax.ejb.EJB
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.facade.PrintedCardFacade
;
import
fi.codecrew.moya.model.PrintedCard
;
/**
* Session Bean implementation class CardTemplateBean
*/
@Stateless
@LocalBean
@DeclareRoles
({
UserPermission
.
S_WRITE_ROLES
})
public
class
PrintedCardBean
implements
PrintedCardBeanLocal
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PrintedCardBean
.
class
);
/**
* Default constructor.
*/
public
PrintedCardBean
()
{
// TODO Auto-generated constructor stub
}
@EJB
private
PrintedCardFacade
printedCardFacade
;
@RolesAllowed
(
UserPermission
.
S_WRITE_ROLES
)
@Override
public
PrintedCard
save
(
PrintedCard
card
)
{
return
printedCardFacade
.
merge
(
card
);
}
@Override
@RolesAllowed
(
UserPermission
.
S_WRITE_ROLES
)
public
PrintedCard
find
(
Integer
id
)
{
return
printedCardFacade
.
find
(
id
);
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/PrintedCardFacade.java
View file @
998d70a
package
fi
.
codecrew
.
moya
.
facade
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
javax.ejb.EJB
;
...
...
@@ -8,13 +10,15 @@ import javax.ejb.Stateless;
import
javax.persistence.TypedQuery
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
fi.codecrew.moya.model.PrintedCard_
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.enums.CardState
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.PrintedCard_
;
@Stateless
@LocalBean
...
...
@@ -39,7 +43,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
return
getSingleNullableResult
(
getEm
().
createQuery
(
cq
));
}
public
PrintedCard
findByBarcode
(
String
barcode
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
...
...
@@ -89,4 +93,22 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
return
getSingleNullableResult
(
q
);
}
public
List
<
PrintedCard
>
findByState
(
CardState
...
state
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
PrintedCard
>
cq
=
cb
.
createQuery
(
PrintedCard
.
class
);
Root
<
PrintedCard
>
root
=
cq
.
from
(
PrintedCard
.
class
);
List
<
Predicate
>
preds
=
new
ArrayList
<
Predicate
>();
preds
.
add
(
cb
.
equal
(
root
.
get
(
PrintedCard_
.
event
),
eventbean
.
getCurrentEvent
()));
if
(
state
.
length
>
0
)
{
preds
.
add
(
root
.
get
(
PrintedCard_
.
cardState
).
in
(
Arrays
.
asList
(
state
)));
}
cq
.
where
(
preds
.
toArray
(
new
Predicate
[
preds
.
size
()]));
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/CardPrintBeanLocal.java
View file @
998d70a
...
...
@@ -4,7 +4,7 @@ import java.util.List;
import
javax.ejb.Local
;
import
fi.codecrew.moya.model.
EventUser
;
import
fi.codecrew.moya.model.
PrintedCard
;
import
fi.codecrew.moya.util.MassPrintResult
;
@Local
...
...
@@ -15,5 +15,5 @@ public interface CardPrintBeanLocal {
public
void
acceptMassPrintResult
(
MassPrintResult
mpr
);
byte
[]
constructPNG
(
EventUser
user
)
throws
Exception
;
byte
[]
constructPNG
(
PrintedCard
card
)
throws
Exception
;
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/CardTemplateBeanLocal.java
View file @
998d70a
...
...
@@ -5,6 +5,7 @@ import java.util.List;
import
javax.ejb.Local
;
import
fi.codecrew.moya.enums.CardState
;
import
fi.codecrew.moya.model.CardTemplate
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.PrintedCard
;
...
...
@@ -37,4 +38,10 @@ public interface CardTemplateBeanLocal extends EntityFinderBean<CardTemplate> {
CardTemplate
getUsersCardtype
(
EventUser
user
);
PrintedCard
saveCard
(
PrintedCard
card
);
PrintedCard
findCard
(
Integer
id
);
List
<
PrintedCard
>
getCardsByState
(
CardState
...
pendingPrint
);
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/EventBeanLocal.java
View file @
998d70a
...
...
@@ -35,4 +35,5 @@ public interface EventBeanLocal {
List
<
LanEventPrivateProperty
>
getPrivateProperties
();
LanEventPrivateProperty
saveOrCreatePrivateProperty
(
LanEventPrivateProperty
privateProperty
);
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/PrintedCardBeanLocal.java
deleted
100644 → 0
View file @
f9a2e13
package
fi
.
codecrew
.
moya
.
beans
;
import
javax.ejb.Local
;
import
fi.codecrew.moya.model.CardTemplate
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.utilities.jsf.EntityFinderBean
;
@Local
public
interface
PrintedCardBeanLocal
extends
EntityFinderBean
<
PrintedCard
>
{
PrintedCard
save
(
PrintedCard
card
);
}
code/MoyaUtilities/src/fi/codecrew/moya/enums/CardState.java
View file @
998d70a
package
fi
.
codecrew
.
moya
.
enums
;
public
enum
CardState
{
// Missing user image, template, template image
// or other printing error.
DATA_MISSING
,
PENDING_VALIDATION
,
REJECTED
,
VALIDATED
,
PENDING_PRINT
,
PRINTING_IN_PROGRESS
,
PRINTED
;
public
String
toStringLower
()
{
return
this
.
toString
().
toLowerCase
();
}
...
...
code/MoyaWeb/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
View file @
998d70a
...
...
@@ -4,4 +4,9 @@
<attribute
name=
"provider-id"
value=
"jsf-no-op-library-provider"
/>
</node>
</facet>
<facet
id=
"jst.jaxrs"
>
<node
name=
"libprov"
>
<attribute
name=
"provider-id"
value=
"com.sun.enterprise.jst.server.sunappsrv.jaxrsLibraryproviderID"
/>
</node>
</facet>
</root>
code/MoyaWeb/.settings/org.eclipse.wst.common.project.facet.core.xml
View file @
998d70a
...
...
@@ -9,4 +9,5 @@
<installed
facet=
"wst.jsdt.web"
version=
"1.0"
/>
<installed
facet=
"java"
version=
"1.7"
/>
<installed
facet=
"jst.jsf"
version=
"2.1"
/>
<installed
facet=
"jst.jaxrs"
version=
"1.1"
/>
</faceted-project>
code/MoyaWeb/WebContent/WEB-INF/web.xml
View file @
998d70a
...
...
@@ -71,6 +71,11 @@
<servlet-name>
PlaceMap
</servlet-name>
<servlet-class>
fi.codecrew.moya.servlet.PlaceMap
</servlet-class>
</servlet>
<servlet>
<description>
JAX-RS Tools Generated - Do not modify
</description>
<servlet-name>
JAX-RS Servlet
</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
Faces Servlet
</servlet-name>
<url-pattern>
*.jsf
</url-pattern>
...
...
@@ -141,4 +146,8 @@
<servlet-name>
PlaceGroupPdf
</servlet-name>
<url-pattern>
/PlaceGroupPdf
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
JAX-RS Servlet
</servlet-name>
<url-pattern>
/rest/*
</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
code/MoyaWeb/src/fi/codecrew/moya/rest/PrinterRestView.java
0 → 100644
View file @
998d70a
package
fi
.
codecrew
.
moya
.
rest
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response.ResponseBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.CardPrintBeanLocal
;
import
fi.codecrew.moya.beans.CardTemplateBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.enums.CardState
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.rest.pojo.PrintedCardRestPojo
;
@RequestScoped
@Path
(
"/card"
)
@Consumes
({
MediaType
.
APPLICATION_JSON
,
MediaType
.
APPLICATION_XML
})
@Produces
({
MediaType
.
APPLICATION_JSON
})
public
class
PrinterRestView
{
@EJB
private
CardTemplateBeanLocal
cardbean
;
@EJB
private
CardPrintBeanLocal
printbean
;
@EJB
private
UserBeanLocal
userbean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PrinterRestView
.
class
);
@GET
@Path
(
"/Printed/{id}/"
)
public
PrintedCardRestPojo
setCardPrinted
(
@PathParam
(
"id"
)
int
cardId
,
@QueryParam
(
"key"
)
String
hash
)
throws
Exception
{
PrintedCard
card
=
cardbean
.
findCard
(
cardId
);
card
.
setCardState
(
CardState
.
PRINTED
);
card
=
cardbean
.
saveCard
(
card
);
return
new
PrintedCardRestPojo
(
card
);
}
@GET
@Path
(
"/Get/{id}/"
)
public
PrintedCardRestPojo
getCard
(
@PathParam
(
"id"
)
int
cardId
,
@QueryParam
(
"key"
)
String
hash
)
throws
Exception
{
PrintedCard
card
=
cardbean
.
findCard
(
cardId
);
return
new
PrintedCardRestPojo
(
card
);
}
@GET
@Path
(
"/GetImage/{id}/"
)
public
Response
getUserCard
(
@PathParam
(
"id"
)
int
cardId
,
@QueryParam
(
"key"
)
String
hash
)
throws
Exception
{
ResponseBuilder
ret
=
null
;
PrintedCard
card
=
null
;
try
{
card
=
cardbean
.
findCard
(
cardId
);
ret
=
Response
.
ok
(
printbean
.
constructPNG
(
card
),
"image/png"
);
}
catch
(
Throwable
t
)
{
card
.
setCardState
(
CardState
.
DATA_MISSING
);
cardbean
.
saveCard
(
card
);
logger
.
warn
(
"Error creating card for user cardId "
+
cardId
,
t
);
ret
=
Response
.
status
(
Response
.
Status
.
NOT_ACCEPTABLE
);
}
return
ret
.
build
();
}
@GET
@Path
(
"/ListUnprinted"
)
public
List
<
PrintedCardRestPojo
>
getUserCard
(
@QueryParam
(
"key"
)
String
key
)
throws
Exception
{
List
<
PrintedCardRestPojo
>
ret
=
PrintedCardRestPojo
.
parseCards
(
cardbean
.
getCardsByState
(
CardState
.
PENDING_PRINT
));
logger
.
info
(
"Returning card pojos: {} for key {}"
,
ret
,
key
);
return
ret
;
}
@GET
@Path
(
"/ListAll"
)
public
List
<
PrintedCardRestPojo
>
getAllCards
(
@QueryParam
(
"key"
)
String
key
)
throws
Exception
{
List
<
PrintedCardRestPojo
>
ret
=
PrintedCardRestPojo
.
parseCards
(
cardbean
.
getCardsByState
());
logger
.
info
(
"Returning card pojos: {} for key {}"
,
ret
,
key
);
return
ret
;
}
}
code/MoyaWeb/src/fi/codecrew/moya/rest/pojo/PrintedCardRestPojo.java
0 → 100644
View file @
998d70a
package
fi
.
codecrew
.
moya
.
rest
.
pojo
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
javax.xml.bind.annotation.XmlTransient
;
import
fi.codecrew.moya.model.PrintedCard
;
@XmlRootElement
(
name
=
"cards"
)
public
class
PrintedCardRestPojo
{
public
PrintedCardRestPojo
()
{
card
=
null
;
}
public
PrintedCardRestPojo
(
PrintedCard
card
)
{
this
.
card
=
card
;
}
@XmlTransient
private
final
PrintedCard
card
;
@XmlElement
(
name
=
"cardId"
)
public
Integer
getId
()
{
return
card
.
getId
();
}
@XmlElement
(
name
=
"cardTemplate"
)
public
String
getTemplate
()
{
return
card
.
getTemplate
().
getName
();
}
@XmlElement
(
name
=
"username"
)
public
String
getUsername
()
{
return
card
.
getUser
().
getNick
();
}
@XmlElement
(
name
=
"wholeName"
)
public
String
getWholeName
()
{
return
card
.
getUser
().
getWholeName
();
}
@XmlElement
(
name
=
"state"
)
public
String
getState
()
{
return
card
.
getCardState
().
toString
();
}
public
static
List
<
PrintedCardRestPojo
>
parseCards
(
List
<
PrintedCard
>
cards
)
{
ArrayList
<
PrintedCardRestPojo
>
ret
=
new
ArrayList
<
PrintedCardRestPojo
>();
for
(
PrintedCard
c
:
cards
)
{
ret
.
add
(
new
PrintedCardRestPojo
(
c
));
}
return
ret
;
}
}
code/MoyaWeb/src/fi/codecrew/moya/servlet/FileDownloadServlet.java
View file @
998d70a
...
...
@@ -70,7 +70,8 @@ public class FileDownloadServlet extends GenericImageServlet {
if
(
urlparts
.
isEmpty
())
{
ret
.
setResponse
(
HttpServletResponse
.
SC_NOT_FOUND
);
}
else
if
(
urlparts
.
get
(
0
).
equals
(
"logo"
))
{
}
else
if
(
urlparts
.
get
(
0
).
equals
(
"logo"
))
{
LanEventProperty
logo
=
orgbean
.
getProperty
(
LanEventPropertyKey
.
EVENT_LOGO
);
if
(
logo
!=
null
)
{
ret
.
setData
(
logo
.
getByteValue
());
...
...
code/MoyaWeb/src/fi/codecrew/moya/servlet/UserPngImageServlet.java
View file @
998d70a
...
...
@@ -8,9 +8,11 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.CardPrintBeanLocal
;
import
fi.codecrew.moya.beans.CardTemplateBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.PrintedCard
;
/**
* Servlet implementation class UploadServlet
...
...
@@ -37,6 +39,8 @@ public class UserPngImageServlet extends GenericImageServlet {
@EJB
private
CardPrintBeanLocal
cardprint
;
private
CardTemplateBeanLocal
cardbean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserPngImageServlet
.
class
);
// /dydata/(userimage|...)/stuff...
...
...
@@ -45,14 +49,12 @@ public class UserPngImageServlet extends GenericImageServlet {
protected
ImageMover
getImagedata
()
{
EventUser
usr
=
permbean
.
getCurrentUser
();
logger
.
info
(
"Trying to print imagedata for user {}"
,
usr
);
ImageMover
ret
=
new
ImageMover
();
if
(
usr
!=
null
)
{
PrintedCard
card
=
cardbean
.
checkPrintedCard
(
usr
);
try
{
byte
[]
img
=
cardprint
.
constructPNG
(
usr
);
byte
[]
img
=
cardprint
.
constructPNG
(
card
);
if
(
img
.
length
>
0
)
{
ret
.
setData
(
img
);
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserView.java
View file @
998d70a
...
...
@@ -24,7 +24,6 @@ import org.slf4j.LoggerFactory;
import
fi.codecrew.moya.beans.CardPrintBeanLocal
;
import
fi.codecrew.moya.beans.CardTemplateBeanLocal
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.PrintedCardBeanLocal
;
import
fi.codecrew.moya.beans.ReaderBeanLocal
;
import
fi.codecrew.moya.beans.RoleBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
...
...
@@ -55,21 +54,20 @@ public class UserView extends GenericCDIView {
@EJB
private
transient
UserBeanLocal
userbean
;
@EJB
private
transient
ReaderBeanLocal
readerbean
;
private
Integer
userid
;
private
transient
UploadedFile
image
;
private
CroppedImage
croppedImage
;
private
EventUser
user
;
@Inject
private
transient
Conversation
conversation
;
@Inject
private
transient
ReaderView
readerView
;
...
...
@@ -88,10 +86,7 @@ public class UserView extends GenericCDIView {
@EJB
private
transient
CardTemplateBeanLocal
cardBean
;
@EJB
private
transient
PrintedCardBeanLocal
printedCardBean
;
private
List
<
Role
>
usersRoles
;
@EJB
private
transient
RoleBeanLocal
rolebean
;
...
...
@@ -105,7 +100,7 @@ public class UserView extends GenericCDIView {
private
MassPrintResult
mpr
=
null
;
private
boolean
waitForAcceptance
=
false
;
private
String
captureForwardUrl
=
""
;
@Produces
@LoggedIn
public
EventUser
getCurrentUser
()
{
...
...
@@ -117,7 +112,7 @@ public class UserView extends GenericCDIView {
byte
[]
data
=
captureEvent
.
getData
();
UserImage
img
=
userbean
.
uploadImage
(
user
,
"image/png"
,
data
,
"userimage.png"
,
"Uploaded image"
);
user
=
userbean
.
getEventUser
(
img
.
getUser
());
//
super.navihandler.forward("/admin/adduser/capturesuccess");
//
super.navihandler.forward("/admin/adduser/capturesuccess");
if
(
getCaptureForwardUrl
().
equals
(
""
))
super
.
navihandler
.
forward
(
getCaptureForwardUrl
());
}
...
...
@@ -184,7 +179,7 @@ public class UserView extends GenericCDIView {
try
{
mpr
=
cardPrintBean
.
getUserCardAsPrintablePdf
(
getSelectedUser
().
getId
());
ByteArrayInputStream
pdfstream
=
new
ByteArrayInputStream
(
mpr
.
getPdf
());
setStreamedFile
(
new
DefaultStreamedContent
(
pdfstream
,
"application/pdf"
,
"user_"
+
getSelectedUser
().
getId
()
+
"_card.pdf"
));
setStreamedFile
(
new
DefaultStreamedContent
(
pdfstream
,
"application/pdf"
,
"user_"
+
getSelectedUser
().
getId
()
+
"_card.pdf"
));
logger
.
info
(
"user_"
+
getSelectedUser
().
getId
()
+
"_card.pdf"
);
}
catch
(
Exception
e
)
{
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
FacesMessage
(
e
.
getMessage
()));
...
...
@@ -213,13 +208,13 @@ public class UserView extends GenericCDIView {
}
public
String
sendImage
()
{
if
(
getImage
()
==
null
)
{
super
.
addFaceMessage
(
"user.imageUpload.imageNotFound"
);
}
else
{
UserImage
userimage
=
userbean
.
uploadImage
(
user
,
getImage
().
getContentType
(),
getImage
().
getContents
(),
getImage
().
getFileName
(),
""
);
user
=
userbean
.
getEventUser
(
userimage
.
getUser
());
super
.
addFaceMessage
(
"user.imageUploaded"
);
...
...
@@ -233,7 +228,7 @@ public class UserView extends GenericCDIView {
super
.
beginConversation
();
}
}
public
void
initView
()
{
/*
...
...
@@ -303,30 +298,31 @@ public class UserView extends GenericCDIView {
{
return
permbean
.
isCurrentUser
(
user
);
}
/**
/**
* attach barcode or rfid to card
*
* @return
*/
public
String
attachBarcodeToCard
()
{
PrintedCard
card
=
readerView
.
getPrintedCard
();
// already attached
if
(
card
!=
null
)
{
if
(
card
!=
null
)
{
super
.
addFaceMessage
(
"usercard.alreadyassociated"
);
return
null
;
}
// still there, we can get real card and update it's barcodes
card
=
cardBean
.
checkPrintedCard
(
user
);
if
(
readerView
.
getBarcode
()
!=
null
&&
!
readerView
.
getBarcode
().
isEmpty
())
{
if
(
readerView
.
getBarcode
()
!=
null
&&
!
readerView
.
getBarcode
().
isEmpty
())
{
card
.
setBarcode
(
readerView
.
getBarcode
());
printedCardBean
.
save
(
card
);
cardBean
.
saveCard
(
card
);
}
//
todo: kato että liittäminen tukee kanssa "barcode" -lukijoita jne.
//
kato kanssa korttihaku, että se tuklee niitä, kuitenkin tarvitaa ne
if
(
readerView
.
getReaderEvent
()
!=
null
)
{
//
todo: kato että liittäminen tukee kanssa "barcode" -lukijoita jne.
//
kato kanssa korttihaku, että se tuklee niitä, kuitenkin tarvitaa ne
if
(
readerView
.
getReaderEvent
()
!=
null
)
{
readerbean
.
assocTagToCard
(
readerView
.
getReaderEvent
().
getValue
(),
readerView
.
getReaderEvent
().
getReader
().
getIdentification
(),
card
);
}
return
null
;
...
...
@@ -336,12 +332,13 @@ public class UserView extends GenericCDIView {
userbean
.
createNewUser
(
user
,
getPassword
());
return
"/user/created"
;
}
public
String
createUserAdduserView
()
{
userbean
.
createNewUser
(
user
,
getPassword
());
authView
.
executeAdduserAutoLogin
(
user
,
getPassword
());
return
"/admin/adduser/update"
;
}
public
String
createAdminUser
()
{
userbean
.
createNewUser
(
user
,
getPassword
());
canSave
=
permbean
.
hasPermission
(
UserPermission
.
MODIFY
);
...
...
@@ -426,7 +423,7 @@ public class UserView extends GenericCDIView {
}
public
StreamedContent
getStreamedFile
()
{
if
(
streamedFile
==
null
)
if
(
streamedFile
==
null
)
logger
.
info
(
"Tried to get empty streamed file"
);
return
streamedFile
;
}
...
...
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