Role of the user in the polarion project

Description
vinayasheelag
Posts: 5
Joined: Thu Jan 04, 2018 7:16 am

Role of the user in the polarion project

Postby vinayasheelag » Thu Jan 04, 2018 7:54 am

I am new to polarion.I am using demo version of polarion web application v3.0.10.
I am programming in c# using webservices.

I am trying to get the roles of the polarion project.I tried with the following api's.
1.getContextRolesForUser(string user, string location)
2.hasCurrentUserPermission("com.polarion.persistence.object.project.delete", ProjectName);

For "SecurityService.getContextRolesForUser", i am struck with the second parameter.I tried giving Project.uri / Project.ProjectGroupUri/ Project.Location,but still failed.It is giving faultexceptions.

For "SecurityService.hasCurrentUserPermission" for admin it is returning true but for project admin it is returning false.Where as in polarion web application "permission Management->Projects->Permissions to delete" have granted permissions to delete the project for "admin" and "Project admin".

From one the topic in this forum i got the below code.But no success to me as i do not have some of the apis(getDataService,getProjectsService,getContextId ).Is this the restrictions with the demo version of polarion?

securityService = trackerService.getDataService().getSecurityService();
project = workItem.getProject();
var projectsservice = trackerService.getProjectsService();
var dataservice = trackerService.getDataService();
var securityservice = dataservice.getSecurityService();
var project = workItem.getProject();
// or:
var project = projectsservice.getProject("YOUR_PROJECT_ID");

var currentprojectroles = securityservice.getContextRolesForUser(securityservice.getCurrentUser(), project.getContextId());

Anyhelp is highly appreciated.

Thanks in advance,
Vinayasheela

ALMighty
Posts: 21
Joined: Wed Apr 27, 2016 10:34 am

Re: Role of the user in the polarion project

Postby ALMighty » Sun Jan 07, 2018 12:48 pm

Hello!

In Short: I am sure that this is not a limitation of the demo version but you should check if you have used the right methods/functions in the right context.

However before I come to my actual answer, here a short Disclaimer:
Like I have wrote in the thread [url]"Get TestRecord content via C#"[/url] I have to admit that I do not know if using the API with C# is possible the same way like I did with Java. I do not know how to get the necessary libraries for C# using the API, only for Java

However what I do know is that this code (and PLEASE! Put your code snippets in your future posts between two Code tags for readability): ...

vinayasheelag wrote:

Code: Select all

securityService = trackerService.getDataService().getSecurityService();
project = workItem.getProject();
var projectsservice = trackerService.getProjectsService();
var dataservice = trackerService.getDataService();
var securityservice = dataservice.getSecurityService();
var project = workItem.getProject();
// or:
var project = projectsservice.getProject("YOUR_PROJECT_ID");

var currentprojectroles = securityservice.getContextRolesForUser(securityservice.getCurrentUser(), project.getContextId());



...cannot work. Invoking trackerService.getDataService() is only possible in Wiki Pages which has to be done with the Velocity language, no C# code can be used in Wiki Pages as far as I know. Besides it looks like Velocity and JavaScript code mixed up since in Velocity variables are set like this ...

Code: Select all

#set($dataService = trackerService.getDataService()) 



But I think you were on the right track nontheless...

vinayasheelag wrote:I am trying to get the roles of the polarion project.I tried with the following api's.
1.getContextRolesForUser(string user, string location)
2.hasCurrentUserPermission("com.polarion.persistence.object.project.delete", ProjectName);


I guess you found these methods in the JavaDoc of the SecurityWebService (a subclass of WebServiceFactory, the class containing basically all Polarion API methods)?

If so, note that the two methods/functions you have stated (getContextRolesForUser and hasCurrentUserPermission) cannot be invoked in a Polarion WikiPage, you have to do that in a Java Project or C# project, if with C# the API can be used (as I mentioned, I do not know yet).

Unfortunately I think there is only one API method left which you could try out and this getRolesForUser() however I do not know what the location parameter.

Of course, there are WikiPage equivalents (which you have to invoke with velocity) for the API methods and sometimes in WikiPages you have more methods at your disposal. The equivalent of the API's SecurityWebService class is the SecurityService class.

In a WikiPage, you would get the Security Service this way (note that $trackerService does not need to be initialized, $trackerService inherently is predefined in the WikiPages)...

Code: Select all

#set($securityService = $trackerService.getDataService().getSecurityService() );


Especially in terms of projects and users, the WikiPage classes offer more than the API so you could try this also out if C# is not a necessity for doing this or other constraints require that your implementation needs to be outside of Polarion WikiPages (like e.g. if you want to trigger your C# code with Jenkins).
---------------------------------------------------------------------------------------------------
Playing a good game is never lame. :D
Image

vinayasheelag
Posts: 5
Joined: Thu Jan 04, 2018 7:16 am

Re: Role of the user in the polarion project

Postby vinayasheelag » Mon Jan 08, 2018 2:22 pm

Hi ALMighty,

Thank you for the information.We are working on the standalone applications and are using c#.Cannot switch to java.

Any idea why the permission management is not returning true for project admin?Below is the api i have used.

For "SecurityService.hasCurrentUserPermission" for admin it is returning true but for project admin it is returning false.Where as in polarion web application "permission Management->Projects->Permissions to delete" have granted permissions to delete the project for "admin" and "Project admin".

Thank you
vinayasheela

ALMighty
Posts: 21
Joined: Wed Apr 27, 2016 10:34 am

Re: Role of the user in the polarion project

Postby ALMighty » Wed Jan 10, 2018 2:44 pm

vinayasheelag wrote:Hi ALMighty,

Thank you for the information.We are working on the standalone applications and are using c#.Cannot switch to java.

Any idea why the permission management is not returning true for project admin?Below is the api i have used.

For "SecurityService.hasCurrentUserPermission" for admin it is returning true but for project admin it is returning false.Where as in polarion web application "permission Management->Projects->Permissions to delete" have granted permissions to delete the project for "admin" and "Project admin".


Can you post the C# snippet in which you try to invoke hasCurrentUserPermission()? :)
Because if the functionally is not bugged/missing in C#, maybe you have a typo somewhere (the camelcasing of types and roles which is typical in Polarion is often a source of an error).
---------------------------------------------------------------------------------------------------
Playing a good game is never lame. :D
Image


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 2 guests