incubator-depot-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickcha...@apache.org
Subject svn commit: rev 10254 - incubator/depot/trunk/update/src/java/org/apache/depot/update/ant
Date Sun, 25 Apr 2004 07:35:23 GMT
Author: nickchalko
Date: Sun Apr 25 00:35:23 2004
New Revision: 10254

Modified:
   incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSet.java
Log:
Since the test is already failing.  
I restarted the getLocalFile  method to follow my basic use case.
Look in local first then only if not found check remote.


Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSet.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSet.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSet.java
Sun Apr 25 00:35:23 2004
@@ -43,9 +43,11 @@
 	public static final String REPOSITORY_DIR_PROPERTY = "repository.dir";
 	private final Project project;
 	private String id;
-	private final CachedResourceFileSet fileSet = new CachedResourceFileSet(this);
+	private final CachedResourceFileSet fileSet = new CachedResourceFileSet(
+			this);
 	private final List resourceList = new ArrayList();
 	private ResourceUpdater m_updater = null;
+	private boolean isAlwaysCheckRemote=false;
 	/**
 	 *  
 	 */
@@ -98,7 +100,8 @@
 	 * @param scanner
 	 * @param r
 	 */
-	private void add(DirectoryScanner scanner, ResourceElement r) throws UpdateException {
+	private void add(DirectoryScanner scanner, ResourceElement r)
+			throws UpdateException {
 		log("Looking for " + r, Project.MSG_DEBUG);
 		File f = getLocalFile(r);
 		if (f != null) {
@@ -113,35 +116,48 @@
 			throw new BuildException("Unable to find " + r);
 		}
 	}
-	public File getLocalFile(ResourceElement r) throws UpdateException {
+	/**
+	 * Find and download if needed a the best local cached copy of a file. First
+	 * check if a compitable file is available locally. If not down load the
+	 * best one available from the repository. And finally return the best
+	 * compatible file.
+	 * 
+	 * @param r
+	 *            resourceElement the ant element describeing the resouce to
+	 *            find
+	 * @return File null if a compatible file can't be found.
+	 * @throws UpdateException
+	 */
+	private File getLocalFile(ResourceElement r) throws UpdateException {
 		File file = null;
-		// Create on the fly...
-		if (null == m_updater) {
-			m_updater = new ResourceUpdater();
-			// Assigned the target (to copy into)
-			m_updater.setDefaultTargetRepository(getLocalRepository());
-			//if (null != configName)
-			//	UpdateConfig.configure(configName);
-			//m_updater.setDefaultRepositorySet(RepositorySet.getRepositorySet(
-			//		"gump", false));
-		}
-		if (r.getRepository() != null) {
-			m_updater.setDefaultRepositorySet(new RepositorySet(r.toString(), r.getIRepository()));
-		}
-		// The group to go get
-		ResourceGroup group = new ResourceGroup(r.getName());
-		// Update...
-		m_updater.updateResourceGroup(group);
-		// Cleanup (to remove duplicates)
-		//m_updater.clean(group);
-		// :TODO: set file [or files]....
+		if (!isAlwaysCheckRemote) {
+			file = getCachedFile(r);
+		}
+		if (file == null) {
+			cacheFile(r);
+		}
+		file = getCachedFile(r);
+		return file;
+	}
+	/**
+	 * @param r
+	 */
+	private void cacheFile(ResourceElement r) {
+		// TODO Auto-generated method stub
+	}
+	/**
+	 * @param r
+	 */
+	private File getCachedFile(ResourceElement r) {
+		// TODO Auto-generated method stub
 		return null;
 	}
 	/**
 	 * @return
 	 */
 	private IRepository getLocalRepository() {
-		DefaultRepository repository = new DefaultRepository(LOCAL_REPOSITORY_ID, ResolvedFile.resolve(getRepoDir()));
+		DefaultRepository repository = new DefaultRepository(
+				LOCAL_REPOSITORY_ID, ResolvedFile.resolve(getRepoDir()));
 		return repository;
 	}
 	/**
@@ -150,7 +166,7 @@
 	private File getRepoDir() {
 		String repoDir = project.getProperty(REPOSITORY_DIR_PROPERTY);
 		if (repoDir == null) {
-			repoDir = getDepotHome() + "/"+DEFAULT_LOCAL_REPOSITORY_DIR_NAME;
+			repoDir = getDepotHome() + "/" + DEFAULT_LOCAL_REPOSITORY_DIR_NAME;
 		}
 		File repo = new File(repoDir);
 		if (!repo.exists()) {
@@ -167,5 +183,19 @@
 			throw new BuildException("The property depot.home must be set");
 		}
 		return property;
+	}
+	/**
+	 * Should the cached set always look the remore repository for updates
+	 * @return Returns the isAlwaysCheckRemote.
+	 */
+	public boolean isAlwaysCheckRemote() {
+		return isAlwaysCheckRemote;
+	}
+	/**
+	 * Should the cached set always look the remore repository for updates
+	 * @param isAlwaysCheckRemote The isAlwaysCheckRemote to set.
+	 */
+	public void setAlwaysCheckRemote(boolean isAlwaysCheckRemote) {
+		this.isAlwaysCheckRemote = isAlwaysCheckRemote;
 	}
 }

Mime
View raw message