com.collabnet.ce.webservices
Class CollabNetApp

java.lang.Object
  extended by com.collabnet.ce.webservices.CollabNetApp

public class CollabNetApp
extends java.lang.Object

This class represents the connection to the CollabNet webservice. Since it contains login/logout data, other webservices will require an instance of it. This is written based on the 5.0 version of the soap services.


Nested Class Summary
static class CollabNetApp.CollabNetAppException
          Exception class to throw when something unexpected goes wrong.
 
Field Summary
static java.lang.String SOAP_SERVICE
           
 
Constructor Summary
CollabNetApp(java.lang.String url)
          Creates a new collabnet app
CollabNetApp(java.lang.String url, java.lang.String username)
          Creates a new CollabNetApp without a session.
CollabNetApp(java.lang.String url, java.lang.String username, java.lang.String password)
          Creates a new session to the server at the given url.
 
Method Summary
 void checkValidSessionId()
          Throws a CollabNetAppException if there is no current sessionId.
 java.util.Collection<java.lang.String> getAdmins(java.lang.String projectId)
          Get the usernames of all project admins.
 java.lang.String getApiVersion()
           
static java.lang.String getApiVersion(java.lang.String url)
           
 java.util.Map<java.lang.String,java.lang.String> getGroups()
          Get the list of all Groups on the system.
 java.util.Collection<java.lang.String> getGroupUsers(java.lang.String groupId)
          Return a collection of users that are active members of the group.
 java.lang.String getProjectId(java.lang.String projectName)
          Find the project that matches the given name, and return it's id.
 java.util.Collection<java.lang.String> getProjects()
          Return the list of project names.
 java.lang.String getServerUrl()
           
 java.lang.String getSessionId()
           
 java.util.Collection<java.lang.String> getUserGroups(java.lang.String username)
          Get a list of the groups the user belongs to.
 java.util.Collection<java.lang.String> getUsers(java.lang.String projectId)
          Get the usernames of all users.
 java.util.Collection<java.lang.String> getUsersInGroups(java.util.Collection<java.lang.String> groupNames)
          Given a list of group names, return a list of all unique users that are members of any of the groups.
 java.lang.String getVersion()
           
 boolean isUserMemberOfGroup(java.lang.String username, java.lang.String group)
          Is the user a member of the group?
 boolean isUserMemberOfProject(java.lang.String username, java.lang.String projectId)
          Is the user a member of the project?
 boolean isUsernameValid(java.lang.String username)
          Can the user can be found on the CollabNet server?
 boolean isUserProjectAdmin(java.lang.String username, java.lang.String projectId)
          Is the user a project admin?
 boolean isUserSuper(java.lang.String username)
           
 void loginWithToken(java.lang.String token)
          Login with a token.
 void logoff()
          Logoff for this user and invalidate the sessionId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOAP_SERVICE

public static java.lang.String SOAP_SERVICE
Constructor Detail

CollabNetApp

public CollabNetApp(java.lang.String url,
                    java.lang.String username,
                    java.lang.String password)
             throws java.rmi.RemoteException
Creates a new session to the server at the given url.

Parameters:
url - of the CollabNet server.
username - to login as.
password - to login with.
Throws:
java.rmi.RemoteException - if we fail to login with the username/password

CollabNetApp

public CollabNetApp(java.lang.String url,
                    java.lang.String username)
Creates a new CollabNetApp without a session.

Parameters:
url - of the CollabNet server.
username - to login as.

CollabNetApp

public CollabNetApp(java.lang.String url)
Creates a new collabnet app

Parameters:
url - url of the CollabNet server
Method Detail

getSessionId

public java.lang.String getSessionId()
Returns:
the session id.

getServerUrl

public java.lang.String getServerUrl()
Returns:
the url of the CollabNet server.

loginWithToken

public void loginWithToken(java.lang.String token)
                    throws java.rmi.RemoteException
Login with a token.

Parameters:
token - one-time token
Throws:
java.rmi.RemoteException

logoff

public void logoff()
            throws java.rmi.RemoteException
Logoff for this user and invalidate the sessionId.

Throws:
java.rmi.RemoteException

getApiVersion

public static java.lang.String getApiVersion(java.lang.String url)
                                      throws java.rmi.RemoteException
Parameters:
url - of the CollabNet server.
Returns:
the API version number string. This string is in the format ${Release major}.${Release minor}.${service pack}.${hot fix}
Throws:
java.rmi.RemoteException

getApiVersion

