diff --git a/docs.xml b/docs.xml
index e662022ad..12f09028e 100644
--- a/docs.xml
+++ b/docs.xml
@@ -16,8 +16,8 @@
-
-
+
@@ -25,7 +25,7 @@
- AnakiaTask is not present! Please check to make sure that
+ AnakiaTask is not present! Please check to make sure that
velocity.jar is in your classpath.
@@ -34,7 +34,7 @@
-
+
-
+
-
+
diff --git a/src/main/org/apache/tools/ant/ExitException.java b/src/main/org/apache/tools/ant/ExitException.java
index 5f9cfe031..74da3a64d 100644
--- a/src/main/org/apache/tools/ant/ExitException.java
+++ b/src/main/org/apache/tools/ant/ExitException.java
@@ -64,7 +64,7 @@ public class ExitException extends SecurityException {
/** Status code */
private int status;
-
+
/**
* Constructs an exit exception.
* @param status the status code returned via System.exit()
diff --git a/src/main/org/apache/tools/ant/MagicNames.java b/src/main/org/apache/tools/ant/MagicNames.java
index 378de29d5..ec9b3c465 100644
--- a/src/main/org/apache/tools/ant/MagicNames.java
+++ b/src/main/org/apache/tools/ant/MagicNames.java
@@ -54,8 +54,8 @@
package org.apache.tools.ant;
/**
- * Magic names used within Ant.
- *
+ * Magic names used within Ant.
+ *
* Not all magic names are here yet.
*
* @author Conor MacNeill
@@ -64,5 +64,9 @@ package org.apache.tools.ant;
public class MagicNames {
/** The name of the script repository used by the script repo task */
public static final String SCRIPT_REPOSITORY = "org.apache.ant.scriptrepo";
+
+ /** The name of the reference to the System Class Loader */
+ public static final String SYSTEM_LOADER_REF = "ant.coreLoader";
+
}
diff --git a/src/main/org/apache/tools/ant/filters/TokenFilter.java b/src/main/org/apache/tools/ant/filters/TokenFilter.java
index 388083e2c..e1529519c 100644
--- a/src/main/org/apache/tools/ant/filters/TokenFilter.java
+++ b/src/main/org/apache/tools/ant/filters/TokenFilter.java
@@ -594,7 +594,7 @@ public class TokenFilter extends BaseFilterReader
* Abstract class that converts derived filter classes into
* ChainableReaderFilter's
*/
- public static abstract class ChainableReaderFilter extends ProjectComponent
+ public abstract static class ChainableReaderFilter extends ProjectComponent
implements ChainableReader, Filter {
private boolean byLine = true;
diff --git a/src/main/org/apache/tools/ant/taskdefs/Classloader.java b/src/main/org/apache/tools/ant/taskdefs/Classloader.java
index c406e793b..070097c5d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Classloader.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Classloader.java
@@ -54,11 +54,15 @@
package org.apache.tools.ant.taskdefs;
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.types.*;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.MagicNames;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.types.Reference;
+import org.apache.tools.ant.types.Path;
-import java.io.*;
-import java.util.*;
+import java.io.File;
/**
* EXPERIMENTAL
@@ -66,11 +70,11 @@ import java.util.*;
* will be used to add classpath elements.
*
* The classpath is a regular path. Currently only file components are
- * supported ( future extensions may allow URLs ).
+ * supported (future extensions may allow URLs).
*
* You can modify the core loader by not specifying any name or using
- * "ant.coreLoader". ( the core loader is used to load system ant
- * tasks and for taskdefs that don't specify an explicit path ).
+ * "ant.coreLoader". (the core loader is used to load system ant
+ * tasks and for taskdefs that don't specify an explicit path).
*
* Taskdef and typedef can use the loader you create if the name follows
* the "ant.loader.NAME" pattern. NAME will be used as a pathref when
@@ -93,58 +97,63 @@ import java.util.*;
* @author Costin Manolache
*/
public class Classloader extends Task {
- public static final String SYSTEM_LOADER_REF="ant.coreLoader";
+ /** @see MagicNames#SYSTEM_LOADER_REF */
+ public static final String SYSTEM_LOADER_REF = MagicNames.SYSTEM_LOADER_REF;
- private String name=null;
+ private String name = null;
private Path classpath;
- private boolean reset=false;
- private boolean parentFirst=true;
- private String parentName=null;
+ private boolean reset = false;
+ private boolean parentFirst = true;
+ private String parentName = null;
+ /**
+ * Default constructor
+ */
public Classloader() {
}
/** Name of the loader. If none, the default loader will be modified
*
- * @param name
+ * @param name the name of this loader
*/
public void setName(String name) {
- this.name=name;
+ this.name = name;
}
- /** Reset the classloader, if it already exists. A new loader will
+ /**
+ * Reset the classloader, if it already exists. A new loader will
* be created and all the references to the old one will be removed.
- * ( it is not possible to remove paths from a loader ). The new
+ * (it is not possible to remove paths from a loader). The new
* path will be used.
*
- * @param b
+ * @param b true if the loader is to be reset.
*/
public void setReset(boolean b) {
- this.reset=b;
+ this.reset = b;
}
- public void setReverse(boolean b ) {
- this.parentFirst= ! b;
+ public void setReverse(boolean b) {
+ this.parentFirst = !b;
}
- public void setParentFirst(boolean b ) {
- this.parentFirst= b;
+ public void setParentFirst(boolean b) {
+ this.parentFirst = b;
}
// TODO: add exceptions for delegation or reverse
// TODO
- public void setParentName( String name ) {
- this.parentName=name;
+ public void setParentName(String name) {
+ this.parentName = name;
}
/** Specify which path will be used. If the loader already exists
- * and is an AntClassLoader ( or any other loader we can extend ),
+ * and is an AntClassLoader (or any other loader we can extend),
* the path will be added to the loader.
*/
- public void setClasspathRef( Reference pathRef ) throws BuildException {
- classpath=(Path)pathRef.getReferencedObject(project);
+ public void setClasspathRef(Reference pathRef) throws BuildException {
+ classpath = (Path) pathRef.getReferencedObject(project);
}
/**
@@ -171,71 +180,70 @@ public class Classloader extends Task {
public void execute() {
try {
// Gump friendly - don't mess with the core loader if only classpath
- if( "only".equals( project.getProperty("build.sysclasspath")) &&
- (name==null || SYSTEM_LOADER_REF.equals( name ))) {
- log( "Changing the system loader is disabled " +
- "by build.sysclasspath=only",
- Project.MSG_WARN);
+ if ("only".equals(project.getProperty("build.sysclasspath"))
+ && (name == null || SYSTEM_LOADER_REF.equals(name))) {
+ log("Changing the system loader is disabled "
+ + "by build.sysclasspath=only", Project.MSG_WARN);
return;
}
- String loaderName=(name==null) ? SYSTEM_LOADER_REF : name;
+ String loaderName = (name == null) ? SYSTEM_LOADER_REF : name;
- Object obj=project.getReference(loaderName);
- if( reset ) {
+ Object obj = project.getReference(loaderName);
+ if (reset) {
// Are any other references held ? Can we 'close' the loader
// so it removes the locks on jars ?
- obj=null; // a new one will be created.
+ obj = null; // a new one will be created.
}
- // XXX maybe use reflection to addPathElement ( other patterns ?)
- if( obj!=null && !(obj instanceof AntClassLoader )) {
- log( "Referenced object is not an AntClassLoader",
+ // XXX maybe use reflection to addPathElement (other patterns ?)
+ if (obj != null && !(obj instanceof AntClassLoader)) {
+ log("Referenced object is not an AntClassLoader",
Project.MSG_ERR);
return;
}
- AntClassLoader acl=(AntClassLoader)obj;
+ AntClassLoader acl = (AntClassLoader) obj;
- if( acl==null ) {
+ if (acl == null) {
// Construct a new class loader
- Object parent=null;
- if( parentName != null ) {
- parent=project.getReference(parentName);
- if( !(parent instanceof ClassLoader) ) {
- parent=null;
+ Object parent = null;
+ if (parentName != null) {
+ parent = project.getReference(parentName);
+ if (!(parent instanceof ClassLoader)) {
+ parent = null;
}
}
// TODO: allow user to request the system or no parent
- if( parent==null ) {
- parent=this.getClass().getClassLoader();
+ if (parent == null) {
+ parent = this.getClass().getClassLoader();
}
- if( name==null ) {
+ if (name == null) {
// The core loader must be reverse
//reverse=true;
}
- project.log("Setting parent loader " + name + " " +
- parent + " " + parentFirst, Project.MSG_DEBUG);
+ project.log("Setting parent loader " + name + " "
+ + parent + " " + parentFirst, Project.MSG_DEBUG);
// The param is "parentFirst"
- acl=new AntClassLoader( (ClassLoader)parent,
- project, classpath, parentFirst );
+ acl = new AntClassLoader((ClassLoader) parent,
+ project, classpath, parentFirst);
- project.addReference( loaderName, acl );
+ project.addReference(loaderName, acl);
- if( name==null ) {
+ if (name == null) {
// This allows the core loader to load optional tasks
// without delegating
- acl.addLoaderPackageRoot( "org.apache.tools.ant.taskdefs.optional");
+ acl.addLoaderPackageRoot("org.apache.tools.ant.taskdefs.optional");
project.setCoreLoader(acl);
}
}
- if( classpath != null ) {
- String list[]=classpath.list();
- for( int i=0; i 1) {
- throw new BuildException("You must not nest more than one condition into ");
+ throw new BuildException("You must not nest more than one "
+ + "condition into ");
}
if (countConditions() < 1) {
throw new BuildException("You must nest a condition into ");
diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingOutputStream.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingOutputStream.java
index a35f51938..110bbea82 100644
--- a/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingOutputStream.java
+++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingOutputStream.java
@@ -63,7 +63,7 @@ import org.apache.tools.ant.taskdefs.LogOutputStream;
*/
class RedirectingOutputStream
extends LogOutputStream {
- private final ChangeLogParser m_parser;
+ private final ChangeLogParser parser;
/**
@@ -73,7 +73,7 @@ class RedirectingOutputStream
*/
public RedirectingOutputStream(final ChangeLogParser parser) {
super(null, 0);
- m_parser = parser;
+ this.parser = parser;
}
@@ -83,7 +83,7 @@ class RedirectingOutputStream
* @param line the line to log.
*/
protected void processLine(final String line) {
- m_parser.stdout(line);
+ parser.stdout(line);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java
index 321c848bb..7c9f3034e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java
+++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java
@@ -74,7 +74,7 @@ class RedirectingStreamHandler
String getErrors() {
try {
- final ByteArrayOutputStream error
+ final ByteArrayOutputStream error
= (ByteArrayOutputStream) getErr();
return error.toString("ASCII");
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java
index 22fb668de..57ed41209 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java
@@ -63,6 +63,9 @@ import java.util.Date;
*/
public class CCMCheckin extends CCMCheck {
+ /**
+ * Default constructor - setup checkin command
+ */
public CCMCheckin() {
super();
setCcmAction(COMMAND_CHECKIN);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
index 6beb50597..082845c0b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
@@ -77,12 +77,16 @@ import org.apache.tools.ant.types.Path;
public class JonasDeploymentTool extends GenericDeploymentTool {
/** Public Id of the standard deployment descriptor DTD. */
- protected static final String EJB_JAR_1_1_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";
- protected static final String EJB_JAR_2_0_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN";
+ protected static final String EJB_JAR_1_1_PUBLIC_ID
+ = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";
+ protected static final String EJB_JAR_2_0_PUBLIC_ID
+ = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN";
/** Public Id of the JOnAS-specific deployment descriptor DTD. */
- protected static final String JONAS_EJB_JAR_2_4_PUBLIC_ID = "-//ObjectWeb//DTD JOnAS 2.4//EN";
- protected static final String JONAS_EJB_JAR_2_5_PUBLIC_ID = "-//ObjectWeb//DTD JOnAS 2.5//EN";
+ protected static final String JONAS_EJB_JAR_2_4_PUBLIC_ID
+ = "-//ObjectWeb//DTD JOnAS 2.4//EN";
+ protected static final String JONAS_EJB_JAR_2_5_PUBLIC_ID
+ = "-//ObjectWeb//DTD JOnAS 2.5//EN";
/** RMI ORB. */
protected static final String RMI_ORB = "RMI";
@@ -104,8 +108,10 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
* Name of the JOnAS-specific deployment descriptor DTD (these files are
* stored in the ${JONAS_ROOT}/xml directory).
*/
- protected static final String JONAS_EJB_JAR_2_4_DTD = "jonas-ejb-jar_2_4.dtd";
- protected static final String JONAS_EJB_JAR_2_5_DTD = "jonas-ejb-jar_2_5.dtd";
+ protected static final String JONAS_EJB_JAR_2_4_DTD
+ = "jonas-ejb-jar_2_4.dtd";
+ protected static final String JONAS_EJB_JAR_2_5_DTD
+ = "jonas-ejb-jar_2_5.dtd";
/** Default JOnAS deployment descriptor name. */
protected static final String JONAS_DD = "jonas-ejb-jar.xml";
@@ -215,7 +221,10 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
*/
private String orb;
- /** true
if GenIC must not be run on the EJB JAR. The default is false
. */
+ /**
+ * true
if GenIC must not be run on the EJB JAR.
+ * The default is false
.
+ */
private boolean nogenic = false;
/* -------------------- */
@@ -365,7 +374,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
super.processDescriptor(descriptorName, saxParser);
- if ( outputdir != null ) {
+ if (outputdir != null) {
// the method deleteOnExit() do not work because the directory is not empty
log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
deleteAllFiles(outputdir);
@@ -378,14 +387,14 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
// create the generic jar first
File genericJarFile = super.getVendorOutputJarFile(baseName);
super.writeJar(baseName, genericJarFile, ejbFiles, publicId);
-
+
// GenIC call on generic jar
addGenICGeneratedFiles(genericJarFile, ejbFiles);
-
+
// create the real jar
super.writeJar(baseName, getVendorOutputJarFile(baseName), ejbFiles, publicId);
-
- if ( !keepgeneric ) {
+
+ if (!keepgeneric) {
log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);
genericJarFile.delete();
}
@@ -397,7 +406,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
jonasDescriptorName = getJonasDescriptorName();
File jonasDD = new File(getConfig().descriptorDir, jonasDescriptorName);
- if ( jonasDD.exists() ) {
+ if (jonasDD.exists()) {
ejbFiles.put(META_DIR + JONAS_DD, jonasDD);
} else {
log("Unable to locate the JOnAS deployment descriptor. It was expected to be in: "
@@ -431,18 +440,19 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
String remainder; // Filename appearing after the name terminator
int startOfFileName = descriptorName.lastIndexOf(File.separatorChar);
- if ( startOfFileName != -1 ) {
+ if (startOfFileName != -1) {
// extract path info
- path = descriptorName.substring(0, startOfFileName+1);
- fileName = descriptorName.substring(startOfFileName+1);
+ path = descriptorName.substring(0, startOfFileName + 1);
+ fileName = descriptorName.substring(startOfFileName + 1);
} else {
// descriptorName is just a file without path
path = "";
fileName = descriptorName;
}
- if ( fileName.startsWith(EJB_DD) )
+ if (fileName.startsWith(EJB_DD)) {
return path + JONAS_DD;
+ }
int endOfBaseName = descriptorName.indexOf(getConfig().baseNameTerminator, startOfFileName);
@@ -451,7 +461,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
* extension aren't found. These will ensure "jonas-" appears at the
* end of the name and before the '.' (if present).
*/
- if ( endOfBaseName < 0 ) {
+ if (endOfBaseName < 0) {
// baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
// not [Foo-ejb-jar.xml,
@@ -468,7 +478,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
baseName = descriptorName.substring(startOfFileName + 1, endOfBaseName + 1);
remainder = descriptorName.substring(endOfBaseName + 1);
- if ( jonasConvention ) {
+ if (jonasConvention) {
jonasDescriptorName = path + "jonas-" + baseName + ".xml";
} else {
jonasDescriptorName = path + baseName + "jonas-" + remainder;
@@ -484,10 +494,10 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
String baseName = null;
- if ( getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR) ) {
+ if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)) {
// try to find JOnAS specific convention name
- if ( descriptorFileName.indexOf(getConfig().baseNameTerminator) == -1 ) {
+ if (descriptorFileName.indexOf(getConfig().baseNameTerminator) == -1) {
// baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
@@ -498,19 +508,19 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/');
int endOfBaseName;
- if ( lastSeparatorIndex != -1 ) {
+ if (lastSeparatorIndex != -1) {
endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex);
} else {
endOfBaseName = descriptorFileName.indexOf(".xml");
}
- if ( endOfBaseName != -1 ) {
+ if (endOfBaseName != -1) {
baseName = descriptorFileName.substring(0, endOfBaseName);
}
}
}
- if ( baseName == null ) {
+ if (baseName == null) {
// else get standard baseName
baseName = super.getJarBaseName(descriptorFileName);
}
@@ -525,7 +535,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
jonasroot + File.separator + "xml" + File.separator + EJB_JAR_1_1_DTD);
handler.registerDTD(EJB_JAR_2_0_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + EJB_JAR_2_0_DTD);
-
+
handler.registerDTD(JONAS_EJB_JAR_2_4_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + JONAS_EJB_JAR_2_4_DTD);
handler.registerDTD(JONAS_EJB_JAR_2_5_PUBLIC_ID,
@@ -539,29 +549,32 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
* @param ejbFiles the hashtable.
*/
private void addGenICGeneratedFiles(File genericJarFile, Hashtable ejbFiles) {
+ // GenIC task
+ Java genicTask = null;
+
+ // GenIC class (3 GenIC classes for various versions of JOnAS
+ // are supported)
+ String genicClass = null;
- Java genicTask = null; // GenIC task
- String genicClass = null; // GenIC class (3 GenIC classes for various versions of JOnAS are supported)
-
- if ( nogenic ) {
+ if (nogenic) {
return;
}
-
+
genicTask = (Java) getTask().getProject().createTask("java");
genicTask.setTaskName("genic");
genicTask.setFork(true);
-
+
// jonasroot
genicTask.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
-
+
// java policy file
String jonasConfigDir = jonasroot + File.separator + "config";
File javaPolicyFile = new File(jonasConfigDir, "java.policy");
- if ( javaPolicyFile.exists() ) {
+ if (javaPolicyFile.exists()) {
genicTask.createJvmarg().setValue("-Djava.security.policy="
+ javaPolicyFile.toString());
}
-
+
// outputdir
try {
outputdir = createTempDir();
@@ -570,121 +583,122 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
throw new BuildException(msg, aIOException);
}
log("Using temporary output directory: " + outputdir, Project.MSG_VERBOSE);
-
+
genicTask.createArg().setValue("-d");
genicTask.createArg().setFile(outputdir);
-
+
// work around a bug of GenIC 2.5
String key;
File f;
Enumeration keys = ejbFiles.keys();
- while ( keys.hasMoreElements() ) {
- key = (String)keys.nextElement();
+ while (keys.hasMoreElements()) {
+ key = (String) keys.nextElement();
f = new File(outputdir + File.separator + key);
f.getParentFile().mkdirs();
}
log("Worked around a bug of GenIC 2.5.", Project.MSG_VERBOSE);
-
+
// classpath
Path classpath = getCombinedClasspath();
- if ( classpath == null ) {
+ if (classpath == null) {
classpath = new Path(getTask().getProject());
}
classpath.append(new Path(classpath.getProject(), jonasConfigDir));
classpath.append(new Path(classpath.getProject(), outputdir.toString()));
-
+
// try to create the classpath for the correct ORB
- if ( orb != null ) {
- String orbJar = jonasroot + File.separator + "lib" + File.separator + orb + "_jonas.jar";
+ if (orb != null) {
+ String orbJar = jonasroot + File.separator + "lib"
+ + File.separator + orb + "_jonas.jar";
classpath.append(new Path(classpath.getProject(), orbJar));
}
-
+
log("Using classpath: " + classpath.toString(), Project.MSG_VERBOSE);
genicTask.setClasspath(classpath);
-
+
// class name (search in the classpath provided for the ejbjar element)
genicClass = getGenicClassName(classpath);
- if ( genicClass == null ) {
+ if (genicClass == null) {
log("Cannot find GenIC class in classpath.", Project.MSG_ERR);
throw new BuildException("GenIC class not found, please check the classpath.");
} else {
log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE);
genicTask.setClassname(genicClass);
}
-
+
// keepgenerated
- if ( keepgenerated ) {
+ if (keepgenerated) {
genicTask.createArg().setValue("-keepgenerated");
}
-
+
// nocompil
- if ( nocompil ) {
+ if (nocompil) {
genicTask.createArg().setValue("-nocompil");
}
-
+
// novalidation
- if ( novalidation ) {
+ if (novalidation) {
genicTask.createArg().setValue("-novalidation");
}
-
+
// javac
- if ( javac != null ) {
+ if (javac != null) {
genicTask.createArg().setValue("-javac");
genicTask.createArg().setLine(javac);
}
-
+
// javacopts
- if ( javacopts != null && !javacopts.equals("") ) {
+ if (javacopts != null && !javacopts.equals("")) {
genicTask.createArg().setValue("-javacopts");
genicTask.createArg().setLine(javacopts);
}
-
+
// rmicopts
- if ( rmicopts != null && !rmicopts.equals("") ) {
+ if (rmicopts != null && !rmicopts.equals("")) {
genicTask.createArg().setValue("-rmicopts");
genicTask.createArg().setLine(rmicopts);
}
-
+
// secpropag
- if ( secpropag ) {
+ if (secpropag) {
genicTask.createArg().setValue("-secpropag");
}
-
+
// verbose
- if ( verbose ) {
+ if (verbose) {
genicTask.createArg().setValue("-verbose");
}
-
+
// additionalargs
- if ( additionalargs != null ) {
+ if (additionalargs != null) {
genicTask.createArg().setValue(additionalargs);
}
-
+
// the generated classes must not be added in the generic JAR!
// is that buggy on old JOnAS (2.4) ??
genicTask.createArg().setValue("-noaddinjar");
-
+
// input file to process by GenIC
genicTask.createArg().setValue(genericJarFile.getPath());
-
+
// calling GenIC task
- log("Calling " + genicClass + " for " + getConfig().descriptorDir + File.separator + descriptorName
- + ".", Project.MSG_VERBOSE);
-
- if ( genicTask.executeJava() != 0 ) {
-
+ log("Calling " + genicClass + " for " + getConfig().descriptorDir
+ + File.separator + descriptorName + ".", Project.MSG_VERBOSE);
+
+ if (genicTask.executeJava() != 0) {
+
// the method deleteOnExit() do not work because the directory is not empty
log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
deleteAllFiles(outputdir);
-
- if ( !keepgeneric ) {
+
+ if (!keepgeneric) {
log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);
genericJarFile.delete();
}
-
+
throw new BuildException("GenIC reported an error.");
}
-
+
// add the generated files to the ejbFiles
addAllFiles(outputdir, "", ejbFiles);
}
@@ -698,41 +712,44 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
*/
String getGenicClassName(Path classpath) {
- log("Looking for GenIC class in classpath: " + classpath.toString(), Project.MSG_VERBOSE);
-
+ log("Looking for GenIC class in classpath: "
+ + classpath.toString(), Project.MSG_VERBOSE);
+
AntClassLoader cl = classpath.getProject().createClassLoader(classpath);
-
+
try {
cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
- log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' in classpath.", Project.MSG_VERBOSE);
+ log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS
+ + "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.GENIC_CLASS;
-
+
} catch (ClassNotFoundException cnf1) {
- log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' not found in classpath.",
+ log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS
+ + "' not found in classpath.",
Project.MSG_VERBOSE);
}
-
+
try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1);
- log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 +
- "' in classpath.", Project.MSG_VERBOSE);
+ log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1
+ + "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_1;
-
+
} catch (ClassNotFoundException cnf2) {
- log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 +
- "' not found in classpath.",
+ log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1
+ + "' not found in classpath.",
Project.MSG_VERBOSE);
}
-
+
try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2);
- log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 +
- "' in classpath.", Project.MSG_VERBOSE);
+ log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2
+ + "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_2;
-
+
} catch (ClassNotFoundException cnf3) {
- log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 +
- "' not found in classpath.",
+ log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2
+ + "' not found in classpath.",
Project.MSG_VERBOSE);
}
return null;
@@ -742,26 +759,28 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
SAXParser saxParser) throws BuildException {
// jonasroot
- if ( jonasroot == null ) {
+ if (jonasroot == null) {
throw new BuildException("The jonasroot attribut is not set.");
- } else if ( !jonasroot.isDirectory() ) {
- throw new BuildException("The jonasroot attribut '" + jonasroot +
- "' is not a valid directory.");
+ } else if (!jonasroot.isDirectory()) {
+ throw new BuildException("The jonasroot attribut '" + jonasroot
+ + "' is not a valid directory.");
}
-
+
// orb
- if ( orb != null && !orb.equals(RMI_ORB) && !orb.equals(JEREMIE_ORB) && !orb.equals(DAVID_ORB) ) {
- throw new BuildException("The orb attribut '" + orb + "' is not valid (must be either " +
- RMI_ORB + ", " + JEREMIE_ORB + " or " + DAVID_ORB + ").");
+ if (orb != null && !orb.equals(RMI_ORB) && !orb.equals(JEREMIE_ORB)
+ && !orb.equals(DAVID_ORB)) {
+ throw new BuildException("The orb attribut '" + orb
+ + "' is not valid (must be either "
+ + RMI_ORB + ", " + JEREMIE_ORB + " or " + DAVID_ORB + ").");
}
-
+
// additionalargs
- if ( additionalargs != null && additionalargs.equals("") ) {
+ if (additionalargs != null && additionalargs.equals("")) {
throw new BuildException("Empty additionalargs attribut.");
}
-
+
// javac
- if ( javac != null && javac.equals("") ) {
+ if (javac != null && javac.equals("")) {
throw new BuildException("Empty javac attribut.");
}
}
@@ -779,7 +798,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
private File createTempDir() throws IOException {
File tmpDir = File.createTempFile("genic", null, null);
tmpDir.delete();
- if ( !tmpDir.mkdir() ) {
+ if (!tmpDir.mkdir()) {
throw new IOException("Cannot create the temporary directory '" + tmpDir + "'.");
}
return tmpDir;
@@ -792,8 +811,8 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
* @param aFile file to delete.
*/
private void deleteAllFiles(File aFile) {
- if ( aFile.isDirectory() ) {
- File someFiles[] = aFile.listFiles();
+ if (aFile.isDirectory()) {
+ File[] someFiles = aFile.listFiles();
for (int i = 0; i < someFiles.length; i++) {
deleteAllFiles(someFiles[i]);
@@ -812,15 +831,15 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
*/
private void addAllFiles(File file, String rootDir, Hashtable hashtable) {
- if ( !file.exists() ) {
+ if (!file.exists()) {
throw new IllegalArgumentException();
}
String newRootDir;
- if ( file.isDirectory() ) {
- File files[] = file.listFiles();
+ if (file.isDirectory()) {
+ File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
- if ( rootDir.length() > 0 ) {
+ if (rootDir.length() > 0) {
newRootDir = rootDir + File.separator + files[i].getName();
} else {
newRootDir = files[i].getName();
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java
index 20bc270a4..c59315e1e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java
@@ -96,7 +96,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
* Description of the Field
*/
private File jonasroot;
-
+
/**
* Description of the Field
*/
@@ -106,7 +106,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
* Description of the Field
*/
private String davidHost;
-
+
/**
* Description of the Field
*/
@@ -114,7 +114,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
/**
- * Set the host for the David ORB; required if
+ * Set the host for the David ORB; required if
* ORB==david.
*
*@param inValue The new davidhost value
@@ -125,7 +125,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
/**
- * Set the port for the David ORB; required if
+ * Set the port for the David ORB; required if
* ORB==david.
*
*@param inValue The new davidport value
@@ -147,11 +147,11 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
/**
- *
+ *
* Choose your ORB : RMI, JEREMIE, DAVID, ...; optional.
* If omitted, it defaults
* to the one present in classpath. The corresponding JOnAS JAR is
- * automatically added to the classpath. If your orb is DAVID (RMI/IIOP) you must
+ * automatically added to the classpath. If your orb is DAVID (RMI/IIOP) you must
* specify davidhost and davidport properties.
*
*@param inValue RMI, JEREMIE, DAVID,...
@@ -217,21 +217,30 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
if (jonasroot == null || jonasroot.isDirectory()) {
java.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
- java.createJvmarg().setValue("-Djava.security.policy=" + jonasroot + "/config/java.policy");
+ java.createJvmarg().setValue("-Djava.security.policy=" + jonasroot
+ + "/config/java.policy");
if ("DAVID".equals(orb)) {
- java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBClass=org.objectweb.david.libs.binding.orbs.iiop.IIOPORB");
- java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBSingletonClass=org.objectweb.david.libs.binding.orbs.ORBSingletonClass");
- java.createJvmarg().setValue("-Djavax.rmi.CORBA.StubClass=org.objectweb.david.libs.stub_factories.rmi.StubDelegate");
- java.createJvmarg().setValue("-Djavax.rmi.CORBA.PortableRemoteObjectClass=org.objectweb.david.libs.binding.rmi.ORBPortableRemoteObjectDelegate");
- java.createJvmarg().setValue("-Djavax.rmi.CORBA.UtilClass=org.objectweb.david.libs.helpers.RMIUtilDelegate");
+ java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBClass"
+ + "=org.objectweb.david.libs.binding.orbs.iiop.IIOPORB");
+ java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBSingletonClass="
+ + "org.objectweb.david.libs.binding.orbs.ORBSingletonClass");
+ java.createJvmarg().setValue("-Djavax.rmi.CORBA.StubClass="
+ + "org.objectweb.david.libs.stub_factories.rmi.StubDelegate");
+ java.createJvmarg().setValue("-Djavax.rmi.CORBA.PortableRemoteObjectClass="
+ + "org.objectweb.david.libs.binding.rmi.ORBPortableRemoteObjectDelegate");
+ java.createJvmarg().setValue("-Djavax.rmi.CORBA.UtilClass="
+ + "org.objectweb.david.libs.helpers.RMIUtilDelegate");
java.createJvmarg().setValue("-Ddavid.CosNaming.default_method=0");
- java.createJvmarg().setValue("-Ddavid.rmi.ValueHandlerClass=com.sun.corba.se.internal.io.ValueHandlerImpl");
+ java.createJvmarg().setValue("-Ddavid.rmi.ValueHandlerClass="
+ + "com.sun.corba.se.internal.io.ValueHandlerImpl");
if (davidHost != null) {
- java.createJvmarg().setValue("-Ddavid.CosNaming.default_host=" + davidHost);
+ java.createJvmarg().setValue("-Ddavid.CosNaming.default_host="
+ + davidHost);
}
if (davidPort != 0) {
- java.createJvmarg().setValue("-Ddavid.CosNaming.default_port=" + davidPort);
+ java.createJvmarg().setValue("-Ddavid.CosNaming.default_port="
+ + davidPort);
}
}
}
@@ -240,9 +249,9 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
java.createArg().setLine("-n " + getServer());
}
- if (action.equals(ACTION_DEPLOY) ||
- action.equals(ACTION_UPDATE) ||
- action.equals("redeploy")) {
+ if (action.equals(ACTION_DEPLOY)
+ || action.equals(ACTION_UPDATE)
+ || action.equals("redeploy")) {
java.createArg().setLine("-a " + getTask().getSource());
} else if (action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) {
java.createArg().setLine("-r " + getTask().getSource());
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
index 244dcbf7f..6aa849e2b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
@@ -87,7 +87,7 @@ import org.apache.tools.ant.util.FileUtils;
* del - delete files from a remote server.
* list - create a file listing.
* chmod - change unix file permissions.
- * rmdir - remove directories, if empty, from a
+ * rmdir - remove directories, if empty, from a
* remote server.
*
* Note: Some FTP servers - notably the Solaris server - seem
@@ -115,6 +115,9 @@ public class FTP
protected static final int CHMOD = 5;
protected static final int RM_DIR = 6;
+ /** Default port for FTP */
+ public static final int DEFAULT_FTP_PORT = 21;
+
private String remotedir;
private String server;
private String userid;
@@ -129,7 +132,7 @@ public class FTP
private Vector dirCache = new Vector();
private int transferred = 0;
private String remoteFileSep = "/";
- private int port = 21;
+ private int port = DEFAULT_FTP_PORT;
private boolean skipFailedTransfers = false;
private int skipped = 0;
private boolean ignoreNoncriticalErrors = false;
@@ -282,31 +285,49 @@ public class FTP
* Sets the remote directory where files will be placed. This may be a
* relative or absolute path, and must be in the path syntax expected by
* the remote server. No correction of path syntax will be performed.
+ *
+ * @param dir the remote directory name.
*/
public void setRemotedir(String dir) {
this.remotedir = dir;
}
- /** Sets the FTP server to send files to. */
+ /**
+ * Sets the FTP server to send files to.
+ *
+ * @param server the remote server name.
+ */
public void setServer(String server) {
this.server = server;
}
- /** Sets the FTP port used by the remote server. */
+ /**
+ * Sets the FTP port used by the remote server.
+ *
+ * @param port the port on which the remote server is listening.
+ */
public void setPort(int port) {
this.port = port;
}
- /** Sets the login user id to use on the specified server. */
+ /**
+ * Sets the login user id to use on the specified server.
+ *
+ * @param userid remote system userid.
+ */
public void setUserid(String userid) {
this.userid = userid;
}
- /** Sets the login password for the given user id. */
+ /**
+ * Sets the login password for the given user id.
+ *
+ * @param password the password on the remote system.
+ */
public void setPassword(String password) {
this.password = password;
}
@@ -314,6 +335,8 @@ public class FTP
/**
* If true, uses binary mode, otherwise text mode (default is binary).
+ *
+ * @param binary if true use binary mode in transfers.
*/
public void setBinary(boolean binary) {
this.binary = binary;
@@ -324,6 +347,8 @@ public class FTP
* Specifies whether to use passive mode. Set to true if you are behind a
* firewall and cannot connect without it. Passive mode is disabled by
* default.
+ *
+ * @param passive true is passive mode should be used.
*/
public void setPassive(boolean passive) {
this.passive = passive;
@@ -333,6 +358,8 @@ public class FTP
/**
* Set to true to receive notification about each file as it is
* transferred.
+ *
+ * @param verbose true if verbose notifications are required.
*/
public void setVerbose(boolean verbose) {
this.verbose = verbose;
@@ -340,8 +367,10 @@ public class FTP
/**
- * A synonym for depends. Set to true to transmit only new or changed
- * files.
+ * A synonym for depends. Set to true to transmit only new
+ * or changed files.
+ *
+ * @param newer if true only transfer newer files.
*/
public void setNewer(boolean newer) {
this.newerOnly = newer;
@@ -350,6 +379,8 @@ public class FTP
/**
* Set to true to preserve modification times for "gotten" files.
+ *
+ * @param preserveLastModified if true preserver modification times.
*/
public void setPreserveLastModified(boolean preserveLastModified) {
this.preserveLastModified = preserveLastModified;
@@ -359,6 +390,8 @@ public class FTP
/**
* Set to true to transmit only files that are new or changed from their
* remote counterparts. The default is to transmit all files.
+ *
+ * @param depends if true only transfer newer files.
*/
public void setDepends(boolean depends) {
this.newerOnly = depends;
@@ -370,6 +403,8 @@ public class FTP
* Unix standard forward slash, but can be manually overridden using this
* call if the remote server requires some other separator. Only the first
* character of the string is used.
+ *
+ * @param separator the file separator on the remote system.
*/
public void setSeparator(String separator) {
remoteFileSep = separator;
@@ -377,16 +412,22 @@ public class FTP
/**
- * Sets the file permission mode (Unix only) for files sent to the server.
+ * Sets the file permission mode (Unix only) for files sent to the
+ * server.
+ *
+ * @param theMode unix style file mode for the files sent to the remote
+ * system.
*/
-
public void setChmod(String theMode) {
this.chmod = theMode;
}
- /** Sets the default mask for file creation on a unix server. */
-
+ /**
+ * Sets the default mask for file creation on a unix server.
+ *
+ * @param theUmask unix style umask for files created on the remote server.
+ */
public void setUmask(String theUmask) {
this.umask = theUmask;
}
@@ -394,6 +435,9 @@ public class FTP
/**
* A set of files to upload or download
+ *
+ * @param set the set of files to be added to the list of files to be
+ * transferred.
*/
public void addFileset(FileSet set) {
filesets.addElement(set);
@@ -409,6 +453,10 @@ public class FTP
* work and also to encapsulate operations on the type in its own
* class.
* @ant.attribute ignore="true"
+ *
+ * @param action the FTP action to be performed.
+ *
+ * @throws BuildException if the action is not a valid action.
*/
public void setAction(String action) throws BuildException {
log("DEPRECATED - The setAction(String) method has been deprecated."
@@ -424,6 +472,10 @@ public class FTP
/**
* Sets the FTP action to be taken. Currently accepts "put", "get", "del",
* "mkdir", "chmod" and "list".
+ *
+ * @param action the FTP action to be performed.
+ *
+ * @throws BuildException if the action is not a valid action.
*/
public void setAction(Action action) throws BuildException {
this.action = action.getAction();
@@ -433,8 +485,10 @@ public class FTP
/**
* The output file for the "list" action. This attribute is ignored for
* any other actions.
+ *
+ * @param listing file in which to store the listing.
*/
- public void setListing(File listing) throws BuildException {
+ public void setListing(File listing) {
this.listing = listing;
}
@@ -443,6 +497,8 @@ public class FTP
* If true, enables unsuccessful file put, delete and get
* operations to be skipped with a warning and the remainder
* of the files still transferred.
+ *
+ * @param skipFailedTransfers true if failures in transfers are ignored.
*/
public void setSkipFailedTransfers(boolean skipFailedTransfers) {
this.skipFailedTransfers = skipFailedTransfers;
@@ -452,13 +508,20 @@ public class FTP
/**
* set the flag to skip errors on directory creation.
* (and maybe later other server specific errors)
+ *
+ * @param ignoreNoncriticalErrors true if non-critical errors should not
+ * cause a failure.
*/
public void setIgnoreNoncriticalErrors(boolean ignoreNoncriticalErrors) {
this.ignoreNoncriticalErrors = ignoreNoncriticalErrors;
}
- /** Checks to see that all required parameters are set. */
+ /**
+ * Checks to see that all required parameters are set.
+ *
+ * @throws BuildException if the configuration is not valid.
+ */
protected void checkConfiguration() throws BuildException {
if (server == null) {
throw new BuildException("server attribute must be set!");
@@ -490,6 +553,14 @@ public class FTP
/**
* For each file in the fileset, do the appropriate action: send, get,
* delete, or list.
+ *
+ * @param ftp the FTPClient instance used to perform FTP actions
+ * @param fs the fileset on which the actions are performed.
+ *
+ * @return the number of files to be transferred.
+ *
+ * @throws IOException if there is a problem reading a file
+ * @throws BuildException if there is a problem in the configuration.
*/
protected int transferFiles(FTPClient ftp, FileSet fs)
throws IOException, BuildException {
@@ -537,46 +608,26 @@ public class FTP
for (int i = 0; i < dsfiles.length; i++) {
switch (action) {
case SEND_FILES:
- {
sendFile(ftp, dir, dsfiles[i]);
break;
- }
-
case GET_FILES:
- {
getFile(ftp, dir, dsfiles[i]);
break;
- }
-
case DEL_FILES:
- {
delFile(ftp, dsfiles[i]);
break;
- }
-
case LIST_FILES:
- {
listFile(ftp, bw, dsfiles[i]);
break;
- }
-
case CHMOD:
- {
doSiteCommand(ftp, "chmod " + chmod + " " + dsfiles[i]);
transferred++;
break;
- }
-
case RM_DIR:
- {
rmDir(ftp, dsfiles[i]);
break;
- }
-
default:
- {
throw new BuildException("unknown ftp action " + action);
- }
}
}
} finally {
@@ -592,6 +643,11 @@ public class FTP
/**
* Sends all files specified by the configured filesets to the remote
* server.
+ *
+ * @param ftp the FTPClient instance used to perform FTP actions
+ *
+ * @throws IOException if there is a problem reading a file
+ * @throws BuildException if there is a problem in the configuration.
*/
protected void transferFiles(FTPClient ftp)
throws IOException, BuildException {
@@ -611,12 +667,11 @@ public class FTP
}
}
- log(transferred + " " + ACTION_TARGET_STRS[action] + " " +
- COMPLETED_ACTION_STRS[action]);
+ log(transferred + " " + ACTION_TARGET_STRS[action] + " "
+ + COMPLETED_ACTION_STRS[action]);
if (skipped != 0) {
- log(skipped + " " + ACTION_TARGET_STRS[action] +
- " were not successfully "
- + COMPLETED_ACTION_STRS[action]);
+ log(skipped + " " + ACTION_TARGET_STRS[action]
+ + " were not successfully " + COMPLETED_ACTION_STRS[action]);
}
}
@@ -627,6 +682,10 @@ public class FTP
* Unix-style paths with forward-slash separators. This can be overridden
* with the separator
task parameter. No attempt is made to
* determine what syntax is appropriate for the remote host.
+ *
+ * @param file the remote file name to be resolved
+ *
+ * @return the filename as it will appear on the server.
*/
protected String resolveFile(String file) {
return file.replace(System.getProperty("file.separator").charAt(0),
@@ -638,6 +697,11 @@ public class FTP
* Creates all parent directories specified in a complete relative
* pathname. Attempts to create existing directories will not cause
* errors.
+ *
+ * @param ftp the FTP client instance to use to execute FTP actions on
+ * the remote server.
+ * @param filename the name of the file whose parents should be created.
+ *
*/
protected void createParents(FTPClient ftp, String filename)
throws IOException, BuildException {
@@ -647,7 +711,7 @@ public class FTP
return;
}
-
+
Vector parents = new Vector();
String dirname;
@@ -662,35 +726,35 @@ public class FTP
// find first non cached dir
int i = parents.size() - 1;
-
+
if (i >= 0) {
String cwd = ftp.printWorkingDirectory();
String parent = dir.getParent();
if (parent != null) {
if (!ftp.changeWorkingDirectory(resolveFile(parent))) {
- throw new BuildException("could not change to "
+ throw new BuildException("could not change to "
+ "directory: " + ftp.getReplyString());
}
}
-
+
while (i >= 0) {
dir = (File) parents.elementAt(i--);
// check if dir exists by trying to change into it.
if (!ftp.changeWorkingDirectory(dir.getName())) {
// could not change to it - try to create it
- log("creating remote directory "
+ log("creating remote directory "
+ resolveFile(dir.getPath()), Project.MSG_VERBOSE);
- if(!ftp.makeDirectory(dir.getName())) {
+ if (!ftp.makeDirectory(dir.getName())) {
handleMkDirFailure(ftp);
}
if (!ftp.changeWorkingDirectory(dir.getName())) {
- throw new BuildException("could not change to "
+ throw new BuildException("could not change to "
+ "directory: " + ftp.getReplyString());
}
}
dirCache.addElement(dir);
}
- ftp.changeWorkingDirectory(cwd);
+ ftp.changeWorkingDirectory(cwd);
}
}
@@ -717,8 +781,8 @@ public class FTP
+ "assuming out of date.", Project.MSG_VERBOSE);
return false;
} else {
- throw new BuildException("could not date test remote file: " +
- ftp.getReplyString());
+ throw new BuildException("could not date test remote file: "
+ + ftp.getReplyString());
}
}
@@ -734,24 +798,24 @@ public class FTP
/** Sends a site command to the ftp server */
- protected void doSiteCommand(FTPClient ftp, String TheCMD)
+ protected void doSiteCommand(FTPClient ftp, String theCMD)
throws IOException, BuildException {
boolean rc;
- String MyReply[] = null;
+ String myReply[] = null;
- log("Doing Site Command: " + TheCMD, Project.MSG_VERBOSE);
+ log("Doing Site Command: " + theCMD, Project.MSG_VERBOSE);
- rc = ftp.sendSiteCommand(TheCMD);
+ rc = ftp.sendSiteCommand(theCMD);
if (rc == false) {
- log("Failed to issue Site Command: " + TheCMD, Project.MSG_WARN);
+ log("Failed to issue Site Command: " + theCMD, Project.MSG_WARN);
} else {
- MyReply = ftp.getReplyStrings();
+ myReply = ftp.getReplyStrings();
- for (int x = 0; x < MyReply.length; x++) {
- if (MyReply[x].indexOf("200") == -1) {
- log(MyReply[x], Project.MSG_WARN);
+ for (int x = 0; x < myReply.length; x++) {
+ if (myReply[x].indexOf("200") == -1) {
+ log(myReply[x], Project.MSG_WARN);
}
}
}
@@ -794,7 +858,7 @@ public class FTP
if (!success) {
String s = "could not put file: " + ftp.getReplyString();
- if (skipFailedTransfers == true) {
+ if (skipFailedTransfers) {
log(s, Project.MSG_WARN);
skipped++;
} else {
@@ -802,7 +866,8 @@ public class FTP
}
} else {
- if (chmod != null) {// see if we should issue a chmod command
+ // see if we should issue a chmod command
+ if (chmod != null) {
doSiteCommand(ftp, "chmod " + chmod + " " + filename);
}
log("File " + file.getAbsolutePath() + " copied to " + server,
@@ -831,7 +896,7 @@ public class FTP
if (!ftp.deleteFile(resolveFile(filename))) {
String s = "could not delete file: " + ftp.getReplyString();
- if (skipFailedTransfers == true) {
+ if (skipFailedTransfers) {
log(s, Project.MSG_WARN);
skipped++;
} else {
@@ -854,7 +919,7 @@ public class FTP
if (!ftp.removeDirectory(resolveFile(dirname))) {
String s = "could not remove directory: " + ftp.getReplyString();
- if (skipFailedTransfers == true) {
+ if (skipFailedTransfers) {
log(s, Project.MSG_WARN);
skipped++;
} else {
@@ -904,7 +969,7 @@ public class FTP
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
String s = "could not get file: " + ftp.getReplyString();
- if (skipFailedTransfers == true) {
+ if (skipFailedTransfers) {
log(s, Project.MSG_WARN);
skipped++;
} else {
@@ -984,13 +1049,15 @@ public class FTP
subdir = st.nextToken();
log("Checking " + subdir, Project.MSG_DEBUG);
if (!ftp.changeWorkingDirectory(subdir)) {
- if(!ftp.makeDirectory(subdir)) {
+ if (!ftp.makeDirectory(subdir)) {
// codes 521, 550 and 553 can be produced by FTP Servers
// to indicate that an attempt to create a directory has
// failed because the directory already exists.
int rc = ftp.getReplyCode();
- if (!(ignoreNoncriticalErrors && (rc == 550 || rc == 553 || rc==521))) {
- throw new BuildException("could not create directory: " + ftp.getReplyString());
+ if (!(ignoreNoncriticalErrors
+ && (rc == 550 || rc == 553 || rc == 521))) {
+ throw new BuildException("could not create directory: "
+ + ftp.getReplyString());
}
if (verbose) {
log("Directory already exists");
@@ -1016,17 +1083,21 @@ public class FTP
*/
private void handleMkDirFailure(FTPClient ftp)
throws BuildException {
- int rc=ftp.getReplyCode();
+ int rc = ftp.getReplyCode();
if (!(ignoreNoncriticalErrors
&& (rc == 550 || rc == 553 || rc == 521))) {
- throw new BuildException("could not create directory: " +
- ftp.getReplyString());
+ throw new BuildException("could not create directory: "
+ + ftp.getReplyString());
}
}
- /** Runs the task. */
- public void execute()
- throws BuildException {
+ /**
+ * Runs the task.
+ *
+ * @throws BuildException if the task fails or is not configured
+ * correctly.
+ */
+ public void execute() throws BuildException {
checkConfiguration();
FTPClient ftp = null;
@@ -1054,8 +1125,8 @@ public class FTP
if (binary) {
ftp.setFileType(org.apache.commons.net.ftp.FTP.IMAGE_FILE_TYPE);
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
- throw new BuildException("could not set transfer type: " +
- ftp.getReplyString());
+ throw new BuildException("could not set transfer type: "
+ + ftp.getReplyString());
}
}
@@ -1064,8 +1135,7 @@ public class FTP
ftp.enterLocalPassiveMode();
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not enter into passive "
- + "mode: " +
- ftp.getReplyString());
+ + "mode: " + ftp.getReplyString());
}
}
@@ -1087,8 +1157,7 @@ public class FTP
ftp.changeWorkingDirectory(remotedir);
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not change remote "
- + "directory: " +
- ftp.getReplyString());
+ + "directory: " + ftp.getReplyString());
}
}
log(ACTION_STRS[action] + " " + ACTION_TARGET_STRS[action]);
@@ -1118,28 +1187,35 @@ public class FTP
*/
public static class Action extends EnumeratedAttribute {
- private static final String[] validActions = {
+ private static final String[] VALID_ACTIONS = {
"send", "put", "recv", "get", "del", "delete", "list", "mkdir",
"chmod", "rmdir"
};
+ /**
+ * Get the valid values
+ *
+ * @return an array of the valid FTP actions.
+ */
public String[] getValues() {
- return validActions;
+ return VALID_ACTIONS;
}
+ /**
+ * Get the symbolic equivalent of the action value.
+ *
+ * @return the SYMBOL representing the given action.
+ */
public int getAction() {
String actionL = getValue().toLowerCase(Locale.US);
- if (actionL.equals("send") ||
- actionL.equals("put")) {
+ if (actionL.equals("send") || actionL.equals("put")) {
return SEND_FILES;
- } else if (actionL.equals("recv") ||
- actionL.equals("get")) {
+ } else if (actionL.equals("recv") || actionL.equals("get")) {
return GET_FILES;
- } else if (actionL.equals("del") ||
- actionL.equals("delete")) {
+ } else if (actionL.equals("del") || actionL.equals("delete")) {
return DEL_FILES;
} else if (actionL.equals("list")) {
return LIST_FILES;