incubator-depot-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: rev 23153 - in incubator/depot/trunk/update/src/java/org/apache/depot/update: protocols protocols/impl repository util/compare util/io util/net util/net/select
Date Thu, 22 Jul 2004 15:27:29 GMT
Author: ajack
Date: Thu Jul 22 08:27:28 2004
New Revision: 23153

Modified:
   incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/DefaultProtocolOperationsManager.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/impl/VfsProtocolOperationsProvider.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/DefaultRepository.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/compare/ComparatorSequence.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/HtmlUtils.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/VfsUtils.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/VirtualResourceLocator.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/ChildVrlSelector.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/MatchingVrlSelector.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/ProtocolVrlSelector.java
Log:
Attempt to avoid 'mailto:'


Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/DefaultProtocolOperationsManager.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/DefaultProtocolOperationsManager.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/DefaultProtocolOperationsManager.java
Thu Jul 22 08:27:28 2004
@@ -48,7 +48,7 @@
 
 			registerProvider(provider);
 			
-			Logger.getLogger().info("Selected " + provider.getClass().getName());
+			Logger.getLogger().info("Selected Provider: " + provider.getClass().getName() + " for
" + context);
 		} catch (Exception ve) {
 			throw new UpdateRuntimeException(
 					"No *Working* Protocol Operation Providers Detected", ve);

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/impl/VfsProtocolOperationsProvider.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/impl/VfsProtocolOperationsProvider.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/protocols/impl/VfsProtocolOperationsProvider.java
Thu Jul 22 08:27:28 2004
@@ -27,6 +27,7 @@
 import org.apache.depot.update.protocols.Protocol;
 import org.apache.depot.update.util.io.VfsUtils;
 import org.apache.depot.update.util.net.VirtualResourceLocator;
+import org.apache.depot.update.util.net.select.ChildVrlSelector;
 import org.apache.depot.update.util.select.ISelector;
 
 /**
@@ -76,9 +77,14 @@
 		// Convert the list of File Objects to Locators... 
 		List locators = new ArrayList(fileObjects.size());
 
+		ISelector childSelector = new ChildVrlSelector(container);
+		
 		for (Iterator i = fileObjects.iterator(); i.hasNext();) {
 			FileObject fileObject = (FileObject) i.next();
-			locators.add(resolveLocator(fileObject));
+			
+			VirtualResourceLocator vrl = resolveLocator(fileObject);
+			if (childSelector.select(vrl))
+				locators.add(vrl);
 		}
 
 		return locators;
@@ -123,11 +129,25 @@
 		}
 	}
 
+	/**
+	 * Resolve an address into a VFS FileObject
+	 * 
+	 * @param address
+	 * @return
+	 * @throws Exception
+	 */
 	private FileObject resolveAddress(VirtualResourceLocator address)
 		throws Exception {
 		return m_fsm.resolveFile(address.toExternalForm());
 	}
 
+	/**
+	 * Resolve a VFS FileObject into an address
+	 * 
+	 * @param fileObject
+	 * @return
+	 * @throws Exception
+	 */
 	private VirtualResourceLocator resolveLocator(FileObject fileObject)
 		throws Exception {
 		return new VirtualResourceLocator(fileObject.getURL());

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/DefaultRepository.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/DefaultRepository.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/DefaultRepository.java
Thu Jul 22 08:27:28 2004
@@ -126,31 +126,34 @@
 		return results;
 	}
 
-public ArtifactInstance publishArtifact(ArtifactUpdaterContext context,
+	public ArtifactInstance publishArtifact(ArtifactUpdaterContext context,
 			ArtifactInstance instance) throws Exception {
 
 		// Create the 'remote' instance
-		ArtifactInstance publishedInstance = 
-				new ArtifactInstance(
-						instance.getArtifact(),
-						new ArtifactLocator(
-								instance.getLocator().getFilename(),
-								instance.getLocator().getExtension(),
-								new VirtualResourceLocator(
-										folderForGroup(instance.getArtifact().getGroup()), 
-						instance.getLocator().getFilename())));
+		ArtifactInstance publishedInstance = new ArtifactInstance(
+				instance.getArtifact(),
+				new ArtifactLocator(
+						instance.getLocator().getFilename(),
+						instance.getLocator().getExtension(),
+						new VirtualResourceLocator(
+								folderForGroup(instance.getArtifact().getGroup()),
+								instance.getLocator().getFilename())));
 
 		// Perform copy
-		context.getProtocolManager().performCopy(instance.getLocator().getLocation(),
-				publishedInstance.getLocator().getLocation(), AllSelector.getInstance());
+		context.getProtocolManager().performCopy(
+				instance.getLocator().getLocation(),
+				publishedInstance.getLocator().getLocation(),
+				AllSelector.getInstance());
 
 		return publishedInstance;
-	}	public void deleteArtifact(ArtifactUpdaterContext context,
+	}
+
+	public void deleteArtifact(ArtifactUpdaterContext context,
 			ArtifactInstance instance) throws Exception {
 
 		// Perform copy
-		context.getProtocolManager().performDelete(instance.getLocator().getLocation(),
-				AllSelector.getInstance());
+		context.getProtocolManager().performDelete(
+				instance.getLocator().getLocation(), AllSelector.getInstance());
 	}
 
 	public static Repository getLocalTestRepository() {

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/compare/ComparatorSequence.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/compare/ComparatorSequence.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/compare/ComparatorSequence.java
Thu Jul 22 08:27:28 2004
@@ -31,9 +31,10 @@
 		super(comparators);
 	}
 
-	//
-	// An Empty
-	//
+	/**
+	 * An empty sequence
+	 *
+	 */
 	public ComparatorSequence() {
 		super();
 	}

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java	Thu
Jul 22 08:27:28 2004
@@ -1,17 +1,17 @@
 /*
- * Copyright  2004 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
  */
 
 package org.apache.depot.update.util.io;
@@ -58,6 +58,12 @@
 		}
 	}
 
