Page 1 of 1

list of the projects available for the logged in user

Posted: Mon Mar 12, 2018 5:15 am
by yashgolwara
After logging in the polarion , i am trying to get the list of the projects available for the logged in user

i am able to login and get the number of users

Code: Select all

      WebServiceFactory factory;
      TrackerWebService trackerService;
      SessionWebService sessionService;
      ProjectWebService projectService;
      
      factory = new WebServiceFactory("http://localhost/polarion/ws/services/");
      

      sessionService = factory.getSessionService();
      sessionService.logIn("userId", "password");
   

now after logging in , i am trying to get the list of users::

Code: Select all

   User[] users = projectService.getUsers();
      String uri = null;
      for (int i = 0; i < users.length; i++) {
         User user = users[i];
         if (user.getId().equals("admin")) {
            System.out.println("id.."+user.getId());
            System.out.println("name..."+user.getName());
            System.out.println("uri...."+user.getUri());// Value: uri....subterra:data-service:objects:/default/${User}admin
            //System.out.println(user.getDescription());

            uri = user.getUri();

         }
      }
      

After getting the user URI , when i am trying to get the project list :

Code: Select all


Project[] projs=projectService.getContainedProjects(uri);

       System.out.println(projs.length);
      
i am getting excpetion : Exception in thread "main" AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: com.polarion.alm.ws.WrongURIException: Expected a URI pointing to a object of interface com.polarion.alm.projects.model.IProjectGroup. Object found for subterra:data-service:objects:/default/${User}admin is a class com.polarion.alm.projects.internal.model.User.
 faultActor:
 faultNode:
 faultDetail:
   {http://xml.apache.org/axis/}stackTrace:com.polarion.alm.ws.WrongURIException: Expected a URI pointing to a object of interface com.polarion.alm.projects.model.IProjectGroup. Object found for subterra:data-service:objects:/default/${User}admin is a class com.polarion.alm.projects.internal.model.User.
   
   

now the issue is i am not getting , how to get the URI for IProjectGroup, as the URI i am getting for the USER interface is not working.


It would be really helpful if someone can provide me some insights on how to proceed further

Re: list of the projects available for the logged in user

Posted: Mon Jul 30, 2018 12:51 pm
by rpn
https://almdemo.polarion.com/polarion/s ... ng.String-

states that the uri-parameter for that function is the projectGroup-URI, not that of a user.
I just let the user do the login and then query the projectgroups over the tracker service. The returned groups reflect the permissions of the logged in user.