Community Announcements have moved! To stay up to date, please join the new Community Announcements group today. Learn more
×Hi Team,
I have developed a Rest API to fetch data saved in Active Objects database tables.
// To delete all the rules present in database table
@DELETE
@Path("/debug/delete/rules")
public Response deleteAllRules() {
boolean result = rules.deleteAllStoredRules();
if (result) {
return Response.noContent().build();
}
return Response.status(205).build();
}
Can anyone please help me to find a way to fetch username in my code who had hit this API via postman/any other way?
Hi @[deleted]
You can get the logged user as below.
import com.atlassian.jira.security.JiraAuthenticationContext;
private final JiraAuthenticationContext authenticationContext;
ApplicationUser currentUser = authenticationContext.getLoggedInUser();
Then you can get the user name and store it in a database table for auditing.
Please let me know if I am missing something.
Hi @Tuncay Senturk _Snapbytes_ ,
Thank you for your reply, Using the above code I am able to get the current user. Can you please help me further in how to check if current user is system admin or not?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use UserManager's isSystemAdmin method to see whether it is a system manager.
See reference: https://docs.atlassian.com/sal-api/3.1.0/sal-api/apidocs/index.html?com/atlassian/sal/api/user/UserManager.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please mark the answer as accepted if it solved your problem. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @[deleted] ,
in my opinion, the best way is to add your custom AO containg all information about user and data and add in your code AO management so that user that invoked that rest API will be added to AO table.
In your app, moreover, you can add a menu that, at administration level, will display history of REST api calls.
Hope this helps,
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.