Package com.collabnet.ce.webservices
Class CollabNetApp
- java.lang.Object
-
- com.collabnet.ce.webservices.CollabNetApp
-
public class CollabNetApp extends 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
Nested Classes Modifier and Type Class Description static class
CollabNetApp.CollabNetAppException
Exception class to throw when something unexpected goes wrong.
-
Field Summary
Fields Modifier and Type Field Description static String
SOAP_SERVICE
-
Constructor Summary
Constructors Constructor Description CollabNetApp(String url)
Creates a new collabnet appCollabNetApp(String url, String username)
Creates a new CollabNetApp without a session.CollabNetApp(String url, String username, String password)
Creates a new session to the server at the given url.CollabNetApp(String url, String username, String password, String sessionId)
Creates a new session to the server without actually authenticating, relying only on values passed in.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
areSslErrorsIgnored()
void
checkValidSessionId()
Throws a CollabNetAppException if there is no current sessionId.CTFGroup
createGroup(String fullName, String description)
Creates Group.String
createProject(String name, String title, String description)
Creates a new project and obtains its ID.CTFUser
createUser(String username, String email, String fullName, String locale, String timeZone, boolean isSuperUser, boolean isRestrictedUser, String password)
Creates new teamforge userstatic CollabNetApp
fromStapler(boolean connectionFactory, String url, String username, String password)
A databinding method from Stapler.CTFGroup
getGroupByTitle(String fullName)
Get the Group for given fullName.CTFList<CTFGroup>
getGroups()
Get the list of all Groups on the system.Collection<String>
getGroupUsers(String groupId)
Return a collection of users that are active members of the group.CTFUser
getMyself()
Returns the current user that's logged in.CTFUser
getMyselfData()
Returns the current user that's logged in.CTFProject
getProjectById(String projectId)
Returns project object for given projectIdCTFProject
getProjectByTitle(String title)
Returns project data for given project titleList<CTFProject>
getProjects()
Return a collection of projectsString
getServerUrl()
String
getSessionId()
CTFUser
getUser(String username)
Retrieves the user with the specified username, or null if no such user exists.String
getUsername()
Returns the user name that this connection is set up with.boolean
isUsernameValid(String username)
Can the user can be found on the CollabNet server?void
loginWithToken(String token)
Login with a token.void
logoff()
Logoff for this user and invalidate the sessionId.CTFFile
upload(File src)
Uploads a file.
-
-
-
Field Detail
-
SOAP_SERVICE
public static String SOAP_SERVICE
-
-
Constructor Detail
-
CollabNetApp
public CollabNetApp(String url, String username, String password) throws IOException
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:
RemoteException
- if we fail to login with the username/passwordIOException
-
CollabNetApp
public CollabNetApp(String url, String username, String password, String sessionId)
Creates a new session to the server without actually authenticating, relying only on values passed in.- Parameters:
url
- of the CollabNet server.username
- to login as.password
- to login with.sessionId
- the session id
-
CollabNetApp
public CollabNetApp(String url, String username)
Creates a new CollabNetApp without a session.- Parameters:
url
- of the CollabNet server.username
- to login as.
-
CollabNetApp
public CollabNetApp(String url)
Creates a new collabnet app- Parameters:
url
- url of the CollabNet server
-
-
Method Detail
-
getUsername
public String getUsername()
Returns the user name that this connection is set up with.
-
getSessionId
public String getSessionId()
- Returns:
- the session id.
-
getServerUrl
public String getServerUrl()
- Returns:
- the url of the CollabNet server.
-
loginWithToken
public void loginWithToken(String token) throws IOException, MalformedURLException, RemoteException
Login with a token.- Parameters:
token
- one-time token- Throws:
IOException
- if any problems occurs reading/writing fileMalformedURLException
- if TeamForge URL is invalidRemoteException
- If unexpected system error occurs
-
logoff
public void logoff() throws RemoteException
Logoff for this user and invalidate the sessionId.- Throws:
RemoteException
- If unexpected system error occurs
-
upload
public CTFFile upload(File src) throws IOException
Uploads a file. The returned file object can be then used as an input to methods likeCTFRelease.addFile(String, String, CTFFile)
.- Parameters:
src
- The file to upload- Returns:
- CTFFile object
- Throws:
IOException
- if any problems occurs reading/writing file
-
isUsernameValid
public boolean isUsernameValid(String username) throws IOException
Can the user can be found on the CollabNet server?- Parameters:
username
- to check.- Returns:
- true, if the user is found, false otherwise.
- Throws:
IOException
- if any problems occurs reading/writing file
-
getGroups
public CTFList<CTFGroup> getGroups() throws IOException
Get the list of all Groups on the system. Can only be called by SuperUsers.- Returns:
- a Map of all group name/ids.
- Throws:
IOException
- if any problems occurs reading/writing file
-
getGroupByTitle
public CTFGroup getGroupByTitle(String fullName) throws IOException
Get the Group for given fullName.- Parameters:
fullName
- the fullName of group- Returns:
- a CTFGroup object
- Throws:
IOException
- if any problems occurs reading/writing file
-
createGroup
public CTFGroup createGroup(String fullName, String description) throws IOException
Creates Group.- Parameters:
fullName
- the fullName of groupdescription
- the description of group- Returns:
- Group object.
- Throws:
IOException
- if any problems occurs reading/writing file
-
createProject
public String createProject(String name, String title, String description) throws IOException
Creates a new project and obtains its ID.- Parameters:
name
- ID of the project. Used as a token in URL. Can be null, in which case inferred from the title parameter.title
- Human readable title of the project that can include whitespace and so on.description
- Longer human readable description of the project.- Returns:
- project id
- Throws:
IOException
- if any problems occurs reading/writing file
-
getGroupUsers
public Collection<String> getGroupUsers(String groupId) throws IOException
Return a collection of users that are active members of the group.- Parameters:
groupId
- groupId- Returns:
- active users (collection of usernames).
- Throws:
IOException
- if any problems occurs reading/writing file
-
checkValidSessionId
public void checkValidSessionId()
Throws a CollabNetAppException if there is no current sessionId.
-
getProjectById
public CTFProject getProjectById(String projectId) throws IOException
Returns project object for given projectId- Parameters:
projectId
- the teamforge project id or path- Returns:
- project object
- Throws:
IOException
- if any problems occurs reading project data
-
getProjects
public List<CTFProject> getProjects() throws IOException
Return a collection of projects- Returns:
- list of projects
- Throws:
IOException
- if any problems occurs reading projects data
-
getProjectByTitle
public CTFProject getProjectByTitle(String title) throws IOException
Returns project data for given project title- Parameters:
title
- project title- Returns:
- project data
- Throws:
IOException
- if any problems occurs reading project data
-
getMyself
public CTFUser getMyself() throws IOException
Returns the current user that's logged in.- Returns:
- current user data
- Throws:
IOException
- if any problems occurs reading user data
-
getMyselfData
public CTFUser getMyselfData() throws IOException
Returns the current user that's logged in.- Returns:
- current user data
- Throws:
IOException
- if any problems occurs reading user data
-
getUser
public CTFUser getUser(String username) throws IOException
Retrieves the user with the specified username, or null if no such user exists.- Parameters:
username
- the username for which the user data to be retrived- Returns:
- user data for specified username
- Throws:
IOException
- if any problems occurs reading user data
-
createUser
public CTFUser createUser(String username, String email, String fullName, String locale, String timeZone, boolean isSuperUser, boolean isRestrictedUser, String password) throws IOException
Creates new teamforge user- Parameters:
username
- the name of the user to be createdemail
- the mail id of the userfullName
- the fullname of the userlocale
- Locale of the new user (currently supported locales are "en" for English, "ja" for Japanese).timeZone
- User's time zone. The ID for a TimeZone, either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "GMT-8:00".isSuperUser
- boolean flagisRestrictedUser
- boolean flagpassword
- the password of the user- Returns:
- user data
- Throws:
IOException
- if any problems occurs reading/writing user data
-
fromStapler
public static CollabNetApp fromStapler(@QueryParameter boolean connectionFactory, @QueryParameter @RelativePath("connectionFactory") String url, @QueryParameter @RelativePath("connectionFactory") String username, @QueryParameter @RelativePath("connectionFactory") String password)
A databinding method from Stapler.- Parameters:
connectionFactory
- relates to the checkbox to override the global authentication parameters
-
areSslErrorsIgnored
public static boolean areSslErrorsIgnored()
-
-