+	/**
+	 * Create a URL for a File path.
+	 * 
+	 * @param file
+	 * @return
+	 */
 	public static URL getFileURL(File file) {
 		URL url = null;
 
@@ -74,6 +80,12 @@
 		return url;
 	}
 
+	/**
+	 * Create a URI for a String file path
+	 * 
+	 * @param path
+	 * @return
+	 */
 	public static String toURI(String path) {
 		return toURI(new File(path));
 	}
@@ -142,4 +154,4 @@
 			IOUtils.close(input);
 		}
 	}
-}
+}
\ No newline at end of file

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/HtmlUtils.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/HtmlUtils.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/HtmlUtils.java	Thu
Jul 22 08:27:28 2004
@@ -22,6 +22,7 @@
 import java.util.List;
 import java.util.StringTokenizer;
 
+import org.apache.depot.common.log.Logger;
 import org.apache.depot.update.util.net.VirtualResourceLocator;
 import org.apache.depot.update.util.net.select.ChildVrlSelector;
 import org.apache.depot.update.util.net.select.MatchingVrlSelector;
@@ -32,6 +33,14 @@
  */
 public class HtmlUtils {
 
+	/**
+	 * Extract the child URLs from a content stream
+	 * 
+	 * @param parent
+	 * @param contentStream
+	 * @return
+	 * @throws IOException
+	 */
 	public static List getChildren(
 		VirtualResourceLocator parent,
 		InputStream contentStream)
@@ -53,6 +62,14 @@
 		return getChildren(parent, content);
 	}
 
+	/**
+	 * Extract the child URLs from a content string
+	 * 
+	 * @param parent
+	 * @param content
+	 * @return
+	 * @throws IOException
+	 */
 	public static List getChildren(
 		VirtualResourceLocator parent,
 		String content)
@@ -60,6 +77,15 @@
 		return getLinks(parent, content, new ChildVrlSelector(parent));
 	}
 
