FileDocCategorySizeDatePackage
StarTeamList.javaAPI DocApache Ant 1.7012287Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.optional.starteam

StarTeamList

public class StarTeamList extends TreeBasedTask
Produces a listing of the contents of the StarTeam repository at the specified view and StarTeamFolder. Created: Tue Dec 25 06:51:14 2001
version
1.0
ant.task
name="stlist" category="scm"

Fields Summary
private boolean
listUncontrolled
private static final SimpleDateFormat
SDF
private static final String
BLANK_STRING
Constructors Summary
Methods Summary
private static java.lang.Stringblanks(int len)


         
        StringBuffer b = new StringBuffer();
        for (int i = 0; i < len; i++) {
            b.append(' ");
        }
        return b.toString();
    
protected com.starbase.starteam.ViewcreateSnapshotView(com.starbase.starteam.View raw)
Override of base-class abstract function creates an appropriately configured view for checkoutlists - either the current view or a view from this.label.

param
raw the unconfigured View
return
the snapshot View appropriately configured.


        int labelID = getLabelID(raw);

        // if a label has been supplied, use it to configure the view
        // otherwise use current view
        if (labelID >= 0) {
            return new View(raw, ViewConfiguration.createFromLabel(labelID));
        }
        // if a date has been supplied use a view configured to the date.
        View view = getViewConfiguredByDate(raw);
        if (view != null) {
            return view;
        // otherwise, use this view configured as the tip.
        } else {
            return new View(raw, ViewConfiguration.createTip());
        }
    
protected voidlist(com.starbase.starteam.File reposFile, java.io.File localFile)
Log a repositary file and it's corresponding local file.

param
reposFile the repositary file to log
param
localFile the corresponding local file
throws
IOException on error getting information from files


                                       
         
              
        StringBuffer b = new StringBuffer();
        int status = reposFile.getStatus();
        java.util.Date displayDate = null;
        if (status == Status.NEW) {
            displayDate = new java.util.Date(localFile.lastModified());
        } else {
            displayDate = reposFile.getModifiedTime().createDate();
        }
        b.append(pad(Status.name(status), 12)).append(' ");
        b.append(pad(getUserName(reposFile.getLocker()), 20))
                .append(' ")
                .append(SDF.format(displayDate))
                .append(rpad(String.valueOf(reposFile.getSize()), 9))
                .append(' ")
                .append(reposFile.getName());

        log(b.toString());
    
protected voidlogOperationDescription(com.starbase.starteam.Folder starteamrootFolder, java.io.File targetrootFolder)
extenders should emit to the log an entry describing the parameters that will be used by this operation.

param
starteamrootFolder root folder in StarTeam for the operation
param
targetrootFolder root local folder for the operation (whether specified by the user or not.

        log((this.isRecursive() ? "Recursive" : "Non-recursive")
            + " Listing of: " + starteamrootFolder.getFolderHierarchy());

        log("Listing against local folder"
            + (null == getRootLocalFolder() ? " (default): " : ": ")
            + targetrootFolder.getAbsolutePath(),
                    Project.MSG_INFO);
        logLabel();
        logAsOfDate();
        logIncludes();
        logExcludes();


    
protected static java.lang.Stringpad(java.lang.String s, int padlen)
Return a padded string.

param
s the string to pad
param
padlen the size of the padded string
return
the padded string

        return (s + BLANK_STRING).substring(0, padlen);
    
protected static java.lang.Stringrpad(java.lang.String s, int padlen)
Return a right padded string.

param
s the string to pad
param
padlen the size of the padded string
return
the padded string

        s = BLANK_STRING + s;
        return s.substring(s.length() - padlen);
    
public voidsetAsOfDate(java.lang.String asOfDateParam)
List files, dates, and statuses as of this date; optional. If not specified, the most recent version of each file will be listed.

param
asOfDateParam the date as of which the listing to be made
since
Ant 1.6

        _setAsOfDate(asOfDateParam);
    
public voidsetAsOfDateFormat(java.lang.String asOfDateFormat)
Date Format with which asOfDate parameter to be parsed; optional. Must be a SimpleDateFormat compatible string. If not specified, and asOfDateParam is specified, parse will use ISO8601 datetime and date formats.

param
asOfDateFormat the SimpleDateFormat-compatible format string
since
Ant 1.6

        _setAsOfDateFormat(asOfDateFormat);
    
public voidsetLabel(java.lang.String label)
List files, dates, and statuses as of this label; optional. The label must exist in starteam or an exception will be thrown. If not specified, the most recent version of each file will be listed.

param
label the label to be listed

                                                   
        
        _setLabel(label);
    
protected voidtestPreconditions()
Required base-class abstract function implementation checks for incompatible parameters.

exception
BuildException thrown on incompatible params specified

        if (null != getLabel() && null != getAsOfDate()) {
            throw new BuildException(
                "Both label and asOfDate specified.  "
                + "Unable to process request.");
        }
    
protected voidvisit(com.starbase.starteam.Folder starteamFolder, java.io.File targetFolder)
Implements base-class abstract function to perform the checkout operation on the files in each folder of the tree.

param
starteamFolder the StarTeam folder from which files to be checked out
param
targetFolder the local mapping of rootStarteamFolder
throws
BuildException on error

        try {
            if (null != getRootLocalFolder()) {
                starteamFolder.setAlternatePathFragment(
                    targetFolder.getAbsolutePath());

            }
            Folder[] subFolders = starteamFolder.getSubFolders();
            Item[] files = starteamFolder.getItems(getTypeNames().FILE);

            UnmatchedFileMap ufm =
                new UnmatchedListingMap().init(
                    targetFolder.getAbsoluteFile(), starteamFolder);

            log("");
            log("Listing StarTeam folder "
                + starteamFolder.getFolderHierarchy());
            log(" against local folder " + targetFolder.getAbsolutePath());


            // For all Files in this folder, we need to check
            // if there have been modifications.

            for (int i = 0; i < files.length; i++) {
                File eachFile = (File) files[i];
                String filename = eachFile.getName();
                java.io.File localFile =
                        new java.io.File(targetFolder, filename);

                ufm.removeControlledItem(localFile);

                // If the file doesn't pass the include/exclude tests, skip it.
                if (!shouldProcess(filename)) {
                    continue;
                }

                list(eachFile, localFile);
            }


            // Now we recursively call this method on all sub folders in this
            // folder unless recursive attribute is off.
            for (int i = 0; i < subFolders.length; i++) {
                java.io.File targetSubfolder =
                        new java.io.File(targetFolder, subFolders[i].getName());
                ufm.removeControlledItem(targetSubfolder);
                if (isRecursive()) {
                    visit(subFolders[i], targetSubfolder);
                }
            }
            if (this.listUncontrolled) {
                ufm.processUncontrolledItems();
            }

        } catch (IOException e) {
            throw new BuildException(e);
        }