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 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 {
...
@@ -81,12 +81,12 @@ public class ReaderRestView {
return
new
ReaderEventRestRoot
(
ReaderEventRestPojo
.
parse
(
events
));
return
new
ReaderEventRestRoot
(
ReaderEventRestPojo
.
parse
(
events
));
}
}
@GET
@GET
@Path
(
"/createevent/{reader}/{code}/{hash}"
)
@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
);
readerbean
.
checkCode
(
readerName
,
readerCode
);
return
Response
.
ok
().
build
();
return
Response
.
ok
().
build
();
}
}
...
@@ -102,46 +102,48 @@ public class ReaderRestView {
...
@@ -102,46 +102,48 @@ public class ReaderRestView {
// public void createRfidEvent(@PathParam("reader") String reader, @PathParam("tagId") String tagId) {
// public void createRfidEvent(@PathParam("reader") String reader, @PathParam("tagId") String tagId) {
//
//
// }
// }
//
// // TBD: WTF! - Tarttis varmaan käydä ajatuksella läpi.. - Tuomari 2014-02-28
// Created for skynett port stuff. - Tuomari ( Does user have permission to enter the event. )
// @GET
@GET
// @Path("/EventRole/{reader}/{tagId}/{roleid}")
@Path
(
"/EventRole/{reader}/{tagId}/{roleid}"
)
// public Response eventRole(@PathParam("reader") String reader, @PathParam("tagId") String tag, @PathParam("roleid") Integer roleId) {
public
Response
isTaguserInRole
(
// ReaderEvent ret = readerbean.checkTag(reader, tag);
@PathParam
(
"reader"
)
String
reader
,
// ResponseBuilder builder = null;
@PathParam
(
"tagId"
)
String
tag
,
// if (roleId == null || roleId.equals(0))
@PathParam
(
"roleid"
)
Integer
roleId
// {
)
{
// builder = Response.status(Status.BAD_REQUEST);
ReaderEvent
ret
=
readerbean
.
checkCode
(
reader
,
tag
);
// builder.entity("role ID is required!");
ResponseBuilder
builder
=
null
;
// builder.type(MediaType.TEXT_PLAIN);
if
(
roleId
==
null
||
roleId
.
equals
(
0
))
{
//
builder
=
Response
.
status
(
Status
.
BAD_REQUEST
);
// }
builder
.
entity
(
"role ID is required!"
);
// if (builder == null)
builder
.
type
(
MediaType
.
TEXT_PLAIN
);
// {
// if (ret == null || ret.getPrintedCard() == null) {
}
// builder = Response.status(Status.NOT_ACCEPTABLE);
if
(
builder
==
null
)
{
// builder.entity("No card found for uid.");
if
(
ret
==
null
||
ret
.
getPrintedCard
()
==
null
)
{
// builder.type(MediaType.TEXT_PLAIN);
builder
=
Response
.
status
(
Status
.
NOT_ACCEPTABLE
);
// } else {
builder
.
entity
(
"No card found for uid."
);
// EventUser user = ret.getPrintedCard().getUser();
builder
.
type
(
MediaType
.
TEXT_PLAIN
);
// boolean found = userbean.isUserInRole(user, roleId);
}
else
{
// if (found) {
EventUser
user
=
ret
.
getPrintedCard
().
getUser
();
// builder = Response.status(Status.OK);
boolean
found
=
userbean
.
isUserInRole
(
user
,
roleId
);
// } else {
if
(
found
)
{
// builder = Response.status(Status.FORBIDDEN);
builder
=
Response
.
status
(
Status
.
OK
);
// }
}
else
{
// builder.entity(new UserPermissionRestPojo(new EventUserRestPojo(user), found));
builder
=
Response
.
status
(
Status
.
FORBIDDEN
);
//
}
// }
builder
.
entity
(
new
UserPermissionRestPojo
(
new
EventUserRestPojo
(
user
),
found
));
// }
//
}
// return builder.build();
}
// }
//
return
builder
.
build
();
// @GET
}
// @Path("/EventCard/{reader}/{cardid}")
//
// public void eventCard(@PathParam("reader") String reader, @PathParam("cardid") String cardId) {
// @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