public java.lang.String getApiVersion()
                               throws java.rmi.RemoteException
Returns:
the api version number string for CTF.
Throws:
java.rmi.RemoteException - if the call fails for some unknown reason

getVersion

public java.lang.String getVersion()
                            throws java.rmi.RemoteException
Returns:
the version number string for SourceForge itself.
Throws:
java.rmi.RemoteException

getProjectId

public java.lang.String getProjectId(java.lang.String projectName)
                              throws java.rmi.RemoteException
Find the project that matches the given name, and return it's id.

Parameters:
projectName -
Returns:
id for this project (if a match is found), null otherwise.
Throws:
java.rmi.RemoteException

getProjects

public java.util.Collection<java.lang.String> getProjects()
                                                   throws java.rmi.RemoteException
Return the list of project names.

Returns:
a Collection of project names.
Throws:
java.rmi.RemoteException

isUsernameValid

public boolean isUsernameValid(java.lang.String username)
                        throws java.rmi.RemoteException
Can the user can be found on the CollabNet server?

Parameters:
username - to check.
Returns:
true, if the user is found, false otherwise.
Throws:
java.rmi.RemoteException

isUserMemberOfProject

public boolean isUserMemberOfProject(java.lang.String username,
                                     java.lang.String projectId)
                              throws java.rmi.RemoteException
Is the user a member of the project?

Parameters:
username - to check.
projectId -
Returns:
true, if the user is a member of the project, false otherwise.
Throws:
java.rmi.RemoteException

isUserMemberOfGroup

public boolean isUserMemberOfGroup(java.lang.String username,
                                   java.lang.String group)
                            throws java.rmi.RemoteException
Is the user a member of the group?

Parameters:
username - to check.
group -
Returns:
true, if the user is a member of the group, false otherwise.
Throws:
java.rmi.RemoteException

getUserGroups

public java.util.Collection<java.lang.String> getUserGroups(java.lang.String username)
                                                     throws java.rmi.RemoteException
Get a list of the groups the user belongs to. This will only work if logged in as the user in question, or if the logged in user has superuser permissions.

Parameters:
username -
Returns:
collection of group names.
Throws:
java.rmi.RemoteException

isUserProjectAdmin

public boolean isUserProjectAdmin(java.lang.String username,
                                  java.lang.String projectId)
                           throws java.rmi.RemoteException
Is the user a project admin?

Parameters:
username - to check.
projectId -
Returns:
true if the user is an admin of this project, false otherwise.
Throws:
java.rmi.RemoteException

isUserSuper

public boolean isUserSuper(java.lang.String username)
                    throws java.rmi.RemoteException
Parameters:
username -
Returns:
true if the user is a super user. False if not, or if the user is not found.
Throws:
java.rmi.RemoteException

getUsers

public java.util.Collection<java.lang.String> getUsers(java.lang.String projectId)
                                                throws java.rmi.RemoteException
Get the usernames of all users.

Parameters:
projectId - the project id
Returns:
collection of usernames
Throws:
java.rmi.RemoteException

getAdmins

public java.util.Collection<java.lang.String> getAdmins(java.lang.String projectId)
                                                 throws java.rmi.RemoteException
Get the usernames of all project admins.

Parameters:
projectId - the project id
Returns:
collection of admin usernames
Throws:
java.rmi.RemoteException

getGroups

public java.util.Map<java.lang.String,java.lang.String> getGroups()
                                                           throws java.rmi.RemoteException
Get the list of all Groups on the system. Can only be called by SuperUsers.

Returns:
a Map of all group name/ids.
Throws:
java.rmi.RemoteException

getUsersInGroups

public java.util.Collection<java.lang.String> getUsersInGroups(java.util.Collection<java.lang.String> groupNames)
                                                        throws java.rmi.RemoteException
Given a list of group names, return a list of all unique users that are members of any of the groups. If the group name is not found, no error is thrown. Only works for SuperUsers.

Parameters:
groupNames - collection of group names.
Returns:
a collection of user names.
Throws:
java.rmi.RemoteException

getGroupUsers

public java.util.Collection<java.lang.String> getGroupUsers(java.lang.String groupId)
                                                     throws java.rmi.RemoteException
Return a collection of users that are active members of the group.

Parameters:
groupId -
Returns:
active users (collection of usernames).
Throws:
java.rmi.RemoteException

checkValidSessionId

public void checkValidSessionId()
Throws a CollabNetAppException if there is no current sessionId.



Copyright © 2010. All Rights Reserved.