FileDocCategorySizeDatePackage
StarTeamTask.javaAPI DocApache Ant 1.7010533Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.taskdefs.optional.starteam

StarTeamTask

public abstract class StarTeamTask extends org.apache.tools.ant.Task
Common super class for all StarTeam tasks. At this level of the hierarchy we are concerned only with obtaining a connection to the StarTeam server. The subclass TreeBasedTask, also abstract defines the tree-walking behavior common to many subtasks.
see
TreeBasedTask
version
1.1

Fields Summary
private String
userName
The username of the connection
private String
password
The username of the connection
private String
servername
name of Starteam server to connect to
private String
serverport
port of Starteam server to connect to
private String
projectname
name of Starteam project to connect to
private String
viewname
name of Starteam view to connect to
private com.starbase.starteam.Server
server
The starteam server through which all activities will be done.
Constructors Summary
Methods Summary
protected abstract com.starbase.starteam.ViewcreateSnapshotView(com.starbase.starteam.View rawview)
Derived classes must override createSnapshotView defining the kind of configured view appropriate to its task.

param
rawview the unconfigured View
return
the snapshot View appropriately configured.
throws
BuildException on error

protected final voiddisconnectFromServer()
disconnects from the StarTeam server. Should be called from the finally clause of every StarTeamTask-based execute method.

        if (null != this.server) {
            this.server.disconnect();
            log("successful disconnect from StarTeam Server " + servername,
                Project.MSG_VERBOSE);
        }
    
public final java.lang.StringgetPassword()
returns the password used for login

return
the password used for login

        return this.password;
    
public final java.lang.StringgetProjectname()
returns the name of the StarTeam project to be acted on

return
the name of the StarTeam project to be acted on
see
#getURL()

        return this.projectname;
    
protected final com.starbase.starteam.ServergetServer()
returns a reference to the server which may be used for informational purposes by subclasses.

return
a reference to the server

        return this.server;
    
public final java.lang.StringgetServername()
returns the name of the StarTeamServer

return
the name of the StarTeam server
see
#getURL()

        return this.servername;
    
public final java.lang.StringgetServerport()
returns the port number of the StarTeam connection

return
the port number of the StarTeam connection
see
#getURL()

        return this.serverport;
    
protected final com.starbase.starteam.TypeNamesgetTypeNames()
returns a list of TypeNames known to the server.

return
a reference to the server's TypeNames

        return this.server.getTypeNames();
    
public final java.lang.StringgetURL()
a convenience method which returns the whole StarTeam connection information as a single URL string of

return
a String of the form "servername:portnum/project/view"
see
#getServername()
see
#getServerport()
see
#getProjectname()
see
#getViewname()

        return this.servername + ":"
            + this.serverport + "/"
            + this.projectname + "/"
            + ((null == this.viewname) ? "" : this.viewname);
    
public final java.lang.StringgetUserName()
returns the name of the StarTeam user

return
the name of the StarTeam user

        return this.userName;
    
protected final java.lang.StringgetUserName(int userID)
Returns the name of the user with the supplied ID or a blank string if user not found.

param
userID a user's ID
return
the name of the user with ID userID

        User u = this.server.getUser(userID);
        if (null == u) {
            return "";
        }
        return u.getName();
    
protected final java.lang.StringgetViewURL()
returns an URL string useful for interacting with many StarTeamFinder methods.

return
the URL string for this task.

        return getUserName() + ":" + getPassword() + "@" + getURL();
    
public final java.lang.StringgetViewname()
returns the name of the StarTeam view to be acted on

return
the name of the StarTeam view to be acted on
see
#getURL()

        return this.viewname;
    
private voidlogStarteamVersion()


       
        log("StarTeam version: "
            + BuildNumber.getDisplayString(), Project.MSG_VERBOSE);
    
protected com.starbase.starteam.ViewopenView()
All subclasses will call on this method to open the view needed for processing. This method also saves a reference to the Server that may be accessed for information at various points in the process.

return
the View that will be used for processing.
see
#createSnapshotView(View)
see
#getServer()
throws
BuildException on error


        logStarteamVersion();
        View view = null;
        try {
            view = StarTeamFinder.openView(getViewURL());
        } catch (Exception e) {
            throw new BuildException(
                "Failed to connect to " + getURL(), e);
        }

        if (null == view) {
            throw new BuildException("Cannot find view" + getURL()
                + " in repository()");
        }

        View snapshot = createSnapshotView(view);
        log("Connected to StarTeam view " + getURL(),
            Project.MSG_VERBOSE);
        this.server = snapshot.getServer();
        return snapshot;
    
public final voidsetPassword(java.lang.String password)
set the password to be used for login; required.

param
password the password to be used for login

        this.password = password;
    
public final voidsetProjectname(java.lang.String projectname)
set the name of the StarTeam project to be acted on; required if URL is not set.

param
projectname the name of the StarTeam project to be acted on
see
#setURL(String)

        this.projectname = projectname;
    
public final voidsetServername(java.lang.String servername)
Set the name of StarTeamServer; required if URL is not set.

param
servername a String value
see
#setURL(String)

        this.servername = servername;
    
public final voidsetServerport(java.lang.String serverport)
set the port number of the StarTeam connection; required if URL is not set.

param
serverport port number to be set
see
#setURL(String)

        this.serverport = serverport;
    
public final voidsetURL(java.lang.String url)
Set the server name, server port, project name and project folder in one shot; optional, but the server connection must be specified somehow.

param
url a String of the form "servername:portnum/project/view"
see
#setServername(String)
see
#setServerport(String)
see
#setProjectname(String)
see
#setViewname(String)

        StringTokenizer t = new StringTokenizer(url, "/");
        if (t.hasMoreTokens()) {
            String unpw = t.nextToken();
            int pos = unpw.indexOf(":");
            if (pos > 0) {
                this.servername = unpw.substring(0, pos);
                this.serverport = unpw.substring(pos + 1);
                if (t.hasMoreTokens()) {
                    this.projectname = t.nextToken();
                    if (t.hasMoreTokens()) {
                        this.viewname = t.nextToken();
                    }
                }
            }
        }
    
public final voidsetUserName(java.lang.String userName)
set the name of the StarTeam user, needed for the connection

param
userName name of the user to be logged in

        this.userName = userName;
    
public final voidsetViewname(java.lang.String viewname)
set the name of the StarTeam view to be acted on; required if URL is not set.

param
viewname the name of the StarTeam view to be acted on
see
#setURL(String)

        this.viewname = viewname;