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 a170840b
authored
Feb 02, 2018
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'asd2' into 'master'
Randomfixes See merge request !386
2 parents
7ea97551
662b4629
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
188 additions
and
172 deletions
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/userinfo/v1/UserPermissionRestPojo.java
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/vip/v2/VipProductDeliveryPojo.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/VipProductPojo.java → code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/vip/v2/VipProductPojo.java
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/vip/v2/VipRestPojo.java
code/moya-web/WebContent/place/eticketStandalone.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/HostnameFilter.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/ReaderRestView.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/VipRestView.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/VipRestPojo.java → code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/VipPojoUtils.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/VipProductDeliveryPojo.java
code/pom.xml
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/userinfo/v1/UserPermissionRestPojo.java
View file @
a170840
/*
/*
* Copyright Codecrew Ry
* Copyright Codecrew Ry
*
*
* All rights reserved.
* All rights reserved.
*
*
* This license applies to any software containing a notice placed by the
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
* This license covers modification, distribution and use of the Software.
*
*
* Any distribution and use in source and binary forms, with or without
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* modification is not permitted without explicit written permission from the
* copyright owner.
* copyright owner.
*
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
* future versions of the Software.
*
*
*/
*/
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
userinfo
.
v1
;
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
userinfo
.
v1
;
...
@@ -25,16 +25,18 @@ import javax.xml.bind.annotation.XmlElement;
...
@@ -25,16 +25,18 @@ import javax.xml.bind.annotation.XmlElement;
@ApiModel
@ApiModel
public
class
UserPermissionRestPojo
{
public
class
UserPermissionRestPojo
{
@XmlElement
()
private
EventUserRestPojo
user
;
@XmlElement
()
private
boolean
accessGranted
=
false
;
public
UserPermissionRestPojo
(
EventUserRestPojo
eventUserRestPojo
,
boolean
granted
)
public
UserPermissionRestPojo
(
EventUserRestPojo
eventUserRestPojo
,
boolean
granted
)
{
{
this
();
this
();
this
.
user
=
eventUserRestPojo
;
this
.
user
=
eventUserRestPojo
;
this
.
accessGranted
=
granted
;
this
.
accessGranted
=
granted
;
}
}
public
UserPermissionRestPojo
()
public
UserPermissionRestPojo
()
{
{
super
();
super
();
}
}
...
@@ -54,9 +56,5 @@ public class UserPermissionRestPojo {
...
@@ -54,9 +56,5 @@ public class UserPermissionRestPojo {
this
.
user
=
user
;
this
.
user
=
user
;
}
}
@XmlElement
()
private
EventUserRestPojo
user
;
@XmlElement
()
private
boolean
accessGranted
=
false
;
}
}
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/vip/v2/VipProductDeliveryPojo.java
0 → 100644
View file @
a170840
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
vip
.
v2
;
import
java.math.BigDecimal
;
import
java.util.Date
;
public
class
VipProductDeliveryPojo
{
public
Integer
id
;
public
Integer
delivererId
;
public
BigDecimal
quantity
;
public
Date
deliveryTime
;
public
String
notes
;
}
code/moya-
web/src/main/java/fi/codecrew/moya/rest/v2/pojo
/VipProductPojo.java
→
code/moya-
restpojo/src/main/java/fi/codecrew/moya/rest/pojo/vip/v2
/VipProductPojo.java
View file @
a170840
package
fi
.
codecrew
.
moya
.
rest
.
v2
.
pojo
;
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
vip
.
v2
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
fi.codecrew.moya.model.VipProduct
;
public
class
VipProductPojo
{
public
class
VipProductPojo
{
public
Integer
id
;
public
Integer
id
;
...
@@ -14,20 +12,7 @@ public class VipProductPojo {
...
@@ -14,20 +12,7 @@ public class VipProductPojo {
public
String
notes
;
public
String
notes
;
public
BigDecimal
quantity
;
public
BigDecimal
quantity
;
public
BigDecimal
delivered
;
public
BigDecimal
delivered
;
public
List
<
VipProductDeliveryPojo
>
deliveries
=
new
ArrayList
<>();
public
List
<
VipProductDeliveryPojo
>
deliveries
=
new
ArrayList
<
VipProductDeliveryPojo
>();
public
static
VipProductPojo
create
(
VipProduct
prod
)
{
VipProductPojo
ret
=
new
VipProductPojo
();
ret
.
id
=
prod
.
getId
();
ret
.
name
=
prod
.
getProductName
();
if
(
prod
.
getProduct
()
!=
null
)
{
ret
.
productId
=
prod
.
getProduct
().
getId
();
}
ret
.
notes
=
prod
.
getNotes
();
ret
.
quantity
=
prod
.
getQuantity
();
ret
.
delivered
=
prod
.
getDelivered
();
ret
.
deliveries
=
VipProductDeliveryPojo
.
create
(
prod
.
getDeliveries
());
return
ret
;
}
}
}
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/vip/v2/VipRestPojo.java
0 → 100644
View file @
a170840
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
vip
.
v2
;
import
io.swagger.annotations.ApiModel
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@XmlRootElement
()
@ApiModel
(
description
=
"vip"
)
public
class
VipRestPojo
{
public
Integer
id
;
public
String
description
;
public
String
shortdescr
;
public
Date
created
;
public
Integer
eventuserId
;
public
Integer
creatorId
;
public
Integer
hostId
;
public
List
<
VipProductPojo
>
products
=
new
ArrayList
<
VipProductPojo
>();
}
code/moya-web/WebContent/place/eticketStandalone.xhtml
View file @
a170840
...
@@ -12,10 +12,12 @@
...
@@ -12,10 +12,12 @@
</f:metadata>
</f:metadata>
<ui:define
name=
"title"
>
<ui:define
name=
"title"
>
<h1>
#{i18n['etickets.title']
}
</h1>
<h1>
#{standaloneEticketView.user.event.name
}
</h1>
</ui:define>
</ui:define>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
<h2>
#{i18n['etickets.title']}
</h2>
<h:form
id=
"etickets"
>
<h:form
id=
"etickets"
>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/HostnameFilter.java
View file @
a170840
...
@@ -39,6 +39,7 @@ import javax.servlet.http.HttpSession;
...
@@ -39,6 +39,7 @@ import javax.servlet.http.HttpSession;
import
fi.codecrew.moya.beans.*
;
import
fi.codecrew.moya.beans.*
;
import
fi.codecrew.moya.utilities.UserLoginUtils
;
import
fi.codecrew.moya.utilities.UserLoginUtils
;
import
org.apache.commons.codec.Charsets
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.MDC
;
import
org.slf4j.MDC
;
...
@@ -181,9 +182,10 @@ public class HostnameFilter implements Filter {
...
@@ -181,9 +182,10 @@ public class HostnameFilter implements Filter {
||
"/dydata"
.
equals
(
httpRequest
.
getServletPath
()))
{
||
"/dydata"
.
equals
(
httpRequest
.
getServletPath
()))
{
authtype
=
AuthType
.
REST
;
authtype
=
AuthType
.
REST
;
if
(!
restAuth
(
httpRequest
,
response
))
{
if
(!
restAuth
(
httpRequest
,
response
)
&&
RestApplicationEntrypoint
.
REST_PATH
.
equals
(
httpRequest
.
getServletPath
()))
{
response
.
reset
();
response
.
reset
();
response
.
getOutputStream
().
write
(
"Rest auth failed! "
.
getBytes
(
UTF
8
));
response
.
getOutputStream
().
write
(
"Rest auth failed! "
.
getBytes
(
Charsets
.
UTF_
8
));
if
(
response
instanceof
HttpServletResponse
)
{
if
(
response
instanceof
HttpServletResponse
)
{
HttpServletResponse
httpResp
=
(
HttpServletResponse
)
response
;
HttpServletResponse
httpResp
=
(
HttpServletResponse
)
response
;
...
@@ -192,7 +194,9 @@ public class HostnameFilter implements Filter {
...
@@ -192,7 +194,9 @@ public class HostnameFilter implements Filter {
// Rest auth failed. Go away!
// Rest auth failed. Go away!
return
;
return
;
}
}
}
else
{
}
if
(
httpRequest
.
getUserPrincipal
()
==
null
)
{
try
{
try
{
authtype
=
AuthType
.
ANON
;
authtype
=
AuthType
.
ANON
;
httpRequest
.
login
(
User
.
ANONYMOUS_LOGINNAME
+
'@'
+
hostname
,
null
);
httpRequest
.
login
(
User
.
ANONYMOUS_LOGINNAME
+
'@'
+
hostname
,
null
);
...
@@ -200,6 +204,7 @@ public class HostnameFilter implements Filter {
...
@@ -200,6 +204,7 @@ public class HostnameFilter implements Filter {
logger
.
warn
(
"Error logging in as anonymous... ignoring.. "
,
t
);
logger
.
warn
(
"Error logging in as anonymous... ignoring.. "
,
t
);
}
}
}
}
}
else
if
(!
httpRequest
.
getUserPrincipal
().
getName
().
equals
(
User
.
ANONYMOUS_LOGINNAME
+
'@'
+
hostname
))
{
}
else
if
(!
httpRequest
.
getUserPrincipal
().
getName
().
equals
(
User
.
ANONYMOUS_LOGINNAME
+
'@'
+
hostname
))
{
authtype
=
AuthType
.
USER
;
authtype
=
AuthType
.
USER
;
sessionmgmt
.
updateSessionUser
(
httpRequest
.
getSession
().
getId
(),
httpRequest
.
getUserPrincipal
().
getName
());
sessionmgmt
.
updateSessionUser
(
httpRequest
.
getSession
().
getId
(),
httpRequest
.
getUserPrincipal
().
getName
());
...
@@ -273,6 +278,9 @@ public class HostnameFilter implements Filter {
...
@@ -273,6 +278,9 @@ public class HostnameFilter implements Filter {
hashBuilder
.
append
(
httpRequest
.
getParameter
(
"appmac"
)).
append
(
":"
);
hashBuilder
.
append
(
httpRequest
.
getParameter
(
"appmac"
)).
append
(
":"
);
hashBuilder
.
append
(
httpRequest
.
getPathInfo
());
hashBuilder
.
append
(
httpRequest
.
getPathInfo
());
restAuthStr
=
hashBuilder
.
toString
();
restAuthStr
=
hashBuilder
.
toString
();
}
else
{
// If no rest authentication is even tried, allow, anon login
return
true
;
}
}
boolean
ret
=
true
;
boolean
ret
=
true
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/ReaderRestView.java
View file @
a170840
/*
/*
* Copyright Codecrew Ry
* Copyright Codecrew Ry
*
*
* All rights reserved.
* All rights reserved.
*
*
* This license applies to any software containing a notice placed by the
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
* This license covers modification, distribution and use of the Software.
*
*
* Any distribution and use in source and binary forms, with or without
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* modification is not permitted without explicit written permission from the
* copyright owner.
* copyright owner.
*
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
* future versions of the Software.
*
*
*/
*/
package
fi
.
codecrew
.
moya
.
rest
;
package
fi
.
codecrew
.
moya
.
rest
;
...
@@ -38,8 +38,8 @@ import fi.codecrew.moya.rest.pojo.userinfo.v1.UserPermissionRestPojo;
...
@@ -38,8 +38,8 @@ import fi.codecrew.moya.rest.pojo.userinfo.v1.UserPermissionRestPojo;
@RequestScoped
@RequestScoped
@Path
(
"/reader"
)
@Path
(
"/reader"
)
@Consumes
({
MediaType
.
APPLICATION_JSON
,
MediaType
.
APPLICATION_XML
})
@Consumes
({
MediaType
.
APPLICATION_JSON
,
MediaType
.
APPLICATION_XML
})
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
public
class
ReaderRestView
{
public
class
ReaderRestView
{
@EJB
@EJB
...
@@ -93,8 +93,7 @@ public class ReaderRestView {
...
@@ -93,8 +93,7 @@ public class ReaderRestView {
@GET
@GET
@Path
(
"/LastEventusers"
)
@Path
(
"/LastEventusers"
)
public
ReaderEventRestRoot
getLastEventusers
()
public
ReaderEventRestRoot
getLastEventusers
()
{
{
return
new
ReaderEventRestRoot
(
PojoUtils
.
parseReaderEvents
(
readerbean
.
getLastReaderEvents
()));
return
new
ReaderEventRestRoot
(
PojoUtils
.
parseReaderEvents
(
readerbean
.
getLastReaderEvents
()));
}
}
...
@@ -108,10 +107,10 @@ public class ReaderRestView {
...
@@ -108,10 +107,10 @@ public class ReaderRestView {
@GET
@GET
@Path
(
"/EventRole/{reader}/{tagId}/{roleid}"
)
@Path
(
"/EventRole/{reader}/{tagId}/{roleid}"
)
public
Response
isTaguserInRole
(
public
Response
isTaguserInRole
(
@PathParam
(
"reader"
)
String
reader
,
@PathParam
(
"reader"
)
String
reader
,
@PathParam
(
"tagId"
)
String
tag
,
@PathParam
(
"tagId"
)
String
tag
,
@PathParam
(
"roleid"
)
Integer
roleId
@PathParam
(
"roleid"
)
Integer
roleId
)
{
)
{
ReaderEvent
ret
=
readerbean
.
checkCode
(
reader
,
tag
);
ReaderEvent
ret
=
readerbean
.
checkCode
(
reader
,
tag
);
ResponseBuilder
builder
=
null
;
ResponseBuilder
builder
=
null
;
if
(
roleId
==
null
||
roleId
.
equals
(
0
))
{
if
(
roleId
==
null
||
roleId
.
equals
(
0
))
{
...
@@ -119,23 +118,20 @@ public class ReaderRestView {
...
@@ -119,23 +118,20 @@ public class ReaderRestView {
builder
.
entity
(
"role ID is required!"
);
builder
.
entity
(
"role ID is required!"
);
builder
.
type
(
MediaType
.
TEXT_PLAIN
);
builder
.
type
(
MediaType
.
TEXT_PLAIN
);
}
}
else
if
(
ret
.
getPrintedCard
()
==
null
)
{
if
(
builder
==
null
)
{
builder
=
Response
.
status
(
Status
.
NOT_ACCEPTABLE
);
if
(
ret
==
null
||
ret
.
getPrintedCard
()
==
null
)
{
builder
.
entity
(
"No card found for uid."
);
builder
=
Response
.
status
(
Status
.
NOT_ACCEPTABLE
);
builder
.
type
(
MediaType
.
TEXT_PLAIN
);
builder
.
entity
(
"No card found for uid."
);
}
else
{
builder
.
type
(
MediaType
.
TEXT_PLAIN
);
EventUser
user
=
ret
.
getPrintedCard
().
getUser
();
boolean
found
=
userbean
.
isUserInRole
(
user
,
roleId
);
if
(
found
)
{
builder
=
Response
.
status
(
Status
.
OK
);
}
else
{
}
else
{
EventUser
user
=
ret
.
getPrintedCard
().
getUser
();
builder
=
Response
.
status
(
Status
.
FORBIDDEN
);
boolean
found
=
userbean
.
isUserInRole
(
user
,
roleId
);
if
(
found
)
{
builder
=
Response
.
status
(
Status
.
OK
);
}
else
{
builder
=
Response
.
status
(
Status
.
FORBIDDEN
);
}
builder
.
entity
(
new
UserPermissionRestPojo
(
PojoUtils
.
initEventUserRestPojo
(
user
),
found
));
}
}
builder
.
entity
(
new
UserPermissionRestPojo
(
PojoUtils
.
initEventUserRestPojo
(
user
),
found
));
}
}
return
builder
.
build
();
return
builder
.
build
();
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/VipRestView.java
View file @
a170840
package
fi
.
codecrew
.
moya
.
rest
.
v2
;
package
fi
.
codecrew
.
moya
.
rest
.
v2
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.GenericEntity
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
io.swagger.annotations.Api
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.ProductBeanLocal
;
import
fi.codecrew.moya.beans.ProductBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
...
@@ -25,16 +7,28 @@ import fi.codecrew.moya.beans.VipBeanLocal;
...
@@ -25,16 +7,28 @@ import fi.codecrew.moya.beans.VipBeanLocal;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Vip
;
import
fi.codecrew.moya.model.Vip
;
import
fi.codecrew.moya.model.VipProduct
;
import
fi.codecrew.moya.model.VipProduct
;
import
fi.codecrew.moya.rest.v2.pojo.VipProductPojo
;
import
fi.codecrew.moya.rest.pojo.vip.v2.VipProductPojo
;
import
fi.codecrew.moya.rest.v2.pojo.VipRestPojo
;
import
fi.codecrew.moya.rest.pojo.vip.v2.VipRestPojo
;
import
fi.codecrew.moya.rest.v2.pojo.VipPojoUtils
;
import
fi.codecrew.moya.utilities.SearchQuery
;
import
fi.codecrew.moya.utilities.SearchQuery
;
import
fi.codecrew.moya.utilities.SearchResult
;
import
fi.codecrew.moya.utilities.SearchResult
;
import
io.swagger.annotations.Api
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.ws.rs.*
;
import
javax.ws.rs.core.GenericEntity
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@RequestScoped
@RequestScoped
@Path
(
"/v2/vip"
)
@Path
(
"/v2/vip"
)
@Api
(
value
=
"/v2/vip"
,
description
=
"Vip list operations"
)
@Api
(
value
=
"/v2/vip"
,
description
=
"Vip list operations"
)
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
@Consumes
({
MediaType
.
APPLICATION_JSON
})
@Consumes
({
MediaType
.
APPLICATION_JSON
})
public
class
VipRestView
{
public
class
VipRestView
{
@EJB
@EJB
...
@@ -51,8 +45,8 @@ public class VipRestView {
...
@@ -51,8 +45,8 @@ public class VipRestView {
@GET
@GET
@Path
(
"/all"
)
@Path
(
"/all"
)
public
Response
getAllVips
()
{
public
Response
getAllVips
()
{
ArrayList
<
VipRestPojo
>
ret
=
Vip
RestPojo
.
create
(
vipbean
.
getAvailableVips
());
ArrayList
<
VipRestPojo
>
ret
=
Vip
PojoUtils
.
createVipList
(
vipbean
.
getAvailableVips
());
return
Response
.
ok
(
ret
).
build
();
return
Response
.
ok
(
new
GenericEntity
<
ArrayList
<
VipRestPojo
>>(
ret
){}
).
build
();
}
}
@GET
@GET
...
@@ -62,7 +56,7 @@ public class VipRestView {
...
@@ -62,7 +56,7 @@ public class VipRestView {
sq
.
setSearch
(
search
);
sq
.
setSearch
(
search
);
sq
.
setPagesize
(
0
);
sq
.
setPagesize
(
0
);
SearchResult
<
Vip
>
result
=
vipbean
.
search
(
sq
);
SearchResult
<
Vip
>
result
=
vipbean
.
search
(
sq
);
ArrayList
<
VipRestPojo
>
ret
=
Vip
RestPojo
.
create
(
result
.
getResults
());
ArrayList
<
VipRestPojo
>
ret
=
Vip
PojoUtils
.
createVipList
(
result
.
getResults
());
GenericEntity
<
ArrayList
<
VipRestPojo
>>
list
=
new
GenericEntity
<
ArrayList
<
VipRestPojo
>>(
ret
)
{
GenericEntity
<
ArrayList
<
VipRestPojo
>>
list
=
new
GenericEntity
<
ArrayList
<
VipRestPojo
>>(
ret
)
{
};
};
...
@@ -74,19 +68,19 @@ public class VipRestView {
...
@@ -74,19 +68,19 @@ public class VipRestView {
public
Response
deleteEntry
(
@PathParam
(
"id"
)
Integer
id
)
{
public
Response
deleteEntry
(
@PathParam
(
"id"
)
Integer
id
)
{
Vip
vip
=
vipbean
.
find
(
id
);
Vip
vip
=
vipbean
.
find
(
id
);
vipbean
.
delete
(
vip
);
vipbean
.
delete
(
vip
);
return
Response
.
ok
(
Vip
RestPojo
.
create
(
vip
)).
build
();
return
Response
.
ok
(
Vip
PojoUtils
.
createVip
(
vip
)).
build
();
}
}
@GET
@GET
@Path
(
"/{id}"
)
@Path
(
"/{id}"
)
public
Response
findEntry
(
@PathParam
(
"id"
)
Integer
id
)
{
public
Response
findEntry
(
@PathParam
(
"id"
)
Integer
id
)
{
Vip
vip
=
vipbean
.
find
(
id
);
Vip
vip
=
vipbean
.
find
(
id
);
return
Response
.
ok
(
Vip
RestPojo
.
create
(
vip
)).
build
();
return
Response
.
ok
(
Vip
PojoUtils
.
createVip
(
vip
)).
build
();
}
}
@POST
@POST
@Path
(
"/create"
)
@Path
(
"/create"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
@Produces
({
MediaType
.
APPLICATION_JSON
})
@Consumes
(
MediaType
.
APPLICATION_JSON
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
Response
createEntry
(
VipRestPojo
create
)
{
public
Response
createEntry
(
VipRestPojo
create
)
{
...
@@ -123,7 +117,8 @@ public class VipRestView {
...
@@ -123,7 +117,8 @@ public class VipRestView {
vipbean
.
create
(
vip
);
vipbean
.
create
(
vip
);
return
Response
.
ok
(
Vip
RestPojo
.
create
(
vip
)).
build
();
return
Response
.
ok
(
Vip
PojoUtils
.
createVip
(
vip
)).
build
();
}
}
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/Vip
RestPojo
.java
→
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/Vip
PojoUtils
.java
View file @
a170840
package
fi
.
codecrew
.
moya
.
rest
.
v2
.
pojo
;
package
fi
.
codecrew
.
moya
.
rest
.
v2
.
pojo
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
io.swagger.annotations.ApiModel
;
import
fi.codecrew.moya.model.Vip
;
import
fi.codecrew.moya.model.Vip
;
import
fi.codecrew.moya.model.VipProduct
;
import
fi.codecrew.moya.model.VipProduct
;
import
fi.codecrew.moya.model.VipProductDelivery
;
import
fi.codecrew.moya.rest.pojo.vip.v2.VipProductDeliveryPojo
;
import
fi.codecrew.moya.rest.pojo.vip.v2.VipProductPojo
;
import
fi.codecrew.moya.rest.pojo.vip.v2.VipRestPojo
;
@XmlRootElement
()
import
java.util.ArrayList
;
@ApiModel
(
description
=
"vip"
)
import
java.util.List
;
public
class
VipRestPojo
{
public
Integer
id
;
public
class
VipPojoUtils
{
public
String
description
;
public
static
VipProductPojo
createVipProduct
(
VipProduct
prod
)
{
public
String
shortdescr
;
VipProductPojo
ret
=
new
VipProductPojo
();
public
Date
created
;
ret
.
id
=
prod
.
getId
();
public
Integer
eventuserId
;
ret
.
name
=
prod
.
getProductName
();
public
Integer
creatorId
;
if
(
prod
.
getProduct
()
!=
null
)
{
public
Integer
hostId
;
ret
.
productId
=
prod
.
getProduct
().
getId
();
public
List
<
VipProductPojo
>
products
=
new
ArrayList
<>();
}
ret
.
notes
=
prod
.
getNotes
();
ret
.
quantity
=
prod
.
getQuantity
();
ret
.
delivered
=
prod
.
getDelivered
();
ret
.
deliveries
=
createDeliveryList
(
prod
.
getDeliveries
());
return
ret
;
}
public
static
ArrayList
<
VipRestPojo
>
create
(
List
<
Vip
>
vips
)
{
public
static
ArrayList
<
VipRestPojo
>
create
VipList
(
List
<
Vip
>
vips
)
{
ArrayList
<
VipRestPojo
>
ret
=
new
ArrayList
<>();
ArrayList
<
VipRestPojo
>
ret
=
new
ArrayList
<>();
for
(
Vip
v
:
vips
)
{
for
(
Vip
v
:
vips
)
{
ret
.
add
(
create
(
v
));
ret
.
add
(
create
Vip
(
v
));
}
}
return
ret
;
return
ret
;
}
}
public
static
VipRestPojo
create
(
Vip
v
)
{
public
static
VipRestPojo
createVip
(
Vip
v
)
{
VipRestPojo
r
=
new
VipRestPojo
();
VipRestPojo
r
=
new
VipRestPojo
();
r
.
id
=
v
.
getId
();
r
.
id
=
v
.
getId
();
r
.
description
=
v
.
getDescription
();
r
.
description
=
v
.
getDescription
();
...
@@ -49,8 +51,27 @@ public class VipRestPojo {
...
@@ -49,8 +51,27 @@ public class VipRestPojo {
r
.
hostId
=
v
.
getHost
().
getId
();
r
.
hostId
=
v
.
getHost
().
getId
();
}
}
for
(
VipProduct
prod
:
v
.
getProducts
())
{
for
(
VipProduct
prod
:
v
.
getProducts
())
{
r
.
products
.
add
(
VipProductPojo
.
create
(
prod
));
r
.
products
.
add
(
createVipProduct
(
prod
));
}
}
return
r
;
return
r
;
}
}
public
static
List
<
VipProductDeliveryPojo
>
createDeliveryList
(
List
<
VipProductDelivery
>
deliveries
)
{
List
<
VipProductDeliveryPojo
>
ret
=
new
ArrayList
<>();
if
(
deliveries
!=
null
)
{
for
(
VipProductDelivery
d
:
deliveries
)
{
VipProductDeliveryPojo
delivery
=
new
VipProductDeliveryPojo
();
ret
.
add
(
delivery
);
if
(
d
.
getDeliverer
()
!=
null
)
{
delivery
.
delivererId
=
d
.
getDeliverer
().
getId
();
}
delivery
.
id
=
d
.
getId
();
delivery
.
deliveryTime
=
d
.
getDeliveryTime
();
delivery
.
quantity
=
d
.
getQuantity
();
delivery
.
notes
=
d
.
getNotes
();
}
}
return
ret
;
}
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/VipProductDeliveryPojo.java
deleted
100644 → 0
View file @
7ea9755
package
fi
.
codecrew
.
moya
.
rest
.
v2
.
pojo
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
fi.codecrew.moya.model.VipProductDelivery
;
public
class
VipProductDeliveryPojo
{
public
Integer
id
;
public
Integer
delivererId
;
public
BigDecimal
quantity
;
public
Date
deliveryTime
;
public
String
notes
;
public
static
List
<
VipProductDeliveryPojo
>
create
(
List
<
VipProductDelivery
>
deliveries
)
{
List
<
VipProductDeliveryPojo
>
ret
=
new
ArrayList
<>();
if
(
deliveries
!=
null
)
{
for
(
VipProductDelivery
d
:
deliveries
)
{
VipProductDeliveryPojo
delivery
=
new
VipProductDeliveryPojo
();
ret
.
add
(
delivery
);
if
(
d
.
getDeliverer
()
!=
null
)
{
delivery
.
delivererId
=
d
.
getDeliverer
().
getId
();
}
delivery
.
id
=
d
.
getId
();
delivery
.
deliveryTime
=
d
.
getDeliveryTime
();
delivery
.
quantity
=
d
.
getQuantity
();
delivery
.
notes
=
d
.
getNotes
();
}
}
return
ret
;
}
}
code/pom.xml
View file @
a170840
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
>
http://maven.apache.org/maven-v4_0_0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
fi.codecrew.moya
</groupId>
<groupId>
fi.codecrew.moya
</groupId>
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
<url>
http://codecrew.fi
</url>
<url>
http://codecrew.fi
</url>
</organization>
</organization>
<scm>
<scm>
<connection>
scm:git:https://gitlab.codecrew.fi/codecrew/moya.git
</connection>
<connection>
scm:git:https://gitlab.codecrew.fi/codecrew/moya.git
</connection>
<developerConnection>
scm:git:git@gitlab.codecrew.fi:codecrew/moya.git
</developerConnection>
<developerConnection>
scm:git:git@gitlab.codecrew.fi:codecrew/moya.git
</developerConnection>
<url>
https://gitlab.codecrew.fi/codecrew/moya
</url>
<url>
https://gitlab.codecrew.fi/codecrew/moya
</url>
</scm>
</scm>
...
@@ -60,6 +60,15 @@
...
@@ -60,6 +60,15 @@
<pluginManagement>
<pluginManagement>
<plugins>
<plugins>
<plugin>
<plugin>
<artifactId>
maven-assembly-plugin
</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
</configuration>
</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>
<version>
${compiler-plugin-version}
</version>
...
@@ -75,7 +84,6 @@
...
@@ -75,7 +84,6 @@
</build>
</build>
<repositories>
<repositories>
<repository>
<repository>
<id>
prime-repo
</id>
<id>
prime-repo
</id>
...
...
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