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 28c01812
authored
Dec 20, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore tag - role checking rest function
1 parent
4d85eae6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
44 deletions
code/moya-web/src/main/java/fi/codecrew/moya/rest/ReaderRestView.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/ReaderRestView.java
View file @
28c0181
...
...
@@ -81,12 +81,12 @@ public class ReaderRestView {
return
new
ReaderEventRestRoot
(
ReaderEventRestPojo
.
parse
(
events
));
}
@GET
@Path
(
"/createevent/{reader}/{code}/{hash}"
)
public
Response
createReaderEvent
(
@PathParam
(
"reader"
)
String
readerName
,
@PathParam
(
"code"
)
String
readerCode
,
@PathParam
(
"hash"
)
String
hash
)
{
public
Response
createReaderEvent
(
@PathParam
(
"reader"
)
String
readerName
,
@PathParam
(
"code"
)
String
readerCode
,
@PathParam
(
"hash"
)
String
hash
)
{
readerbean
.
checkCode
(
readerName
,
readerCode
);
return
Response
.
ok
().
build
();
}
...
...
@@ -102,46 +102,48 @@ public class ReaderRestView {
// public void createRfidEvent(@PathParam("reader") String reader, @PathParam("tagId") String tagId) {
//
// }
//
// // TBD: WTF! - Tarttis varmaan käydä ajatuksella läpi.. - Tuomari 2014-02-28
// @GET
// @Path("/EventRole/{reader}/{tagId}/{roleid}")
// public Response eventRole(@PathParam("reader") String reader, @PathParam("tagId") String tag, @PathParam("roleid") Integer roleId) {
// ReaderEvent ret = readerbean.checkTag(reader, tag);
// ResponseBuilder builder = null;
// if (roleId == null || roleId.equals(0))
// {
// builder = Response.status(Status.BAD_REQUEST);
// builder.entity("role ID is required!");
// builder.type(MediaType.TEXT_PLAIN);
//
// }
// if (builder == null)
// {
// if (ret == null || ret.getPrintedCard() == null) {
// builder = Response.status(Status.NOT_ACCEPTABLE);
// builder.entity("No card found for uid.");
// builder.type(MediaType.TEXT_PLAIN);
// } else {
// EventUser user = ret.getPrintedCard().getUser();
// boolean found = userbean.isUserInRole(user, roleId);
// if (found) {
// builder = Response.status(Status.OK);
// } else {
// builder = Response.status(Status.FORBIDDEN);
// }
// builder.entity(new UserPermissionRestPojo(new EventUserRestPojo(user), found));
//
// }
// }
//
// return builder.build();
// }
//
// @GET
// @Path("/EventCard/{reader}/{cardid}")
// public void eventCard(@PathParam("reader") String reader, @PathParam("cardid") String cardId) {
//
// }
// Created for skynett port stuff. - Tuomari ( Does user have permission to enter the event. )
@GET
@Path
(
"/EventRole/{reader}/{tagId}/{roleid}"
)
public
Response
isTaguserInRole
(
@PathParam
(
"reader"
)
String
reader
,
@PathParam
(
"tagId"
)
String
tag
,
@PathParam
(
"roleid"
)
Integer
roleId
)
{
ReaderEvent
ret
=
readerbean
.
checkCode
(
reader
,
tag
);
ResponseBuilder
builder
=
null
;
if
(
roleId
==
null
||
roleId
.
equals
(
0
))
{
builder
=
Response
.
status
(
Status
.
BAD_REQUEST
);
builder
.
entity
(
"role ID is required!"
);
builder
.
type
(
MediaType
.
TEXT_PLAIN
);
}
if
(
builder
==
null
)
{
if
(
ret
==
null
||
ret
.
getPrintedCard
()
==
null
)
{
builder
=
Response
.
status
(
Status
.
NOT_ACCEPTABLE
);
builder
.
entity
(
"No card found for uid."
);
builder
.
type
(
MediaType
.
TEXT_PLAIN
);
}
else
{
EventUser
user
=
ret
.
getPrintedCard
().
getUser
();
boolean
found
=
userbean
.
isUserInRole
(
user
,
roleId
);
if
(
found
)
{
builder
=
Response
.
status
(
Status
.
OK
);
}
else
{
builder
=
Response
.
status
(
Status
.
FORBIDDEN
);
}
builder
.
entity
(
new
UserPermissionRestPojo
(
new
EventUserRestPojo
(
user
),
found
));
}
}
return
builder
.
build
();
}
//
// @GET
// @Path("/EventCard/{reader}/{cardid}")
// public void eventCard(@PathParam("reader") String reader, @PathParam("cardid") String cardId) {
//
// }
}
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