Browse Source

Checkstyle

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274797 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
e612a58418
6 changed files with 265 additions and 303 deletions
  1. +43
    -48
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckin.java
  2. +87
    -100
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckout.java
  3. +23
    -26
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamLabel.java
  4. +22
    -27
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamList.java
  5. +12
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamTask.java
  6. +78
    -89
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java

+ 43
- 48
src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckin.java View File

@@ -63,7 +63,7 @@ import java.util.Enumeration;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;


/** /**
* Checks files into a StarTeam project.
* Checks files into a StarTeam project.
* Optionally adds files and in the local tree that * Optionally adds files and in the local tree that
* are not managed by the repository to its control. * are not managed by the repository to its control.
* Created: Sat Dec 15 20:26:07 2001 * Created: Sat Dec 15 20:26:07 2001
@@ -128,7 +128,7 @@ public class StarTeamCheckin extends TreeBasedTask {
} }


/** /**
* if true, any files or folders NOT in StarTeam will be
* if true, any files or folders NOT in StarTeam will be
* added to the repository. Defaults to "false". * added to the repository. Defaults to "false".
* @param addUncontrolled Value to assign to addUncontrolled. * @param addUncontrolled Value to assign to addUncontrolled.
*/ */
@@ -147,7 +147,7 @@ public class StarTeamCheckin extends TreeBasedTask {
/** /**
* Set to do an unlocked checkout; optional, default is false; * Set to do an unlocked checkout; optional, default is false;
* If true, file will be unlocked so that other users may * If true, file will be unlocked so that other users may
* change it. If false, lock status will not change.
* change it. If false, lock status will not change.
* @param v true means do an unlocked checkout * @param v true means do an unlocked checkout
* false means leave status alone. * false means leave status alone.
*/ */
@@ -175,45 +175,44 @@ public class StarTeamCheckin extends TreeBasedTask {
* Implements base-class abstract function to define tests for * Implements base-class abstract function to define tests for
* any preconditons required by the task. * any preconditons required by the task.
* *
* @exception BuildException thrown if both rootLocalFolder
* @exception BuildException thrown if both rootLocalFolder
* and viewRootLocalFolder are defined * and viewRootLocalFolder are defined
*/ */
protected void testPreconditions() throws BuildException { protected void testPreconditions() throws BuildException {
} }
/** /**
* Implements base-class abstract function to emit to the log an
* Implements base-class abstract function to emit to the log an
* entry describing the parameters that will be used by this operation. * entry describing the parameters that will be used by this operation.
* *
* @param starteamrootFolder * @param starteamrootFolder
* root folder in StarTeam for the operation * root folder in StarTeam for the operation
* @param targetrootFolder * @param targetrootFolder
* root local folder for the operation
* root local folder for the operation
* (whether specified by the user or not). * (whether specified by the user or not).
*/ */
protected void logOperationDescription( protected void logOperationDescription(
Folder starteamrootFolder, java.io.File targetrootFolder)
{
Folder starteamrootFolder, java.io.File targetrootFolder) {
log((this.isRecursive() ? "Recursive" : "Non-recursive") log((this.isRecursive() ? "Recursive" : "Non-recursive")
+" Checkin from"
+ (null == getRootLocalFolder() ? " (default): " : ": ")
+ " Checkin from"
+ (null == getRootLocalFolder() ? " (default): " : ": ")
+ targetrootFolder.getAbsolutePath()); + targetrootFolder.getAbsolutePath());
log("Checking in to: " + starteamrootFolder.getFolderHierarchy()); log("Checking in to: " + starteamrootFolder.getFolderHierarchy());
logIncludes(); logIncludes();
logExcludes(); logExcludes();


if (this.lockStatus == Item.LockType.UNLOCKED) { if (this.lockStatus == Item.LockType.UNLOCKED) {
log(" Items will be checked in unlocked."); log(" Items will be checked in unlocked.");
}
else {
} else {
log(" Items will be checked in with no change in lock status."); log(" Items will be checked in with no change in lock status.");
} }


if (this.isForced()) { if (this.isForced()) {
log(" Items will be checked in in accordance with repository status and regardless of lock status.");
}
else {
log(" Items will be checked in regardless of repository status only if locked." );
log(" Items will be checked in in accordance with repository "
+ "status and regardless of lock status.");
} else {
log(" Items will be checked in regardless of repository status "
+ "only if locked.");
} }




@@ -225,12 +224,11 @@ public class StarTeamCheckin extends TreeBasedTask {
* *
* @param starteamFolder the StarTeam folder to which files * @param starteamFolder the StarTeam folder to which files
* will be checked in * will be checked in
* @param localFolder local folder from which files will be checked in
* @param targetFolder local folder from which files will be checked in
* @exception BuildException if any error occurs * @exception BuildException if any error occurs
*/ */
protected void visit(Folder starteamFolder, java.io.File targetFolder) protected void visit(Folder starteamFolder, java.io.File targetFolder)
throws BuildException
{
throws BuildException {
try { try {
if (null != getRootLocalFolder()) { if (null != getRootLocalFolder()) {
starteamFolder.setAlternatePathFragment( starteamFolder.setAlternatePathFragment(
@@ -239,20 +237,20 @@ public class StarTeamCheckin extends TreeBasedTask {


Folder[] foldersList = starteamFolder.getSubFolders(); Folder[] foldersList = starteamFolder.getSubFolders();
Item[] stFiles = starteamFolder.getItems(getTypeNames().FILE); Item[] stFiles = starteamFolder.getItems(getTypeNames().FILE);
// note, it's important to scan the items BEFORE we make the // note, it's important to scan the items BEFORE we make the
// UnmatchedFileMap because that creates a bunch of NEW // UnmatchedFileMap because that creates a bunch of NEW
// folders and files (unattached to repository) and we // folders and files (unattached to repository) and we
// don't want to include those in our traversal. // don't want to include those in our traversal.


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




for (int i = 0, size = foldersList.length; i < size; i++) { for (int i = 0, size = foldersList.length; i < size; i++) {
Folder stFolder = foldersList[i]; Folder stFolder = foldersList[i];
java.io.File subfolder =
java.io.File subfolder =
new java.io.File(targetFolder, stFolder.getName()); new java.io.File(targetFolder, stFolder.getName());


ufm.removeControlledItem(subfolder); ufm.removeControlledItem(subfolder);
@@ -262,12 +260,12 @@ public class StarTeamCheckin extends TreeBasedTask {
} }
} }


for (int i = 0, size = stFiles.length; i < size; i++) { for (int i = 0, size = stFiles.length; i < size; i++) {
com.starbase.starteam.File stFile =
com.starbase.starteam.File stFile =
(com.starbase.starteam.File) stFiles[i]; (com.starbase.starteam.File) stFiles[i];
processFile(stFile); processFile(stFile);
ufm.removeControlledItem( ufm.removeControlledItem(
new java.io.File(targetFolder, stFile.getName())); new java.io.File(targetFolder, stFile.getName()));
} }
@@ -284,13 +282,12 @@ public class StarTeamCheckin extends TreeBasedTask {


/** /**
* provides a string showing from and to full paths for logging * provides a string showing from and to full paths for logging
*
*
* @param remotefile the Star Team file being processed. * @param remotefile the Star Team file being processed.
*
*
* @return a string showing from and to full paths * @return a string showing from and to full paths
*/ */
private String describeCheckin(com.starbase.starteam.File remotefile)
{
private String describeCheckin(com.starbase.starteam.File remotefile) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append(remotefile.getFullName()) sb.append(remotefile.getFullName())
.append(" --> ") .append(" --> ")
@@ -328,23 +325,21 @@ public class StarTeamCheckin extends TreeBasedTask {


if (fileStatus == Status.MODIFIED) { if (fileStatus == Status.MODIFIED) {
log("Checking in: " + describeCheckin(eachFile)); log("Checking in: " + describeCheckin(eachFile));
}
else if (fileStatus == Status.MISSING) {
} else if (fileStatus == Status.MISSING) {
log("Local file missing: " + describeCheckin(eachFile)); log("Local file missing: " + describeCheckin(eachFile));
checkin = false; checkin = false;
}
else {
} else {
if (isForced()) { if (isForced()) {
log("Forced checkin of " + describeCheckin(eachFile) +
" over status " + Status.name(fileStatus));
log("Forced checkin of " + describeCheckin(eachFile)
+ " over status " + Status.name(fileStatus));
} else { } else {
log("Skipping: " + getFullRepositoryPath(eachFile) +
" - status: " + Status.name(fileStatus));
log("Skipping: " + getFullRepositoryPath(eachFile)
+ " - status: " + Status.name(fileStatus));
checkin = false; checkin = false;
} }
} }
if (checkin) { if (checkin) {
eachFile.checkin(this.comment, this.lockStatus,
eachFile.checkin(this.comment, this.lockStatus,
this.isForced(), true, true); this.isForced(), true, true);
} }
} }
@@ -357,10 +352,10 @@ public class StarTeamCheckin extends TreeBasedTask {
return StarTeamCheckin.this.addUncontrolled; return StarTeamCheckin.this.addUncontrolled;
} }


/** /**
* This override adds all its members to the repository. It is assumed
* that this method will not be called until all the items in the
* This override adds all its members to the repository. It is assumed
* that this method will not be called until all the items in the
* corresponding folder have been processed, and that the internal map * corresponding folder have been processed, and that the internal map
* will contain only uncontrolled items. * will contain only uncontrolled items.
*/ */
@@ -371,26 +366,26 @@ public class StarTeamCheckin extends TreeBasedTask {
java.io.File local = (java.io.File) e.nextElement(); java.io.File local = (java.io.File) e.nextElement();
Item remoteItem = (Item) this.get(local); Item remoteItem = (Item) this.get(local);
remoteItem.update(); remoteItem.update();
// once we find a folder that isn't in the repository,
// once we find a folder that isn't in the repository,
// we know we can add it. // we know we can add it.
if (local.isDirectory()) { if (local.isDirectory()) {
Folder folder = (Folder) remoteItem; Folder folder = (Folder) remoteItem;
log("Added uncontrolled folder "
log("Added uncontrolled folder "
+ folder.getFolderHierarchy() + folder.getFolderHierarchy()
+ " from " + local.getAbsoluteFile()); + " from " + local.getAbsoluteFile());
if (isRecursive()) { if (isRecursive()) {
UnmatchedFileMap submap =
UnmatchedFileMap submap =
new CheckinMap().init(local, folder); new CheckinMap().init(local, folder);
submap.processUncontrolledItems(); submap.processUncontrolledItems();
} }
} else { } else {
com.starbase.starteam.File remoteFile = com.starbase.starteam.File remoteFile =
(com.starbase.starteam.File) remoteItem; (com.starbase.starteam.File) remoteItem;
log("Added uncontrolled file "
log("Added uncontrolled file "
+ TreeBasedTask.getFullRepositoryPath(remoteFile) + TreeBasedTask.getFullRepositoryPath(remoteFile)
+ " from " + local.getAbsoluteFile()); + " from " + local.getAbsoluteFile());
} }
} }
} }


+ 87
- 100
src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckout.java View File

@@ -59,6 +59,7 @@ import com.starbase.starteam.Status;
import com.starbase.starteam.View; import com.starbase.starteam.View;
import com.starbase.starteam.ViewConfiguration; import com.starbase.starteam.ViewConfiguration;
import java.io.IOException; import java.io.IOException;
import java.io.File;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
@@ -100,7 +101,7 @@ public class StarTeamCheckout extends TreeBasedTask {


/** /**
* holder for the deleteUncontrolled attribute. If true, * holder for the deleteUncontrolled attribute. If true,
* (default) local non-binary files will be checked out using the local
* (default) local non-binary files will be checked out using the local
* platform's EOL convention. If false, checkouts will preserve the * platform's EOL convention. If false, checkouts will preserve the
* server's EOL convention. * server's EOL convention.
*/ */
@@ -134,10 +135,10 @@ public class StarTeamCheckout extends TreeBasedTask {
public void setConvertEOL(boolean value) { public void setConvertEOL(boolean value) {
this.convertEOL = value; this.convertEOL = value;
} }
/** /**
* Sets the label StarTeam is to use for checkout; defaults to the most recent file. * Sets the label StarTeam is to use for checkout; defaults to the most recent file.
* The label must exist in starteam or an exception will be thrown.
* The label must exist in starteam or an exception will be thrown.
* @param label the label to be used * @param label the label to be used
*/ */
public void setLabel(String label) { public void setLabel(String label) {
@@ -156,7 +157,7 @@ public class StarTeamCheckout extends TreeBasedTask {
private int lockStatus = Item.LockType.UNCHANGED; private int lockStatus = Item.LockType.UNCHANGED;


/** /**
* Set to do a locked checkout; optional default is false.
* Set to do a locked checkout; optional default is false.
* @param v True to do a locked checkout, false to checkout without * @param v True to do a locked checkout, false to checkout without
* changing status/. * changing status/.
* @exception BuildException if both locked and unlocked are set true * @exception BuildException if both locked and unlocked are set true
@@ -190,27 +191,26 @@ public class StarTeamCheckout extends TreeBasedTask {


/** /**
* should checked out files get the timestamp from the repository * should checked out files get the timestamp from the repository
* or the time they are checked out. True means use the repository
* or the time they are checked out. True means use the repository
* timestamp. * timestamp.
*/ */
private boolean useRepositoryTimeStamp = false; private boolean useRepositoryTimeStamp = false;


/** /**
* sets the useRepositoryTimestmp member. * sets the useRepositoryTimestmp member.
*
*
* @param useRepositoryTimeStamp * @param useRepositoryTimeStamp
* true means checked out files will get the repository timestamp. * true means checked out files will get the repository timestamp.
* false means the checked out files will be timestamped at the time * false means the checked out files will be timestamped at the time
* of checkout. * of checkout.
*/ */
public void setUseRepositoryTimeStamp(boolean useRepositoryTimeStamp)
{
public void setUseRepositoryTimeStamp(boolean useRepositoryTimeStamp) {
this.useRepositoryTimeStamp = useRepositoryTimeStamp; this.useRepositoryTimeStamp = useRepositoryTimeStamp;
} }


/** /**
* returns the value of the useRepositoryTimestamp member * returns the value of the useRepositoryTimestamp member
*
*
* @return the value of the useRepositoryTimestamp member * @return the value of the useRepositoryTimestamp member
*/ */
public boolean getUseRepositoryTimeStamp() { public boolean getUseRepositoryTimeStamp() {
@@ -221,24 +221,22 @@ public class StarTeamCheckout extends TreeBasedTask {
* appropriately configured view for checkouts - either * appropriately configured view for checkouts - either
* the current view or a view from this.label or the raw * the current view or a view from this.label or the raw
* view itself in the case of a revision label. * view itself in the case of a revision label.
*
*
* @param raw the unconfigured <code>View</code> * @param raw the unconfigured <code>View</code>
*
*
* @return the snapshot <code>View</code> appropriately configured. * @return the snapshot <code>View</code> appropriately configured.
* @exception BuildException * @exception BuildException
*/ */
protected View createSnapshotView(View raw)
throws BuildException
{
protected View createSnapshotView(View raw) throws BuildException {


int labelID = getLabelID(raw); int labelID = getLabelID(raw);


// if a label has been supplied and it is a view label, use it
// if a label has been supplied and it is a view label, use it
// to configure the view // to configure the view
if (this.isUsingViewLabel()) { if (this.isUsingViewLabel()) {
return new View(raw, ViewConfiguration.createFromLabel(labelID)); return new View(raw, ViewConfiguration.createFromLabel(labelID));
}
// if a label has been supplied and it is a revision label, use the raw
}
// if a label has been supplied and it is a revision label, use the raw
// the view as the snapshot // the view as the snapshot
else if (this.isUsingRevisionLabel()) { else if (this.isUsingRevisionLabel()) {
return raw; return raw;
@@ -253,37 +251,36 @@ public class StarTeamCheckout extends TreeBasedTask {
* Implements base-class abstract function to define tests for * Implements base-class abstract function to define tests for
* any preconditons required by the task. * any preconditons required by the task.
* *
* @exception BuildException thrown if both rootLocalFolder
* @exception BuildException thrown if both rootLocalFolder
* and viewRootLocalFolder are defined * and viewRootLocalFolder are defined
*/ */
protected void testPreconditions() throws BuildException { protected void testPreconditions() throws BuildException {
if (this.isUsingRevisionLabel() && this.createDirs) { if (this.isUsingRevisionLabel() && this.createDirs) {
log("Ignoring createworkingdirs while using a revision label." +
" Folders will be created only as needed.",
log("Ignoring createworkingdirs while using a revision label."
+ " Folders will be created only as needed.",
Project.MSG_WARN); Project.MSG_WARN);
this.createDirs=false;
this.createDirs = false;
} }
} }


/** /**
* extenders should emit to the log an entry describing the parameters * extenders should emit to the log an entry describing the parameters
* that will be used by this operation. * that will be used by this operation.
*
*
* @param starteamrootFolder * @param starteamrootFolder
* root folder in StarTeam for the operation * root folder in StarTeam for the operation
* @param targetrootFolder * @param targetrootFolder
* root local folder for the operation (whether specified
* root local folder for the operation (whether specified
* by the user or not. * by the user or not.
*/ */


protected void logOperationDescription( protected void logOperationDescription(
Folder starteamrootFolder, java.io.File targetrootFolder)
{
log((this.isRecursive() ? "Recursive" : "Non-recursive") +
" Checkout from: " + starteamrootFolder.getFolderHierarchy());
Folder starteamrootFolder, java.io.File targetrootFolder) {
log((this.isRecursive() ? "Recursive" : "Non-recursive")
+ " Checkout from: " + starteamrootFolder.getFolderHierarchy());


log(" Checking out to"
+ (null == getRootLocalFolder() ? "(default): " : ": ")
log(" Checking out to"
+ (null == getRootLocalFolder() ? "(default): " : ": ")
+ targetrootFolder.getAbsolutePath()); + targetrootFolder.getAbsolutePath());




@@ -293,32 +290,28 @@ public class StarTeamCheckout extends TreeBasedTask {


if (this.lockStatus == Item.LockType.EXCLUSIVE) { if (this.lockStatus == Item.LockType.EXCLUSIVE) {
log(" Items will be checked out with Exclusive locks."); log(" Items will be checked out with Exclusive locks.");
}
else if (this.lockStatus == Item.LockType.UNLOCKED) {
} else if (this.lockStatus == Item.LockType.UNLOCKED) {
log(" Items will be checked out unlocked " log(" Items will be checked out unlocked "
+"(even if presently locked).");
}
else {
+ "(even if presently locked).");
} else {
log(" Items will be checked out with no change in lock status."); log(" Items will be checked out with no change in lock status.");
} }
log(" Items will be checked out with " +
(this.useRepositoryTimeStamp ? "repository timestamps."
log(" Items will be checked out with "
+ (this.useRepositoryTimeStamp ? "repository timestamps."
: "the current timestamp.")); : "the current timestamp."));
log(" Items will be checked out " +
(this.isForced() ? "regardless of" : "in accordance with") +
log(" Items will be checked out "
+ (this.isForced() ? "regardless of" : "in accordance with") +
" repository status."); " repository status.");
if (this.deleteUncontrolled) { if (this.deleteUncontrolled) {
log(" Local items not found in the repository will be deleted."); log(" Local items not found in the repository will be deleted.");
} }
log(" Items will be checked out " +
(this.convertEOL
? "using the local machine's EOL convention"
log(" Items will be checked out "
+ (this.convertEOL ? "using the local machine's EOL convention"
: "without changing the EOL convention used on the server")); : "without changing the EOL convention used on the server"));
log(" Directories will be created"+
(this.createDirs
? " wherever they exist in the repository, even if empty."
log(" Directories will be created"
+ (this.createDirs ? " wherever they exist in the repository, even if empty."
: " only where needed to check out files.")); : " only where needed to check out files."));
} }
/** /**
* Implements base-class abstract function to perform the checkout * Implements base-class abstract function to perform the checkout
@@ -330,8 +323,7 @@ public class StarTeamCheckout extends TreeBasedTask {
* @exception BuildException if any error occurs * @exception BuildException if any error occurs
*/ */
protected void visit(Folder starteamFolder, java.io.File targetFolder) protected void visit(Folder starteamFolder, java.io.File targetFolder)
throws BuildException
{
throws BuildException {
try { try {




@@ -339,7 +331,7 @@ public class StarTeamCheckout extends TreeBasedTask {
starteamFolder.setAlternatePathFragment( starteamFolder.setAlternatePathFragment(
targetFolder.getAbsolutePath()); targetFolder.getAbsolutePath());
} }
if (!targetFolder.exists()) { if (!targetFolder.exists()) {
if (!this.isUsingRevisionLabel()) { if (!this.isUsingRevisionLabel()) {
if (this.createDirs) { if (this.createDirs) {
@@ -352,8 +344,8 @@ public class StarTeamCheckout extends TreeBasedTask {
} }
} }
} }
Folder[] foldersList = starteamFolder.getSubFolders(); Folder[] foldersList = starteamFolder.getSubFolders();
Item[] filesList = starteamFolder.getItems(getTypeNames().FILE); Item[] filesList = starteamFolder.getItems(getTypeNames().FILE);


@@ -361,32 +353,32 @@ public class StarTeamCheckout extends TreeBasedTask {


// prune away any files not belonging to the revision label // prune away any files not belonging to the revision label
// this is one ugly API from Starteam SDK // this is one ugly API from Starteam SDK
Hashtable labelItems = new Hashtable(filesList.length); Hashtable labelItems = new Hashtable(filesList.length);
int s = filesList.length; int s = filesList.length;
int[] ids = new int[s]; int[] ids = new int[s];
for (int i=0; i < s; i++) {
ids[i]=filesList[i].getItemID();
for (int i = 0; i < s; i++) {
ids[i] = filesList[i].getItemID();
labelItems.put(new Integer(ids[i]), new Integer(i)); labelItems.put(new Integer(ids[i]), new Integer(i));
} }
int[] foundIds = getLabelInUse().getLabeledItemIDs(ids); int[] foundIds = getLabelInUse().getLabeledItemIDs(ids);
s = foundIds.length; s = foundIds.length;
Item[] labeledFiles = new Item[s]; Item[] labeledFiles = new Item[s];
for (int i=0; i < s; i++) {
Integer ID = new Integer(foundIds[i]);
labeledFiles[i] =
filesList[((Integer) labelItems.get(ID)).intValue()];
for (int i = 0; i < s; i++) {
Integer id = new Integer(foundIds[i]);
labeledFiles[i] =
filesList[((Integer) labelItems.get(id)).intValue()];
} }
filesList = labeledFiles; filesList = labeledFiles;
} }
// note, it's important to scan the items BEFORE we make the // note, it's important to scan the items BEFORE we make the
// Unmatched file map because that creates a bunch of NEW // Unmatched file map because that creates a bunch of NEW
// folders and files (unattached to repository) and we // folders and files (unattached to repository) and we
// don't want to include those in our traversal. // don't want to include those in our traversal.


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


@@ -395,7 +387,7 @@ public class StarTeamCheckout extends TreeBasedTask {
for (int i = 0; i < foldersList.length; i++) { for (int i = 0; i < foldersList.length; i++) {
Folder stFolder = foldersList[i]; Folder stFolder = foldersList[i];


java.io.File subfolder =
java.io.File subfolder =
new java.io.File(targetFolder, stFolder.getName()); new java.io.File(targetFolder, stFolder.getName());


ufm.removeControlledItem(subfolder); ufm.removeControlledItem(subfolder);
@@ -406,10 +398,10 @@ public class StarTeamCheckout extends TreeBasedTask {
} }


for (int i = 0; i < filesList.length; i++) { for (int i = 0; i < filesList.length; i++) {
com.starbase.starteam.File stFile =
com.starbase.starteam.File stFile =
(com.starbase.starteam.File) filesList[i]; (com.starbase.starteam.File) filesList[i];
processFile( stFile, targetFolder);
processFile(stFile, targetFolder);
ufm.removeControlledItem( ufm.removeControlledItem(
new java.io.File(targetFolder, stFile.getName())); new java.io.File(targetFolder, stFile.getName()));
} }
@@ -424,14 +416,13 @@ public class StarTeamCheckout extends TreeBasedTask {


/** /**
* provides a string showing from and to full paths for logging * provides a string showing from and to full paths for logging
*
*
* @param remotefile the Star Team file being processed. * @param remotefile the Star Team file being processed.
*
*
* @return a string showing from and to full paths * @return a string showing from and to full paths
*/ */
private String describeCheckout(com.starbase.starteam.File remotefile, private String describeCheckout(com.starbase.starteam.File remotefile,
java.io.File localFile)
{
java.io.File localFile) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append(getFullRepositoryPath(remotefile)) sb.append(getFullRepositoryPath(remotefile))
.append(" --> "); .append(" --> ");
@@ -443,7 +434,7 @@ public class StarTeamCheckout extends TreeBasedTask {
return sb.toString(); return sb.toString();
} }
private String describeCheckout(com.starbase.starteam.File remotefile) { private String describeCheckout(com.starbase.starteam.File remotefile) {
return describeCheckout(remotefile,null);
return describeCheckout(remotefile, null);
} }
/** /**
* Processes (checks out) <code>stFiles</code>files from StarTeam folder. * Processes (checks out) <code>stFiles</code>files from StarTeam folder.
@@ -452,17 +443,16 @@ public class StarTeamCheckout extends TreeBasedTask {
* @param targetFolder a java.io.File (Folder) to work * @param targetFolder a java.io.File (Folder) to work
* @throws IOException when StarTeam API fails to work with files * @throws IOException when StarTeam API fails to work with files
*/ */
private void processFile(com.starbase.starteam.File eachFile,
java.io.File targetFolder )
throws IOException
{
private void processFile(com.starbase.starteam.File eachFile,
File targetFolder)
throws IOException {
String filename = eachFile.getName(); String filename = eachFile.getName();


java.io.File localFile = new java.io.File(targetFolder, filename); java.io.File localFile = new java.io.File(targetFolder, filename);


// If the file doesn't pass the include/exclude tests, skip it. // If the file doesn't pass the include/exclude tests, skip it.
if (!shouldProcess(filename)) { if (!shouldProcess(filename)) {
log("Excluding " + getFullRepositoryPath(eachFile),
log("Excluding " + getFullRepositoryPath(eachFile),
Project.MSG_INFO); Project.MSG_INFO);
return; return;
} }
@@ -486,8 +476,7 @@ public class StarTeamCheckout extends TreeBasedTask {
if (success) { if (success) {
log("Checked out " + describeCheckout(eachFile, localFile)); log("Checked out " + describeCheckout(eachFile, localFile));
} }
}
else {
} else {
boolean checkout = true; boolean checkout = true;


// Just a note: StarTeam has a status for NEW which implies // Just a note: StarTeam has a status for NEW which implies
@@ -506,15 +495,14 @@ public class StarTeamCheckout extends TreeBasedTask {
// We try to update the status once to give StarTeam // We try to update the status once to give StarTeam
// another chance. // another chance.


if (fileStatus == Status.MERGE ||
fileStatus == Status.UNKNOWN)
{
if (fileStatus == Status.MERGE
|| fileStatus == Status.UNKNOWN) {
eachFile.updateStatus(true, true); eachFile.updateStatus(true, true);
fileStatus = (eachFile.getStatus()); fileStatus = (eachFile.getStatus());
} }


log(eachFile.toString() + " has status of " +
Status.name(fileStatus), Project.MSG_DEBUG);
log(eachFile.toString() + " has status of "
+ Status.name(fileStatus), Project.MSG_DEBUG);




switch (fileStatus) { switch (fileStatus) {
@@ -524,12 +512,12 @@ public class StarTeamCheckout extends TreeBasedTask {
break; break;
default: default:
if (isForced()) { if (isForced()) {
log("Forced checkout of "
+ describeCheckout(eachFile)
log("Forced checkout of "
+ describeCheckout(eachFile)
+ " over status " + Status.name(fileStatus)); + " over status " + Status.name(fileStatus));
} else { } else {
log("Skipping: " + getFullRepositoryPath(eachFile) +
" - status: " + Status.name(fileStatus));
log("Skipping: " + getFullRepositoryPath(eachFile)
+ " - status: " + Status.name(fileStatus));
checkout = false; checkout = false;
} }
} }
@@ -543,7 +531,7 @@ public class StarTeamCheckout extends TreeBasedTask {
"Failed to create local folder " + targetFolder); "Failed to create local folder " + targetFolder);
} }
} }
eachFile.checkout(this.lockStatus,
eachFile.checkout(this.lockStatus,
!this.useRepositoryTimeStamp, this.convertEOL, true); !this.useRepositoryTimeStamp, this.convertEOL, true);
} }
} }
@@ -560,7 +548,7 @@ public class StarTeamCheckout extends TreeBasedTask {
* override of the base class init. It can be much simpler, since * override of the base class init. It can be much simpler, since
* the action to be taken is simply to delete the local files. No * the action to be taken is simply to delete the local files. No
* further interaction with the repository is necessary. * further interaction with the repository is necessary.
*
*
* @param localFolder * @param localFolder
* the local folder from which the mappings will be made. * the local folder from which the mappings will be made.
* @param remoteFolder * @param remoteFolder
@@ -572,18 +560,17 @@ public class StarTeamCheckout extends TreeBasedTask {
} }


String[] localFiles = localFolder.list(); String[] localFiles = localFolder.list();
for (int i=0; i < localFiles.length; i++) {
java.io.File localFile =
for (int i = 0; i < localFiles.length; i++) {
java.io.File localFile =
new java.io.File(localFolder, localFiles[i]).getAbsoluteFile(); new java.io.File(localFolder, localFiles[i]).getAbsoluteFile();
log("adding " + localFile + " to UnmatchedFileMap", log("adding " + localFile + " to UnmatchedFileMap",
Project.MSG_DEBUG); Project.MSG_DEBUG);
if (localFile.isDirectory()) { if (localFile.isDirectory()) {
this.put(localFile, ""); this.put(localFile, "");
}
else {
} else {
this.put(localFile, ""); this.put(localFile, "");
} }
} }
@@ -591,7 +578,7 @@ public class StarTeamCheckout extends TreeBasedTask {
} }




/** /**
* deletes uncontrolled items from the local tree. It is assumed * deletes uncontrolled items from the local tree. It is assumed
* that this method will not be called until all the items in the * that this method will not be called until all the items in the
@@ -607,23 +594,23 @@ public class StarTeamCheckout extends TreeBasedTask {
} }
} }
} }
/** /**
* deletes all files and if the file is a folder recursively deletes * deletes all files and if the file is a folder recursively deletes
* everything in it. * everything in it.
*
*
* @param local The local file or folder to be deleted. * @param local The local file or folder to be deleted.
*/ */
void delete(java.io.File local) { void delete(java.io.File local) {
// once we find a folder that isn't in the repository,
// once we find a folder that isn't in the repository,
// anything below it can be deleted. // anything below it can be deleted.
if (local.isDirectory() && isRecursive()) { if (local.isDirectory() && isRecursive()) {
String[] contents = local.list(); String[] contents = local.list();
for (int i=0; i< contents.length; i++) {
for (int i = 0; i < contents.length; i++) {
java.io.File file = new java.io.File(local, contents[i]); java.io.File file = new java.io.File(local, contents[i]);
delete(file); delete(file);
} }
}
}
local.delete(); local.delete();
log("Deleted uncontrolled item " + local.getAbsolutePath()); log("Deleted uncontrolled item " + local.getAbsolutePath());
} }


+ 23
- 26
src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamLabel.java View File

@@ -98,7 +98,7 @@ public class StarTeamLabel extends StarTeamTask {
* true. * true.
*/ */
private boolean buildlabel = false; private boolean buildlabel = false;
/** /**
* If true, this will be a revision label. If false, it will be a build * If true, this will be a revision label. If false, it will be a build
* label. The default is false. * label. The default is false.
@@ -130,31 +130,31 @@ public class StarTeamLabel extends StarTeamTask {
} }


/** /**
* set the type of label based on the supplied value - if true, this
* set the type of label based on the supplied value - if true, this
* label will be a revision label, if false, a build label. * label will be a revision label, if false, a build label.
*
* @param revision If true this will be a revision label; if false,
*
* @param buildlabel If true this will be a revision label; if false,
* a build label * a build label
*/ */
public void setBuildLabel( boolean buildlabel ) {
public void setBuildLabel(boolean buildlabel) {
this.buildlabel = buildlabel; this.buildlabel = buildlabel;
} }
/** /**
* set the type of label based on the supplied value - if true, this
* set the type of label based on the supplied value - if true, this
* label will be a revision label, if false, a build label. * label will be a revision label, if false, a build label.
*
* @param revision If true this will be a revision label; if false,
*
* @param revisionlabel If true this will be a revision label; if false,
* a build label * a build label
*/ */
public void setRevisionLabel( boolean revisionlabel ) {
public void setRevisionLabel(boolean revisionlabel) {
this.revisionlabel = revisionlabel; this.revisionlabel = revisionlabel;
} }






/** /**
* The timestamp of the build that will be stored with the label; required.
* The timestamp of the build that will be stored with the label; required.
* Must be formatted <code>yyyyMMddHHmmss</code> * Must be formatted <code>yyyyMMddHHmmss</code>
*/ */
public void setLastBuild(String lastbuild) throws BuildException { public void setLastBuild(String lastbuild) throws BuildException {
@@ -162,8 +162,8 @@ public class StarTeamLabel extends StarTeamTask {
Date lastBuildTime = DATE_FORMAT.parse(lastbuild); Date lastBuildTime = DATE_FORMAT.parse(lastbuild);
this.lastBuild = new OLEDate(lastBuildTime); this.lastBuild = new OLEDate(lastBuildTime);
} catch (ParseException e) { } catch (ParseException e) {
throw new BuildException("Unable to parse the date '" +
lastbuild + "'", e);
throw new BuildException("Unable to parse the date '"
+ lastbuild + "'", e);
} }
} }


@@ -175,9 +175,8 @@ public class StarTeamLabel extends StarTeamTask {
public void execute() throws BuildException { public void execute() throws BuildException {


if (this.revisionlabel && this.buildlabel) { if (this.revisionlabel && this.buildlabel) {
throw new BuildException(
"'revisionlabel' and 'buildlabel' both specified. " +
"A revision label cannot be a build label.");
throw new BuildException("'revisionlabel' and 'buildlabel' "
+ "both specified. A revision label cannot be a build label.");
} }


View snapshot = openView(); View snapshot = openView();
@@ -187,19 +186,17 @@ public class StarTeamLabel extends StarTeamTask {
if (this.revisionlabel) { if (this.revisionlabel) {
new Label(snapshot, this.labelName, this.description).update(); new Label(snapshot, this.labelName, this.description).update();
log("Created Revision Label " + this.labelName); log("Created Revision Label " + this.labelName);
}
else if (null != lastBuild){
new Label(snapshot, this.labelName, this.description,this.lastBuild,
} else if (null != lastBuild) {
new Label(snapshot, this.labelName, this.description, this.lastBuild,
this.buildlabel).update(); this.buildlabel).update();
log("Created View Label ("
+(this.buildlabel ? "" : "non-") + "build) " + this.labelName
+" as of " + this.lastBuild.toString());
}
else {
log("Created View Label ("
+ (this.buildlabel ? "" : "non-") + "build) " + this.labelName
+ " as of " + this.lastBuild.toString());
} else {
new Label(snapshot, this.labelName, this.description, new Label(snapshot, this.labelName, this.description,
this.buildlabel).update(); this.buildlabel).update();
log("Created View Label ("
+(this.buildlabel ? "" : "non-") + "build) " + this.labelName);
log("Created View Label ("
+ (this.buildlabel ? "" : "non-") + "build) " + this.labelName);
} }
} }




+ 22
- 27
src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamList.java View File

@@ -81,7 +81,7 @@ public class StarTeamList extends TreeBasedTask {
private boolean listUncontrolled = true; private boolean listUncontrolled = true;
/** /**
* List files, dates, and statuses as of this label; optional. * List files, dates, and statuses as of this label; optional.
* The label must exist in starteam or an exception will be thrown.
* 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. * If not specified, the most recent version of each file will be listed.
* *
* @param label the label to be listed * @param label the label to be listed
@@ -93,7 +93,7 @@ public class StarTeamList extends TreeBasedTask {
/** /**
* Override of base-class abstract function creates an * Override of base-class abstract function creates an
* appropriately configured view for checkoutlists - either * appropriately configured view for checkoutlists - either
* the current view or a view from this.label.
* the current view or a view from this.label.
* *
* @param raw the unconfigured <code>View</code> * @param raw the unconfigured <code>View</code>
* @return the snapshot <code>View</code> appropriately configured. * @return the snapshot <code>View</code> appropriately configured.
@@ -130,11 +130,11 @@ public class StarTeamList extends TreeBasedTask {
* root local folder for the operation (whether specified by the user or not. * root local folder for the operation (whether specified by the user or not.
*/ */
protected void logOperationDescription(Folder starteamrootFolder, java.io.File targetrootFolder) { protected void logOperationDescription(Folder starteamrootFolder, java.io.File targetrootFolder) {
log((this.isRecursive() ? "Recursive" : "Non-recursive") +
" Listing of: " + starteamrootFolder.getFolderHierarchy());
log((this.isRecursive() ? "Recursive" : "Non-recursive")
+ " Listing of: " + starteamrootFolder.getFolderHierarchy());


log("Listing against local folder"
+ (null == getRootLocalFolder() ? " (default): " : ": ")
log("Listing against local folder"
+ (null == getRootLocalFolder() ? " (default): " : ": ")
+ targetrootFolder.getAbsolutePath(), + targetrootFolder.getAbsolutePath(),
Project.MSG_INFO); Project.MSG_INFO);
logLabel(); logLabel();
@@ -161,16 +161,15 @@ public class StarTeamList extends TreeBasedTask {
} }
Folder[] subFolders = starteamFolder.getSubFolders(); Folder[] subFolders = starteamFolder.getSubFolders();
Item[] files = starteamFolder.getItems(getTypeNames().FILE); Item[] files = starteamFolder.getItems(getTypeNames().FILE);
UnmatchedFileMap ufm =
UnmatchedFileMap ufm =
new UnmatchedListingMap().init( new UnmatchedListingMap().init(
targetFolder.getAbsoluteFile(), starteamFolder); targetFolder.getAbsoluteFile(), starteamFolder);


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




// For all Files in this folder, we need to check // For all Files in this folder, we need to check
@@ -212,7 +211,7 @@ public class StarTeamList extends TreeBasedTask {
} }
} }


private static final SimpleDateFormat SDF =
private static final SimpleDateFormat SDF =
new SimpleDateFormat("yyyy-MM-dd hh:mm:ss zzz"); new SimpleDateFormat("yyyy-MM-dd hh:mm:ss zzz");


protected void list(File reposFile, java.io.File localFile) protected void list(File reposFile, java.io.File localFile)
@@ -220,7 +219,7 @@ public class StarTeamList extends TreeBasedTask {
StringBuffer b = new StringBuffer(); StringBuffer b = new StringBuffer();
int status = reposFile.getStatus(); int status = reposFile.getStatus();
java.util.Date displayDate = null; java.util.Date displayDate = null;
if (status==Status.NEW) {
if (status == Status.NEW) {
displayDate = new java.util.Date(localFile.lastModified()); displayDate = new java.util.Date(localFile.lastModified());
} else { } else {
displayDate = reposFile.getModifiedTime().createDate(); displayDate = reposFile.getModifiedTime().createDate();
@@ -263,23 +262,23 @@ public class StarTeamList extends TreeBasedTask {
protected boolean isActive() { protected boolean isActive() {
return StarTeamList.this.listUncontrolled; return StarTeamList.this.listUncontrolled;
} }
/** /**
* lists uncontrolled items from the local tree. It is assumed * lists uncontrolled items from the local tree. It is assumed
* that this method will not be called until all the items in the * that this method will not be called until all the items in the
* corresponding folder have been processed, and that the internal map * corresponding folder have been processed, and that the internal map
* will contain only uncontrolled items. * will contain only uncontrolled items.
*/ */
void processUncontrolledItems() throws BuildException{
void processUncontrolledItems() throws BuildException {
if (this.isActive()) { if (this.isActive()) {
Enumeration e = this.keys(); Enumeration e = this.keys();
// handle the files so they appear first // handle the files so they appear first
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
java.io.File local = (java.io.File) e.nextElement(); java.io.File local = (java.io.File) e.nextElement();
Item remoteItem = (Item) this.get(local); Item remoteItem = (Item) this.get(local);


// once we find a folder that isn't in the repository,
// once we find a folder that isn't in the repository,
// we know we can add it. // we know we can add it.
if (local.isFile()) { if (local.isFile()) {
com.starbase.starteam.File remoteFile = com.starbase.starteam.File remoteFile =
@@ -287,7 +286,7 @@ public class StarTeamList extends TreeBasedTask {
try { try {
list(remoteFile, local); list(remoteFile, local);
} catch (IOException ie) { } catch (IOException ie) {
throw new BuildException("IOError in stlist",ie);
throw new BuildException("IOError in stlist", ie);
} }
} }
} }
@@ -297,15 +296,15 @@ public class StarTeamList extends TreeBasedTask {
java.io.File local = (java.io.File) e.nextElement(); java.io.File local = (java.io.File) e.nextElement();
Item remoteItem = (Item) this.get(local); Item remoteItem = (Item) this.get(local);


// once we find a folder that isn't in the repository,
// once we find a folder that isn't in the repository,
// we know we can add it. // we know we can add it.
if (local.isDirectory()) { if (local.isDirectory()) {
Folder folder = (Folder) remoteItem; Folder folder = (Folder) remoteItem;
if (isRecursive()) { if (isRecursive()) {
log("Listing uncontrolled folder "
log("Listing uncontrolled folder "
+ folder.getFolderHierarchy() + folder.getFolderHierarchy()
+ " from " + local.getAbsoluteFile()); + " from " + local.getAbsoluteFile());
UnmatchedFileMap submap =
UnmatchedFileMap submap =
new UnmatchedListingMap().init(local, folder); new UnmatchedListingMap().init(local, folder);
submap.processUncontrolledItems(); submap.processUncontrolledItems();
} }
@@ -313,11 +312,7 @@ public class StarTeamList extends TreeBasedTask {
} }
} }
} }


} }


}// StarTeamList
}





+ 12
- 13
src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamTask.java View File

@@ -116,8 +116,8 @@ public abstract class StarTeamTask extends Task {
private Server server = null; private Server server = null;


private void logStarteamVersion() { private void logStarteamVersion() {
log("StarTeam version: "+
BuildNumber.getDisplayString(), Project.MSG_DEBUG);
log("StarTeam version: "
+ BuildNumber.getDisplayString(), Project.MSG_DEBUG);
} }




@@ -191,7 +191,7 @@ public abstract class StarTeamTask extends Task {
* set the name of the StarTeam view to be acted on; * set the name of the StarTeam view to be acted on;
* required if <tt>URL</tt> is not set. * required if <tt>URL</tt> is not set.
* *
* @param projectname the name of the StarTeam view to be acted on
* @param viewname the name of the StarTeam view to be acted on
* @see #setURL(String) * @see #setURL(String)
*/ */
public final void setViewname(String viewname) { public final void setViewname(String viewname) {
@@ -212,7 +212,7 @@ public abstract class StarTeamTask extends Task {
/** /**
* Set the server name, server port, * Set the server name, server port,
* project name and project folder in one shot; * project name and project folder in one shot;
* optional, but the server connection must be specified somehow.
* optional, but the server connection must be specified somehow.
* *
* @param url a <code>String</code> of the form * @param url a <code>String</code> of the form
* "servername:portnum/project/view" * "servername:portnum/project/view"
@@ -256,17 +256,16 @@ public abstract class StarTeamTask extends Task {
* @see #getViewname() * @see #getViewname()
*/ */
public final String getURL() { public final String getURL() {
return
this.servername + ":" +
this.serverport + "/" +
this.projectname + "/" +
((null == this.viewname) ? "" : this.viewname);
return this.servername + ":"
+ this.serverport + "/"
+ this.projectname + "/"
+ ((null == this.viewname) ? "" : this.viewname);
} }


/** /**
* returns an URL string useful for interacting with many StarTeamFinder * returns an URL string useful for interacting with many StarTeamFinder
* methods. * methods.
*
*
* @return the URL string for this task. * @return the URL string for this task.
*/ */
protected final String getViewURL() { protected final String getViewURL() {
@@ -333,7 +332,7 @@ public abstract class StarTeamTask extends Task {
* @param rawview the unconfigured <code>View</code> * @param rawview the unconfigured <code>View</code>
* @return the snapshot <code>View</code> appropriately configured. * @return the snapshot <code>View</code> appropriately configured.
*/ */
protected abstract View createSnapshotView(View rawview)
protected abstract View createSnapshotView(View rawview)
throws BuildException; throws BuildException;


/** /**
@@ -358,8 +357,8 @@ public abstract class StarTeamTask extends Task {
} }


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


View snapshot = createSnapshotView(view); View snapshot = createSnapshotView(view);


+ 78
- 89
src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java View File

@@ -164,7 +164,7 @@ public abstract class TreeBasedTask extends StarTeamTask {
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////


/** /**
* Set the root of the subtree in the StarTeam repository from which to
* Set the root of the subtree in the StarTeam repository from which to
* work; optional. Defaults to the root folder of the view ('/'). * work; optional. Defaults to the root folder of the view ('/').
* @param rootStarteamFolder the root folder * @param rootStarteamFolder the root folder
*/ */
@@ -186,11 +186,11 @@ public abstract class TreeBasedTask extends StarTeamTask {
* to which files are checked out; optional. * to which files are checked out; optional.
* If this is not supplied, then the StarTeam "default folder" * If this is not supplied, then the StarTeam "default folder"
* associated with <tt>rootstarteamfolder</tt> is used. * associated with <tt>rootstarteamfolder</tt> is used.
*
*
* @param rootLocalFolder * @param rootLocalFolder
* the local folder that will mirror * the local folder that will mirror
* this.rootStarteamFolder * this.rootStarteamFolder
*
*
* @see rootLocalFolder * @see rootLocalFolder
*/ */
public void setRootLocalFolder(String rootLocalFolder) { public void setRootLocalFolder(String rootLocalFolder) {
@@ -203,7 +203,7 @@ public abstract class TreeBasedTask extends StarTeamTask {
* Returns the local folder specified by the user, * Returns the local folder specified by the user,
* corresponding to the starteam folder for this operation * corresponding to the starteam folder for this operation
* or null if not specified. * or null if not specified.
*
*
* @return the local folder that mirrors this.rootStarteamFolder * @return the local folder that mirrors this.rootStarteamFolder
* @see rootLocalFolder * @see rootLocalFolder
*/ */
@@ -213,7 +213,7 @@ public abstract class TreeBasedTask extends StarTeamTask {




/** /**
* Declare files to include using standard <tt>includes</tt> patterns; optional.
* Declare files to include using standard <tt>includes</tt> patterns; optional.
* @param includes A string of filter patterns to include. Separate the * @param includes A string of filter patterns to include. Separate the
* patterns by spaces. * patterns by spaces.
* @see #getIncludes() * @see #getIncludes()
@@ -243,12 +243,12 @@ public abstract class TreeBasedTask extends StarTeamTask {
*/ */
protected void logIncludes() { protected void logIncludes() {
if (this.DEFAULT_INCLUDESETTING != this.includes) { if (this.DEFAULT_INCLUDESETTING != this.includes) {
log(" Includes specified: "+ this.includes);
log(" Includes specified: " + this.includes);
} }
} }


/** /**
* Declare files to exclude using standard <tt>excludes</tt> patterns; optional.
* Declare files to exclude using standard <tt>excludes</tt> patterns; optional.
* When filtering files, AntStarTeamCheckOut * When filtering files, AntStarTeamCheckOut
* uses an unmodified version of <CODE>DirectoryScanner</CODE>'s * uses an unmodified version of <CODE>DirectoryScanner</CODE>'s
* <CODE>match</CODE> method, so here are the patterns straight from the * <CODE>match</CODE> method, so here are the patterns straight from the
@@ -304,7 +304,7 @@ public abstract class TreeBasedTask extends StarTeamTask {
*/ */
protected void logExcludes() { protected void logExcludes() {
if (this.DEFAULT_EXCLUDESETTING != this.excludes) { if (this.DEFAULT_EXCLUDESETTING != this.excludes) {
log(" Excludes specified: "+ this.excludes);
log(" Excludes specified: " + this.excludes);
} }
} }


@@ -373,11 +373,11 @@ public abstract class TreeBasedTask extends StarTeamTask {
} }


/** /**
* Flag to force actions regardless of the status
* that StarTeam is maintaining for the file; optional, default false.
* If <tt>rootlocalfolder</tt> is set then
* this should be set "true" as otherwise the checkout will be based on statuses
* which do not relate to the target folder.
* Flag to force actions regardless of the status
* that StarTeam is maintaining for the file; optional, default false.
* If <tt>rootlocalfolder</tt> is set then
* this should be set "true" as otherwise the checkout will be based on statuses
* which do not relate to the target folder.
* @param v Value to assign to forced. * @param v Value to assign to forced.
*/ */
public void setForced(boolean v) { public void setForced(boolean v) {
@@ -386,27 +386,25 @@ public abstract class TreeBasedTask extends StarTeamTask {


/** /**
* returns true if a label has been specified and it is a view label. * returns true if a label has been specified and it is a view label.
*
*
* @return true if a label has been specified and it is a view label * @return true if a label has been specified and it is a view label
*/ */
protected boolean isUsingViewLabel() { protected boolean isUsingViewLabel() {
return null != this.labelInUse &&
this.labelInUse.isViewLabel();
return null != this.labelInUse && this.labelInUse.isViewLabel();
} }
/** /**
* returns true if a label has been specified and it is a revision label. * returns true if a label has been specified and it is a revision label.
*
*
* @return true if a label has been specified and it is a revision label * @return true if a label has been specified and it is a revision label
*/ */
protected boolean isUsingRevisionLabel() { protected boolean isUsingRevisionLabel() {
return null != this.labelInUse &&
this.labelInUse.isRevisionLabel();
return null != this.labelInUse && this.labelInUse.isRevisionLabel();
} }


/** /**
* returns the label being used * returns the label being used
*
* @return
*
* @return
*/ */
protected Label getLabelInUse() { protected Label getLabelInUse() {
return this.labelInUse; return this.labelInUse;
@@ -418,8 +416,7 @@ public abstract class TreeBasedTask extends StarTeamTask {
protected void logLabel() { protected void logLabel() {
if (this.isUsingViewLabel()) { if (this.isUsingViewLabel()) {
log(" Using view label " + getLabel()); log(" Using view label " + getLabel());
}
else if (this.isUsingRevisionLabel()) {
} else if (this.isUsingRevisionLabel()) {
log(" Using revision label " + getLabel()); log(" Using revision label " + getLabel());
} }
} }
@@ -435,9 +432,9 @@ public abstract class TreeBasedTask extends StarTeamTask {
* Look if the file should be processed by the task. * Look if the file should be processed by the task.
* Don't process it if it fits no include filters or if * Don't process it if it fits no include filters or if
* it fits an exclude filter. * it fits an exclude filter.
*
*
* @param pName the item name to look for being included. * @param pName the item name to look for being included.
*
*
* @return whether the file should be processed or not. * @return whether the file should be processed or not.
*/ */
protected boolean shouldProcess(String pName) { protected boolean shouldProcess(String pName) {
@@ -469,14 +466,13 @@ public abstract class TreeBasedTask extends StarTeamTask {
/** /**
* Finds and opens the root starteam folder of the operation specified * Finds and opens the root starteam folder of the operation specified
* by this task. This will be one of the following cases: * by this task. This will be one of the following cases:
*
*
* @return Starteam's root folder for the operation. * @return Starteam's root folder for the operation.
* @exception BuildException * @exception BuildException
* if the root folder cannot be found in the repository * if the root folder cannot be found in the repository
*/ */
private final Folder configureRootStarteamFolder()
throws BuildException
{
private final Folder configureRootStarteamFolder()
throws BuildException {
Folder starteamrootfolder = null; Folder starteamrootfolder = null;
try { try {
// no root local mapping has been specified. // no root local mapping has been specified.
@@ -502,37 +498,33 @@ public abstract class TreeBasedTask extends StarTeamTask {
} }




}
catch (BuildException e) {
} catch (BuildException e) {
throw e; throw e;
}
catch (Exception e) {
throw new BuildException(
"Unable to find root folder " + this.rootStarteamFolder +
" in repository at " + getURL(), e);
} catch (Exception e) {
throw new BuildException("Unable to find root folder "
+ this.rootStarteamFolder + " in repository at " + getURL(), e);


} }


if (null == starteamrootfolder) { if (null == starteamrootfolder) {
throw new BuildException(
"Unable to find root folder " + this.rootStarteamFolder +
" in repository at " + getURL());
}
throw new BuildException("Unable to find root folder "
+ this.rootStarteamFolder + " in repository at " + getURL());
}

return starteamrootfolder; return starteamrootfolder;
} }
/** /**
* Returns the local folder mapped to the given StarTeam root folder * Returns the local folder mapped to the given StarTeam root folder
* of the operation. There are two cases here, depending on whether * of the operation. There are two cases here, depending on whether
* <code>rootLocalFolder</code> is defined.
* If <code>rootLocalFolder</code> is defined, it will be used to
* establish a root mapping. Otherwise, the repository's default root
* <code>rootLocalFolder</code> is defined.
* If <code>rootLocalFolder</code> is defined, it will be used to
* establish a root mapping. Otherwise, the repository's default root
* folder will be used. * folder will be used.
*
*
* @param starteamrootfolder * @param starteamrootfolder
* root Starteam folder initialized for the operation * root Starteam folder initialized for the operation
*
*
* @return the local folder corresponding to the root Starteam folder. * @return the local folder corresponding to the root Starteam folder.
* @see findRootStarteamFolder * @see findRootStarteamFolder
*/ */
@@ -541,33 +533,32 @@ public abstract class TreeBasedTask extends StarTeamTask {
String localrootfolder; String localrootfolder;
if (null != this.rootLocalFolder) { if (null != this.rootLocalFolder) {
localrootfolder = rootLocalFolder; localrootfolder = rootLocalFolder;
}
else {
} else {
// either use default path or root local mapping, // either use default path or root local mapping,
// which is now embedded in the root folder // which is now embedded in the root folder
localrootfolder = starteamrootfolder.getPathFragment(); localrootfolder = starteamrootfolder.getPathFragment();
} }


return new java.io.File(localrootfolder); return new java.io.File(localrootfolder);
} }


/** /**
* extenders should emit to the log an entry describing the parameters * extenders should emit to the log an entry describing the parameters
* that will be used by this operation. * that will be used by this operation.
*
*
* @param starteamrootFolder * @param starteamrootFolder
* root folder in StarTeam for the operation * root folder in StarTeam for the operation
* @param targetrootFolder * @param targetrootFolder
* root local folder for the operation (whether specified by the user or not. * root local folder for the operation (whether specified by the user or not.
*/ */
protected abstract void logOperationDescription(
protected abstract void logOperationDescription(
Folder starteamrootFolder, java.io.File targetrootFolder); Folder starteamrootFolder, java.io.File targetrootFolder);


/** /**
* This method does the work of opening the supplied Starteam view and * This method does the work of opening the supplied Starteam view and
* calling the <code>visit()</code> method to perform the task. * calling the <code>visit()</code> method to perform the task.
* Derived classes can customize the called methods
* Derived classes can customize the called methods
* <code>testPreconditions()</code> and <code>visit()</code>. * <code>testPreconditions()</code> and <code>visit()</code>.
* *
* @exception BuildException if any error occurs in the processing * @exception BuildException if any error occurs in the processing
@@ -581,14 +572,14 @@ public abstract class TreeBasedTask extends StarTeamTask {
Folder starteamrootfolder = configureRootStarteamFolder(); Folder starteamrootfolder = configureRootStarteamFolder();


// set the local folder. // set the local folder.
java.io.File localrootfolder =
java.io.File localrootfolder =
getLocalRootMapping(starteamrootfolder); getLocalRootMapping(starteamrootfolder);


testPreconditions(); testPreconditions();
// Tell user what he is doing // Tell user what he is doing
logOperationDescription(starteamrootfolder, localrootfolder); logOperationDescription(starteamrootfolder, localrootfolder);
// Inspect everything in the root folder and then recursively // Inspect everything in the root folder and then recursively
visit(starteamrootfolder, localrootfolder); visit(starteamrootfolder, localrootfolder);


@@ -645,12 +636,12 @@ public abstract class TreeBasedTask extends StarTeamTask {
/** /**
* Derived classes must override this class to define actual processing * Derived classes must override this class to define actual processing
* to be performed on each folder in the tree defined for the task * to be performed on each folder in the tree defined for the task
*
*
* @param rootStarteamFolder * @param rootStarteamFolder
* the StarTeam folderto be visited * the StarTeam folderto be visited
* @param rootLocalFolder * @param rootLocalFolder
* the local mapping of rootStarteamFolder * the local mapping of rootStarteamFolder
*
*
* @exception BuildException * @exception BuildException
*/ */
protected abstract void visit(Folder rootStarteamFolder, protected abstract void visit(Folder rootStarteamFolder,
@@ -676,14 +667,13 @@ public abstract class TreeBasedTask extends StarTeamTask {
/** /**
* Return the full repository path name of a file. Surprisingly there's * Return the full repository path name of a file. Surprisingly there's
* no method in com.starbase.starteam.File to provide this. * no method in com.starbase.starteam.File to provide this.
*
*
* @param remotefile the Star Team file whose path is to be returned * @param remotefile the Star Team file whose path is to be returned
*
*
* @return the full repository path name of a file. * @return the full repository path name of a file.
*/ */
public static String getFullRepositoryPath( public static String getFullRepositoryPath(
com.starbase.starteam.File remotefile)
{
com.starbase.starteam.File remotefile) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append(remotefile.getParentFolderHierarchy()) sb.append(remotefile.getParentFolderHierarchy())
.append(remotefile.getName()); .append(remotefile.getName());
@@ -696,24 +686,24 @@ public abstract class TreeBasedTask extends StarTeamTask {
* upon recursing into a directory. Each local item is mapped to an * upon recursing into a directory. Each local item is mapped to an
* unattached StarTeam object of the proper type, File->File and * unattached StarTeam object of the proper type, File->File and
* Directory->Folder. * Directory->Folder.
*
*
* As the TreeBased does its work, it deletes from the map all items * As the TreeBased does its work, it deletes from the map all items
* it has processed.
*
* it has processed.
*
* When the TreeBased task processes all the items from the repository, * When the TreeBased task processes all the items from the repository,
* whatever items left in the UnmatchedFileMap are uncontrolled items * whatever items left in the UnmatchedFileMap are uncontrolled items
* and can be processed as appropriate to the task. In the case of * and can be processed as appropriate to the task. In the case of
* Checkouts, they can be optionally deleted from the local tree. In the
* Checkouts, they can be optionally deleted from the local tree. In the
* case of Checkins they can optionally be added to the repository. * case of Checkins they can optionally be added to the repository.
*/ */
protected abstract class UnmatchedFileMap extends Hashtable { protected abstract class UnmatchedFileMap extends Hashtable {
/** /**
* initializes the UnmatchedFileMap with entries from the local folder * initializes the UnmatchedFileMap with entries from the local folder
* These will be mapped to the corresponding StarTeam entry even though * These will be mapped to the corresponding StarTeam entry even though
* it will not, in fact, exist in the repository. But through it, it
* it will not, in fact, exist in the repository. But through it, it
* can be added, listed, etc. * can be added, listed, etc.
*
*
* @param localFolder * @param localFolder
* the local folder from which the mappings will be made. * the local folder from which the mappings will be made.
* @param remoteFolder * @param remoteFolder
@@ -725,20 +715,19 @@ public abstract class TreeBasedTask extends StarTeamTask {
} }


String[] localFiles = localFolder.list(); String[] localFiles = localFolder.list();
for (int i=0; i < localFiles.length; i++) {
for (int i = 0; i < localFiles.length; i++) {
String fn = localFiles[i]; String fn = localFiles[i];
java.io.File localFile =
java.io.File localFile =
new java.io.File(localFolder, localFiles[i]).getAbsoluteFile(); new java.io.File(localFolder, localFiles[i]).getAbsoluteFile();
log("adding " + localFile + " to UnmatchedFileMap", log("adding " + localFile + " to UnmatchedFileMap",
Project.MSG_DEBUG); Project.MSG_DEBUG);
if (localFile.isDirectory()) { if (localFile.isDirectory()) {
this.put(localFile, new Folder( remoteFolder, fn, fn));
}
else {
com.starbase.starteam.File remoteFile =
this.put(localFile, new Folder(remoteFolder, fn, fn));
} else {
com.starbase.starteam.File remoteFile =
new com.starbase.starteam.File(remoteFolder); new com.starbase.starteam.File(remoteFolder);
remoteFile.setName(fn); remoteFile.setName(fn);
this.put(localFile, remoteFile); this.put(localFile, remoteFile);
@@ -746,37 +735,37 @@ public abstract class TreeBasedTask extends StarTeamTask {
} }
return this; return this;
} }
/** /**
* remove an item found to be controlled from the map. * remove an item found to be controlled from the map.
*
*
* @param localFile the local item found to be controlled. * @param localFile the local item found to be controlled.
*/ */
void removeControlledItem(java.io.File localFile) { void removeControlledItem(java.io.File localFile) {
if (isActive()) { if (isActive()) {
log("removing processed " + localFile.getAbsoluteFile() +
" from UnmatchedFileMap", Project.MSG_DEBUG);
log("removing processed " + localFile.getAbsoluteFile()
+ " from UnmatchedFileMap", Project.MSG_DEBUG);
this.remove(localFile.getAbsoluteFile()); this.remove(localFile.getAbsoluteFile());
} }
} }
/** /**
* override will perform the action appropriate for its task to perform * override will perform the action appropriate for its task to perform
* on items which are on the local tree but not in StarTeam. It is
* on items which are on the local tree but not in StarTeam. It is
* assumed that this method will not be called until all the items in * assumed that this method will not be called until all the items in
* the corresponding folder have been processed, and that the internal
* the corresponding folder have been processed, and that the internal
* map * will contain only uncontrolled items. * map * will contain only uncontrolled items.
*/ */
abstract void processUncontrolledItems() throws BuildException; abstract void processUncontrolledItems() throws BuildException;
/** /**
* overrides must define this to declare how this method knows if it
* overrides must define this to declare how this method knows if it
* is active. This presents extra clock cycles when the functionality * is active. This presents extra clock cycles when the functionality
* is not called for. * is not called for.
*
*
* @return True if this object is to perform its functionality. * @return True if this object is to perform its functionality.
*/ */
abstract protected boolean isActive();
protected abstract boolean isActive();
} }


} }


Loading…
Cancel
Save