It's all about the answers!

Ask a question

ServiceMethodInvocationError when fetching repository permissions for current user


Marko Tomljenovic (3163165) | asked May 03 '16, 4:56 p.m.
I am using following code to see what repository permissions the currently logged in user has.

  public RepositoryPermissions getRepositoryPermissions(final String userId) {
    if (!this.repo.loggedIn()) {
      throw new IllegalStateException("Not logged in repository: " + this.repo.getRepositoryURI());
    }

    IExternalUserRegistryManager userRegistryManager = this.repo.externalUserRegistryManager();
    try {
      // this calls throws an exception if the currently logged in user does not have JazzAdmins permissions and it is
      // tried to get the permissions for a different user than the currently logged in one.
      String[] groupsForUser = userRegistryManager.fetchGroupsForUser(userId, null);
      boolean isJazzGuest = false;
      boolean isJazzUser = false;
      boolean isJazzAdmin = false;
      boolean isJazzDWAdmin = false;
      boolean isJazzProjectAdmin = false;
      for (String group : groupsForUser) {
        switch (group) {
          case IPermissionService.JAZZ_ADMINS:
            isJazzAdmin = true;
            break;
          case IPermissionService.JAZZ_DW_ADMINS:
            isJazzDWAdmin = true;
            break;
          case IPermissionService.JAZZ_GUESTS:
            isJazzGuest = true;
            break;
          case IPermissionService.JAZZ_PROJECT_ADMINS:
            isJazzProjectAdmin = true;
            break;
          case IPermissionService.JAZZ_USERS:
            isJazzUser = true;
            break;

          default:
            throw new IllegalStateException("Unsupported group encountered! Please add to switch clause!");
        }
      }
      return new RepositoryPermissions(isJazzGuest, isJazzUser, isJazzDWAdmin, isJazzProjectAdmin, isJazzAdmin, userId);
    }
    catch (TeamRepositoryException e) { // NOSONAR
      return null;
    }


For my user account I always get the above mentioned exception with the following stacktrace.

com.ibm.team.repository.common.transport.ServiceMethodInvocationError: java.lang.NullPointerException: An error response was received from the Jazz Team Server. Status=500.  Message: null
at com.ibm.team.repository.transport.client.RemoteTeamService.getAppropriateException(RemoteTeamService.java:740)
at com.ibm.team.repository.transport.client.RemoteTeamService.executeMethod(RemoteTeamService.java:573)
at com.ibm.team.repository.transport.client.RemoteTeamService.invoke(RemoteTeamService.java:202)
at com.ibm.team.repository.transport.client.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:43)
at com.sun.proxy.$Proxy20.fetchGroupsForUser(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invokeServiceCall(ServiceInterfaceProxy.java:254)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invoke(ServiceInterfaceProxy.java:110)
at com.sun.proxy.$Proxy20.fetchGroupsForUser(Unknown Source)
at com.ibm.team.repository.client.internal.ExternalUserRegistryManager$8.run(ExternalUserRegistryManager.java:304)
at com.ibm.team.repository.client.internal.ExternalUserRegistryManager$8.run(ExternalUserRegistryManager.java:1)
at com.ibm.team.repository.client.internal.TeamRepository$3.run(TeamRepository.java:1327)
at com.ibm.team.repository.common.transport.CancelableCaller.call(CancelableCaller.java:79)
at com.ibm.team.repository.client.internal.TeamRepository.callCancelableService(TeamRepository.java:1322)
at com.ibm.team.repository.client.internal.TeamPlatformObject.callCancelableService(TeamPlatformObject.java:42)
at com.ibm.team.repository.client.internal.ExternalUserRegistryManager.callCancelableService(ExternalUserRegistryManager.java:393)
at com.ibm.team.repository.client.internal.ExternalUserRegistryManager.fetchGroupsForUser(ExternalUserRegistryManager.java:302)

A colleague of mine can run the code without any problems.
Any idea what the problem could be?

I am running RTC 5.0.2 that has an external user registry (LDAP).
In the repository where I want to get the permissions from my user has the permissions JazzProjectAdmin and JazzUser

Comments
Marko Tomljenovic commented May 04 '16, 4:13 p.m.
Small additional info. This does not happen on all servers in our landscape that I have access to.

Be the first one to answer this question!


Register or to post your answer.