-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RESTWS-701 Added REST Implementation for Server logs #329
Conversation
@dkayiwa Could you please take a look at here? |
I think it's important that we add a privilege check here. (Or, maybe openmrs-core already enforces that?) |
Yes, we need to add privilege check here. Let me add it here. Thanks @djazayeri |
@djazayeri I have added the privilege check here, can you please take a look at here? |
Did you take a look at the above travis failure? |
Yah, I have noticed that one. But the error does not relate to this change. Every PR for this repo has the Travis failure due to this issue. |
Thanks, @sumangala028 for pointing out the new changes in the POM file to resolve the issue mentioned above. @dkayiwa Can you please take a look at here for the test errors. |
Do the pass locally? |
62fc4e6
to
94805ff
Compare
@dkayiwa, I have fixed the issues. Can you please take a look again |
Does this appear in the online swagger docs? |
Sorry, I didn't get you properly. What do you mean by "online swagger docs"? |
@gayanW do you have a minute to respond to the above? 😊 |
Yeah you'd need implement However your resource class does not seem extend any of the base resource classes. FYI: methods such as You can find more information here: |
I have implemented this class from Listable Interface, not with DelegatingResourceHandler Interface. Listable Interface doesn't have any methods like getGETModel, getCreatableProperties for the swagger access. So how can I override those methods here? |
To my understanding most resources extends one of the base resource classes which inherit DelegatingResourceHandler. DelegatingResourceHandler is the one that is currently being used to describe resource representations. @dkayiwa will have an idea on what to do in this case :) |
f3135bc
to
a67ee55
Compare
@dkayiwa If you have time, Could you please review it and help me to complete this work to release the SysAdmin 1.1 OWA :-) |
/** | ||
* Constants used for the Server Log REST Service privilege checking | ||
*/ | ||
public static final String GET_SERVER_LOGS = "Get Server Logs"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you prefix this with PRIV_ to make it clearer from the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the variable name. Thanks @dkayiwa
return logElements; | ||
} | ||
catch (PatternSyntaxException e) { | ||
// In case of Exception, It will return empty array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then how will the client differentiate between finding no match and errors occurred?
@suthagar23 did you compile, install, and test to see if your resource shows up in the online swagger docs? |
Yes @dkayiwa, I can see those resources in the online swagger docs. You can see it below, |
Do your resources show up in the online swagger docs when running on the latest snapshot version of openmrs-core? |
I have just checked the latest snapshot version of openmrs-core (openmrs-2.2.0-SNAPSHOT). But I couldn't see the swagger docs 😞 . |
Can you raise it on talk? |
Sure @dkayiwa I will post it to talk. |
@Override | ||
public SimpleObject getAll(RequestContext context) throws ResponseException { | ||
SimpleObject rest = new SimpleObject(); | ||
rest.put("serverLog", serverLogActionWrapper.getServerLogs()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to put the logs in single field? I'd Imagine that you just need to a return a list of server logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought to get that list of logs from "serverlog" field. Anyway, returning that list directly to the resource also a good point. Thanks @wluyima
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the server logs will return nearly 100 lines, I kept those inside a single key to reduce the complexity for now. We can add some other keys based later as well.
@Override | ||
public DelegatingResourceDescription getRepresentationDescription(Representation rep) { | ||
DelegatingResourceDescription description = new DelegatingResourceDescription(); | ||
description.addProperty("serverLog", "serverLog"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The properties should be the individual fields on the ServerLogWrapper class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added this property to the ServerLogActionWrapper
class here - https://github.com/openmrs/openmrs-module-webservices.rest/pull/329/files#diff-410f1f6f7c035020e68aa6abe419b84bR28
Do we need another ServerLogWrapper
Class also?
} | ||
|
||
@Override | ||
public String getUri(Object instance) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to override this?
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/*** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you format your code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the mistake, I will make it better
@suthagar23 did you eventually figure this out? |
Not yet @dkayiwa. I am working on this to figure out the actual problem and looking for the changes in the new release which is blocking this resource in the swagger documentation. |
Swagger doc loads fine in the qa-refapp. I didn't have chance to test it locally. |
@suthagar23 are you doing any more changes on this? |
@dkayiwa Let me check again the issue here. |
@suthagar23 did you address Wyclif's comments? |
@suthagar23 did you see the above? |
@suthagar23 can you finish this up? |
00f888a
to
6db0cb8
Compare
@dkayiwa I have updated the PR now. Extremely sorry for the delay since I forgot this work for a long time 😢 |
6be7252
to
6783a01
Compare
…d point. Added REST Implementation with Privilege check for the Server logs end point. Added REST Implementation with Privilege check for the Server logs end point. Added REST Implementation with Privilege check for the Server logs end point. Added REST Implementation with Privilege check for the Server logs end point. Added REST Implementation with Privilege check for the Server logs end point. Added REST Implementation with Privilege check for the Server logs end point. Added REST Implementation with Privilege check for Server Logs end point. Added REST Implementation for Server logs Privilege check added for the REST end point updated the privilege check Comments updated Changed support class for the resource Minor fix in REST Constants Added more improvements to get it in the Swagger Docs Added some testcases to serverLogController Added some unit tests to increase the coverage Added some unit tests Fix some minor issues Fixed minor formatting issues Fixed minor issues Added some tests Added some tests Added some tests Added some tests for serverLog resource Added some tests for serverLog resource Added some tests for serverLog resource
It will be helped to expose the Server logs through the REST Webservices. There are some minor logics included using the Wrapper classes to increase the usage of the log lines.
The user needs the "Get Server Logs" privilege to access this endpoint.
Issue: RESTWS-701