Class 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.
    • 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/password
        IOException
      • 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.
      • logoff

        public void logoff()
                    throws RemoteException
        Logoff for this user and invalidate the sessionId.
        Throws:
        RemoteException - If unexpected system error occurs
      • 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 group
        description - 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 created
        email - the mail id of the user
        fullName - the fullname of the user
        locale - 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 flag
        isRestrictedUser - boolean flag
        password - 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()