diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckin.java b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckin.java index f3bcca79d..37c3acdca 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckin.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckin.java @@ -63,7 +63,7 @@ import java.util.Enumeration; 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 * are not managed by the repository to its control. * 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". * @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; * 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 * false means leave status alone. */ @@ -175,45 +175,44 @@ public class StarTeamCheckin extends TreeBasedTask { * Implements base-class abstract function to define tests for * any preconditons required by the task. * - * @exception BuildException thrown if both rootLocalFolder + * @exception BuildException thrown if both rootLocalFolder * and viewRootLocalFolder are defined */ 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. * * @param starteamrootFolder * root folder in StarTeam for the operation * @param targetrootFolder - * root local folder for the operation + * root local folder for the operation * (whether specified by the user or not). */ protected void logOperationDescription( - Folder starteamrootFolder, java.io.File targetrootFolder) - { + Folder starteamrootFolder, java.io.File targetrootFolder) { log((this.isRecursive() ? "Recursive" : "Non-recursive") - +" Checkin from" - + (null == getRootLocalFolder() ? " (default): " : ": ") + + " Checkin from" + + (null == getRootLocalFolder() ? " (default): " : ": ") + targetrootFolder.getAbsolutePath()); - + log("Checking in to: " + starteamrootFolder.getFolderHierarchy()); logIncludes(); logExcludes(); if (this.lockStatus == Item.LockType.UNLOCKED) { log(" Items will be checked in unlocked."); - } - else { + } else { log(" Items will be checked in with no change in lock status."); } 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 * 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 */ protected void visit(Folder starteamFolder, java.io.File targetFolder) - throws BuildException - { + throws BuildException { try { if (null != getRootLocalFolder()) { starteamFolder.setAlternatePathFragment( @@ -239,20 +237,20 @@ public class StarTeamCheckin extends TreeBasedTask { Folder[] foldersList = starteamFolder.getSubFolders(); Item[] stFiles = starteamFolder.getItems(getTypeNames().FILE); - + // note, it's important to scan the items BEFORE we make the // UnmatchedFileMap because that creates a bunch of NEW // folders and files (unattached to repository) and we // don't want to include those in our traversal. - UnmatchedFileMap ufm = + UnmatchedFileMap ufm = new CheckinMap().init( targetFolder.getAbsoluteFile(), starteamFolder); for (int i = 0, size = foldersList.length; i < size; i++) { Folder stFolder = foldersList[i]; - java.io.File subfolder = + java.io.File subfolder = new java.io.File(targetFolder, stFolder.getName()); ufm.removeControlledItem(subfolder); @@ -262,12 +260,12 @@ public class StarTeamCheckin extends TreeBasedTask { } } - + 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]; processFile(stFile); - + ufm.removeControlledItem( 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 - * + * * @param remotefile the Star Team file being processed. - * + * * @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(); sb.append(remotefile.getFullName()) .append(" --> ") @@ -328,23 +325,21 @@ public class StarTeamCheckin extends TreeBasedTask { if (fileStatus == Status.MODIFIED) { log("Checking in: " + describeCheckin(eachFile)); - } - else if (fileStatus == Status.MISSING) { + } else if (fileStatus == Status.MISSING) { log("Local file missing: " + describeCheckin(eachFile)); checkin = false; - } - else { + } else { 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 { - log("Skipping: " + getFullRepositoryPath(eachFile) + - " - status: " + Status.name(fileStatus)); + log("Skipping: " + getFullRepositoryPath(eachFile) + + " - status: " + Status.name(fileStatus)); checkin = false; } } if (checkin) { - eachFile.checkin(this.comment, this.lockStatus, + eachFile.checkin(this.comment, this.lockStatus, this.isForced(), true, true); } } @@ -357,10 +352,10 @@ public class StarTeamCheckin extends TreeBasedTask { 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 * will contain only uncontrolled items. */ @@ -371,26 +366,26 @@ public class StarTeamCheckin extends TreeBasedTask { java.io.File local = (java.io.File) e.nextElement(); Item remoteItem = (Item) this.get(local); 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. if (local.isDirectory()) { Folder folder = (Folder) remoteItem; - log("Added uncontrolled folder " + log("Added uncontrolled folder " + folder.getFolderHierarchy() + " from " + local.getAbsoluteFile()); if (isRecursive()) { - UnmatchedFileMap submap = + UnmatchedFileMap submap = new CheckinMap().init(local, folder); submap.processUncontrolledItems(); } } else { com.starbase.starteam.File remoteFile = (com.starbase.starteam.File) remoteItem; - log("Added uncontrolled file " + log("Added uncontrolled file " + TreeBasedTask.getFullRepositoryPath(remoteFile) + " from " + local.getAbsoluteFile()); - + } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckout.java b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckout.java index c4ab13df3..35f193f36 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckout.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckout.java @@ -59,6 +59,7 @@ import com.starbase.starteam.Status; import com.starbase.starteam.View; import com.starbase.starteam.ViewConfiguration; import java.io.IOException; +import java.io.File; import java.util.Enumeration; import java.util.Hashtable; import org.apache.tools.ant.BuildException; @@ -100,7 +101,7 @@ public class StarTeamCheckout extends TreeBasedTask { /** * 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 * server's EOL convention. */ @@ -134,10 +135,10 @@ public class StarTeamCheckout extends TreeBasedTask { public void setConvertEOL(boolean value) { this.convertEOL = value; } - + /** * 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 */ public void setLabel(String label) { @@ -156,7 +157,7 @@ public class StarTeamCheckout extends TreeBasedTask { 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 * changing status/. * @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 - * 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. */ private boolean useRepositoryTimeStamp = false; /** * sets the useRepositoryTimestmp member. - * + * * @param useRepositoryTimeStamp * true means checked out files will get the repository timestamp. * false means the checked out files will be timestamped at the time * of checkout. */ - public void setUseRepositoryTimeStamp(boolean useRepositoryTimeStamp) - { + public void setUseRepositoryTimeStamp(boolean useRepositoryTimeStamp) { this.useRepositoryTimeStamp = useRepositoryTimeStamp; } /** * returns the value of the useRepositoryTimestamp member - * + * * @return the value of the useRepositoryTimestamp member */ public boolean getUseRepositoryTimeStamp() { @@ -221,24 +221,22 @@ public class StarTeamCheckout extends TreeBasedTask { * appropriately configured view for checkouts - either * the current view or a view from this.label or the raw * view itself in the case of a revision label. - * + * * @param raw the unconfigured View - * + * * @return the snapshot View appropriately configured. * @exception BuildException */ - protected View createSnapshotView(View raw) - throws BuildException - { + protected View createSnapshotView(View raw) throws BuildException { 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 if (this.isUsingViewLabel()) { 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 else if (this.isUsingRevisionLabel()) { return raw; @@ -253,37 +251,36 @@ public class StarTeamCheckout extends TreeBasedTask { * Implements base-class abstract function to define tests for * any preconditons required by the task. * - * @exception BuildException thrown if both rootLocalFolder + * @exception BuildException thrown if both rootLocalFolder * and viewRootLocalFolder are defined */ protected void testPreconditions() throws BuildException { 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); - this.createDirs=false; + this.createDirs = false; } } /** * 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 + * root local folder for the operation (whether specified * by the user or not. */ 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()); @@ -293,32 +290,28 @@ public class StarTeamCheckout extends TreeBasedTask { if (this.lockStatus == Item.LockType.EXCLUSIVE) { 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 " - +"(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 " + - (this.useRepositoryTimeStamp ? "repository timestamps." + log(" Items will be checked out with " + + (this.useRepositoryTimeStamp ? "repository timestamps." : "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."); if (this.deleteUncontrolled) { 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")); - 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.")); - + } /** * Implements base-class abstract function to perform the checkout @@ -330,8 +323,7 @@ public class StarTeamCheckout extends TreeBasedTask { * @exception BuildException if any error occurs */ protected void visit(Folder starteamFolder, java.io.File targetFolder) - throws BuildException - { + throws BuildException { try { @@ -339,7 +331,7 @@ public class StarTeamCheckout extends TreeBasedTask { starteamFolder.setAlternatePathFragment( targetFolder.getAbsolutePath()); } - + if (!targetFolder.exists()) { if (!this.isUsingRevisionLabel()) { if (this.createDirs) { @@ -352,8 +344,8 @@ public class StarTeamCheckout extends TreeBasedTask { } } } - - + + Folder[] foldersList = starteamFolder.getSubFolders(); 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 // this is one ugly API from Starteam SDK - + Hashtable labelItems = new Hashtable(filesList.length); int s = filesList.length; 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)); } int[] foundIds = getLabelInUse().getLabeledItemIDs(ids); s = foundIds.length; 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; } - - + + // note, it's important to scan the items BEFORE we make the // Unmatched file map because that creates a bunch of NEW // folders and files (unattached to repository) and we // don't want to include those in our traversal. - UnmatchedFileMap ufm = + UnmatchedFileMap ufm = new CheckoutMap(). init(targetFolder.getAbsoluteFile(), starteamFolder); @@ -395,7 +387,7 @@ public class StarTeamCheckout extends TreeBasedTask { for (int i = 0; i < foldersList.length; i++) { Folder stFolder = foldersList[i]; - java.io.File subfolder = + java.io.File subfolder = new java.io.File(targetFolder, stFolder.getName()); ufm.removeControlledItem(subfolder); @@ -406,10 +398,10 @@ public class StarTeamCheckout extends TreeBasedTask { } for (int i = 0; i < filesList.length; i++) { - com.starbase.starteam.File stFile = + com.starbase.starteam.File stFile = (com.starbase.starteam.File) filesList[i]; - processFile( stFile, targetFolder); - + processFile(stFile, targetFolder); + ufm.removeControlledItem( 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 - * + * * @param remotefile the Star Team file being processed. - * + * * @return a string showing from and to full paths */ private String describeCheckout(com.starbase.starteam.File remotefile, - java.io.File localFile) - { + java.io.File localFile) { StringBuffer sb = new StringBuffer(); sb.append(getFullRepositoryPath(remotefile)) .append(" --> "); @@ -443,7 +434,7 @@ public class StarTeamCheckout extends TreeBasedTask { return sb.toString(); } private String describeCheckout(com.starbase.starteam.File remotefile) { - return describeCheckout(remotefile,null); + return describeCheckout(remotefile, null); } /** * Processes (checks out) stFilesfiles from StarTeam folder. @@ -452,17 +443,16 @@ public class StarTeamCheckout extends TreeBasedTask { * @param targetFolder a java.io.File (Folder) to work * @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(); java.io.File localFile = new java.io.File(targetFolder, filename); // If the file doesn't pass the include/exclude tests, skip it. if (!shouldProcess(filename)) { - log("Excluding " + getFullRepositoryPath(eachFile), + log("Excluding " + getFullRepositoryPath(eachFile), Project.MSG_INFO); return; } @@ -486,8 +476,7 @@ public class StarTeamCheckout extends TreeBasedTask { if (success) { log("Checked out " + describeCheckout(eachFile, localFile)); } - } - else { + } else { boolean checkout = true; // 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 // another chance. - if (fileStatus == Status.MERGE || - fileStatus == Status.UNKNOWN) - { + if (fileStatus == Status.MERGE + || fileStatus == Status.UNKNOWN) { eachFile.updateStatus(true, true); 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) { @@ -524,12 +512,12 @@ public class StarTeamCheckout extends TreeBasedTask { break; default: if (isForced()) { - log("Forced checkout of " - + describeCheckout(eachFile) + log("Forced checkout of " + + describeCheckout(eachFile) + " over status " + Status.name(fileStatus)); } else { - log("Skipping: " + getFullRepositoryPath(eachFile) + - " - status: " + Status.name(fileStatus)); + log("Skipping: " + getFullRepositoryPath(eachFile) + + " - status: " + Status.name(fileStatus)); checkout = false; } } @@ -543,7 +531,7 @@ public class StarTeamCheckout extends TreeBasedTask { "Failed to create local folder " + targetFolder); } } - eachFile.checkout(this.lockStatus, + eachFile.checkout(this.lockStatus, !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 * the action to be taken is simply to delete the local files. No * further interaction with the repository is necessary. - * + * * @param localFolder * the local folder from which the mappings will be made. * @param remoteFolder @@ -572,18 +560,17 @@ public class StarTeamCheckout extends TreeBasedTask { } 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(); - + log("adding " + localFile + " to UnmatchedFileMap", Project.MSG_DEBUG); - + if (localFile.isDirectory()) { this.put(localFile, ""); - } - else { + } else { this.put(localFile, ""); } } @@ -591,7 +578,7 @@ public class StarTeamCheckout extends TreeBasedTask { } - + /** * deletes uncontrolled items from the local tree. It is assumed * 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 * everything in it. - * + * * @param local The local file or folder to be deleted. */ 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. if (local.isDirectory() && isRecursive()) { 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]); delete(file); } - } + } local.delete(); log("Deleted uncontrolled item " + local.getAbsolutePath()); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamLabel.java b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamLabel.java index 0f0667895..1e91d42f9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamLabel.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamLabel.java @@ -98,7 +98,7 @@ public class StarTeamLabel extends StarTeamTask { * true. */ private boolean buildlabel = false; - + /** * If true, this will be a revision label. If false, it will be a build * 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. - * - * @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 */ - public void setBuildLabel( boolean buildlabel ) { + public void setBuildLabel(boolean 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. - * - * @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 */ - public void setRevisionLabel( boolean revisionlabel ) { + public void setRevisionLabel(boolean 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 yyyyMMddHHmmss */ public void setLastBuild(String lastbuild) throws BuildException { @@ -162,8 +162,8 @@ public class StarTeamLabel extends StarTeamTask { Date lastBuildTime = DATE_FORMAT.parse(lastbuild); this.lastBuild = new OLEDate(lastBuildTime); } 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 { 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(); @@ -187,19 +186,17 @@ public class StarTeamLabel extends StarTeamTask { if (this.revisionlabel) { new Label(snapshot, this.labelName, this.description).update(); 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(); - 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, this.buildlabel).update(); - log("Created View Label (" - +(this.buildlabel ? "" : "non-") + "build) " + this.labelName); + log("Created View Label (" + + (this.buildlabel ? "" : "non-") + "build) " + this.labelName); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamList.java b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamList.java index 541a92f2f..e5faa85d9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamList.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamList.java @@ -81,7 +81,7 @@ public class StarTeamList extends TreeBasedTask { private boolean listUncontrolled = true; /** * 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. * * @param label the label to be listed @@ -93,7 +93,7 @@ public class StarTeamList extends TreeBasedTask { /** * Override of base-class abstract function creates an * 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 View * @return the snapshot View appropriately configured. @@ -130,11 +130,11 @@ public class StarTeamList extends TreeBasedTask { * root local folder for the operation (whether specified by the user or not. */ 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(), Project.MSG_INFO); logLabel(); @@ -161,16 +161,15 @@ public class StarTeamList extends TreeBasedTask { } Folder[] subFolders = starteamFolder.getSubFolders(); Item[] files = starteamFolder.getItems(getTypeNames().FILE); - - UnmatchedFileMap ufm = + + UnmatchedFileMap ufm = new UnmatchedListingMap().init( targetFolder.getAbsoluteFile(), starteamFolder); 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 @@ -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"); protected void list(File reposFile, java.io.File localFile) @@ -220,7 +219,7 @@ public class StarTeamList extends TreeBasedTask { StringBuffer b = new StringBuffer(); int status = reposFile.getStatus(); java.util.Date displayDate = null; - if (status==Status.NEW) { + if (status == Status.NEW) { displayDate = new java.util.Date(localFile.lastModified()); } else { displayDate = reposFile.getModifiedTime().createDate(); @@ -263,23 +262,23 @@ public class StarTeamList extends TreeBasedTask { protected boolean isActive() { return StarTeamList.this.listUncontrolled; } - + /** * lists uncontrolled items from the local tree. 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 * will contain only uncontrolled items. */ - void processUncontrolledItems() throws BuildException{ + void processUncontrolledItems() throws BuildException { if (this.isActive()) { Enumeration e = this.keys(); - + // handle the files so they appear first while (e.hasMoreElements()) { java.io.File local = (java.io.File) e.nextElement(); 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. if (local.isFile()) { com.starbase.starteam.File remoteFile = @@ -287,7 +286,7 @@ public class StarTeamList extends TreeBasedTask { try { list(remoteFile, local); } 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(); 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. if (local.isDirectory()) { Folder folder = (Folder) remoteItem; if (isRecursive()) { - log("Listing uncontrolled folder " + log("Listing uncontrolled folder " + folder.getFolderHierarchy() + " from " + local.getAbsoluteFile()); - UnmatchedFileMap submap = + UnmatchedFileMap submap = new UnmatchedListingMap().init(local, folder); submap.processUncontrolledItems(); } @@ -313,11 +312,7 @@ public class StarTeamList extends TreeBasedTask { } } } - - } - - -}// StarTeamList +} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamTask.java index 5816528c3..cbe0f50c0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamTask.java @@ -116,8 +116,8 @@ public abstract class StarTeamTask extends Task { private Server server = null; 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; * required if URL 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) */ public final void setViewname(String viewname) { @@ -212,7 +212,7 @@ public abstract class StarTeamTask extends Task { /** * Set the server name, server port, * 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 String of the form * "servername:portnum/project/view" @@ -256,17 +256,16 @@ public abstract class StarTeamTask extends Task { * @see #getViewname() */ 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 * methods. - * + * * @return the URL string for this task. */ protected final String getViewURL() { @@ -333,7 +332,7 @@ public abstract class StarTeamTask extends Task { * @param rawview the unconfigured View * @return the snapshot View appropriately configured. */ - protected abstract View createSnapshotView(View rawview) + protected abstract View createSnapshotView(View rawview) throws BuildException; /** @@ -358,8 +357,8 @@ public abstract class StarTeamTask extends Task { } 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); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java index 3010427d3..bafc193d2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java @@ -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 ('/'). * @param rootStarteamFolder the root folder */ @@ -186,11 +186,11 @@ public abstract class TreeBasedTask extends StarTeamTask { * to which files are checked out; optional. * If this is not supplied, then the StarTeam "default folder" * associated with rootstarteamfolder is used. - * + * * @param rootLocalFolder * the local folder that will mirror * this.rootStarteamFolder - * + * * @see rootLocalFolder */ public void setRootLocalFolder(String rootLocalFolder) { @@ -203,7 +203,7 @@ public abstract class TreeBasedTask extends StarTeamTask { * Returns the local folder specified by the user, * corresponding to the starteam folder for this operation * or null if not specified. - * + * * @return the local folder that mirrors this.rootStarteamFolder * @see rootLocalFolder */ @@ -213,7 +213,7 @@ public abstract class TreeBasedTask extends StarTeamTask { /** - * Declare files to include using standard includes patterns; optional. + * Declare files to include using standard includes patterns; optional. * @param includes A string of filter patterns to include. Separate the * patterns by spaces. * @see #getIncludes() @@ -243,12 +243,12 @@ public abstract class TreeBasedTask extends StarTeamTask { */ protected void logIncludes() { if (this.DEFAULT_INCLUDESETTING != this.includes) { - log(" Includes specified: "+ this.includes); + log(" Includes specified: " + this.includes); } } /** - * Declare files to exclude using standard excludes patterns; optional. + * Declare files to exclude using standard excludes patterns; optional. * When filtering files, AntStarTeamCheckOut * uses an unmodified version of DirectoryScanner's * match method, so here are the patterns straight from the @@ -304,7 +304,7 @@ public abstract class TreeBasedTask extends StarTeamTask { */ protected void logExcludes() { 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 rootlocalfolder 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 rootlocalfolder 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. */ 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. - * + * * @return true if a label has been specified and it is a view label */ 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. - * + * * @return true if a label has been specified and it is a revision label */ protected boolean isUsingRevisionLabel() { - return null != this.labelInUse && - this.labelInUse.isRevisionLabel(); + return null != this.labelInUse && this.labelInUse.isRevisionLabel(); } /** * returns the label being used - * - * @return + * + * @return */ protected Label getLabelInUse() { return this.labelInUse; @@ -418,8 +416,7 @@ public abstract class TreeBasedTask extends StarTeamTask { protected void logLabel() { if (this.isUsingViewLabel()) { log(" Using view label " + getLabel()); - } - else if (this.isUsingRevisionLabel()) { + } else if (this.isUsingRevisionLabel()) { 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. * Don't process it if it fits no include filters or if * it fits an exclude filter. - * + * * @param pName the item name to look for being included. - * + * * @return whether the file should be processed or not. */ 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 * by this task. This will be one of the following cases: - * + * * @return Starteam's root folder for the operation. * @exception BuildException * 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; try { // 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; - } - 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) { - 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; } - + /** * Returns the local folder mapped to the given StarTeam root folder * of the operation. There are two cases here, depending on whether - * rootLocalFolder is defined. - * If rootLocalFolder is defined, it will be used to - * establish a root mapping. Otherwise, the repository's default root + * rootLocalFolder is defined. + * If rootLocalFolder is defined, it will be used to + * establish a root mapping. Otherwise, the repository's default root * folder will be used. - * + * * @param starteamrootfolder * root Starteam folder initialized for the operation - * + * * @return the local folder corresponding to the root Starteam folder. * @see findRootStarteamFolder */ @@ -541,33 +533,32 @@ public abstract class TreeBasedTask extends StarTeamTask { String localrootfolder; if (null != this.rootLocalFolder) { localrootfolder = rootLocalFolder; - } - else { + } else { // either use default path or root local mapping, // which is now embedded in the root folder localrootfolder = starteamrootfolder.getPathFragment(); } return new java.io.File(localrootfolder); - + } /** * 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. */ - protected abstract void logOperationDescription( + protected abstract void logOperationDescription( Folder starteamrootFolder, java.io.File targetrootFolder); /** * This method does the work of opening the supplied Starteam view and * calling the visit() method to perform the task. - * Derived classes can customize the called methods + * Derived classes can customize the called methods * testPreconditions() and visit(). * * @exception BuildException if any error occurs in the processing @@ -581,14 +572,14 @@ public abstract class TreeBasedTask extends StarTeamTask { Folder starteamrootfolder = configureRootStarteamFolder(); // set the local folder. - java.io.File localrootfolder = + java.io.File localrootfolder = getLocalRootMapping(starteamrootfolder); testPreconditions(); - + // Tell user what he is doing logOperationDescription(starteamrootfolder, localrootfolder); - + // Inspect everything in the root folder and then recursively visit(starteamrootfolder, localrootfolder); @@ -645,12 +636,12 @@ public abstract class TreeBasedTask extends StarTeamTask { /** * Derived classes must override this class to define actual processing * to be performed on each folder in the tree defined for the task - * + * * @param rootStarteamFolder * the StarTeam folderto be visited * @param rootLocalFolder * the local mapping of rootStarteamFolder - * + * * @exception BuildException */ 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 * no method in com.starbase.starteam.File to provide this. - * + * * @param remotefile the Star Team file whose path is to be returned - * + * * @return the full repository path name of a file. */ public static String getFullRepositoryPath( - com.starbase.starteam.File remotefile) - { + com.starbase.starteam.File remotefile) { StringBuffer sb = new StringBuffer(); sb.append(remotefile.getParentFolderHierarchy()) .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 * unattached StarTeam object of the proper type, File->File and * Directory->Folder. - * + * * 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, * whatever items left in the UnmatchedFileMap are uncontrolled items * 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. */ protected abstract class UnmatchedFileMap extends Hashtable { - + /** * initializes the UnmatchedFileMap with entries from the local folder * 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. - * + * * @param localFolder * the local folder from which the mappings will be made. * @param remoteFolder @@ -725,20 +715,19 @@ public abstract class TreeBasedTask extends StarTeamTask { } String[] localFiles = localFolder.list(); - - for (int i=0; i < localFiles.length; i++) { + + for (int i = 0; i < localFiles.length; i++) { String fn = localFiles[i]; - java.io.File localFile = + java.io.File localFile = new java.io.File(localFolder, localFiles[i]).getAbsoluteFile(); - + log("adding " + localFile + " to UnmatchedFileMap", Project.MSG_DEBUG); - + 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); remoteFile.setName(fn); this.put(localFile, remoteFile); @@ -746,37 +735,37 @@ public abstract class TreeBasedTask extends StarTeamTask { } return this; } - + /** * remove an item found to be controlled from the map. - * + * * @param localFile the local item found to be controlled. */ void removeControlledItem(java.io.File localFile) { 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()); } } /** * 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 - * 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. */ 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 not called for. - * + * * @return True if this object is to perform its functionality. */ - abstract protected boolean isActive(); - + protected abstract boolean isActive(); + } }