Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
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 1f25944b
authored
Mar 02, 2015
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/rest-exceptions' into 'master'
rest exceptions, etc. See merge request !249
2 parents
d6be3845
54671cde
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
127 additions
and
68 deletions
code/moya-parent/pom-root.xml
code/moya-web/pom.xml
code/moya-web/src/main/java/fi/codecrew/moya/rest/MapAdminView.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-parent/pom-root.xml
View file @
1f25944
...
@@ -10,13 +10,13 @@
...
@@ -10,13 +10,13 @@
<properties>
<properties>
<moya.version>
1.0
</moya.version>
<moya.version>
1.0
</moya.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<java-version>
1.
7
</java-version>
<java-version>
1.
8
</java-version>
<!-- plugin versions -->
<!-- plugin versions -->
<ejb-plugin-version>
2.3
</ejb-plugin-version>
<ejb-plugin-version>
2.3
</ejb-plugin-version>
<war-plugin-version>
2.4
</war-plugin-version>
<war-plugin-version>
2.4
</war-plugin-version>
<ear-plugin-version>
2.9
</ear-plugin-version>
<ear-plugin-version>
2.9
</ear-plugin-version>
<compiler-plugin-version>
3.
1
</compiler-plugin-version>
<compiler-plugin-version>
3.
2
</compiler-plugin-version>
<!-- dependency versions -->
<!-- dependency versions -->
<javaee-api-version>
7.0
</javaee-api-version>
<javaee-api-version>
7.0
</javaee-api-version>
<!-- EJB spec version -->
<!-- EJB spec version -->
...
@@ -40,10 +40,9 @@
...
@@ -40,10 +40,9 @@
<version>
${compiler-plugin-version}
</version>
<version>
${compiler-plugin-version}
</version>
<configuration>
<configuration>
<source>
1.7
</source>
<source>
${java-version}
</source>
<target>
1.7
</target>
<target>
${java-version}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</configuration>
</plugin>
</plugin>
</plugins>
</plugins>
...
...
code/moya-web/pom.xml
View file @
1f25944
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<configuration>
<configuration>
<warSourceDirectory>
WebContent
</warSourceDirectory>
<warSourceDirectory>
WebContent
</warSourceDirectory>
<failOnMissingWebXml>
false
</failOnMissingWebXml>
<failOnMissingWebXml>
false
</failOnMissingWebXml>
<packagingIncludes>
WEB-INF/lib/moya-restpojo*,WEB-INF/lib/javamelody-core*,WEB-INF/lib/primefaces*,WEB-INF/lib/*-1.0.8.jar,**/*.xml,**/*.xhtml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,resources/*
</packagingIncludes>
<packagingIncludes>
WEB-INF/lib/moya-restpojo*,WEB-INF/lib/javamelody-core*,WEB-INF/lib/primefaces*,WEB-INF/lib/*-1.0.8.jar,**/*.xml,**/*.xhtml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,resources/*
,swagger/**
</packagingIncludes>
</configuration>
</configuration>
</plugin>
</plugin>
</plugins>
</plugins>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/MapAdminView.java
View file @
1f25944
...
@@ -84,9 +84,14 @@ public class MapAdminView {
...
@@ -84,9 +84,14 @@ public class MapAdminView {
@ApiResponse
(
code
=
200
,
message
=
"Return backround map as JPEG"
)
@ApiResponse
(
code
=
200
,
message
=
"Return backround map as JPEG"
)
public
Response
getMapBg
(
@PathParam
(
"mapId"
)
Integer
mapid
)
public
Response
getMapBg
(
@PathParam
(
"mapId"
)
Integer
mapid
)
{
{
EventMap
map
=
placebean
.
findMap
(
mapid
);
try
{
ByteArrayInputStream
istream
=
new
ByteArrayInputStream
(
map
.
getMapData
());
EventMap
map
=
placebean
.
findMap
(
mapid
);
return
Response
.
ok
().
entity
(
istream
).
type
(
"image/jpeg"
).
build
();
ByteArrayInputStream
istream
=
new
ByteArrayInputStream
(
map
.
getMapData
());
return
Response
.
ok
().
entity
(
istream
).
type
(
"image/jpeg"
).
build
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"GET /placeadmin/background/{mapId} threw an exception"
,
e
);
throw
e
;
}
}
}
@GET
@GET
...
@@ -94,28 +99,43 @@ public class MapAdminView {
...
@@ -94,28 +99,43 @@ public class MapAdminView {
@ApiOperation
(
value
=
"Get All maps"
,
response
=
MapRoot
.
class
)
@ApiOperation
(
value
=
"Get All maps"
,
response
=
MapRoot
.
class
)
@ApiResponse
(
code
=
200
,
message
=
"Return all maps"
)
@ApiResponse
(
code
=
200
,
message
=
"Return all maps"
)
public
MapRoot
getAllMaps
()
{
public
MapRoot
getAllMaps
()
{
MapRoot
ret
=
PojoUtils
.
parseMaps
(
eventbean
.
getCurrentEvent
().
getEventMaps
());
try
{
logger
.
info
(
"getallmaps called! {}"
,
ret
);
MapRoot
ret
=
PojoUtils
.
parseMaps
(
eventbean
.
getCurrentEvent
().
getEventMaps
());
return
ret
;
logger
.
info
(
"getallmaps called! {}"
,
ret
);
return
ret
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"GET /placeadmin/maps threw an exception"
,
e
);
throw
e
;
}
}
}
@GET
@GET
@Path
(
"/places/{mapId}"
)
@Path
(
"/places/{mapId}"
)
@ApiOperation
(
value
=
"Get places by mapId"
,
response
=
PlaceRoot
.
class
)
@ApiOperation
(
value
=
"Get places by mapId"
,
response
=
PlaceRoot
.
class
)
public
PlaceRoot
getPlaces
(
@PathParam
(
"mapId"
)
Integer
mapid
)
{
public
PlaceRoot
getPlaces
(
@PathParam
(
"mapId"
)
Integer
mapid
)
{
EventMap
map
=
placebean
.
findMap
(
mapid
);
try
{
PlaceRoot
ret
=
PojoUtils
.
initPlaceRoot
(
map
);
EventMap
map
=
placebean
.
findMap
(
mapid
);
logger
.
info
(
"returning map {} entity {}"
,
mapid
,
ret
);
PlaceRoot
ret
=
PojoUtils
.
initPlaceRoot
(
map
);
return
ret
;
logger
.
info
(
"returning map {} entity {}"
,
mapid
,
ret
);
return
ret
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"PUT /placeadmin/places/{mapId} threw an exception"
,
e
);
throw
e
;
}
}
}
@DELETE
@DELETE
@Path
(
"/place/{id}"
)
@Path
(
"/place/{id}"
)
@ApiOperation
(
"Delete a place"
)
@ApiOperation
(
"Delete a place"
)
public
Response
deletePlace
(
@PathParam
(
"id"
)
Integer
id
)
{
public
Response
deletePlace
(
@PathParam
(
"id"
)
Integer
id
)
{
Place
place
=
eventmapbean
.
findPlace
(
id
);
try
{
eventmapbean
.
deletePlace
(
place
);
Place
place
=
eventmapbean
.
findPlace
(
id
);
return
Response
.
ok
().
build
();
eventmapbean
.
deletePlace
(
place
);
return
Response
.
ok
().
build
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"DELETE /placeadmin/place/{id} threw an exception"
,
e
);
throw
e
;
}
}
}
@GET
@GET
...
@@ -123,81 +143,105 @@ public class MapAdminView {
...
@@ -123,81 +143,105 @@ public class MapAdminView {
@ApiOperation
(
value
=
"Always returns 406 - Not acceptable"
)
@ApiOperation
(
value
=
"Always returns 406 - Not acceptable"
)
@ApiResponse
(
code
=
406
,
message
=
"Nope. Not acceptable."
)
@ApiResponse
(
code
=
406
,
message
=
"Nope. Not acceptable."
)
public
Response
getPlaceError
()
{
public
Response
getPlaceError
()
{
ResponseBuilder
ret
=
Response
.
ok
();
try
{
ret
=
ret
.
status
(
Status
.
NOT_ACCEPTABLE
);
ResponseBuilder
ret
=
Response
.
ok
();
ret
.
entity
(
"Method not allowed!\nGET is not supported for /place/. See api for correct use!"
);
ret
=
ret
.
status
(
Status
.
NOT_ACCEPTABLE
);
return
ret
.
build
();
ret
.
entity
(
"Method not allowed!\nGET is not supported for /place/. See api for correct use!"
);
return
ret
.
build
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"GET /placeadmin/place/ threw an exception"
,
e
);
throw
e
;
}
}
}
@POST
@POST
@Path
(
"/place/"
)
@Path
(
"/place/"
)
@ApiOperation
(
value
=
"Create a place"
,
response
=
PlacePojo
.
class
)
@ApiOperation
(
value
=
"Create a place"
,
response
=
PlacePojo
.
class
)
public
Response
createPlace
(
PlacePojo
create
)
{
public
Response
createPlace
(
PlacePojo
create
)
{
logger
.
info
(
"Finding map with id {}"
,
create
.
getMapId
());
try
{
EventMap
map
=
eventmapbean
.
find
(
create
.
getMapId
());
logger
.
info
(
"Finding map with id {}"
,
create
.
getMapId
());
if
(
map
==
null
)
{
EventMap
map
=
eventmapbean
.
find
(
create
.
getMapId
());
logger
.
warn
(
"No map found!"
);
if
(
map
==
null
)
{
return
Response
.
serverError
().
entity
(
"Error with mapId"
).
build
();
logger
.
warn
(
"No map found!"
);
}
return
Response
.
serverError
().
entity
(
"Error with mapId"
).
build
();
Place
place
=
new
Place
();
}
place
.
setMap
(
map
);
Place
place
=
new
Place
();
setUpdatablePlaceValues
(
place
,
create
);
place
.
setMap
(
map
);
if
(
create
.
getProductId
()
!=
null
&&
(
place
.
getProduct
()
==
null
||
!
place
.
getProduct
().
getId
().
equals
(
create
.
getProductId
())))
setUpdatablePlaceValues
(
place
,
create
);
return
Response
.
serverError
().
entity
(
"Product id unknown!"
).
build
();
if
(
create
.
getProductId
()
!=
null
&&
(
place
.
getProduct
()
==
null
||
!
place
.
getProduct
().
getId
().
equals
(
create
.
getProductId
())))
logger
.
info
(
"Creating new place {}"
,
place
.
getName
());
return
Response
.
serverError
().
entity
(
"Product id unknown!"
).
build
();
eventmapbean
.
createPlace
(
place
);
logger
.
info
(
"Creating new place {}"
,
place
.
getName
());
return
Response
.
ok
().
entity
(
PojoUtils
.
initPlacePojo
(
place
)).
build
();
eventmapbean
.
createPlace
(
place
);
return
Response
.
ok
().
entity
(
PojoUtils
.
initPlacePojo
(
place
)).
build
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"POST /placeadmin/place/ threw an exception"
,
e
);
throw
e
;
}
}
}
@PUT
@PUT
@Path
(
"/place/{id}"
)
@Path
(
"/place/{id}"
)
@ApiOperation
(
value
=
"Set a place"
,
response
=
PlacePojo
.
class
)
@ApiOperation
(
value
=
"Set a place"
,
response
=
PlacePojo
.
class
)
public
Response
updatePlace
(
@PathParam
(
"id"
)
Integer
id
,
PlacePojo
update
)
{
public
Response
updatePlace
(
@PathParam
(
"id"
)
Integer
id
,
PlacePojo
update
)
{
if
(
update
==
null
||
id
==
null
)
{
try
{
return
Response
.
serverError
().
entity
(
"'id' field is required!"
).
build
();
if
(
update
==
null
||
id
==
null
)
{
}
return
Response
.
serverError
().
entity
(
"'id' field is required!"
).
build
();
Place
place
=
eventmapbean
.
findPlace
(
id
);
}
if
(
place
==
null
)
{
Place
place
=
eventmapbean
.
findPlace
(
id
);
return
Response
.
serverError
().
entity
(
"place not found with id: "
+
id
).
build
();
if
(
place
==
null
)
{
}
return
Response
.
serverError
().
entity
(
"place not found with id: "
+
id
).
build
();
setUpdatablePlaceValues
(
place
,
update
);
}
if
(
update
.
getProductId
()
!=
null
&&
(
place
.
getProduct
()
==
null
||
!
place
.
getProduct
().
getId
().
equals
(
update
.
getProductId
())))
setUpdatablePlaceValues
(
place
,
update
);
return
Response
.
serverError
().
entity
(
"Product id unknown!"
).
build
();
if
(
update
.
getProductId
()
!=
null
&&
(
place
.
getProduct
()
==
null
||
!
place
.
getProduct
().
getId
().
equals
(
update
.
getProductId
())))
return
Response
.
serverError
().
entity
(
"Product id unknown!"
).
build
();
place
=
eventmapbean
.
updatePlace
(
place
);
place
=
eventmapbean
.
updatePlace
(
place
);
return
Response
.
ok
(
PojoUtils
.
initPlacePojo
(
place
)).
build
();
return
Response
.
ok
(
PojoUtils
.
initPlacePojo
(
place
)).
build
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"PUT /placeadmin/place/{id} threw an exception"
,
e
);
throw
e
;
}
}
}
@PUT
@PUT
@Path
(
"/place/{placeId}/release"
)
@Path
(
"/place/{placeId}/release"
)
@ApiOperation
(
"Release a class"
)
@ApiOperation
(
"Release a class"
)
public
Response
releasePlace
(
@PathParam
(
"placeId"
)
Integer
placeId
)
{
public
Response
releasePlace
(
@PathParam
(
"placeId"
)
Integer
placeId
)
{
Place
place
=
eventmapbean
.
findPlace
(
placeId
);
try
{
if
(
place
==
null
)
{
Place
place
=
eventmapbean
.
findPlace
(
placeId
);
return
Response
.
serverError
().
entity
(
"Place not found!"
).
build
();
if
(
place
==
null
)
{
}
return
Response
.
serverError
().
entity
(
"Place not found!"
).
build
();
logger
.
info
(
"Releasing place {}"
,
place
);
}
placebean
.
unbuyPlace
(
place
);
logger
.
info
(
"Releasing place {}"
,
place
);
placebean
.
unbuyPlace
(
place
);
return
Response
.
ok
().
build
();
return
Response
.
ok
().
build
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"PUT /placeadmin/place/{placeId}/release threw an exception"
,
e
);
throw
e
;
}
}
}
@PUT
@PUT
@Path
(
"/place/{placeId}/reserve/{eventuserId}"
)
@Path
(
"/place/{placeId}/reserve/{eventuserId}"
)
@ApiOperation
(
"Reserve a place"
)
@ApiOperation
(
"Reserve a place"
)
public
Response
reserve
(
@PathParam
(
"placeId"
)
Integer
placeId
,
@PathParam
(
"eventuserId"
)
Integer
eventuserId
)
{
public
Response
reserve
(
@PathParam
(
"placeId"
)
Integer
placeId
,
@PathParam
(
"eventuserId"
)
Integer
eventuserId
)
{
Place
place
=
eventmapbean
.
findPlace
(
placeId
);
try
{
EventUser
eventuser
=
eventuserbean
.
findByEventUserId
(
eventuserId
);
Place
place
=
eventmapbean
.
findPlace
(
placeId
);
if
(
placebean
.
reservePlace
(
place
,
eventuser
))
EventUser
eventuser
=
eventuserbean
.
findByEventUserId
(
eventuserId
);
{
if
(
placebean
.
reservePlace
(
place
,
eventuser
))
{
try
{
try
{
placebean
.
reserveSelectedPlaces
(
eventuser
);
placebean
.
reserveSelectedPlaces
(
eventuser
);
return
Response
.
ok
().
build
();
return
Response
.
ok
().
build
();
}
catch
(
BortalCatchableException
e
)
{
}
catch
(
BortalCatchableException
e
)
{
logger
.
warn
(
"Wtf! Bortalerror"
);
logger
.
warn
(
"Wtf! Bortalerror"
,
e
);
}
}
}
}
return
Response
.
serverError
().
build
();
return
Response
.
serverError
().
build
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"PUT /placeadmin/place/{placeId}/reserve/{eventuserId} threw an exception"
,
e
);
throw
e
;
}
}
}
private
void
setUpdatablePlaceValues
(
Place
place
,
PlacePojo
update
)
{
private
void
setUpdatablePlaceValues
(
Place
place
,
PlacePojo
update
)
{
...
...
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n.properties
View file @
1f25944
...
@@ -517,3 +517,8 @@ cardTextData.deleteQ=Delete text data from card template?
...
@@ -517,3 +517,8 @@ cardTextData.deleteQ=Delete text data from card template?
cardObjectData.delete
=
Delete
cardObjectData.delete
=
Delete
cardTextData.delete
=
Delete
cardTextData.delete
=
Delete
placegroup.noPlacegroups
=
Sinulla t
\u
00E4ytyy olla paikkoja ett
\u
00E4 voit n
\u
00E4hd
\u
00E4 lippusi
placegroup.noPlacegroups
=
Sinulla t
\u
00E4ytyy olla paikkoja ett
\u
00E4 voit n
\u
00E4hd
\u
00E4 lippusi
bortalApplication.VIP
=
VIP list
bortalApplication.vip.VIEW
=
View VIP list
bortalApplication.vip.USAGE
=
Use VIP list
bortalApplication.vip.EDIT
=
Edit VIP list
bortalApplication.event.VIEW_STATISTICS
=
View event statistics
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
View file @
1f25944
...
@@ -1734,3 +1734,8 @@ cardTextData.deleteQ=Delete text data from card template?
...
@@ -1734,3 +1734,8 @@ cardTextData.deleteQ=Delete text data from card template?
cardObjectData.delete
=
Delete
cardObjectData.delete
=
Delete
cardTextData.delete
=
Delete
cardTextData.delete
=
Delete
placegroup.noPlacegroups
=
You must have placegroups that you can have places
placegroup.noPlacegroups
=
You must have placegroups that you can have places
bortalApplication.VIP
=
VIP list
bortalApplication.vip.VIEW
=
View VIP list
bortalApplication.vip.USAGE
=
Use VIP list
bortalApplication.vip.EDIT
=
Edit VIP list
bortalApplication.event.VIEW_STATISTICS
=
View event statistics
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
View file @
1f25944
...
@@ -1717,3 +1717,9 @@ cardTextData.deleteQ=Poistetaanko tekstidata korttipohjalta?
...
@@ -1717,3 +1717,9 @@ cardTextData.deleteQ=Poistetaanko tekstidata korttipohjalta?
cardObjectData.delete
=
Poista
cardObjectData.delete
=
Poista
cardTextData.delete
=
Poista
cardTextData.delete
=
Poista
placegroup.noPlacegroups
=
Sinulla t
\u
00E4ytyy olla paikkoja ett
\u
00E4 voit n
\u
00E4hd
\u
00E4 lippusi
placegroup.noPlacegroups
=
Sinulla t
\u
00E4ytyy olla paikkoja ett
\u
00E4 voit n
\u
00E4hd
\u
00E4 lippusi
bortalApplication.VIP
=
VIP-lista
bortalApplication.vip.VIEW
=
Näytä VIP-lista
bortalApplication.vip.USAGE
=
Käytä VIP-listaa
bortalApplication.vip.EDIT
=
Muokkaa VIP-listaa
bortalApplication.event.VIEW_STATISTICS
=
Näytä tapahtuman tilastot
lecture.showParticipants
=
Näytä osallistujat
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