You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/06/05 12:02:43 UTC
svn commit: r544459 [26/36] - in /incubator/ivy/core/trunk:
src/java/org/apache/ivy/ src/java/org/apache/ivy/ant/
src/java/org/apache/ivy/core/ src/java/org/apache/ivy/core/cache/
src/java/org/apache/ivy/core/check/ src/java/org/apache/ivy/core/deliver...
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java Tue Jun 5 05:02:27 2007
@@ -27,7 +27,6 @@
import org.apache.ivy.core.IvyContext;
-
/**
*
*/
@@ -35,55 +34,62 @@
// messages level copied from ant project, to avoid dependency on ant
/** Message priority of "error". */
public static final int MSG_ERR = 0;
+
/** Message priority of "warning". */
public static final int MSG_WARN = 1;
+
/** Message priority of "information". */
public static final int MSG_INFO = 2;
+
/** Message priority of "verbose". */
public static final int MSG_VERBOSE = 3;
+
/** Message priority of "debug". */
public static final int MSG_DEBUG = 4;
-
private static List _problems = new ArrayList();
+
private static List _warns = new ArrayList();
+
private static List _errors = new ArrayList();
-
+
private static boolean _showProgress = true;
-
+
private static boolean _showedInfo = false;
-
+
public static void init(MessageImpl impl) {
IvyContext.getContext().setMessageImpl(impl);
showInfo();
}
- /**
+ /**
* same as init, but without displaying info
+ *
* @param impl
*/
public static void setImpl(MessageImpl impl) {
IvyContext.getContext().setMessageImpl(impl);
}
-
+
public static MessageImpl getImpl() {
- return IvyContext.getContext().getMessageImpl();
+ return IvyContext.getContext().getMessageImpl();
}
-
+
public static boolean isInitialised() {
return IvyContext.getContext().getMessageImpl() != null;
}
private static void showInfo() {
- if (!_showedInfo ) {
+ if (!_showedInfo) {
Properties props = new Properties();
URL moduleURL = Message.class.getResource("/module.properties");
if (moduleURL != null) {
try {
- InputStream module = moduleURL.openStream();
+ InputStream module = moduleURL.openStream();
props.load(module);
- debug("version information loaded from "+moduleURL);
- info(":: Ivy "+props.getProperty("version")+" - "+props.getProperty("date")+" :: http://incubator.apache.org/ivy/ ::");
+ debug("version information loaded from " + moduleURL);
+ info(":: Ivy " + props.getProperty("version") + " - "
+ + props.getProperty("date") + " :: http://incubator.apache.org/ivy/ ::");
module.close();
} catch (IOException e) {
info(":: Ivy non official version :: http://incubator.apache.org/ivy/ ::");
@@ -97,97 +103,102 @@
public static void debug(String msg) {
MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
- if (messageImpl != null) {
+ if (messageImpl != null) {
messageImpl.log(msg, MSG_DEBUG);
} else {
System.err.println(msg);
}
}
+
public static void verbose(String msg) {
MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
- if (messageImpl != null) {
+ if (messageImpl != null) {
messageImpl.log(msg, MSG_VERBOSE);
} else {
System.err.println(msg);
}
}
+
public static void info(String msg) {
MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
- if (messageImpl != null) {
+ if (messageImpl != null) {
messageImpl.log(msg, MSG_INFO);
} else {
System.err.println(msg);
}
}
+
public static void rawinfo(String msg) {
MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
- if (messageImpl != null) {
+ if (messageImpl != null) {
messageImpl.rawlog(msg, MSG_INFO);
} else {
System.err.println(msg);
}
}
- public static void deprecated(String msg) {
+ public static void deprecated(String msg) {
MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
- if (messageImpl != null) {
- messageImpl.log("DEPRECATED: "+msg, MSG_WARN);
+ if (messageImpl != null) {
+ messageImpl.log("DEPRECATED: " + msg, MSG_WARN);
} else {
System.err.println(msg);
}
- }
+ }
+
public static void warn(String msg) {
MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
- if (messageImpl != null) {
- messageImpl.log("WARN: "+msg, MSG_VERBOSE);
+ if (messageImpl != null) {
+ messageImpl.log("WARN: " + msg, MSG_VERBOSE);
} else {
System.err.println(msg);
}
- _problems.add("WARN: "+msg);
+ _problems.add("WARN: " + msg);
_warns.add(msg);
}
+
public static void error(String msg) {
MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
- if (messageImpl != null) {
- // log in verbose mode because message is appended as a problem, and will be
+ if (messageImpl != null) {
+ // log in verbose mode because message is appended as a problem, and will be
// logged at the end at error level
- messageImpl.log("ERROR: "+msg, MSG_VERBOSE);
+ messageImpl.log("ERROR: " + msg, MSG_VERBOSE);
} else {
System.err.println(msg);
}
- _problems.add("\tERROR: "+msg);
+ _problems.add("\tERROR: " + msg);
_errors.add(msg);
}
public static List getProblems() {
return _problems;
}
-
+
public static void sumupProblems() {
if (_problems.size() > 0) {
info("\n:: problems summary ::");
MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
- if (_warns.size() > 0) {
- info(":::: WARNINGS");
- for (Iterator iter = _warns.iterator(); iter.hasNext();) {
- String msg = (String) iter.next();
+ if (_warns.size() > 0) {
+ info(":::: WARNINGS");
+ for (Iterator iter = _warns.iterator(); iter.hasNext();) {
+ String msg = (String) iter.next();
if (messageImpl != null) {
- messageImpl.log("\t"+msg+"\n", MSG_WARN);
+ messageImpl.log("\t" + msg + "\n", MSG_WARN);
} else {
System.err.println(msg);
}
- }
+ }
}
if (_errors.size() > 0) {
info(":::: ERRORS");
- for (Iterator iter = _errors.iterator(); iter.hasNext();) {
- String msg = (String) iter.next();
+ for (Iterator iter = _errors.iterator(); iter.hasNext();) {
+ String msg = (String) iter.next();
if (messageImpl != null) {
- messageImpl.log("\t"+msg+"\n", MSG_ERR);
+ messageImpl.log("\t" + msg + "\n", MSG_ERR);
} else {
System.err.println(msg);
}
- }
+ }
}
info("\n:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS");
_problems.clear();
@@ -199,7 +210,7 @@
public static void progress() {
if (_showProgress) {
MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
- if (messageImpl != null) {
+ if (messageImpl != null) {
messageImpl.progress();
} else {
System.out.println(".");
@@ -214,7 +225,7 @@
public static void endProgress(String msg) {
if (_showProgress) {
MessageImpl messageImpl = IvyContext.getContext().getMessageImpl();
- if (messageImpl != null) {
+ if (messageImpl != null) {
messageImpl.endProgress(msg);
}
}
@@ -223,6 +234,7 @@
public static boolean isShowProgress() {
return _showProgress;
}
+
public static void setShowProgress(boolean progress) {
_showProgress = progress;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/MessageImpl.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/MessageImpl.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/MessageImpl.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/MessageImpl.java Tue Jun 5 05:02:27 2007
@@ -19,7 +19,10 @@
public interface MessageImpl {
public void log(String msg, int level);
+
public void rawlog(String msg, int level);
+
public void progress();
+
public void endProgress(String msg);
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/PropertiesFile.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/PropertiesFile.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/PropertiesFile.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/PropertiesFile.java Tue Jun 5 05:02:27 2007
@@ -23,12 +23,12 @@
import java.io.IOException;
import java.util.Properties;
-
/**
* A simple Properties extension easing the loading and saving of data
*/
public class PropertiesFile extends Properties {
private File _file;
+
private String _header;
public PropertiesFile(File file, String header) {
@@ -38,9 +38,10 @@
FileInputStream fis = null;
try {
fis = new FileInputStream(_file);
- load(fis);
+ load(fis);
} catch (Exception ex) {
- Message.warn("exception occured while reading properties file "+_file+": "+ex.getMessage());
+ Message.warn("exception occured while reading properties file " + _file + ": "
+ + ex.getMessage());
}
try {
if (fis != null) {
@@ -60,7 +61,8 @@
fos = new FileOutputStream(_file);
store(fos, _header);
} catch (Exception ex) {
- Message.warn("exception occured while writing properties file "+_file+": "+ex.getMessage());
+ Message.warn("exception occured while writing properties file " + _file + ": "
+ + ex.getMessage());
}
try {
if (fos != null) {
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/StringUtils.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/StringUtils.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/StringUtils.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/StringUtils.java Tue Jun 5 05:02:27 2007
@@ -17,13 +17,9 @@
*/
package org.apache.ivy.util;
-
/**
- * Convenient class used only for uncapitalization
- * Usually use commons lang but here we do not want to have such
- * a dependency for only one feature
- *
- *
+ * Convenient class used only for uncapitalization Usually use commons lang but here we do not want
+ * to have such a dependency for only one feature
*/
public class StringUtils {
public static String uncapitalize(String string) {
@@ -33,12 +29,12 @@
if (string.length() == 1) {
return string.toLowerCase();
}
- return string.substring(0,1).toLowerCase() + string.substring(1);
+ return string.substring(0, 1).toLowerCase() + string.substring(1);
}
/**
- * Joins the given object array in one string, each separated by the given separator.
- * Example: join(new String[] {"one", "two", "three"}, ", ") -> "one, two, three"
+ * Joins the given object array in one string, each separated by the given separator. Example:
+ * join(new String[] {"one", "two", "three"}, ", ") -> "one, two, three"
*
* @param objs
* @param sep
@@ -49,68 +45,67 @@
for (int i = 0; i < objs.length; i++) {
buf.append(objs[i]).append(sep);
}
- if (objs.length > 0) {
+ if (objs.length > 0) {
buf.setLength(buf.length() - sep.length()); // delete sep
}
return buf.toString();
}
-
-
+
// basic string codec (same algo as CVS passfile, inspired by ant CVSPass class
/** Array contain char conversion data */
- private final static char[] SHIFTS = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 114, 120, 53, 79, 96, 109, 72, 108, 70, 64, 76, 67, 116, 74, 68, 87,
- 111, 52, 75, 119, 49, 34, 82, 81, 95, 65, 112, 86, 118, 110, 122, 105,
- 41, 57, 83, 43, 46, 102, 40, 89, 38, 103, 45, 50, 42, 123, 91, 35,
- 125, 55, 54, 66, 124, 126, 59, 47, 92, 71, 115, 78, 88, 107, 106, 56,
- 36, 121, 117, 104, 101, 100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48,
- 58, 113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85, 223,
- 225, 216, 187, 166, 229, 189, 222, 188, 141, 249, 148, 200, 184, 136, 248, 190,
- 199, 170, 181, 204, 138, 232, 218, 183, 255, 234, 220, 247, 213, 203, 226, 193,
- 174, 172, 228, 252, 217, 201, 131, 230, 197, 211, 145, 238, 161, 179, 160, 212,
- 207, 221, 254, 173, 202, 146, 224, 151, 140, 196, 205, 130, 135, 133, 143, 246,
- 192, 159, 244, 239, 185, 168, 215, 144, 139, 165, 180, 157, 147, 186, 214, 176,
- 227, 231, 219, 169, 175, 156, 206, 198, 129, 164, 150, 210, 154, 177, 134, 127,
- 182, 128, 158, 208, 162, 132, 167, 209, 149, 241, 153, 251, 237, 236, 171, 195,
- 243, 233, 253, 240, 194, 250, 191, 155, 142, 137, 245, 235, 163, 242, 178, 152
- };
+ private final static char[] SHIFTS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 114, 120, 53, 79, 96, 109,
+ 72, 108, 70, 64, 76, 67, 116, 74, 68, 87, 111, 52, 75, 119, 49, 34, 82, 81, 95, 65,
+ 112, 86, 118, 110, 122, 105, 41, 57, 83, 43, 46, 102, 40, 89, 38, 103, 45, 50, 42, 123,
+ 91, 35, 125, 55, 54, 66, 124, 126, 59, 47, 92, 71, 115, 78, 88, 107, 106, 56, 36, 121,
+ 117, 104, 101, 100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48, 58, 113, 32, 90, 44, 98,
+ 60, 51, 33, 97, 62, 77, 84, 80, 85, 223, 225, 216, 187, 166, 229, 189, 222, 188, 141,
+ 249, 148, 200, 184, 136, 248, 190, 199, 170, 181, 204, 138, 232, 218, 183, 255, 234,
+ 220, 247, 213, 203, 226, 193, 174, 172, 228, 252, 217, 201, 131, 230, 197, 211, 145,
+ 238, 161, 179, 160, 212, 207, 221, 254, 173, 202, 146, 224, 151, 140, 196, 205, 130,
+ 135, 133, 143, 246, 192, 159, 244, 239, 185, 168, 215, 144, 139, 165, 180, 157, 147,
+ 186, 214, 176, 227, 231, 219, 169, 175, 156, 206, 198, 129, 164, 150, 210, 154, 177,
+ 134, 127, 182, 128, 158, 208, 162, 132, 167, 209, 149, 241, 153, 251, 237, 236, 171,
+ 195, 243, 233, 253, 240, 194, 250, 191, 155, 142, 137, 245, 235, 163, 242, 178, 152};
+
/**
- * Encrypt the given string in a way which anybody having access to this method
- * algorithm can easily decrypt.
+ * Encrypt the given string in a way which anybody having access to this method algorithm can
+ * easily decrypt. This is useful only to avoid clear string storage in a file for example, but
+ * shouldn't be considered as a real mean of security. This only works with simple characters
+ * (char < 256).
*
- * This is useful only to avoid clear string storage in a file for example,
- * but shouldn't be considered as a real mean of security.
- *
- * This only works with simple characters (char < 256).
- * @param str the string to encrypt
+ * @param str
+ * the string to encrypt
* @return the encrypted version of the string
*/
public final static String encrypt(String str) {
- if (str == null) {
- return null;
- }
+ if (str == null) {
+ return null;
+ }
StringBuffer buf = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c >= SHIFTS.length) {
- throw new IllegalArgumentException("encrypt method can only be used with simple characters. '"+c+"' not allowed");
+ throw new IllegalArgumentException(
+ "encrypt method can only be used with simple characters. '" + c
+ + "' not allowed");
}
- buf.append(SHIFTS[c]);
+ buf.append(SHIFTS[c]);
}
return buf.toString();
}
/**
* Decrypts a string encrypted with encrypt.
- * @param str the encrypted string to decrypt
+ *
+ * @param str
+ * the encrypted string to decrypt
* @return
*/
public final static String decrypt(String str) {
- if (str == null) {
- return null;
- }
+ if (str == null) {
+ return null;
+ }
StringBuffer buf = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
buf.append(decrypt(str.charAt(i)));
@@ -118,13 +113,14 @@
return buf.toString();
}
- private static char decrypt(char c) {
- for (char i = 0; i < SHIFTS.length; i++) {
- if (SHIFTS[i] == c) {
- return i;
- }
- }
- throw new IllegalArgumentException("Impossible to decrypt '"+c+"'. Unhandled character.");
- }
+ private static char decrypt(char c) {
+ for (char i = 0; i < SHIFTS.length; i++) {
+ if (SHIFTS[i] == c) {
+ return i;
+ }
+ }
+ throw new IllegalArgumentException("Impossible to decrypt '" + c
+ + "'. Unhandled character.");
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java Tue Jun 5 05:02:27 2007
@@ -31,7 +31,6 @@
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.DefaultHandler;
-
public abstract class XMLHelper {
private static SAXParserFactory _validatingFactory = SAXParserFactory.newInstance();
@@ -50,7 +49,8 @@
_validatingFactory.setValidating(true);
}
- private static SAXParser newSAXParser(URL schema, InputStream schemaStream) throws ParserConfigurationException, SAXException {
+ private static SAXParser newSAXParser(URL schema, InputStream schemaStream)
+ throws ParserConfigurationException, SAXException {
if (!_canUseSchemaValidation || schema == null) {
return _factory.newSAXParser();
}
@@ -60,7 +60,9 @@
parser.setProperty(JAXP_SCHEMA_SOURCE, schemaStream);
return parser;
} catch (SAXNotRecognizedException ex) {
- System.err.println("WARNING: problem while setting JAXP validating property on SAXParser... XML validation will not be done: " + ex.getMessage());
+ System.err
+ .println("WARNING: problem while setting JAXP validating property on SAXParser... XML validation will not be done: "
+ + ex.getMessage());
_canUseSchemaValidation = false;
return _factory.newSAXParser();
}
@@ -70,38 +72,44 @@
// do not cause exception
// implement warning error and fatalError methods in handler to be informed
// of validation errors
- public static void parse(URL xmlURL, URL schema, DefaultHandler handler) throws SAXException, IOException, ParserConfigurationException {
- parse(xmlURL, schema, handler, null);
+ public static void parse(URL xmlURL, URL schema, DefaultHandler handler) throws SAXException,
+ IOException, ParserConfigurationException {
+ parse(xmlURL, schema, handler, null);
}
-
- public static void parse(URL xmlURL, URL schema, DefaultHandler handler, LexicalHandler lHandler) throws SAXException, IOException, ParserConfigurationException {
- InputStream xmlStream = URLHandlerRegistry.getDefault().openStream(xmlURL);
- try {
- parse(xmlStream, schema, handler, lHandler);
- } finally {
- try {
- xmlStream.close();
- } catch (IOException e) {}
- }
- }
-
- public static void parse(InputStream xmlStream, URL schema, DefaultHandler handler, LexicalHandler lHandler) throws SAXException, IOException, ParserConfigurationException {
+
+ public static void parse(URL xmlURL, URL schema, DefaultHandler handler, LexicalHandler lHandler)
+ throws SAXException, IOException, ParserConfigurationException {
+ InputStream xmlStream = URLHandlerRegistry.getDefault().openStream(xmlURL);
+ try {
+ parse(xmlStream, schema, handler, lHandler);
+ } finally {
+ try {
+ xmlStream.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ public static void parse(InputStream xmlStream, URL schema, DefaultHandler handler,
+ LexicalHandler lHandler) throws SAXException, IOException, ParserConfigurationException {
InputStream schemaStream = null;
try {
if (schema != null) {
schemaStream = URLHandlerRegistry.getDefault().openStream(schema);
}
SAXParser parser = XMLHelper.newSAXParser(schema, schemaStream);
-
+
if (lHandler != null) {
- try {
- parser.setProperty("http://xml.org/sax/properties/lexical-handler", lHandler);
- } catch (SAXException ex) {
- System.err.println("WARNING: problem while setting the lexical handler property on SAXParser: " + ex.getMessage());
+ try {
+ parser.setProperty("http://xml.org/sax/properties/lexical-handler", lHandler);
+ } catch (SAXException ex) {
+ System.err
+ .println("WARNING: problem while setting the lexical handler property on SAXParser: "
+ + ex.getMessage());
// continue without the lexical handler
- }
+ }
}
-
+
parser.parse(xmlStream, handler);
} finally {
if (schemaStream != null) {
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/DefaultExtendableItem.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/DefaultExtendableItem.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/DefaultExtendableItem.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/DefaultExtendableItem.java Tue Jun 5 05:02:27 2007
@@ -26,15 +26,19 @@
public DefaultExtendableItem() {
this(null, null);
}
+
public DefaultExtendableItem(Map stdAttributes, Map extraAttributes) {
super(stdAttributes, extraAttributes);
}
+
public void setExtraAttribute(String attName, String attValue) {
super.setExtraAttribute(attName, attValue);
}
+
public void setStandardAttribute(String attName, String attValue) {
super.setStandardAttribute(attName, attValue);
}
+
public void setAttribute(String attName, String attValue, boolean extra) {
super.setAttribute(attName, attValue, extra);
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItem.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItem.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItem.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItem.java Tue Jun 5 05:02:27 2007
@@ -21,42 +21,56 @@
public interface ExtendableItem {
/**
- * Gets the value of an attribute
- * Can be used to access the value of a standard attribute (like organisation, revision) or of an extra attribute.
- * @param attName the name of the attribute to get
+ * Gets the value of an attribute Can be used to access the value of a standard attribute (like
+ * organisation, revision) or of an extra attribute.
+ *
+ * @param attName
+ * the name of the attribute to get
* @return the value of the attribute, null if the attribute doesn't exist
*/
String getAttribute(String attName);
+
/**
- * Gets the value of a standard attribute
- * Can be used only to access the value of a standard attribute (like organisation, revision), not an extra one
- * @param attName the name of the standard attribute to get
+ * Gets the value of a standard attribute Can be used only to access the value of a standard
+ * attribute (like organisation, revision), not an extra one
+ *
+ * @param attName
+ * the name of the standard attribute to get
* @return the value of the attribute, null if the attribute doesn't exist
*/
String getStandardAttribute(String attName);
+
/**
- * Gets the value of an extra attribute
- * Can be used only to access the value of an extra attribute, not a standard one (like organisation, revision)
- * @param attName the name of the extra attribute to get
+ * Gets the value of an extra attribute Can be used only to access the value of an extra
+ * attribute, not a standard one (like organisation, revision)
+ *
+ * @param attName
+ * the name of the extra attribute to get
* @return the value of the attribute, null if the attribute doesn't exist
*/
String getExtraAttribute(String attName);
-
+
/**
* Returns a Map of all attributes of this extendable item, including standard and extra ones.
- * The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too)
+ * The Map keys are attribute names as Strings, and values are corresponding attribute values
+ * (as String too)
+ *
* @return
*/
Map getAttributes();
+
/**
- * Returns a Map of all standard attributes of this extendable item.
- * The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too)
+ * Returns a Map of all standard attributes of this extendable item. The Map keys are attribute
+ * names as Strings, and values are corresponding attribute values (as String too)
+ *
* @return
*/
Map getStandardAttributes();
+
/**
- * Returns a Map of all extra attributes of this extendable item.
- * The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too)
+ * Returns a Map of all extra attributes of this extendable item. The Map keys are attribute
+ * names as Strings, and values are corresponding attribute values (as String too)
+ *
* @return
*/
Map getExtraAttributes();
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java Tue Jun 5 05:02:27 2007
@@ -25,12 +25,11 @@
import org.xml.sax.Attributes;
-
public class ExtendableItemHelper {
public static Map getExtraAttributes(Attributes attributes, String prefix) {
Map ret = new HashMap();
- for (int i=0; i<attributes.getLength(); i++) {
+ for (int i = 0; i < attributes.getLength(); i++) {
if (attributes.getQName(i).startsWith(prefix)) {
ret.put(attributes.getQName(i).substring(prefix.length()), attributes.getValue(i));
}
@@ -41,7 +40,7 @@
public static Map getExtraAttributes(Attributes attributes, String[] ignoredAttNames) {
Map ret = new HashMap();
Collection ignored = Arrays.asList(ignoredAttNames);
- for (int i=0; i<attributes.getLength(); i++) {
+ for (int i = 0; i < attributes.getLength(); i++) {
if (!ignored.contains(attributes.getQName(i))) {
ret.put(attributes.getQName(i), attributes.getValue(i));
}
@@ -49,11 +48,12 @@
return ret;
}
- public static void fillExtraAttributes(DefaultExtendableItem item, Attributes attributes, String[] ignoredAttNames) {
+ public static void fillExtraAttributes(DefaultExtendableItem item, Attributes attributes,
+ String[] ignoredAttNames) {
Map att = getExtraAttributes(attributes, ignoredAttNames);
for (Iterator iter = att.keySet().iterator(); iter.hasNext();) {
- String attName = (String)iter.next();
- String attValue = (String)att.get(attName);
+ String attName = (String) iter.next();
+ String attValue = (String) att.get(attName);
item.setExtraAttribute(attName, attValue);
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java Tue Jun 5 05:02:27 2007
@@ -23,12 +23,17 @@
public class UnmodifiableExtendableItem implements ExtendableItem {
private Map _attributes = new HashMap();
+
private Map _unmodifiableAttributesView = Collections.unmodifiableMap(_attributes);
+
private Map _stdAttributes = new HashMap();
+
private Map _unmodifiableStdAttributesView = Collections.unmodifiableMap(_stdAttributes);
+
private Map _extraAttributes = new HashMap();
+
private Map _unmodifiableExtraAttributesView = Collections.unmodifiableMap(_extraAttributes);
-
+
public UnmodifiableExtendableItem(Map stdAttributes, Map extraAttributes) {
if (stdAttributes != null) {
_attributes.putAll(stdAttributes);
@@ -39,21 +44,27 @@
_extraAttributes.putAll(extraAttributes);
}
}
+
public String getAttribute(String attName) {
- return (String)_attributes.get(attName);
+ return (String) _attributes.get(attName);
}
+
public String getExtraAttribute(String attName) {
- return (String)_extraAttributes.get(attName);
+ return (String) _extraAttributes.get(attName);
}
+
public String getStandardAttribute(String attName) {
- return (String)_stdAttributes.get(attName);
+ return (String) _stdAttributes.get(attName);
}
+
protected void setExtraAttribute(String attName, String attValue) {
setAttribute(attName, attValue, true);
}
+
protected void setStandardAttribute(String attName, String attValue) {
setAttribute(attName, attValue, false);
}
+
protected void setAttribute(String attName, String attValue, boolean extra) {
if (extra) {
_extraAttributes.put(attName, attValue);
@@ -62,12 +73,15 @@
}
_attributes.put(attName, attValue);
}
+
public Map getAttributes() {
return _unmodifiableAttributesView;
}
+
public Map getStandardAttributes() {
return _unmodifiableStdAttributesView;
}
+
public Map getExtraAttributes() {
return _unmodifiableExtraAttributesView;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/AndFilter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/AndFilter.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/AndFilter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/AndFilter.java Tue Jun 5 05:02:27 2007
@@ -18,20 +18,24 @@
package org.apache.ivy.util.filter;
public class AndFilter implements Filter {
- private Filter _op1;
- private Filter _op2;
-
- public AndFilter(Filter op1, Filter op2) {
- _op1 = op1;
- _op2 = op2;
- }
- public Filter getOp1() {
- return _op1;
- }
- public Filter getOp2() {
- return _op2;
- }
- public boolean accept(Object o) {
- return _op1.accept(o) && _op2.accept(o);
- }
+ private Filter _op1;
+
+ private Filter _op2;
+
+ public AndFilter(Filter op1, Filter op2) {
+ _op1 = op1;
+ _op2 = op2;
+ }
+
+ public Filter getOp1() {
+ return _op1;
+ }
+
+ public Filter getOp2() {
+ return _op2;
+ }
+
+ public boolean accept(Object o) {
+ return _op1.accept(o) && _op2.accept(o);
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/ArtifactTypeFilter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/ArtifactTypeFilter.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/ArtifactTypeFilter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/ArtifactTypeFilter.java Tue Jun 5 05:02:27 2007
@@ -22,19 +22,18 @@
import org.apache.ivy.core.module.descriptor.Artifact;
-
public class ArtifactTypeFilter implements Filter {
private Collection _acceptedTypes;
-
+
public ArtifactTypeFilter(Collection acceptedTypes) {
_acceptedTypes = new ArrayList(acceptedTypes);
}
-
+
public boolean accept(Object o) {
- if (! (o instanceof Artifact)) {
+ if (!(o instanceof Artifact)) {
return false;
}
- Artifact art = (Artifact)o;
+ Artifact art = (Artifact) o;
return _acceptedTypes.contains(art.getType());
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java Tue Jun 5 05:02:27 2007
@@ -24,7 +24,7 @@
public class FilterHelper {
public static Filter NO_FILTER = NoFilter.INSTANCE;
-
+
public static Filter getArtifactTypeFilter(String types) {
if (types == null || types.trim().equals("*")) {
return NO_FILTER;
@@ -38,8 +38,9 @@
}
/**
- * we could have used commons-collections facility for this...
- * if we accepted to add dependencies on third party jars
+ * we could have used commons-collections facility for this... if we accepted to add
+ * dependencies on third party jars
+ *
* @param col
* @param filter
* @return
@@ -50,7 +51,7 @@
}
Collection ret = new ArrayList(col);
for (Iterator iter = ret.iterator(); iter.hasNext();) {
- Object element = (Object)iter.next();
+ Object element = (Object) iter.next();
if (!filter.accept(element)) {
iter.remove();
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NoFilter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NoFilter.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NoFilter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NoFilter.java Tue Jun 5 05:02:27 2007
@@ -18,11 +18,11 @@
package org.apache.ivy.util.filter;
public class NoFilter implements Filter {
- public static final Filter INSTANCE = new NoFilter();
-
- private NoFilter() {
- }
-
+ public static final Filter INSTANCE = new NoFilter();
+
+ private NoFilter() {
+ }
+
public boolean accept(Object o) {
return true;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NotFilter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NotFilter.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NotFilter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/NotFilter.java Tue Jun 5 05:02:27 2007
@@ -18,15 +18,17 @@
package org.apache.ivy.util.filter;
public class NotFilter implements Filter {
- private Filter _op;
-
- public NotFilter(Filter op) {
- _op = op;
- }
- public Filter getOp() {
- return _op;
- }
- public boolean accept(Object o) {
- return !_op.accept(o);
- }
+ private Filter _op;
+
+ public NotFilter(Filter op) {
+ _op = op;
+ }
+
+ public Filter getOp() {
+ return _op;
+ }
+
+ public boolean accept(Object o) {
+ return !_op.accept(o);
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/OrFilter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/OrFilter.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/OrFilter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/filter/OrFilter.java Tue Jun 5 05:02:27 2007
@@ -18,20 +18,24 @@
package org.apache.ivy.util.filter;
public class OrFilter implements Filter {
- private Filter _op1;
- private Filter _op2;
-
- public OrFilter(Filter op1, Filter op2) {
- _op1 = op1;
- _op2 = op2;
- }
- public Filter getOp1() {
- return _op1;
- }
- public Filter getOp2() {
- return _op2;
- }
- public boolean accept(Object o) {
- return _op1.accept(o) || _op2.accept(o);
- }
+ private Filter _op1;
+
+ private Filter _op2;
+
+ public OrFilter(Filter op1, Filter op2) {
+ _op1 = op1;
+ _op2 = op2;
+ }
+
+ public Filter getOp1() {
+ return _op1;
+ }
+
+ public Filter getOp2() {
+ return _op2;
+ }
+
+ public boolean accept(Object o) {
+ return _op1.accept(o) || _op2.accept(o);
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java Tue Jun 5 05:02:27 2007
@@ -23,20 +23,24 @@
public boolean isReachable(URL url) {
return getURLInfo(url).isReachable();
}
+
public boolean isReachable(URL url, int timeout) {
return getURLInfo(url, timeout).isReachable();
}
+
public long getContentLength(URL url) {
return getURLInfo(url).getContentLength();
}
+
public long getContentLength(URL url, int timeout) {
- return getURLInfo(url, timeout).getContentLength();
+ return getURLInfo(url, timeout).getContentLength();
}
-
+
public long getLastModified(URL url) {
return getURLInfo(url).getLastModified();
}
+
public long getLastModified(URL url, int timeout) {
- return getURLInfo(url, timeout).getLastModified();
+ return getURLInfo(url, timeout).getLastModified();
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java Tue Jun 5 05:02:27 2007
@@ -17,7 +17,6 @@
*/
package org.apache.ivy.util.url;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -30,93 +29,85 @@
import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;
-
/**
- * Utility class which helps to list urls under a given url. This has been
- * tested with Apache 1.3.33 server listing, as the one used at ibiblio, and
- * with Apache 2.0.53 server listing, as the one on mirrors.sunsite.dk.
- *
+ * Utility class which helps to list urls under a given url. This has been tested with Apache 1.3.33
+ * server listing, as the one used at ibiblio, and with Apache 2.0.53 server listing, as the one on
+ * mirrors.sunsite.dk.
*/
public class ApacheURLLister {
- //~ Static variables/initializers ------------------------------------------
+ // ~ Static variables/initializers ------------------------------------------
- private static final Pattern PATTERN =
- Pattern.compile("<a[^>]*href=\"([^\"]*)\"[^>]*>(?:<[^>]+>)*?([^<>]+?)(?:<[^>]+>)*?</a>",
- Pattern.CASE_INSENSITIVE);
+ private static final Pattern PATTERN = Pattern.compile(
+ "<a[^>]*href=\"([^\"]*)\"[^>]*>(?:<[^>]+>)*?([^<>]+?)(?:<[^>]+>)*?</a>",
+ Pattern.CASE_INSENSITIVE);
- //~ Methods ----------------------------------------------------------------
+ // ~ Methods ----------------------------------------------------------------
/**
- * Returns a list of sub urls of the given url. The returned list is a list
- * of URL.
- *
- * @param url The base URL from which to retrieve the listing.
- *
+ * Returns a list of sub urls of the given url. The returned list is a list of URL.
+ *
+ * @param url
+ * The base URL from which to retrieve the listing.
* @return a list of sub urls of the given url.
- *
- * @throws IOException If an error occures retrieving the HTML.
+ * @throws IOException
+ * If an error occures retrieving the HTML.
*/
public List listAll(URL url) throws IOException {
return retrieveListing(url, true, true);
}
-
/**
- * Returns a list of sub 'directories' of the given url. The returned list
- * is a list of URL.
- *
- * @param url The base URL from which to retrieve the listing.
- *
+ * Returns a list of sub 'directories' of the given url. The returned list is a list of URL.
+ *
+ * @param url
+ * The base URL from which to retrieve the listing.
* @return a list of sub 'directories' of the given url.
- *
- * @throws IOException If an error occures retrieving the HTML.
+ * @throws IOException
+ * If an error occures retrieving the HTML.
*/
public List listDirectories(URL url) throws IOException {
return retrieveListing(url, false, true);
}
-
/**
- * Returns a list of sub 'files' (in opposition to directories) of the
- * given url. The returned list is a list of URL.
- *
- * @param url The base URL from which to retrieve the listing.
- *
+ * Returns a list of sub 'files' (in opposition to directories) of the given url. The returned
+ * list is a list of URL.
+ *
+ * @param url
+ * The base URL from which to retrieve the listing.
* @return a list of sub 'files' of the given url.
- *
- * @throws IOException If an error occures retrieving the HTML.
+ * @throws IOException
+ * If an error occures retrieving the HTML.
*/
public List listFiles(URL url) throws IOException {
return retrieveListing(url, true, false);
}
-
/**
- * Retrieves a {@link List} of {@link URL}s corresponding to the files
- * and/or directories found at the supplied base URL.
- *
- * @param url The base URL from which to retrieve the listing.
- * @param includeFiles If true include files in the returned list.
- * @param includeDirectories If true include directories in the returned
- * list.
- *
+ * Retrieves a {@link List} of {@link URL}s corresponding to the files and/or directories found
+ * at the supplied base URL.
+ *
+ * @param url
+ * The base URL from which to retrieve the listing.
+ * @param includeFiles
+ * If true include files in the returned list.
+ * @param includeDirectories
+ * If true include directories in the returned list.
* @return A {@link List} of {@link URL}s.
- *
- * @throws IOException If an error occures retrieving the HTML.
+ * @throws IOException
+ * If an error occures retrieving the HTML.
*/
- public List retrieveListing(URL url, boolean includeFiles,
- boolean includeDirectories) throws IOException {
+ public List retrieveListing(URL url, boolean includeFiles, boolean includeDirectories)
+ throws IOException {
List urlList = new ArrayList();
// add trailing slash for relative urls
if (!url.getPath().endsWith("/") && !url.getPath().endsWith(".html")) {
- url = new URL(url.getProtocol(), url.getHost(), url.getPort(),
- url.getPath() + "/");
+ url = new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getPath() + "/");
}
- BufferedReader r =
- new BufferedReader(new InputStreamReader(URLHandlerRegistry.getDefault()
- .openStream(url)));
+ BufferedReader r = new BufferedReader(new InputStreamReader(URLHandlerRegistry.getDefault()
+ .openStream(url)));
String htmlText = FileUtil.readEntirely(r);
@@ -126,18 +117,18 @@
// get the href text and the displayed text
String href = matcher.group(1);
String text = matcher.group(2);
-
+
if ((href == null) || (text == null)) {
// the groups were not found (shouldn't happen, really)
continue;
}
-
- text = text.trim();
+
+ text = text.trim();
// absolute href: convert to relative one
if (href.startsWith("/")) {
int slashIndex = href.substring(0, href.length() - 1).lastIndexOf('/');
- href= href.substring(slashIndex+1);
+ href = href.substring(slashIndex + 1);
}
// exclude those where they do not match
@@ -145,16 +136,15 @@
// may have a '.' from either the extension (.jar) or "..>"
int dotIndex = text.indexOf('.');
- if ( ((dotIndex != -1) && !href.startsWith(text.substring(0, dotIndex)))
- || ((dotIndex == -1) && !href.equalsIgnoreCase(text)) ) {
+ if (((dotIndex != -1) && !href.startsWith(text.substring(0, dotIndex)))
+ || ((dotIndex == -1) && !href.equalsIgnoreCase(text))) {
// the href and the text do not "match"
continue;
}
boolean directory = href.endsWith("/");
- if ((directory && includeDirectories)
- || (!directory && includeFiles)) {
+ if ((directory && includeDirectories) || (!directory && includeFiles)) {
URL child = new URL(url, href);
urlList.add(child);
Message.debug("ApacheURLLister found URL=[" + child + "].");
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java Tue Jun 5 05:02:27 2007
@@ -31,7 +31,6 @@
import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;
-
/**
*
*/
@@ -39,54 +38,55 @@
private static interface HttpStatus {
static final int SC_OK = 200;
+
static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
}
public BasicURLHandler() {
- Message.debug("installing "+IvyAuthenticator.INSTANCE.getClass()); // do not remove, ensure IvyAuthenticator class loading!
+ Message.debug("installing " + IvyAuthenticator.INSTANCE.getClass()); // do not remove,
+ // ensure
+ // IvyAuthenticator
+ // class loading!
}
public URLInfo getURLInfo(URL url) {
return getURLInfo(url, 0);
}
+
public URLInfo getURLInfo(URL url, int timeout) {
URLConnection con = null;
try {
con = url.openConnection();
if (con instanceof HttpURLConnection) {
- int status = ((HttpURLConnection)con).getResponseCode();
+ int status = ((HttpURLConnection) con).getResponseCode();
if (status == HttpStatus.SC_OK) {
- return new URLInfo(
- true,
- ((HttpURLConnection)con).getContentLength(),
- con.getLastModified()
- );
+ return new URLInfo(true, ((HttpURLConnection) con).getContentLength(), con
+ .getLastModified());
}
if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
Message.warn("Your proxy requires authentication.");
- }else if (String.valueOf(status).startsWith("4")) {
- Message.verbose("CLIENT ERROR: "+((HttpURLConnection)con).getResponseMessage()+" url="+url);
- }else if (String.valueOf(status).startsWith("5")) {
- Message.error("SERVER ERROR: "+((HttpURLConnection)con).getResponseMessage()+" url="+url);
+ } else if (String.valueOf(status).startsWith("4")) {
+ Message.verbose("CLIENT ERROR: "
+ + ((HttpURLConnection) con).getResponseMessage() + " url=" + url);
+ } else if (String.valueOf(status).startsWith("5")) {
+ Message.error("SERVER ERROR: " + ((HttpURLConnection) con).getResponseMessage()
+ + " url=" + url);
}
- Message.debug("HTTP response status: "+status+" url="+url);
+ Message.debug("HTTP response status: " + status + " url=" + url);
} else {
int contentLength = con.getContentLength();
if (contentLength <= 0) {
return UNAVAILABLE;
} else {
- return new URLInfo(
- true,
- contentLength,
- con.getLastModified()
- );
+ return new URLInfo(true, contentLength, con.getLastModified());
}
}
} catch (UnknownHostException e) {
- Message.warn("Host " + e.getMessage() +" not found. url="+url);
- Message.info("You probably access the destination server through a proxy server that is not well configured.");
+ Message.warn("Host " + e.getMessage() + " not found. url=" + url);
+ Message
+ .info("You probably access the destination server through a proxy server that is not well configured.");
} catch (IOException e) {
- Message.error("Server access Error: "+e.getMessage()+" url="+url);
+ Message.error("Server access Error: " + e.getMessage() + " url=" + url);
} finally {
disconnect(con);
}
@@ -100,22 +100,22 @@
conn = url.openConnection();
inStream = conn.getInputStream();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-
+
byte[] buffer = new byte[4096];
int len;
while ((len = inStream.read(buffer)) > 0) {
outStream.write(buffer, 0, len);
}
return new ByteArrayInputStream(outStream.toByteArray());
- }
- finally {
+ } finally {
if (inStream != null) {
inStream.close();
}
-
+
disconnect(conn);
}
}
+
public void download(URL src, File dest, CopyProgressListener l) throws IOException {
URLConnection srcConn = null;
try {
@@ -123,26 +123,31 @@
int contentLength = srcConn.getContentLength();
FileUtil.copy(srcConn.getInputStream(), dest, l);
if (dest.length() != contentLength && contentLength != -1) {
- dest.delete();
- throw new IOException("Downloaded file size doesn't match expected Content Length for "+src+". Please retry.");
+ dest.delete();
+ throw new IOException(
+ "Downloaded file size doesn't match expected Content Length for " + src
+ + ". Please retry.");
}
- }
- finally {
+ } finally {
disconnect(srcConn);
}
}
private void disconnect(URLConnection con) {
- if (con instanceof HttpURLConnection) {
- ((HttpURLConnection)con).disconnect();
- } else if (con != null && "sun.net.www.protocol.file.FileURLConnection".equals(con.getClass().getName())) {
- // ugly fix for a sun jre bug:
- // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4257700
- //
- // getting header info on the fileurlconnection opens the connection,
- // which opens a file input stream without closing it.
- try {con.getInputStream().close();} catch (IOException e) {}
- }
- }
-
+ if (con instanceof HttpURLConnection) {
+ ((HttpURLConnection) con).disconnect();
+ } else if (con != null
+ && "sun.net.www.protocol.file.FileURLConnection".equals(con.getClass().getName())) {
+ // ugly fix for a sun jre bug:
+ // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4257700
+ //
+ // getting header info on the fileurlconnection opens the connection,
+ // which opens a file input stream without closing it.
+ try {
+ con.getInputStream().close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java Tue Jun 5 05:02:27 2007
@@ -23,7 +23,6 @@
import org.apache.ivy.util.Credentials;
import org.apache.ivy.util.Message;
-
/**
*
*/
@@ -32,25 +31,26 @@
* A Map of Credentials objects keyed by the 'key' of the Credentials.
*/
private final static Map keyring = new HashMap();
+
public final static CredentialsStore INSTANCE = new CredentialsStore();
-
+
private CredentialsStore() {
}
public void addCredentials(String realm, String host, String userName, String passwd) {
- if (userName == null) {
- return;
- }
+ if (userName == null) {
+ return;
+ }
Credentials c = new Credentials(realm, host, userName, passwd);
- Message.debug("credentials added: "+c);
+ Message.debug("credentials added: " + c);
keyring.put(c.getKey(), c);
- // add also with host only, to be able to find credential with host only
+ // add also with host only, to be able to find credential with host only
// (useful for httpclient especially)
- keyring.put(c.getHost(), c);
+ keyring.put(c.getHost(), c);
}
- public Credentials getCredentials(String realm, String host) {
- return (Credentials) keyring.get(Credentials.buildKey(realm, host));
- }
+ public Credentials getCredentials(String realm, String host) {
+ return (Credentials) keyring.get(Credentials.buildKey(realm, host));
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java Tue Jun 5 05:02:27 2007
@@ -42,57 +42,59 @@
import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;
-
/**
*
*/
public class HttpClientHandler extends AbstractURLHandler {
- private static final SimpleDateFormat LAST_MODIFIED_FORMAT = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.US);
-
+ private static final SimpleDateFormat LAST_MODIFIED_FORMAT = new SimpleDateFormat(
+ "EEE, d MMM yyyy HH:mm:ss z", Locale.US);
+
// proxy configuration: obtain from system properties
private int _proxyPort;
private String _proxyRealm = null;
+
private String _proxyHost = null;
+
private String _proxyUserName = null;
+
private String _proxyPasswd = null;
-
+
private HttpClientHelper _httpClientHelper;
-
+
public HttpClientHandler() {
configureProxy();
}
private void configureProxy() {
_proxyRealm = null;
- //no equivalent for realm in jdk proxy support ?
+ // no equivalent for realm in jdk proxy support ?
_proxyHost = System.getProperty("http.proxyHost");
- //TODO constant is better ...
- if(useProxy()) {
+ // TODO constant is better ...
+ if (useProxy()) {
_proxyPort = Integer.parseInt(System.getProperty("http.proxyPort", "80"));
_proxyUserName = System.getProperty("http.proxyUser");
_proxyPasswd = System.getProperty("http.proxyPassword");
- //It seems there is no equivalent in HttpClient for
+ // It seems there is no equivalent in HttpClient for
// 'http.nonProxyHosts' property
- Message.verbose("proxy configured: host="+_proxyHost+" port="+_proxyPort+" user="+_proxyUserName);
+ Message.verbose("proxy configured: host=" + _proxyHost + " port=" + _proxyPort
+ + " user=" + _proxyUserName);
} else {
Message.verbose("no proxy configured");
}
}
-
-
-
+
public InputStream openStream(URL url) throws IOException {
GetMethod get = doGet(url);
return new GETInputStream(get);
}
-
+
public void download(URL src, File dest, CopyProgressListener l) throws IOException {
GetMethod get = doGet(src);
FileUtil.copy(get.getResponseBodyAsStream(), dest, l);
get.releaseConnection();
}
-
+
public URLInfo getURLInfo(URL url) {
return getURLInfo(url, 0);
}
@@ -108,27 +110,30 @@
}
if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
Message.error("Your proxy requires authentication.");
- }else if (String.valueOf(status).startsWith("4")) {
- Message.verbose("CLIENT ERROR: "+head.getStatusText()+" url="+url);
- }else if (String.valueOf(status).startsWith("5")) {
- Message.warn("SERVER ERROR: "+head.getStatusText()+" url="+url);
+ } else if (String.valueOf(status).startsWith("4")) {
+ Message.verbose("CLIENT ERROR: " + head.getStatusText() + " url=" + url);
+ } else if (String.valueOf(status).startsWith("5")) {
+ Message.warn("SERVER ERROR: " + head.getStatusText() + " url=" + url);
}
- Message.debug("HTTP response status: "+status +"="+head.getStatusText()+" url="+url);
+ Message.debug("HTTP response status: " + status + "=" + head.getStatusText() + " url="
+ + url);
} catch (HttpException e) {
- Message.error("HttpClientHandler: "+e.getMessage()+":" + e.getReasonCode()+"="+e.getReason()+" url="+url);
+ Message.error("HttpClientHandler: " + e.getMessage() + ":" + e.getReasonCode() + "="
+ + e.getReason() + " url=" + url);
} catch (UnknownHostException e) {
- Message.warn("Host " + e.getMessage() +" not found. url="+url);
- Message.info("You probably access the destination server through a proxy server that is not well configured.");
- }catch (IOException e) {
- Message.error("HttpClientHandler: "+e.getMessage()+" url="+url);
- } finally{
- if(head != null) {
+ Message.warn("Host " + e.getMessage() + " not found. url=" + url);
+ Message
+ .info("You probably access the destination server through a proxy server that is not well configured.");
+ } catch (IOException e) {
+ Message.error("HttpClientHandler: " + e.getMessage() + " url=" + url);
+ } finally {
+ if (head != null) {
head.releaseConnection();
}
}
return UNAVAILABLE;
}
-
+
private long getLastModified(HeadMethod head) {
Header header = head.getResponseHeader("last-modified");
if (header != null) {
@@ -155,8 +160,9 @@
_httpClientHelper = new HttpClientHelper3x();
Message.verbose("using commons httpclient 3.x helper");
} catch (SecurityException e) {
- Message.verbose("unable to get access to getResponseContentLength of commons-httpclient HeadMethod. Please use commons-httpclient 3.0 or use ivy with sufficient security permissions.");
- Message.verbose("exception: "+e.getMessage());
+ Message
+ .verbose("unable to get access to getResponseContentLength of commons-httpclient HeadMethod. Please use commons-httpclient 3.0 or use ivy with sufficient security permissions.");
+ Message.verbose("exception: " + e.getMessage());
_httpClientHelper = new HttpClientHelper2x();
Message.verbose("using commons httpclient 2.x helper");
} catch (NoSuchMethodException e) {
@@ -166,10 +172,10 @@
}
return _httpClientHelper;
}
-
+
public int getHttpClientMajorVersion() {
- HttpClientHelper helper = getHttpClientHelper();
- return helper.getHttpClientMajorVersion();
+ HttpClientHelper helper = getHttpClientHelper();
+ return helper.getHttpClientMajorVersion();
}
private GetMethod doGet(URL url) throws IOException, HttpException {
@@ -193,7 +199,7 @@
private HttpClient getClient(URL url) {
HttpClient client = new HttpClient();
-
+
List authPrefs = new ArrayList(2);
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
@@ -209,12 +215,9 @@
}
Credentials c = getCredentials(url);
if (c != null) {
- Message.debug("found credentials for "+url+": "+c);
- client.getState().setCredentials(
- c.getRealm(),
- c.getHost(),
- new UsernamePasswordCredentials(c.getUserName(), c.getPasswd())
- );
+ Message.debug("found credentials for " + url + ": " + c);
+ client.getState().setCredentials(c.getRealm(), c.getHost(),
+ new UsernamePasswordCredentials(c.getUserName(), c.getPasswd()));
}
return client;
}
@@ -222,20 +225,22 @@
private boolean useProxy() {
return _proxyHost != null && _proxyHost.trim().length() > 0;
}
+
private boolean useAuthentication(URL url) {
return getCredentials(url) != null;
}
-
+
private Credentials getCredentials(URL url) {
- return CredentialsStore.INSTANCE.getCredentials(null, url.getHost());
- }
+ return CredentialsStore.INSTANCE.getCredentials(null, url.getHost());
+ }
- private boolean useProxyAuthentication() {
+ private boolean useProxyAuthentication() {
return (_proxyUserName != null && _proxyUserName.trim().length() > 0);
}
-
+
private static final class GETInputStream extends InputStream {
private InputStream _is;
+
private GetMethod _get;
private GETInputStream(GetMethod get) throws IOException {
@@ -292,6 +297,7 @@
return _is.toString();
}
}
+
private static final class HttpClientHelper3x implements HttpClientHelper {
private HttpClientHelper3x() {
}
@@ -300,13 +306,14 @@
return head.getResponseContentLength();
}
- /**
- * {@inheritDoc}
- */
- public int getHttpClientMajorVersion() {
- return 3;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int getHttpClientMajorVersion() {
+ return 3;
+ }
}
+
private static final class HttpClientHelper2x implements HttpClientHelper {
private HttpClientHelper2x() {
}
@@ -323,15 +330,17 @@
return 0;
}
- /**
- * {@inheritDoc}
- */
- public int getHttpClientMajorVersion() {
- return 2;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int getHttpClientMajorVersion() {
+ return 2;
+ }
}
+
public interface HttpClientHelper {
long getResponseContentLength(HeadMethod head);
+
int getHttpClientMajorVersion();
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java Tue Jun 5 05:02:27 2007
@@ -23,21 +23,19 @@
import org.apache.ivy.util.Credentials;
import org.apache.ivy.util.Message;
-
/**
*
*/
public final class IvyAuthenticator extends Authenticator {
-
/**
* The sole instance.
*/
public final static IvyAuthenticator INSTANCE = new IvyAuthenticator();
/**
- * Private c'tor to prevent instantiation. Also installs this as the default
- * Authenticator to use by the JVM.
+ * Private c'tor to prevent instantiation. Also installs this as the default Authenticator to
+ * use by the JVM.
*/
private IvyAuthenticator() {
// Install this as the default Authenticator object.
@@ -49,10 +47,13 @@
// Overriding Authenticator *********************************************
protected PasswordAuthentication getPasswordAuthentication() {
- Credentials c = CredentialsStore.INSTANCE.getCredentials(getRequestingPrompt(), getRequestingHost());
- Message.debug("authentication: k='"+Credentials.buildKey(getRequestingPrompt(), getRequestingHost())+"' c='" + c + "'");
- return c != null ? new PasswordAuthentication(c.getUserName(), c.getPasswd().toCharArray()) : null;
+ Credentials c = CredentialsStore.INSTANCE.getCredentials(getRequestingPrompt(),
+ getRequestingHost());
+ Message.debug("authentication: k='"
+ + Credentials.buildKey(getRequestingPrompt(), getRequestingHost()) + "' c='" + c
+ + "'");
+ return c != null ? new PasswordAuthentication(c.getUserName(), c.getPasswd().toCharArray())
+ : null;
}
-
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java Tue Jun 5 05:02:27 2007
@@ -24,92 +24,115 @@
import org.apache.ivy.util.CopyProgressListener;
-
/**
- * This interface is responsible for handling some URL manipulation
- * (stream opening, downloading, check reachability, ...).
- *
- *
+ * This interface is responsible for handling some URL manipulation (stream opening, downloading,
+ * check reachability, ...).
*/
public interface URLHandler {
public static class URLInfo {
private long _contentLength;
+
private long _lastModified;
+
private boolean _available;
-
+
protected URLInfo(boolean available, long contentLength, long lastModified) {
_available = available;
_contentLength = contentLength;
_lastModified = lastModified;
}
+
public boolean isReachable() {
return _available;
}
+
public long getContentLength() {
return _contentLength;
}
+
public long getLastModified() {
return _lastModified;
}
}
- public static final URLInfo UNAVAILABLE = new URLInfo(false, 0,0);
-
+
+ public static final URLInfo UNAVAILABLE = new URLInfo(false, 0, 0);
+
/**
* Please prefer getURLInfo when several infos are needed.
- * @param url the url to check
+ *
+ * @param url
+ * the url to check
* @return true if the target is reachable
*/
public boolean isReachable(URL url);
+
/**
* Please prefer getURLInfo when several infos are needed.
- * @param url the url to check
+ *
+ * @param url
+ * the url to check
* @return true if the target is reachable
*/
public boolean isReachable(URL url, int timeout);
+
/**
- * Returns the length of the target if the given url is reachable, and without
- * error code in case of http urls.
- * Please prefer getURLInfo when several infos are needed.
- * @param url the url to check
+ * Returns the length of the target if the given url is reachable, and without error code in
+ * case of http urls. Please prefer getURLInfo when several infos are needed.
+ *
+ * @param url
+ * the url to check
* @return the length of the target if available, 0 if not reachable
*/
public long getContentLength(URL url);
+
/**
- * Returns the length of the target if the given url is reachable, and without
- * error code in case of http urls.
- * @param url the url to check
- * @param timeout the maximum time before considering an url is not reachable
- * a timeout of zero indicates no timeout
+ * Returns the length of the target if the given url is reachable, and without error code in
+ * case of http urls.
+ *
+ * @param url
+ * the url to check
+ * @param timeout
+ * the maximum time before considering an url is not reachable a timeout of zero
+ * indicates no timeout
* @return the length of the target if available, 0 if not reachable
*/
public long getContentLength(URL url, int timeout);
-
+
/**
* Please prefer getURLInfo when several infos are needed.
- * @param url the url to check
+ *
+ * @param url
+ * the url to check
* @return last modified timestamp of the given url
*/
public long getLastModified(URL url);
+
/**
* Please prefer getURLInfo when several infos are needed.
- * @param url the url to check
+ *
+ * @param url
+ * the url to check
* @return last modified timestamp of the given url
*/
public long getLastModified(URL url, int timeout);
-
+
/**
* never returns null, return UNAVAILABLE when url is not reachable
+ *
* @param url
* @return
*/
public URLInfo getURLInfo(URL url);
+
/**
* never returns null, return UNAVAILABLE when url is not reachable
+ *
* @param url
* @return
*/
public URLInfo getURLInfo(URL url, int timeout);
-
+
public InputStream openStream(URL url) throws IOException;
+
public void download(URL src, File dest, CopyProgressListener l) throws IOException;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java Tue Jun 5 05:02:27 2007
@@ -26,35 +26,32 @@
import org.apache.ivy.util.CopyProgressListener;
-
/**
* This class is used to dispatch downloading requests
- *
- *
*/
public class URLHandlerDispatcher implements URLHandler {
protected Map _handlers = new HashMap();
+
protected URLHandler _default = new BasicURLHandler();
public URLHandlerDispatcher() {
}
-
+
public boolean isReachable(URL url) {
return getHandler(url.getProtocol()).isReachable(url);
}
-
+
public boolean isReachable(URL url, int timeout) {
return getHandler(url.getProtocol()).isReachable(url, timeout);
}
-
+
public long getContentLength(URL url) {
return getHandler(url.getProtocol()).getContentLength(url);
}
-
+
public long getContentLength(URL url, int timeout) {
return getHandler(url.getProtocol()).getContentLength(url, timeout);
}
-
public long getLastModified(URL url) {
return getHandler(url.getProtocol()).getLastModified(url);
@@ -71,26 +68,28 @@
public URLInfo getURLInfo(URL url, int timeout) {
return getHandler(url.getProtocol()).getURLInfo(url, timeout);
}
+
public InputStream openStream(URL url) throws IOException {
return getHandler(url.getProtocol()).openStream(url);
}
-
+
public void download(URL src, File dest, CopyProgressListener l) throws IOException {
getHandler(src.getProtocol()).download(src, dest, l);
}
-
+
public void setDownloader(String protocol, URLHandler downloader) {
_handlers.put(protocol, downloader);
}
-
+
public URLHandler getHandler(String protocol) {
- URLHandler downloader = (URLHandler)_handlers.get(protocol);
+ URLHandler downloader = (URLHandler) _handlers.get(protocol);
return downloader == null ? _default : downloader;
}
-
+
public URLHandler getDefault() {
return _default;
}
+
public void setDefault(URLHandler default1) {
_default = default1;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerRegistry.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerRegistry.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerRegistry.java Tue Jun 5 05:02:27 2007
@@ -28,15 +28,14 @@
public static URLHandler getDefault() {
return _default;
}
+
public static void setDefault(URLHandler def) {
_default = def;
}
-
+
/**
- * This method is used to get appropriate http downloader
- * dependening on Jakarta Commons HttpClient
- * availability in classpath, or simply use jdk url
- * handling in other cases.
+ * This method is used to get appropriate http downloader dependening on Jakarta Commons
+ * HttpClient availability in classpath, or simply use jdk url handling in other cases.
*
* @return most accurate http downloader
*/
@@ -45,21 +44,22 @@
Class.forName("org.apache.commons.httpclient.HttpClient");
Class handler = Class.forName("org.apache.ivy.util.url.HttpClientHandler");
Message.verbose("jakarta commons httpclient detected: using it for http downloading");
- return (URLHandler) handler.newInstance();
+ return (URLHandler) handler.newInstance();
} catch (ClassNotFoundException e) {
Message.verbose("jakarta commons httpclient not found: using jdk url handling");
return new BasicURLHandler();
- } catch (NoClassDefFoundError e) {
- Message.verbose("error occurred while loading jakarta commons httpclient: " + e.getMessage());
- Message.verbose("Using jdk url handling instead.");
+ } catch (NoClassDefFoundError e) {
+ Message.verbose("error occurred while loading jakarta commons httpclient: "
+ + e.getMessage());
+ Message.verbose("Using jdk url handling instead.");
return new BasicURLHandler();
} catch (InstantiationException e) {
Message.verbose("couldn't instantiate HttpClientHandler: using jdk url handling");
return new BasicURLHandler();
- } catch (IllegalAccessException e) {
+ } catch (IllegalAccessException e) {
Message.verbose("couldn't instantiate HttpClientHandler: using jdk url handling");
return new BasicURLHandler();
- }
+ }
}
}
Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java Tue Jun 5 05:02:27 2007
@@ -26,12 +26,16 @@
public class TestHelper {
- public static File getArchiveFileInCache(Ivy ivy, File cache, String organisation, String module, String revision, String artifact, String type, String ext) {
- return getArchiveFileInCache(ivy.getCacheManager(cache), organisation, module, revision, artifact, type, ext);
- }
+ public static File getArchiveFileInCache(Ivy ivy, File cache, String organisation,
+ String module, String revision, String artifact, String type, String ext) {
+ return getArchiveFileInCache(ivy.getCacheManager(cache), organisation, module, revision,
+ artifact, type, ext);
+ }
- public static File getArchiveFileInCache(CacheManager cacheManager, String organisation, String module, String revision, String artifact, String type, String ext) {
- return cacheManager.getArchiveFileInCache(new DefaultArtifact(ModuleRevisionId.newInstance(organisation, module, revision), new Date(), artifact, type, ext));
- }
+ public static File getArchiveFileInCache(CacheManager cacheManager, String organisation,
+ String module, String revision, String artifact, String type, String ext) {
+ return cacheManager.getArchiveFileInCache(new DefaultArtifact(ModuleRevisionId.newInstance(
+ organisation, module, revision), new Date(), artifact, type, ext));
+ }
}
Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/AntBuildTriggerTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/AntBuildTriggerTest.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/AntBuildTriggerTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/AntBuildTriggerTest.java Tue Jun 5 05:02:27 2007
@@ -26,21 +26,21 @@
import org.apache.ivy.util.FileUtil;
public class AntBuildTriggerTest extends TestCase {
- public void test() throws Exception {
- assertFalse(new File("test/triggers/ant-build/A/A.jar").exists());
+ public void test() throws Exception {
+ assertFalse(new File("test/triggers/ant-build/A/A.jar").exists());
- Ivy ivy = new Ivy();
- ivy.configure(new File("test/triggers/ant-build/ivysettings.xml"));
+ Ivy ivy = new Ivy();
+ ivy.configure(new File("test/triggers/ant-build/ivysettings.xml"));
- ResolveReport r = ivy.resolve(new File("test/triggers/ant-build/B/ivy.xml"));
- assertFalse(r.hasError());
+ ResolveReport r = ivy.resolve(new File("test/triggers/ant-build/B/ivy.xml"));
+ assertFalse(r.hasError());
- // should have triggered an A publish
- assertTrue(new File("test/triggers/ant-build/local/A/A.jar").exists());
- }
+ // should have triggered an A publish
+ assertTrue(new File("test/triggers/ant-build/local/A/A.jar").exists());
+ }
- protected void tearDown() throws Exception {
- FileUtil.forceDelete(new File("test/triggers/ant-build/local/A"));
- FileUtil.forceDelete(new File("test/triggers/ant-build/cache"));
- }
+ protected void tearDown() throws Exception {
+ FileUtil.forceDelete(new File("test/triggers/ant-build/local/A"));
+ FileUtil.forceDelete(new File("test/triggers/ant-build/cache"));
+ }
}