hi all
i'm trying to remove roles from user account via Java SDK, but not able to find available methods in SecurityWebService, ProjectWebService or SessionWebService to do it
is there any other way to do it?
thanks and regards
Kevin
remove roles from user via SDK
Re: remove roles from user via SDK
kevin1119 wrote:i'm trying to remove roles from user account via Java SDK, but not able to find available methods in SecurityWebService, ProjectWebService or SessionWebService to do it
Apart from the classes that are directly generated by the WebServiceFactory class, I checked the User and Project class (because there is at least the possibility to update users via API). However there is nothing in there that would fit your needs and I guess this was done intentionally by the Polarion Developers because not many things that can be done in the Admin Panel of a project can be done via the API.

Re: remove roles from user via SDK
thanks Almighty
that update method only applies to email/description. it can't even change user id.
it's a pain to update hundred of users manually
that update method only applies to email/description. it can't even change user id.
it's a pain to update hundred of users manually
-
- Posts: 20
- Joined: Thu Jan 18, 2018 11:02 am
- Location: Frauenauracher Str. 85, 91056 Erlangen
Re: remove roles from user via SDK
Hey Almighty and Kevin,
I'll post a code snippet of a servlet that managed to do the job. (changing roles of users, etc.)
As Almighty already mentioned, you can not change such settings for a user over the WebServices (!)
You have to do this over servlets (see SDK examples, there's one there I believe, as basis) and call methods from the Open SDK API (https://almdemo.polarion.com/polarion/s ... index.html).
In there, you have methods that can actually do the things an admin can do over his Admin Panel.
Exemplary code (its a draft stage, so might be clumsy) right here:
From Servlet.Java:
Important parts here are:
- Get projecserv = IProjectService (check API):
- Get secserv = ISecurityService (check API):
- Get current user and project, call removeContextRoleFromUser and give id, role, currentProjectID
- wrap in beginTx - commitTx (this can be tricky, best of luck)
- check results and hopefully be happy
Sorry if this was confusing. This is how we managed to execute code to adapt users.
I'll check in here again, just ask away if there's any confusion.
I'll post a code snippet of a servlet that managed to do the job. (changing roles of users, etc.)
As Almighty already mentioned, you can not change such settings for a user over the WebServices (!)
You have to do this over servlets (see SDK examples, there's one there I believe, as basis) and call methods from the Open SDK API (https://almdemo.polarion.com/polarion/s ... index.html).
In there, you have methods that can actually do the things an admin can do over his Admin Panel.
Exemplary code (its a draft stage, so might be clumsy) right here:
From Servlet.Java:
Code: Select all
some.debug.print("Removing access to project...");
currentuser = projecserv.getUser("some_user_id");
currentproject = projecserv.getProject("myproject_id");
some_debug_string += "Firstly, displaying global + context roles for user";
some_debug_string += secserv.getRolesForUser(userid,currentuser
.getContextId()).toString();
some_debug_string += "Now, removing project rights for test purposes.<br>";
transserv.beginTx();
secserv.removeContextRoleFromUser(userid, "project_user",
currentproject.getContextId());
try {
transserv.commitTx();
} catch (Exception e) {
e.printStackTrace();
}
some_debug_string += "Results: "+secserv.getContextRolesForUser(userid,
currentproject.getContextId()).toString() + "<br>";
Important parts here are:
- Get projecserv = IProjectService (check API):
Code: Select all
IProjectService projecserv = (IProjectService) PlatformContext.getPlatform()
.lookupService(IProjectService.class);
- Get secserv = ISecurityService (check API):
Code: Select all
ISecurityService secserv = (ISecurityService) PlatformContext.getPlatform()
.lookupService(ISecurityService.class);
- Get current user and project, call removeContextRoleFromUser and give id, role, currentProjectID
- wrap in beginTx - commitTx (this can be tricky, best of luck)
- check results and hopefully be happy
Sorry if this was confusing. This is how we managed to execute code to adapt users.
I'll check in here again, just ask away if there's any confusion.
Best Regards,
Patrick Claus
External service provider at Valeo Siemens eAutomotive GmbH
Frauenauracher Str. 85
91056 Erlangen, Germany
Mail Address
Patrick Claus
External service provider at Valeo Siemens eAutomotive GmbH
Frauenauracher Str. 85
91056 Erlangen, Germany
Mail Address
Re: remove roles from user via SDK
PatrickClaus wrote:Important parts here are:
- Get projecserv = IProjectService (check API):Code: Select all
IProjectService projecserv = (IProjectService) PlatformContext.getPlatform()
.lookupService(IProjectService.class);
- Get secserv = ISecurityService (check API):Code: Select all
ISecurityService secserv = (ISecurityService) PlatformContext.getPlatform()
.lookupService(ISecurityService.class);
- Get current user and project, call removeContextRoleFromUser and give id, role, currentProjectID
- wrap in beginTx - commitTx (this can be tricky, best of luck)
- check results and hopefully be happy
Very interesting. How did you manage to use the IProjectService and ISecurityService classes in a Java/JSP project although both classes are actually meant for usage in Wikipages or at least I have thought that)?

What librares do you use in your Java/JSP project in order to use the IProjectService and ISecurityService?

Re: remove roles from user via SDK
thanks Patrick and Almighty for providing some light in the tunnel
i'm trying to find out which lib contains those classes but no lucks.
i'm trying to find out which lib contains those classes but no lucks.
-
- Posts: 20
- Joined: Thu Jan 18, 2018 11:02 am
- Location: Frauenauracher Str. 85, 91056 Erlangen
Re: remove roles from user via SDK
Hello again,
IProjectService and ISecurityService were used from libs that were referenced from Polarion.
I think this was mentioned in one of the examples for the SDK Servlet as well, and which configuration is necessary for Eclipse (e.g.) to reference the dependencies / libraries.
As can be seen in the links from Open API SDK:
For ISecurityService:
https://almdemo.polarion.com/polarion/s ... rvice.html
it is com.polarion.platform.security
and for IProjectService:
https://almdemo.polarion.com/polarion/s ... rvice.html
it is com.polarion.alm.projects
So, we need:
- alm.projects
- platform.security
from libs: projects.jar and security.jar
found under: \Polarion\polarion\plugins\com.polarion.alm.projects_3.17.3
and \Polarion\polarion\plugins\com.polarion.platform_3.17.3
Plug those into dependencies, and
Import statement for Java-File in Eclipse:
and voila.
Of course, you need additional imports, depending on the functionality of the code and what you want to do inside of Polarion.
I really recommend looking at \polarion\SDK\examples\com.polarion.example.administration
as this example provides functionality for admin-user login and accessing general admin functionality. For the rest, its happy digging through the OpenApi JavaDoc, i'm afraid.
IProjectService and ISecurityService were used from libs that were referenced from Polarion.
I think this was mentioned in one of the examples for the SDK Servlet as well, and which configuration is necessary for Eclipse (e.g.) to reference the dependencies / libraries.
As can be seen in the links from Open API SDK:
For ISecurityService:
https://almdemo.polarion.com/polarion/s ... rvice.html
it is com.polarion.platform.security
and for IProjectService:
https://almdemo.polarion.com/polarion/s ... rvice.html
it is com.polarion.alm.projects
So, we need:
- alm.projects
- platform.security
from libs: projects.jar and security.jar
found under: \Polarion\polarion\plugins\com.polarion.alm.projects_3.17.3
and \Polarion\polarion\plugins\com.polarion.platform_3.17.3
Plug those into dependencies, and
Import statement for Java-File in Eclipse:
Code: Select all
package com.polarion.siemens.somePackage.servlet;
...
import com.polarion.platform.security.ISecurityService;
import com.polarion.alm.projects.IProjectService;
...
and voila.
Of course, you need additional imports, depending on the functionality of the code and what you want to do inside of Polarion.
I really recommend looking at \polarion\SDK\examples\com.polarion.example.administration
as this example provides functionality for admin-user login and accessing general admin functionality. For the rest, its happy digging through the OpenApi JavaDoc, i'm afraid.
Best Regards,
Patrick Claus
External service provider at Valeo Siemens eAutomotive GmbH
Frauenauracher Str. 85
91056 Erlangen, Germany
Mail Address
Patrick Claus
External service provider at Valeo Siemens eAutomotive GmbH
Frauenauracher Str. 85
91056 Erlangen, Germany
Mail Address
Re: remove roles from user via SDK
hi Patrick
i'm new to Polarion and trying to import the servlet exmple into eclipse.
for the sake of not missing any thing, i imported it and added the following jars to class path
platform-persistence.jar
platform.jar
projects.jar
tracker.jar
util.jar
that resolved all errors in the java file. but the plugin.xm keeps complaining about
Bundle 'com.polarion.alm.tracker' and 'com.polarion.portal.tomcat' can't be resovled
and unknow extension point: 'com.polarion.portal.tomcat.webapps'
i have the tracker lib in the class path of the MANIFEST.MF, but it fails
and i can't find the tomcat jar
do you know why ?
thanks and regards
K
i'm new to Polarion and trying to import the servlet exmple into eclipse.
for the sake of not missing any thing, i imported it and added the following jars to class path
platform-persistence.jar
platform.jar
projects.jar
tracker.jar
util.jar
that resolved all errors in the java file. but the plugin.xm keeps complaining about
Bundle 'com.polarion.alm.tracker' and 'com.polarion.portal.tomcat' can't be resovled
and unknow extension point: 'com.polarion.portal.tomcat.webapps'
i have the tracker lib in the class path of the MANIFEST.MF, but it fails
and i can't find the tomcat jar
do you know why ?
thanks and regards
K
Return to “Polarion Application Lifecycle Management (ALM)”
Who is online
Users browsing this forum: No registered users and 9 guests