Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.collabnet.ce.webservices;
  
  import  com.collabnet.ce.soap50.webservices.ClientSoapStubFactory;
  
  import  com.collabnet.ce.soap50.webservices.rbac.IRbacAppSoap;
  import  com.collabnet.ce.soap50.webservices.rbac.RoleSoapList;
  import  com.collabnet.ce.soap50.webservices.rbac.RoleSoapRow;
  
Class to hold the role-related methods. Wraps a collabNetApp.
 
 public class RbacApp {
     private CollabNetApp collabNetApp;
     private IRbacAppSoap iras;

    
Constructs a new RbacApp.

Parameters:
collabNetApp a valid (logged-in) instance.
 
     public RbacApp(CollabNetApp collabNetApp) {
         this. = collabNetApp;
         this. = this.getIRbacAppSoap();
     }

    

Returns:
an instance of the Client Soap stub for RbacApp.wsdl.
 
     private IRbacAppSoap getIRbacAppSoap() {
         String soapURL = this.getUrl() + . +
             "RbacApp?wsdl";
         return (IRbacAppSoap) ClientSoapStubFactory.
             getSoapStub(IRbacAppSoap.classsoapURL);
     }

    

Parameters:
projectId
Returns:
roles associated with the given project
Throws:
RemoteException
 
     public Collection<StringgetRoles(String projectId
         throws RemoteException {
         this.checkValidSessionId();
         RoleSoapList rsList = this..getRoleList(this.getSessionId(), 
                                                     projectId);
         Collection<StringroleNames = new ArrayList<String>();
         for (RoleSoapRow rowrsList.getDataRows()) {
             roleNames.add(row.getTitle());
         }
         return roleNames;
     }

    
Add a set of roles with descriptions to the project. Only adds roles if they are not already present.

Parameters:
projectId
roles to add (only added if missing).
descriptions of roles to add (the nth description refers to the nth role)
Returns:
true if some roles were added, false if none were.
Throws:
RemoteException
 
     public boolean addRoles(String projectIdString[] roles
                             String[] descriptionsthrows RemoteException {
         this.checkValidSessionId();
         boolean rolesAdded = false;
         if (roles.length != descriptions.length) {
             throw new IllegalArgumentException("RbacApp: addRoles: the " +
                                                "number of role names and " +
                                                "descriptions  are not equal.");
         }
         Collection<StringexistingRoles = this.getRoles(projectId);
         for (int i = 0; i < roles.lengthi++) {
             if (!existingRoles.contains(roles[i])) {
                 this.addRole(projectIdroles[i], descriptions[i]);
                 rolesAdded = true;
             }
         }
         return rolesAdded;
     }

    
Add a single role to the project. Does not pre-check for existence.

Parameters:
projectId
role
description
Throws:
RemoteException
 
     public void addRole(String projectIdString roleString description
         throws RemoteException {
         this.checkValidSessionId();
         this..createRole(this.getSessionId(), projectIdrole
                             description);
    }

    
Grant the given role to the user.

Parameters:
projectId
roleName
username
Throws:
RemoteException
    public void grantRole(String projectIdString roleNameString username
        throws RemoteException {
        this.checkValidSessionId();
        String roleId = this.findRoleId(projectIdroleName);
        this..addUser(this.getSessionId(), roleIdusername);
    }

    
Find the roleId for the roleName.

Parameters:
projectId
roleName
Returns:
roleId
Throws:
RemoteException
    private String findRoleId(String projectIdString roleName
        throws RemoteException {
        this.checkValidSessionId();
        RoleSoapList rsList = this..getRoleList(this.getSessionId(), 
                                                    projectId);
        for (RoleSoapRow rowrsList.getDataRows()) {
            if (row.getTitle().equals(roleName)) {
                return row.getId();
            }
        }
        return null;
    }

    
Get a list of role the user has in the given project.

Parameters:
projectId
username
Throws:
RemoteException
    public Collection<StringgetUserRoles(String projectIdString username
        throws RemoteException {
        this.checkValidSessionId();
        Collection<Stringroles = new ArrayList<String>();
        RoleSoapList rsList = this..getUserRoleList(this.getSessionId(), 
                                                         projectIdusername);
        for (int i = 0; i < rsList.getDataRows().length; i++) {
            roles.add(rsList.getDataRows()[i].getTitle());
        }
        return roles;
    }


Below are wrapping functions, to make the code neater and in case, something changes. /
    
    private void checkValidSessionId() {
        this..checkValidSessionId();
    }
    
    private String getSessionId() {
        return this..getSessionId();
    }
    
    private String getUrl() {
        return this..getServerUrl();
    }
New to GrepCode? Check out our FAQ X