Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
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 06960395
authored
Feb 21, 2016
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more informative responses for place delete function
1 parent
860254e3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
code/moya-web/src/main/java/fi/codecrew/moya/rest/MapAdminView.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/MapAdminView.java
View file @
0696039
...
@@ -82,13 +82,12 @@ public class MapAdminView {
...
@@ -82,13 +82,12 @@ public class MapAdminView {
@GET
@GET
@Path
(
"/background/{mapId}"
)
@Path
(
"/background/{mapId}"
)
@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
)
{
{
try
{
try
{
EventMap
map
=
placebean
.
findMap
(
mapid
);
EventMap
map
=
placebean
.
findMap
(
mapid
);
ByteArrayInputStream
istream
=
new
ByteArrayInputStream
(
map
.
getMapData
());
ByteArrayInputStream
istream
=
new
ByteArrayInputStream
(
map
.
getMapData
());
return
Response
.
ok
().
entity
(
istream
).
type
(
"image/jpeg"
).
build
();
return
Response
.
ok
().
entity
(
istream
).
type
(
"image/jpeg"
).
build
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"GET /placeadmin/background/{mapId} threw an exception"
,
e
);
logger
.
error
(
"GET /placeadmin/background/{mapId} threw an exception"
,
e
);
throw
e
;
throw
e
;
}
}
...
@@ -103,7 +102,7 @@ public class MapAdminView {
...
@@ -103,7 +102,7 @@ public class MapAdminView {
MapRoot
ret
=
PojoUtils
.
parseMaps
(
eventbean
.
getCurrentEvent
().
getEventMaps
());
MapRoot
ret
=
PojoUtils
.
parseMaps
(
eventbean
.
getCurrentEvent
().
getEventMaps
());
logger
.
info
(
"getallmaps called! {}"
,
ret
);
logger
.
info
(
"getallmaps called! {}"
,
ret
);
return
ret
;
return
ret
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"GET /placeadmin/maps threw an exception"
,
e
);
logger
.
error
(
"GET /placeadmin/maps threw an exception"
,
e
);
throw
e
;
throw
e
;
}
}
...
@@ -118,7 +117,7 @@ public class MapAdminView {
...
@@ -118,7 +117,7 @@ public class MapAdminView {
PlaceRoot
ret
=
PojoUtils
.
initPlaceRoot
(
map
);
PlaceRoot
ret
=
PojoUtils
.
initPlaceRoot
(
map
);
logger
.
info
(
"returning map {} entity {}"
,
mapid
,
ret
);
logger
.
info
(
"returning map {} entity {}"
,
mapid
,
ret
);
return
ret
;
return
ret
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"PUT /placeadmin/places/{mapId} threw an exception"
,
e
);
logger
.
error
(
"PUT /placeadmin/places/{mapId} threw an exception"
,
e
);
throw
e
;
throw
e
;
}
}
...
@@ -130,11 +129,14 @@ public class MapAdminView {
...
@@ -130,11 +129,14 @@ public class MapAdminView {
public
Response
deletePlace
(
@PathParam
(
"id"
)
Integer
id
)
{
public
Response
deletePlace
(
@PathParam
(
"id"
)
Integer
id
)
{
try
{
try
{
Place
place
=
eventmapbean
.
findPlace
(
id
);
Place
place
=
eventmapbean
.
findPlace
(
id
);
if
(
place
==
null
)
{
return
Response
.
status
(
Status
.
NOT_FOUND
).
entity
(
"Place not found for id "
+
id
).
build
();
}
eventmapbean
.
deletePlace
(
place
);
eventmapbean
.
deletePlace
(
place
);
return
Response
.
ok
().
build
();
return
Response
.
ok
().
build
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"DELETE /placeadmin/place/{id} threw an exception"
,
e
);
logger
.
error
(
"DELETE /placeadmin/place/{id} threw an exception"
,
e
);
throw
e
;
return
Response
.
serverError
().
entity
(
"Got exception when removing place: "
+
e
.
getMessage
()).
build
()
;
}
}
}
}
...
@@ -148,7 +150,7 @@ public class MapAdminView {
...
@@ -148,7 +150,7 @@ public class MapAdminView {
ret
=
ret
.
status
(
Status
.
NOT_ACCEPTABLE
);
ret
=
ret
.
status
(
Status
.
NOT_ACCEPTABLE
);
ret
.
entity
(
"Method not allowed!\nGET is not supported for /place/. See api for correct use!"
);
ret
.
entity
(
"Method not allowed!\nGET is not supported for /place/. See api for correct use!"
);
return
ret
.
build
();
return
ret
.
build
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"GET /placeadmin/place/ threw an exception"
,
e
);
logger
.
error
(
"GET /placeadmin/place/ threw an exception"
,
e
);
throw
e
;
throw
e
;
}
}
...
@@ -173,7 +175,7 @@ public class MapAdminView {
...
@@ -173,7 +175,7 @@ public class MapAdminView {
logger
.
info
(
"Creating new place {}"
,
place
.
getName
());
logger
.
info
(
"Creating new place {}"
,
place
.
getName
());
eventmapbean
.
createPlace
(
place
);
eventmapbean
.
createPlace
(
place
);
return
Response
.
ok
().
entity
(
PojoUtils
.
initPlacePojo
(
place
)).
build
();
return
Response
.
ok
().
entity
(
PojoUtils
.
initPlacePojo
(
place
)).
build
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"POST /placeadmin/place/ threw an exception"
,
e
);
logger
.
error
(
"POST /placeadmin/place/ threw an exception"
,
e
);
throw
e
;
throw
e
;
}
}
...
@@ -238,7 +240,7 @@ public class MapAdminView {
...
@@ -238,7 +240,7 @@ public class MapAdminView {
}
}
}
}
return
Response
.
serverError
().
build
();
return
Response
.
serverError
().
build
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"PUT /placeadmin/place/{placeId}/reserve/{eventuserId} threw an exception"
,
e
);
logger
.
error
(
"PUT /placeadmin/place/{placeId}/reserve/{eventuserId} threw an exception"
,
e
);
throw
e
;
throw
e
;
}
}
...
...
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