+	/**
+	 * Get all links matching this pattern.
+	 * 
+	 * @param parent
+	 * @param content
+	 * @param pattern
+	 * @return
+	 * @throws IOException
+	 */
 	public static List getMatching(
 		VirtualResourceLocator parent,
 		String content,
@@ -67,15 +93,27 @@
 		throws IOException {
 		return getLinks(parent, content, new MatchingVrlSelector(pattern));
 	}
-
+	
+	/**
+	 * Get all links matching this selector.
+	 * 
+	 * @param parent
+	 * @param content
+	 * @param pattern
+	 * @return
+	 * @throws IOException
+	 */
 	public static List getLinks(
 		VirtualResourceLocator parent,
 		String content,
 		ISelector selector)
 		throws IOException {
 		List children = new ArrayList();
-//		System.out.println("Selector      : " + selector);
+		Logger.getLogger().debug("Extract HTML Links Selector      : " + selector);
+		
+		// Dro pthe case everywhere, to simplify
 		String lowerCaseContent = content.toLowerCase();
+		
 		int index = 0;
 		while ((index = lowerCaseContent.indexOf("<a", index)) != -1) {
 			if ((index = lowerCaseContent.indexOf("href", index)) == -1) {
@@ -92,9 +130,9 @@
 			if ((strLink.length() > 0)
 				&& (strLink.indexOf("?") == -1)
 				&& (!"/".equals(strLink))) {
-//				boolean added = false;
+				boolean added = false;
 
-//				System.out.println("Link          : " + strLink);
+				Logger.getLogger().debug("Link          : " + strLink);
 
 				VirtualResourceLocator v =
 					new VirtualResourceLocator(parent, strLink);
@@ -107,12 +145,12 @@
 						//
 						if (!children.contains(v)) {
 							children.add(v);
-//							added = true;
+							added = true;
 						}
 
-//						if (added)
-//							System.out.println(
-//								"Selected      : " + strLink);
+						if (added)
+							Logger.getLogger().debug(
+								"Selected      : " + strLink);
 					}
 				}
 				catch (Exception e) {

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/VfsUtils.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/VfsUtils.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/VfsUtils.java	Thu
Jul 22 08:27:28 2004
@@ -117,7 +117,7 @@
 
 	public static List getChildren(FileObject folder)
 		throws IOException, MalformedURLException, FileSystemException {
-
+		
 		List result = new ArrayList();
 
 		if (folder.getFileSystem().hasCapability(Capability.LIST_CHILDREN)) {
@@ -135,6 +135,8 @@
 			ArrayList list = new ArrayList();
 			InputStream urlStream = null;
 
+			//Logger.getLogger().debug("Extract HTML Links from VFS");
+			
 			// try opening the URL
 			urlStream = null;
 
@@ -181,14 +183,14 @@
 								new StringTokenizer(remaining, "\t\n\r\">#");
 							String strLink = st.nextToken();
 
+							// Filter out dynamics... and mail
 							if ((strLink.length() > 0)
-								&& (strLink.indexOf("?") == -1)) {
-//								boolean added = false;
+								&& (strLink.indexOf("?") == -1)
+								&& (!strLink.startsWith("mailto:"))) {
+								//boolean added = false;
 								FileObject f = folder.resolveFile(strLink);
 
-								//
 								// Check not ".."
-								//
 								if (!f.equals(folder.getParent())) {
 
 									//
@@ -201,8 +203,12 @@
 										//
 										if (!list.contains(f)) {
 											list.add(f);
-//											added = true;
+											//added = true;
 										}
+
+										//if (added)
+										//	Logger.getLogger().debug(
+										//		"Selected      : " + strLink);
 									}
 								}
 

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/VirtualResourceLocator.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/VirtualResourceLocator.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/VirtualResourceLocator.java
Thu Jul 22 08:27:28 2004
@@ -55,6 +55,7 @@
 
 	public VirtualResourceLocator(VirtualResourceLocator context, String url) {
 
+		// If we have a protocol, we have an absolute URL
 		if (-1 != url.indexOf(":")) {
 			// Absolute URL
 			parseString(url);
@@ -88,6 +89,7 @@
 		else
 			m_protocol = Protocol.FILE_PROTOCOL;
 
+		// Crude, but.
 		m_isDirectory = m_url.endsWith("/");
 	}
 

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/ChildVrlSelector.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/ChildVrlSelector.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/ChildVrlSelector.java
Thu Jul 22 08:27:28 2004
@@ -24,7 +24,7 @@
  * @author arb_jack
  */
 public class ChildVrlSelector extends AbstractVrlSelector {
-	VirtualResourceLocator m_parent = null;
+	private VirtualResourceLocator m_parent = null;
 	
 	
 	/**

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/MatchingVrlSelector.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/MatchingVrlSelector.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/MatchingVrlSelector.java
Thu Jul 22 08:27:28 2004
@@ -26,7 +26,7 @@
  * @author arb_jack
  */
 public class MatchingVrlSelector extends AbstractVrlSelector {
-	RegularExpressionSelector m_regexp = null;
+	private RegularExpressionSelector m_regexp = null;
 
 	/**
 	 * @param expression

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/ProtocolVrlSelector.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/ProtocolVrlSelector.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/select/ProtocolVrlSelector.java
Thu Jul 22 08:27:28 2004
@@ -26,9 +26,8 @@
  * @author arb_jack
  */
 public class ProtocolVrlSelector extends AbstractVrlSelector {
-	Set m_protocols = null;
+	private Set m_protocols = null;
 
-	
 	/**
 	 * @param expression
 	 */

Mime
View raw message