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 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
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
143 additions
and
127 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
...
...
@@ -25,16 +25,18 @@ import javax.xml.bind.annotation.XmlElement;
@ApiModel
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
.
user
=
eventUserRestPojo
;
this
.
accessGranted
=
granted
;
}
public
UserPermissionRestPojo
()
{
public
UserPermissionRestPojo
()
{
super
();
}
...
...
@@ -54,9 +56,5 @@ public class UserPermissionRestPojo {
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.util.ArrayList
;
import
java.util.List
;
import
fi.codecrew.moya.model.VipProduct
;
public
class
VipProductPojo
{
public
Integer
id
;
...
...
@@ -14,20 +12,7 @@ public class VipProductPojo {
public
String
notes
;
public
BigDecimal
quantity
;
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 @@
</f:metadata>
<ui:define
name=
"title"
>
<h1>
#{i18n['etickets.title']
}
</h1>
<h1>
#{standaloneEticketView.user.event.name
}
</h1>
</ui:define>
<ui:define
name=
"content"
>
<h2>
#{i18n['etickets.title']}
</h2>
<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;
import
fi.codecrew.moya.beans.*
;
import
fi.codecrew.moya.utilities.UserLoginUtils
;
import
org.apache.commons.codec.Charsets
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.MDC
;
...
...
@@ -181,9 +182,10 @@ public class HostnameFilter implements Filter {
||
"/dydata"
.
equals
(
httpRequest
.
getServletPath
()))
{
authtype
=
AuthType
.
REST
;
if
(!
restAuth
(
httpRequest
,
response
))
{
if
(!
restAuth
(
httpRequest
,
response
)
&&
RestApplicationEntrypoint
.
REST_PATH
.
equals
(
httpRequest
.
getServletPath
()))
{
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
)
{
HttpServletResponse
httpResp
=
(
HttpServletResponse
)
response
;
...
...
@@ -192,7 +194,9 @@ public class HostnameFilter implements Filter {
// Rest auth failed. Go away!
return
;
}
}
else
{
}
if
(
httpRequest
.
getUserPrincipal
()
==
null
)
{
try
{
authtype
=
AuthType
.
ANON
;
httpRequest
.
login
(
User
.
ANONYMOUS_LOGINNAME
+
'@'
+
hostname
,
null
);
...
...
@@ -200,6 +204,7 @@ public class HostnameFilter implements Filter {
logger
.
warn
(
"Error logging in as anonymous... ignoring.. "
,
t
);
}
}
}
else
if
(!
httpRequest
.
getUserPrincipal
().
getName
().
equals
(
User
.
ANONYMOUS_LOGINNAME
+
'@'
+
hostname
))
{
authtype
=
AuthType
.
USER
;
sessionmgmt
.
updateSessionUser
(
httpRequest
.
getSession
().
getId
(),
httpRequest
.
getUserPrincipal
().
getName
());
...
...
@@ -273,6 +278,9 @@ public class HostnameFilter implements Filter {
hashBuilder
.
append
(
httpRequest
.
getParameter
(
"appmac"
)).
append
(
":"
);
hashBuilder
.
append
(
httpRequest
.
getPathInfo
());
restAuthStr
=
hashBuilder
.
toString
();
}
else
{
// If no rest authentication is even tried, allow, anon login
return
true
;
}
boolean
ret
=
true
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/ReaderRestView.java
View file @
a170840
...
...
@@ -38,8 +38,8 @@ import fi.codecrew.moya.rest.pojo.userinfo.v1.UserPermissionRestPojo;
@RequestScoped
@Path
(
"/reader"
)
@Consumes
({
MediaType
.
APPLICATION_JSON
,
MediaType
.
APPLICATION_XML
})
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
@Consumes
({
MediaType
.
APPLICATION_JSON
,
MediaType
.
APPLICATION_XML
})
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
public
class
ReaderRestView
{
@EJB
...
...
@@ -93,8 +93,7 @@ public class ReaderRestView {
@GET
@Path
(
"/LastEventusers"
)
public
ReaderEventRestRoot
getLastEventusers
()
{
public
ReaderEventRestRoot
getLastEventusers
()
{
return
new
ReaderEventRestRoot
(
PojoUtils
.
parseReaderEvents
(
readerbean
.
getLastReaderEvents
()));
}
...
...
@@ -119,9 +118,7 @@ public class ReaderRestView {
builder
.
entity
(
"role ID is required!"
);
builder
.
type
(
MediaType
.
TEXT_PLAIN
);
}
if
(
builder
==
null
)
{
if
(
ret
==
null
||
ret
.
getPrintedCard
()
==
null
)
{
}
else
if
(
ret
.
getPrintedCard
()
==
null
)
{
builder
=
Response
.
status
(
Status
.
NOT_ACCEPTABLE
);
builder
.
entity
(
"No card found for uid."
);
builder
.
type
(
MediaType
.
TEXT_PLAIN
);
...
...
@@ -136,7 +133,6 @@ public class ReaderRestView {
builder
.
entity
(
new
UserPermissionRestPojo
(
PojoUtils
.
initEventUserRestPojo
(
user
),
found
));
}
}
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
;
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.ProductBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
...
...
@@ -25,16 +7,28 @@ import fi.codecrew.moya.beans.VipBeanLocal;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Vip
;
import
fi.codecrew.moya.model.VipProduct
;
import
fi.codecrew.moya.rest.v2.pojo.VipProductPojo
;
import
fi.codecrew.moya.rest.v2.pojo.VipRestPojo
;
import
fi.codecrew.moya.rest.pojo.vip.v2.VipProductPojo
;
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.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
@Path
(
"/v2/vip"
)
@Api
(
value
=
"/v2/vip"
,
description
=
"Vip list operations"
)
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
@Consumes
({
MediaType
.
APPLICATION_JSON
})
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
@Consumes
({
MediaType
.
APPLICATION_JSON
})
public
class
VipRestView
{
@EJB
...
...
@@ -51,8 +45,8 @@ public class VipRestView {
@GET
@Path
(
"/all"
)
public
Response
getAllVips
()
{
ArrayList
<
VipRestPojo
>
ret
=
Vip
RestPojo
.
create
(
vipbean
.
getAvailableVips
());
return
Response
.
ok
(
ret
).
build
();
ArrayList
<
VipRestPojo
>
ret
=
Vip
PojoUtils
.
createVipList
(
vipbean
.
getAvailableVips
());
return
Response
.
ok
(
new
GenericEntity
<
ArrayList
<
VipRestPojo
>>(
ret
){}
).
build
();
}
@GET
...
...
@@ -62,7 +56,7 @@ public class VipRestView {
sq
.
setSearch
(
search
);
sq
.
setPagesize
(
0
);
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
)
{
};
...
...
@@ -74,19 +68,19 @@ public class VipRestView {
public
Response
deleteEntry
(
@PathParam
(
"id"
)
Integer
id
)
{
Vip
vip
=
vipbean
.
find
(
id
);
vipbean
.
delete
(
vip
);
return
Response
.
ok
(
Vip
RestPojo
.
create
(
vip
)).
build
();
return
Response
.
ok
(
Vip
PojoUtils
.
createVip
(
vip
)).
build
();
}
@GET
@Path
(
"/{id}"
)
public
Response
findEntry
(
@PathParam
(
"id"
)
Integer
id
)
{
Vip
vip
=
vipbean
.
find
(
id
);
return
Response
.
ok
(
Vip
RestPojo
.
create
(
vip
)).
build
();
return
Response
.
ok
(
Vip
PojoUtils
.
createVip
(
vip
)).
build
();
}
@POST
@Path
(
"/create"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
@Produces
({
MediaType
.
APPLICATION_JSON
})
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
Response
createEntry
(
VipRestPojo
create
)
{
...
...
@@ -123,7 +117,8 @@ public class VipRestView {
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
;
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.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
()
@ApiModel
(
description
=
"vip"
)
public
class
VipRestPojo
{
import
java.util.ArrayList
;
import
java.util.List
;
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
<>();
public
class
VipPojoUtils
{
public
static
VipProductPojo
createVipProduct
(
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
=
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
<>();
for
(
Vip
v
:
vips
)
{
ret
.
add
(
create
(
v
));
ret
.
add
(
create
Vip
(
v
));
}
return
ret
;
}
public
static
VipRestPojo
create
(
Vip
v
)
{
public
static
VipRestPojo
createVip
(
Vip
v
)
{
VipRestPojo
r
=
new
VipRestPojo
();
r
.
id
=
v
.
getId
();
r
.
description
=
v
.
getDescription
();
...
...
@@ -49,8 +51,27 @@ public class VipRestPojo {
r
.
hostId
=
v
.
getHost
().
getId
();
}
for
(
VipProduct
prod
:
v
.
getProducts
())
{
r
.
products
.
add
(
VipProductPojo
.
create
(
prod
));
r
.
products
.
add
(
createVipProduct
(
prod
));
}
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
...
...
@@ -60,6 +60,15 @@
<pluginManagement>
<plugins>
<plugin>
<artifactId>
maven-assembly-plugin
</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
${compiler-plugin-version}
</version>
...
...
@@ -75,7 +84,6 @@
</build>
<repositories>
<repository>
<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