You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by aj...@apache.org on 2004/06/25 19:59:13 UTC
svn commit: rev 22111 - in incubator/depot/trunk/update: . src/documentation/content/xdocs src/documentation/content/xdocs/ant src/documentation/content/xdocs/config src/java src/java/org/apache/depot/update src/java/org/apache/depot/update/ant/cache src/java/org/apache/depot/update/ant/sync src/java/org/apache/depot/update/ant/tool src/java/org/apache/depot/update/download src/java/org/apache/depot/update/impl src/java/org/apache/depot/update/monitor src/java/org/apache/depot/update/query src/java/org/apache/depot/update/repository src/java/org/apache/depot/update/sample src/java/org/apache/depot/update/tool src/java/org/apache/depot/update/util/text src/resources src/sample/CachedResourceSet src/sample/export src/test/org/apache/depot/update/ant src/test/org/apache/depot/update/ant/cache src/test/org/apache/depot/update/artifact src/test/org/apache/depot/update/query src/test/org/apache/depot/update/repository src/test/org/apache/depot/update/usecases src/test/org/apache/depot/update/util/security
Author: ajack
Date: Fri Jun 25 12:59:12 2004
New Revision: 22111
Added:
incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdaterOptions.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/download/
incubator/depot/trunk/update/src/java/org/apache/depot/update/download/DownloadManager.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/query/QueryEngine.java
incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/CachedArtifactSetTaskTest.java
incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/ArtifactTests.java
Removed:
incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/ArtifactUpdaterEngine.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/ArtifactUpdaterOptions.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/query/DefaultQueryEngine.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositoryManager.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositorySetSortContext.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositorySorterConfig.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/sample/FileUpdater.java
incubator/depot/trunk/update/src/resources/
incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/CachedResourceSetTaskTest.java
incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/FindTests.java
incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/SynchronizeTests.java
Modified:
incubator/depot/trunk/update/build-depend.xml
incubator/depot/trunk/update/src/documentation/content/xdocs/ant/index.xml
incubator/depot/trunk/update/src/documentation/content/xdocs/config/index.xml
incubator/depot/trunk/update/src/documentation/content/xdocs/index.xml
incubator/depot/trunk/update/src/documentation/content/xdocs/overview.xml
incubator/depot/trunk/update/src/java/depot-update.xml
incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdater.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdaterFactory.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/Repository.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/cache/ArtifactElement.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/cache/CachedArtifactSet.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/sync/SynchronizeTask.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/tool/RepositoryToolTask.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/ArtifactUpdaterContext.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/RepositoryWrapper.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/monitor/StatisticsMonitor.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/query/ArtifactQuery.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/query/ArtifactResultHelper.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/AbstractHierarchicalRepository.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/AbstractRepository.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/ApacheRepository.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/DefaultRepository.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/MockRepository.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositoryAttribute.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositoryCapability.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/sample/FileAssistant.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/ArtifactTool.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/DownloaderTool.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/RepositoryTool.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/util/text/MessageConstants.java
incubator/depot/trunk/update/src/sample/CachedResourceSet/build.xml
incubator/depot/trunk/update/src/sample/export/build.xml
incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/build.xml
incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/cache/test1-export.build.xml
incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/test1-export.build.xml
incubator/depot/trunk/update/src/test/org/apache/depot/update/artifact/ArtifactTests.java
incubator/depot/trunk/update/src/test/org/apache/depot/update/query/QueryTests.java
incubator/depot/trunk/update/src/test/org/apache/depot/update/repository/RepositoryTests.java
incubator/depot/trunk/update/src/test/org/apache/depot/update/util/security/HashCodeManagerTest.java
Log:
More simplification...
Modified: incubator/depot/trunk/update/build-depend.xml
==============================================================================
--- incubator/depot/trunk/update/build-depend.xml (original)
+++ incubator/depot/trunk/update/build-depend.xml Fri Jun 25 12:59:12 2004
@@ -31,13 +31,13 @@
<repository id="maven" url="http://www.ibiblio.org/maven/" remote="true" />
<repository id="nickchalko-sandbox" url="http://cvs.apache.org/~nickchalko/SNAPSHOTS/" remote="true" />
<cachedset id="depot-update.dependent.jars">
- <resource name="log4j" ext="jar" version="1.2" repository="maven" />
- <resource name="commons-vfs" ext="jar" version="20030518103800" repository="maven" />
- <resource name="commons-logging" ext="jar" repository="maven" />
- <resource name="commons-httpclient" ext="jar" version="2.0" repository="maven" />
- <resource name="commons-codec" ext="jar" version="1.2" repository="maven" />
+ <artifact name="log4j" ext="jar" version="1.2" repository="maven" />
+ <artifact name="commons-vfs" ext="jar" version="20030518103800" repository="maven" />
+ <artifact name="commons-logging" ext="jar" repository="maven" />
+ <artifact name="commons-httpclient" ext="jar" version="2.0" repository="maven" />
+ <artifact name="commons-codec" ext="jar" version="1.2" repository="maven" />
- <resource name="regexp" ext="jar" repository="maven" />
+ <artifact name="regexp" ext="jar" repository="maven" />
</cachedset>
Modified: incubator/depot/trunk/update/src/documentation/content/xdocs/ant/index.xml
==============================================================================
--- incubator/depot/trunk/update/src/documentation/content/xdocs/ant/index.xml (original)
+++ incubator/depot/trunk/update/src/documentation/content/xdocs/ant/index.xml Fri Jun 25 12:59:12 2004
@@ -12,12 +12,12 @@
<body>
<section><title>Ant Tasks</title>
<p>Apache-Ruper <fork href="http://ant.apache.org">Ant</fork> Tasks are designed to
- enable <strong>resource updating</strong> with the minimal of developer effort.
+ enable <strong>artifact updating</strong> with the minimal of developer effort.
</p>
<p>It implements the following ANT tasks:</p>
<table>
<tr><th>Task</th><th>Description</th></tr>
- <tr><td><link href="reposync.html">reposync</link></td><td>Synchronize resources with repositories</td></tr>
+ <tr><td><link href="reposync.html">reposync</link></td><td>Synchronize artifacts with repositories</td></tr>
<tr><td><link href="repotool.html">repotool</link></td><td>Tinker w/ Repositories (introspect, clean, etc.)</td></tr>
</table>
Modified: incubator/depot/trunk/update/src/documentation/content/xdocs/config/index.xml
==============================================================================
--- incubator/depot/trunk/update/src/documentation/content/xdocs/config/index.xml (original)
+++ incubator/depot/trunk/update/src/documentation/content/xdocs/config/index.xml Fri Jun 25 12:59:12 2004
@@ -14,7 +14,7 @@
<section><title>Configuration</title>
<p>Apache-Ruper .</p>
<section><title>Ruper.xml</title>
- <p>Configuration is done via API or XML resource. Ruper ships with the following.</p>
+ <p>Configuration is done via API or XML artifact. Ruper ships with the following.</p>
<source>
<?xml version="1.0"?>
<!--
Modified: incubator/depot/trunk/update/src/documentation/content/xdocs/index.xml
==============================================================================
--- incubator/depot/trunk/update/src/documentation/content/xdocs/index.xml (original)
+++ incubator/depot/trunk/update/src/documentation/content/xdocs/index.xml Fri Jun 25 12:59:12 2004
@@ -7,9 +7,9 @@
<body>
<section>
<title>Resource Updater</title>
- <p>Apache-Ruper is a resource updater,
- meaning it <strong>automatically</strong> keeps local resources up-to-date with
- versions of the resource found in repositories.</p>
+ <p>Apache-Ruper is a artifact updater,
+ meaning it <strong>automatically</strong> keeps local artifacts up-to-date with
+ versions of the artifact found in repositories.</p>
<p>Say you have a build script that uses releases of certain jars, e.g. junit.jar
or commons-logging.jar, you could ask Ruper to get the latest <strong>release</strong>
of these, and store it in your <code>./lib</code> directory.
Modified: incubator/depot/trunk/update/src/documentation/content/xdocs/overview.xml
==============================================================================
--- incubator/depot/trunk/update/src/documentation/content/xdocs/overview.xml (original)
+++ incubator/depot/trunk/update/src/documentation/content/xdocs/overview.xml Fri Jun 25 12:59:12 2004
@@ -11,8 +11,8 @@
<p>Ruper introduces terminology for the participants in it's worldview.</p>
<ul>
<li><strong>Resource:</strong> A named item (a file of sorts)</li>
- <li><strong>Repository:</strong> A repository object contains resources</li>
- <li><strong>Instance of Resource:</strong> E.g. X-01012003.jar is an instance of the X resource</li>
+ <li><strong>Repository:</strong> A repository object contains artifacts</li>
+ <li><strong>Instance of Resource:</strong> E.g. X-01012003.jar is an instance of the X artifact</li>
</ul>
</section>
Modified: incubator/depot/trunk/update/src/java/depot-update.xml
==============================================================================
--- incubator/depot/trunk/update/src/java/depot-update.xml (original)
+++ incubator/depot/trunk/update/src/java/depot-update.xml Fri Jun 25 12:59:12 2004
@@ -33,7 +33,7 @@
remote="true"/>
<repository id="test"
- url="./src/resources/test/repo"
+ url="./src/artifacts/test/repo"
remote="true"/>
</repositoryset>
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdater.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdater.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdater.java Fri Jun 25 12:59:12 2004
@@ -16,7 +16,6 @@
package org.apache.depot.update;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -26,20 +25,22 @@
import org.apache.depot.common.log.Logger;
import org.apache.depot.update.artifact.ArtifactGroup;
import org.apache.depot.update.config.UpdateConfig;
+import org.apache.depot.update.download.DownloadManager;
import org.apache.depot.update.impl.ArtifactUpdaterContext;
-import org.apache.depot.update.impl.ArtifactUpdaterEngine;
-import org.apache.depot.update.impl.ReferenceManager;
+import org.apache.depot.update.impl.RepositorySetWrapper;
+import org.apache.depot.update.impl.RepositoryWrapper;
+import org.apache.depot.update.protocols.DefaultProtocolOperationsManager;
import org.apache.depot.update.query.ArtifactQuery;
import org.apache.depot.update.query.ArtifactQueryHelper;
import org.apache.depot.update.query.ArtifactResult;
import org.apache.depot.update.query.ArtifactResultHelper;
+import org.apache.depot.update.query.QueryEngine;
+import org.apache.depot.update.repository.RepositoryException;
import org.apache.depot.update.repository.RepositorySet;
-import org.apache.depot.update.repository.RepositorySetSortContext;
import org.apache.depot.update.updater.DefaultArtifactUpdater;
import org.apache.depot.update.util.UpdateConstants;
import org.apache.depot.update.util.identity.GenericIdentifier;
import org.apache.depot.update.util.reference.IReferenceable;
-import org.apache.depot.update.util.reference.NoSuchReferenceException;
import org.apache.depot.update.util.text.MessageConstants;
import org.apache.depot.update.util.text.Messages;
@@ -48,7 +49,7 @@
*
* @see DefaultArtifactUpdater, StandardResourceUpdater
*
- * @author anou_mana
+ * @author arb_jack
*/
public class ArtifactUpdater implements IReferenceable {
@@ -70,470 +71,222 @@
}
// The identity...
- private ArtifactUpdater.Identifier m_identifier = null;
+ private ArtifactUpdater.Identifier m_identifier;
+
+ // Context:
+ ArtifactUpdaterContext m_context;
// Options for configuring the Updater
- private Map m_resourceConfigOptions = new HashMap();
+ private Map m_artifactConfigOptions = new HashMap();
+
+ // Query Engine
+ private QueryEngine m_queryEngine;
+
+ // Download Manager
+ private DownloadManager m_downloadManager;
+ // Repository pool
+ private RepositorySet m_repositorySet;
+
// Target repository
private Repository m_targetRepository;
- //Updater
- private ArtifactUpdaterEngine m_updateEngine;
-
/**
- * Get the default (locally configured) ResourceUpdater.
- *
- * @return ResourceUpdater
- * @throws UpdateException if unable to comply.
+ * Construct an unnamed ArtifactUpdater (the default)
+ * @param id the public name
+ * @throws UpdateException
*/
- public static ArtifactUpdater getResourceUpdater() throws UpdateException {
- return getResourceUpdater(UpdateConstants.DEFAULT, true);
- }
-
- /**
- * Get a named ResourceUpdater (optionally create on demand)
- *
- * @param id The name of the resource updater
- * @param createIfRequired true for create on demand
- * @return ResourceUpdater
- * @throws UpdateException if unable to comply
- */
- public static ArtifactUpdater getResourceUpdater(
- String id,
- final boolean createIfRequired)
- throws UpdateException {
-
- ArtifactUpdater updater = null;
- GenericIdentifier identifier =
- new GenericIdentifier(UpdateConstants.DEFAULT, id);
-
- if (ReferenceManager.hasReference(identifier)) {
- try {
- updater =
- (ArtifactUpdater) ReferenceManager.getReference(identifier);
- }
- catch (NoSuchReferenceException exp) {
- Logger.getLogger().warn(
- "No Depot Update reference in the RefMgr ",
- exp);
- }
- }
-
- // Create on demand...
- if ((null == updater) && createIfRequired) {
- updater = new ArtifactUpdater(id);
- // Register this puppy...
- ReferenceManager.createReference(updater);
- }
-
- return updater;
+ public ArtifactUpdater() {
+ m_identifier = new ArtifactUpdater.Identifier(UpdateConstants.DEFAULT);
+ artifactConfigInit();
}
/**
- * Construct a named ResourceUpdater
+ * Construct a named ArtifactUpdater
* @param id the public name
* @throws UpdateException
*/
public ArtifactUpdater(String id) throws UpdateException {
- m_identifier = new ArtifactUpdater.Identifier(id);
- m_updateEngine = new ArtifactUpdaterEngine();
- resourceConfigInit();
+ this(new ArtifactUpdater.Identifier(id));
}
/**
- * Construct a named ResourceUpdater
+ * Construct a named ArtifactUpdater
* @param id the public name
* @throws UpdateException
*/
public ArtifactUpdater(ArtifactUpdater.Identifier id)
throws UpdateException {
m_identifier = id;
- m_updateEngine = new ArtifactUpdaterEngine();
- resourceConfigInit();
+ artifactConfigInit();
}
- /**
- * Construct an unnamed ResourceUpdater (the default)
- * @param id the public name
- * @throws UpdateException
- */
- public ArtifactUpdater() {
- m_identifier = new ArtifactUpdater.Identifier(UpdateConstants.DEFAULT);
- m_updateEngine = new ArtifactUpdaterEngine();
- resourceConfigInit();
- }
+ private void initClass() {
+ if (null == m_context)
+ m_context = ArtifactUpdaterContext.getDefaultContext();
+ // How to perform Queries...
+ m_queryEngine = new QueryEngine();
+
+ // Protocol operations..
+ getContext().setProtocolManager(
+ new DefaultProtocolOperationsManager(getContext()));
+
+ // How to perform downloads
+ m_downloadManager = new DownloadManager(getContext());
+ }
+
/**
* Configure the updater
*
*/
- private void resourceConfigInit() {
+ private void artifactConfigInit() {
//TODO put the options like "BestOfAll", "ReleaseOnly"
// and the selector / comparator for it
}
/**
- * Access configuration options
* @return
*/
- public Set getResourceConfigOptions() {
- return m_resourceConfigOptions.keySet();
+ public GenericIdentifier getIdentifier() {
+ return m_identifier;
}
- /** Access the context (files/protocols handle) this runs within.
- *
+ /**
+ * Access configuration options
* @return
*/
- public ArtifactUpdaterContext getContext() {
- return m_updateEngine.getContext();
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#getDefaultRepositorySet()
- */
- public RepositorySet getDefaultRepositorySet() {
- return m_updateEngine.getDefaultSortedRepositorySet();
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#setDefaultRepositorySet(org.apache.depot.update.repository.RepositorySet)
- */
- public void setDefaultRepositorySet(RepositorySet set) {
- m_updateEngine.setDefaultSortedRepositorySet(set);
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#setRepositorySetSortContext(org.apache.depot.update.repository.RepositorySetSortContext)
- */
- public void setRepositorySetSortContext(RepositorySetSortContext sortContext) {
-
- m_updateEngine.setDefaultRepositorySetSortContext(sortContext);
- }
-
- public RepositorySetSortContext getRepositorySetSortContext() {
- return RepositorySetSortContext.getDefaultRepositorySetSortContext();
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#updateResources(java.util.List)
- */
- public void updateResources(List resources) throws UpdateException {
- updateResources(resources, null);
+ public Set getArtifactConfigOptions() {
+ return m_artifactConfigOptions.keySet();
}
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#updateResources(java.util.List, org.apache.depot.update.repository.Repository)
- */
- public void updateResources(List resources, Repository targetRepository)
- throws UpdateException {
- for (Iterator iterator = resources.iterator(); iterator.hasNext();) {
- ArtifactInstance resource = (ArtifactInstance) iterator.next();
- updateResource(resource, targetRepository);
- }
- }
-
- /* (non-Javadoc)
- */
- public void updateResource(ArtifactInstance resource) throws UpdateException {
- updateResource(resource, null);
- }
-
- /* (non-Javadoc)
+ /**
+ * Access the context (files/protocols handle) this runs within.
+ *
+ * @return
*/
- public void updateResource(ArtifactInstance resource, Repository targetRepository)
- throws UpdateException {
-
- if (resource != null) {
-
- // get the resource specifier query
- ArtifactQuery resourceQuery =
- ArtifactQueryHelper.getArtifactQuery(resource);
- updateResource(resourceQuery, targetRepository);
- }
- else {
- String message = Messages.getString(MessageConstants.NULL_RESOURCE);
- Logger.getLogger().error(message);
-
- throw new UpdateException(message);
- }
+ public ArtifactUpdaterContext getContext() {
+ return m_context;
}
/* (non-Javadoc)
*/
- public void updateResourceGroup(ArtifactGroup group)
- throws UpdateException {
- updateResourceGroup(group, null);
+ public ArtifactInstance getInstance(Artifact artifact) throws UpdateException {
+
+ // get the artifact specifier query
+ ArtifactQuery artifactQuery =
+ ArtifactQueryHelper.getArtifactQuery(artifact, m_repositorySet);
+
+ List localInstances = get(artifactQuery);
+
+ return (ArtifactInstance)localInstances.get(0);
}
/* (non-Javadoc)
*/
- public void updateResourceGroup(
- ArtifactGroup group,
- Repository targetRepository)
+ public List getArtifacts(ArtifactGroup group)
throws UpdateException {
-
- if (group != null) {
- // get the resource specifier query
- ArtifactQuery resourceQuery =
- ArtifactQueryHelper.getArtifactGroupQuery(group);
- updateResource(resourceQuery, targetRepository);
- }
- else {
+
+ if (group == null) {
String message = Messages.getString(MessageConstants.NULL_GROUP);
Logger.getLogger().error(message);
throw new UpdateException(message);
}
+
+ // get the artifact specifier query
+ ArtifactQuery artifactQuery =
+ ArtifactQueryHelper.getArtifactGroupQuery(group, m_repositorySet);
+
+ return get(artifactQuery);
}
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#updateResource(org.apache.depot.update.resource.Resource, org.apache.depot.update.query.ResourceQuery)
- */
- public void updateResource(ArtifactQuery resourceQuery)
- throws UpdateException {
- updateResource(resourceQuery, null);
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#updateResource(org.apache.depot.update.resource.Resource, org.apache.depot.update.query.ResourceQuery)
+ /**
+ * Perform the query, download the updates (if any) to the local (target)
+ * repository, and return the instances (in that local repository).
+ *
+ * @param artifactQuery
+ * @throws UpdateException
*/
- public void updateResource(
- ArtifactQuery resourceQuery,
- Repository targetRepository)
+ private List get(ArtifactQuery artifactQuery)
throws UpdateException {
-
- //check for target repository
- if (targetRepository == null) {
- targetRepository = this.m_targetRepository;
- }
- if (targetRepository == null) {
- String message = "Resource Update failed with no target repository";
- //String message = Messages.getString(MessageConstants.RESOURCE_REQUEST, request);
- //Logger.getLog().error(message);
- throw new UpdateException(message);
- }
-
// Query the repositories to get the result
- ArtifactResult resourceResult = m_updateEngine.query(resourceQuery);
+ ArtifactResult artifactResult = query(artifactQuery);
// Query the target repository to get the result
- resourceQuery.setRepositorySet(new RepositorySet(targetRepository));
- ArtifactResult targetResult = m_updateEngine.query(resourceQuery);
+ artifactQuery.setRepositorySet(new RepositorySet(m_targetRepository));
+ ArtifactResult targetResult = query(artifactQuery);
// Sort the two result sets
- List resources =
- determineUpdates(resourceQuery, resourceResult, targetResult);
+ List updates =
+ orderResults(artifactQuery, artifactResult, targetResult);
+
+ // Copy the artifact to the local repository
+ if (updates != null)
+ m_downloadManager.downloadTo(updates, m_targetRepository);
+
+ // Query again (once downloaded)
+ return query(artifactQuery);
+ }
+ private ArtifactResult query(ArtifactQuery query) throws UpdateException {
+ RepositorySet repositorySet = query.getRepositorySet();
- // Copy the resource to the repository
- if (resources != null)
- downloadResources(resources, targetRepository);
- }
+ RepositorySetWrapper wrappers =
+ new RepositorySetWrapper(repositorySet, m_context);
+ return m_queryEngine.queryRepositories(wrappers, query);
+ }
+
/**
* Sort results using the ORDER_BY clause of the query.
*
- * @param resourceQuery The query containing the order_by portion
- * @param resourceResult The result set
+ * @param artifactQuery The query containing the order_by portion
+ * @param artifactResult The result set
* @param targetResult The (local|target) result set
* @return
*/
- private List determineUpdates(
- ArtifactQuery resourceQuery,
- ArtifactResult resourceResult,
+ private List orderResults(
+ ArtifactQuery artifactQuery,
+ ArtifactResult artifactResult,
ArtifactResult targetResult) {
- List resources = null;
+ List artifacts = null;
// Assuming we found something in the main search repositories...
- if (!ArtifactResultHelper.noResult(resourceResult)) {
+ if (!ArtifactResultHelper.noResult(artifactResult)) {
// Compare Results Set using the OrderBy Comparator
if (ArtifactResultHelper
.compareTo(
- resourceResult,
+ artifactResult,
targetResult,
- resourceQuery.getOrderBy())
+ artifactQuery.getOrderBy())
> 0) {
- resources =
- ArtifactResultHelper.getResourceList(resourceResult);
+ artifacts =
+ ArtifactResultHelper.getArtifactList(artifactResult);
// Got something
Logger.getLogger().verbose(
Messages.getString(
MessageConstants.UPDATE_FOUND,
- resources));
+ artifacts));
}
else
// Nothing to update
Logger.getLogger().verbose(
Messages.getString(
MessageConstants.NO_UPDATE_FOUND,
- resourceQuery));
+ artifactQuery));
}
else
// Nothing found
Logger.getLogger().verbose(
Messages.getString(
MessageConstants.NO_RESOURCES_FOUND,
- resourceQuery));
-
- return resources;
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#findResource(org.apache.depot.update.resource.Resource)
- */
- public List findResource(ArtifactInstance resource) throws UpdateException {
- return findResource(resource, null);
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#findResources(java.util.List)
- */
- public Map findResources(List resources) throws UpdateException {
- return findResources(resources, null);
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#findResources(java.util.List, org.apache.depot.update.repository.Repository)
- */
- public Map findResources(List resources, Repository target)
- throws UpdateException {
- Map resourceMap = new HashMap();
- List foundResources = null;
-
- for (Iterator iterator = resources.iterator(); iterator.hasNext();) {
- ArtifactInstance resource = (ArtifactInstance) iterator.next();
- foundResources = findResource(resource, target);
- if (foundResources != null) {
- resourceMap.put(resource, foundResources);
- }
- }
- return resourceMap;
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#findResource(org.apache.depot.update.resource.Resource, org.apache.depot.update.repository.Repository)
- */
- public List findResource(ArtifactInstance resource, Repository target)
- throws UpdateException {
- // get the resource specifier query
- ArtifactQuery resourceQuery =
- ArtifactQueryHelper.getArtifactQuery(resource);
- //set the target repository
- if (target != null)
- resourceQuery.setRepositorySet(new RepositorySet(target));
- // Query the repositories to get the result
- ArtifactResult resourceResult = m_updateEngine.query(resourceQuery);
- List resources = ArtifactResultHelper.getResourceList(resourceResult);
-
- return resources;
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#findResource(org.apache.depot.update.resource.Resource, org.apache.depot.update.query.ResourceQuery)
- */
- public List findResource(ArtifactQuery resourceQuery)
- throws UpdateException {
- // Query the repositories to get the result
- ArtifactResult resourceResult = m_updateEngine.query(resourceQuery);
- List foundResources =
- ArtifactResultHelper.getResourceList(resourceResult);
-
- return foundResources;
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#copyResources(java.util.List)
- */
- public void downloadArtifacts(List resources) throws UpdateException {
- downloadResources(resources, null);
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#copyResource(org.apache.depot.update.resource.Resource)
- */
- public void downloadArtifact(ArtifactInstance resource) throws UpdateException {
- downloadArtifact(resource, null);
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#copyResource(org.apache.depot.update.resource.Resource)
- */
- public void downloadArtifact(
- ArtifactInstance resource,
- Repository targetRepository)
- throws UpdateException {
- if (resource != null) {
- List resources = new ArrayList();
- resources.add(resource);
- downloadResources(resources, targetRepository);
- }
- else {
- String message = Messages.getString(MessageConstants.NULL_RESOURCE);
- Logger.getLogger().error(message);
-
- throw new UpdateException(message);
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.depot.update.api.ResourceAPIInterface#copyResources(java.util.List)
- */
- public void downloadResources(List resources, Repository targetRepository)
- throws UpdateException {
- //check for target repository
- if (targetRepository == null) {
- targetRepository = m_targetRepository;
- }
-
- if (targetRepository == null) {
- String message =
- Messages.getString(MessageConstants.NO_TARGET_REPOSITORY);
- Logger.getLogger().error(message);
-
- throw new UpdateException(message);
- }
+ artifactQuery));
- m_updateEngine.copyTo(resources, targetRepository);
- }
-
- public void downloadArtifactGroup(
- ArtifactGroup group,
- Repository targetRepository)
- throws UpdateException {
-
- if (group != null) {
- // get the resource specifier query
- ArtifactQuery resourceQuery =
- ArtifactQueryHelper.getArtifactGroupQuery(group);
- downloadArtifact(resourceQuery, targetRepository);
- }
- else {
- String message = Messages.getString(MessageConstants.NULL_GROUP);
- Logger.getLogger().error(message);
-
- throw new UpdateException(message);
- }
- }
-
- public void downloadArtifact(
- ArtifactQuery resourceQuery,
- Repository targetRepository)
- throws UpdateException {
-
- // Query the repositories to get the result
- List resources = findResource(resourceQuery);
-
- //
- // Copy the resource to the repository
- //
- if (resources != null)
- downloadResources(resources, targetRepository);
+ return artifacts;
}
public void cleanTarget(ArtifactGroup group) throws UpdateException {
@@ -544,75 +297,54 @@
throws UpdateException {
// Query & sort by version
- // get the resource specifier query
- ArtifactQuery resourceQuery =
+ // get the artifact specifier query
+ ArtifactQuery artifactQuery =
ArtifactQueryHelper.getArtifactGroupQuery(group);
// Where to look
- resourceQuery.setRepositorySet(new RepositorySet(repository));
+ artifactQuery.setRepositorySet(new RepositorySet(repository));
// Query the repositories to get the result
- ArtifactResult resourceResult = m_updateEngine.query(resourceQuery);
- List olderResources =
- ArtifactResultHelper.getRemainderResources(resourceResult);
+ ArtifactResult artifactResult = query(artifactQuery);
+ List olderArtifacts =
+ ArtifactResultHelper.getRemainderArtifacts(artifactResult);
- //DebugUtils.dump("Older Resources", olderResources);
+ //DebugUtils.dump("Older Artifacts", olderArtifacts);
// Delete all but 'best'
- m_updateEngine.delete(repository, olderResources);
- }
-
- /**
- * @return
- */
- public Repository getDefaultTargetRepository() {
- return m_targetRepository;
- }
-
- /**
- * @param repository
- */
- public void setDefaultTargetRepository(Repository repository) {
- m_targetRepository = repository;
- }
-
- public static ArtifactUpdater getDefaultResourceUpdater()
- throws UpdateException {
- return getResourceUpdater(
- UpdateConstants.DEFAULT,
- true);
+ delete(repository, olderArtifacts);
}
-
- public static ArtifactUpdater getResourceUpdater(
- ArtifactUpdater.Identifier identifier,
- final boolean createIfRequired)
+
+ private void delete(Repository repository, List artifacts)
throws UpdateException {
- ArtifactUpdater updater = null;
+ RepositoryWrapper repo =
+ new RepositoryWrapper(repository, m_context);
- if (ReferenceManager.hasReference(identifier)) {
- updater = (ArtifactUpdater) ReferenceManager.getReference(identifier);
- }
- else {
- if (!createIfRequired)
- throw new UpdateException(
- "Failed to access ResourceUpdater [" + identifier + "]");
-
- updater = new ArtifactUpdater(identifier);
-
- ReferenceManager.createReference(updater);
+ for (Iterator i = artifacts.iterator(); i.hasNext();) {
+ ArtifactInstance artifact = (ArtifactInstance) i.next();
+ try {
+ repo.deleteArtifact(artifact);
+ }
+ catch (Exception e) {
+ //
+ // (1) log (2) stash in result set error table
+ //
+ throw new RepositoryException(
+ repository,
+ "Failed to delete artifact: " + artifact,
+ e);
+ }
}
-
- return updater;
}
+
/**
- * @return
+ * @param repository
*/
- public GenericIdentifier getIdentifier() {
- return m_identifier;
+ public void setTargetRepository(Repository repository) {
+ m_targetRepository = repository;
}
-
/**
* @return
*/
@@ -621,25 +353,15 @@
}
/**
- * @param map
- */
- public void setResourceConfigOptions(Map map) {
- m_resourceConfigOptions = map;
- }
-
- /**
- * @param repository
+ * @return Returns the repositorySet.
*/
- public void setTargetRepository(Repository repository) {
- m_targetRepository = repository;
+ public RepositorySet getRepositorySet() {
+ return m_repositorySet;
}
-
/**
- *
- * :TODO: temporary, until we figure out what RU and RE both do.
- * @return
+ * @param repositorySet The repositorySet to set.
*/
- ArtifactUpdaterEngine getUpdateEngine() {
- return m_updateEngine;
+ public void setRepositorySet(RepositorySet repositorySet) {
+ m_repositorySet = repositorySet;
}
}
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdaterFactory.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdaterFactory.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdaterFactory.java Fri Jun 25 12:59:12 2004
@@ -16,6 +16,7 @@
package org.apache.depot.update;
+import org.apache.depot.update.impl.ReferenceManager;
import org.apache.depot.update.updater.ConfiguredArtifactUpdater;
import org.apache.depot.update.updater.DefaultArtifactUpdater;
import org.apache.depot.update.util.UpdateConstants;
@@ -29,13 +30,49 @@
*/
public class ArtifactUpdaterFactory {
- public static ArtifactUpdater getDefaultUpdater() throws UpdateException
- {
+ public static ArtifactUpdater getDefaultUpdater() throws UpdateException {
return new DefaultArtifactUpdater(UpdateConstants.DEFAULT);
}
-
- public static ArtifactUpdater getConfiguredUpdater(String filename) throws UpdateException
- {
+
+ public static ArtifactUpdater getConfiguredUpdater(String filename)
+ throws UpdateException {
return new ConfiguredArtifactUpdater(filename, filename);
}
-}
+
+ public static ArtifactUpdater getUpdater(String updater)
+ throws UpdateException {
+ return ArtifactUpdaterFactory.getUpdater(
+ new ArtifactUpdater.Identifier(updater), true);
+ }
+
+ public static ArtifactUpdater getUpdater(
+ ArtifactUpdater.Identifier identifier,
+ boolean createIfRequired)
+ throws UpdateException {
+
+ ArtifactUpdater updater = null;
+
+ if (ReferenceManager.hasReference(identifier)) {
+ updater =
+ (ArtifactUpdater) ReferenceManager.getReference(
+ identifier);
+ }
+ else {
+ if (!createIfRequired)
+ throw new UpdateException(
+ "Failed to access ResourceUpdaterContext ["
+ + identifier
+ + "]");
+
+ if ( identifier.getId().equals(UpdateConstants.DEFAULT))
+ updater = getDefaultUpdater();
+ else
+ updater = new ArtifactUpdater(identifier);
+
+ // Store for re-use
+ ReferenceManager.createReference(updater);
+ }
+
+ return updater;
+ }
+}
\ No newline at end of file
Added: incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdaterOptions.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactUpdaterOptions.java Fri Jun 25 12:59:12 2004
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * @author arb_jack
+ */
+public class ArtifactUpdaterOptions {
+
+// :TODO:
+// Low Bandwidth
+// Latest/Greatest...
+
+}
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/Repository.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/Repository.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/Repository.java Fri Jun 25 12:59:12 2004
@@ -86,11 +86,12 @@
throws Exception;
/**
- * Return a list of ResourceSpecifiers, using selector
+ * Return a list of Artifacts. (filtered using selector)
+ *
* @param selector
* @return
*/
- List listSpecifiers(
+ List listArtifacts(
ArtifactUpdaterContext context,
ArtifactGroup group,
ISelector selector)
@@ -113,7 +114,7 @@
* @param selector
* @return
*/
- List listArtifacts(
+ List listInstances(
ArtifactUpdaterContext context,
ArtifactGroup group,
ISelector selector)
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/cache/ArtifactElement.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/cache/ArtifactElement.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/cache/ArtifactElement.java Fri Jun 25 12:59:12 2004
@@ -34,7 +34,7 @@
import org.apache.depot.update.protocols.DefaultProtocolOperationsManager;
import org.apache.depot.update.query.ArtifactQuery;
import org.apache.depot.update.query.ArtifactResult;
-import org.apache.depot.update.query.DefaultQueryEngine;
+import org.apache.depot.update.query.QueryEngine;
import org.apache.depot.update.repository.DefaultRepository;
import org.apache.depot.update.repository.RepositorySet;
import org.apache.depot.update.util.io.ResolvedFile;
@@ -279,7 +279,7 @@
// experiment
getProject().log("Looking for " + this, Project.MSG_DEBUG);
try {
- DefaultQueryEngine dqe = new DefaultQueryEngine();
+ QueryEngine dqe = new QueryEngine();
ArtifactQuery query = new ArtifactQuery(getArtifactGroup(),
getArtifactSelector(), null, VersionComparator.REVERSE);
//TODO need to be a better way to sort by.
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/cache/CachedArtifactSet.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/cache/CachedArtifactSet.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/cache/CachedArtifactSet.java Fri Jun 25 12:59:12 2004
@@ -24,8 +24,10 @@
import org.apache.depot.common.ant.util.AntLogListener;
import org.apache.depot.common.log.Logger;
+import org.apache.depot.update.Artifact;
import org.apache.depot.update.ArtifactInstance;
import org.apache.depot.update.ArtifactUpdater;
+import org.apache.depot.update.ArtifactUpdaterFactory;
import org.apache.depot.update.Repository;
import org.apache.depot.update.UpdateException;
import org.apache.depot.update.ant.AntUtils;
@@ -255,9 +257,9 @@
* @param resource
* @throws UpdateException
*/
- private void downLoadRemoteResult(ArtifactInstance resource) throws UpdateException {
- ArtifactUpdater ru = new ArtifactUpdater();
- ru.downloadArtifact(resource, getLocalRepository());
+ private void downLoadRemoteResult(Artifact artifact) throws UpdateException {
+ ArtifactUpdater ru = ArtifactUpdaterFactory.getDefaultUpdater();
+ ru.getInstance(artifact);
}
/**
* @return Returns the unmodifiableList of resources.
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/sync/SynchronizeTask.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/sync/SynchronizeTask.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/sync/SynchronizeTask.java Fri Jun 25 12:59:12 2004
@@ -19,6 +19,7 @@
import org.apache.depot.common.ant.util.AntLogListener;
import org.apache.depot.common.log.Logger;
import org.apache.depot.update.ArtifactUpdater;
+import org.apache.depot.update.ArtifactUpdaterFactory;
import org.apache.depot.update.UpdateException;
import org.apache.depot.update.artifact.ArtifactGroup;
import org.apache.depot.update.repository.DefaultRepository;
@@ -33,7 +34,7 @@
public class SynchronizeTask extends Task {
private String m_group = null;
- private String m_ruper = UpdateConstants.DEFAULT;
+ private String m_updater = UpdateConstants.DEFAULT;
private String m_target = UpdateConstants.LIBRARY;
private String m_repositories = UpdateConstants.DEFAULT;
@@ -47,8 +48,8 @@
/**
* @param string
*/
- public void setRuper(String string) {
- m_ruper = string;
+ public void setUpdater(String updater) {
+ m_updater = updater;
}
/**
@@ -61,15 +62,15 @@
/**
* @param string
*/
- public void setGroup(String string) {
- m_group = string;
+ public void setGroup(String groupd) {
+ m_group = groupd;
}
/**
* @param string
*/
- public void setTarget(String string) {
- m_target = string;
+ public void setTarget(String target) {
+ m_target = target;
}
/* (non-Javadoc)
@@ -86,17 +87,17 @@
//
// This uses default or configured stuff..
//
- if (!UpdateConstants.DEFAULT.equals(m_ruper))
- log("Resource Updater: " + m_ruper, Project.MSG_INFO);
+ if (!UpdateConstants.DEFAULT.equals(m_updater))
+ log("Resource Updater: " + m_updater, Project.MSG_INFO);
// Get the Resource Updater asked for
- ArtifactUpdater ruper = new ArtifactUpdater(m_ruper);
+ ArtifactUpdater updater = ArtifactUpdaterFactory.getUpdater(m_updater);
if (!UpdateConstants.LIBRARY.equals(m_target))
log("Target Repository: " + m_target, Project.MSG_INFO);
// Assigned the target (to copy into)
- ruper.setDefaultTargetRepository(
+ updater.setTargetRepository(
DefaultRepository.getRepository(m_target, true));
if (null != m_group) {
@@ -105,10 +106,10 @@
ArtifactGroup group = new ArtifactGroup(m_group);
// Update...
- ruper.updateResourceGroup(group);
+ updater.getArtifacts(group);
// Cleanup (to remove duplicates)
- ruper.cleanTarget(group);
+ updater.cleanTarget(group);
}
else
throw new BuildException("Missing mandatory attribute 'group' required.");
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/tool/RepositoryToolTask.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/tool/RepositoryToolTask.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/tool/RepositoryToolTask.java Fri Jun 25 12:59:12 2004
@@ -107,20 +107,20 @@
try {
- List specifiers = repo.listSpecifiers(group,
+ List artifacts = repo.listArtifacts(group,
AllSelector.getInstance());
- log(" - Group: " + group + " (Specifiers : "
- + specifiers.size() + ")");
+ log(" - Group: " + group + " (Artifacts : "
+ + artifacts.size() + ")");
- for (Iterator si = specifiers.iterator(); si.hasNext();) {
+ for (Iterator si = artifacts.iterator(); si.hasNext();) {
Artifact specifier = (Artifact) si.next();
log(" - " + specifier, Project.MSG_VERBOSE);
}
} catch (UpdateException re) {
Logger.getLogger().error(
- " - Failed to list specifiers in group: "
+ " - Failed to list artifacts in group: "
+ group, re);
}
}
@@ -133,10 +133,10 @@
try {
// List groups ...
- List specifiers = repo.listSpecifiers(group,
+ List artifacts = repo.listArtifacts(group,
AllSelector.getInstance());
- for (Iterator gi = specifiers.iterator(); gi.hasNext();) {
+ for (Iterator gi = artifacts.iterator(); gi.hasNext();) {
Artifact specifier = (Artifact) gi.next();
log(" - " + specifier, Project.MSG_VERBOSE);
Added: incubator/depot/trunk/update/src/java/org/apache/depot/update/download/DownloadManager.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/download/DownloadManager.java Fri Jun 25 12:59:12 2004
@@ -0,0 +1,77 @@
+/*
+ * 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.download;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.depot.update.ArtifactInstance;
+import org.apache.depot.update.Repository;
+import org.apache.depot.update.UpdateException;
+import org.apache.depot.update.impl.ArtifactUpdaterContext;
+import org.apache.depot.update.impl.RepositoryWrapper;
+import org.apache.depot.update.repository.RepositoryException;
+
+/**
+ * @author arb_jack
+ */
+public class DownloadManager {
+
+ private final ArtifactUpdaterContext m_context;
+
+ /**
+ *
+ */
+ public DownloadManager(ArtifactUpdaterContext context) {
+ m_context = context;
+ initClass();
+ }
+
+ private void initClass() {
+ }
+
+
+ public void downloadTo(List instances, Repository targetRepository)
+ throws UpdateException {
+
+ RepositoryWrapper target =
+ new RepositoryWrapper(targetRepository, m_context);
+
+ // for (Iterator i = result.iterator(); i.hasNext();) {
+ // List group = (List) i.next();
+ //
+ // for (Iterator j = group.iterator(); j.hasNext();) {
+ // Resource resource = (Resource) j.next();
+ //
+
+ for (Iterator i = instances.iterator(); i.hasNext();) {
+ ArtifactInstance resource = (ArtifactInstance) i.next();
+ try {
+ target.publishArtifact(resource);
+ }
+ catch (Exception e) {
+ //
+ // (1) log (2) stash in result set error table
+ //
+ throw new RepositoryException(
+ targetRepository,
+ "Failed to publish resource: " + resource,
+ e);
+ }
+ }
+ }
+}
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/ArtifactUpdaterContext.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/ArtifactUpdaterContext.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/ArtifactUpdaterContext.java Fri Jun 25 12:59:12 2004
@@ -19,6 +19,7 @@
import java.io.File;
import org.apache.depot.common.util.SystemUtils;
+import org.apache.depot.update.ArtifactUpdaterOptions;
import org.apache.depot.update.UpdateException;
import org.apache.depot.update.config.UpdateConfig;
import org.apache.depot.update.protocols.DefaultProtocolOperationsManager;
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/RepositoryWrapper.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/RepositoryWrapper.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/RepositoryWrapper.java Fri Jun 25 12:59:12 2004
@@ -73,7 +73,7 @@
}
/**
- * Return a list of ResourceGroups, using selector
+ * Return a list of ArtifactGroups, using selector
* @param selector
* @return
*/
@@ -104,22 +104,22 @@
}
/**
- * Return a list of ResourceSpeficiers, using selector
+ * Return a list of ArtifactSpeficiers, using selector
*
* Hmm, is this not just another query?
*
* @param selector
* @return
*/
- public List listSpecifiers(ArtifactGroup group, ISelector selector)
+ public List listArtifacts(ArtifactGroup group, ISelector selector)
throws UpdateException {
Logger.getLogger().debug(
Messages.getString(
- MessageConstants.LIST_SPECIFIERS,
+ MessageConstants.LIST_ARTIFACTS,
new Object[] { m_repository, group, selector }));
- testCapability(RepositoryCapability.LISTABLE_SPECIFIERS);
+ testCapability(RepositoryCapability.LISTABLE_ARTIFACTS);
if (!m_initialized)
initialize(m_context);
@@ -127,21 +127,21 @@
List categories = null;
try {
categories =
- m_repository.listSpecifiers(m_context, group, selector);
+ m_repository.listArtifacts(m_context, group, selector);
}
catch (Exception e) {
throw new RepositoryException(
m_repository,
- MessageConstants.LIST_SPECIFIERS_FAILED,
+ MessageConstants.LIST_ARTIFACTS_FAILED,
e);
}
return categories;
}
/**
- * Return a list of ResourceSpeficiers, using selector
+ * Return a Manifest of Artifacts, using selector
*
- * Hmm, is this not just another query?
+ * :TODO: Hmm, is this not just another query?
*
* @param selector
* @return
@@ -168,7 +168,7 @@
catch (Exception e) {
throw new RepositoryException(
m_repository,
- MessageConstants.LIST_SPECIFIERS_FAILED,
+ MessageConstants.LIST_ARTIFACTS_FAILED,
e);
}
@@ -181,7 +181,7 @@
* @param selector
* @return
*/
- public List listResources(ArtifactGroup group, ISelector selector)
+ public List listInstances(ArtifactGroup group, ISelector selector)
throws UpdateException {
Logger.getLogger().debug(
@@ -194,11 +194,9 @@
List resources = null;
try {
- resources = m_repository.listArtifacts(m_context, group, selector);
+ resources = m_repository.listInstances(m_context, group, selector);
- //
// Notify what resources were listed
- //
for (Iterator i = resources.iterator(); i.hasNext();) {
Monitor.getMonitor().notify(
new ArtifactEvent(
@@ -223,7 +221,7 @@
* @param selector
* @return
*/
- public void deleteResource(ArtifactInstance resource) throws UpdateException {
+ public void deleteArtifact(ArtifactInstance resource) throws UpdateException {
Logger.getLogger().debug(
Messages.getString(
@@ -254,12 +252,12 @@
* @param selector
* @return
*/
- public ArtifactInstance publishResource(ArtifactInstance resource) throws UpdateException {
+ public ArtifactInstance publishArtifact(ArtifactInstance instance) throws UpdateException {
Logger.getLogger().debug(
Messages.getString(
MessageConstants.PUBLISH_RESOURCE,
- new Object[] { m_repository, resource }));
+ new Object[] { m_repository, instance }));
testCapability(RepositoryCapability.PUBLISHABLE);
@@ -269,7 +267,7 @@
ArtifactInstance publishedArtifact = null;
try {
publishedArtifact =
- m_repository.publishArtifact(m_context, resource);
+ m_repository.publishArtifact(m_context, instance);
}
catch (Exception e) {
throw new RepositoryException(m_repository, "Publish Failed", e);
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/monitor/StatisticsMonitor.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/monitor/StatisticsMonitor.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/monitor/StatisticsMonitor.java Fri Jun 25 12:59:12 2004
@@ -84,8 +84,8 @@
ArtifactEvent artifactEvent = (ArtifactEvent) event;
//
- // switch (resourceEvent.getType()) {
- // case ResourceEvent.LISTED :
+ // switch (artifactEvent.getType()) {
+ // case ArtifactEvent.LISTED :
// {
ArtifactInstance artifact = artifactEvent.getArtifactInstance();
@@ -197,7 +197,7 @@
if (verbose) {
DebugUtils.printSeparator(out, depth);
- DebugUtils.dump(out, depth, "Resources", verbose, m_artifacts);
+ DebugUtils.dump(out, depth, "Artifacts", verbose, m_artifacts);
DebugUtils.printSeparator(out, depth);
DebugUtils.dump(out, depth, "Parsed", verbose, m_parsedObjects);
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/query/ArtifactQuery.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/query/ArtifactQuery.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/query/ArtifactQuery.java Fri Jun 25 12:59:12 2004
@@ -25,7 +25,6 @@
import org.apache.depot.common.util.debug.Dumpable;
import org.apache.depot.update.artifact.ArtifactGroup;
import org.apache.depot.update.repository.RepositorySet;
-import org.apache.depot.update.repository.RepositorySetSortContext;
import org.apache.depot.update.util.select.ISelector;
/**
@@ -61,11 +60,6 @@
// :TODO: Hmm, ought repositories be on query at all?
private RepositorySet m_repositorySet = null;
- // :TODO: I'm not sure this ought be on here, I don't think
- // how to pick the repositories ought be on the query over
- // repositories. I don't know, same w/ above I guess...
- private RepositorySetSortContext m_repositorySetSortContext = null;
-
private ISelector m_where = null;
private Comparator m_orderBy = null;
private Comparator m_groupBy = null;
@@ -244,21 +238,7 @@
buffer.append(" ORDER_BY ");
buffer.append(m_orderBy);
}
- //:TODO:Anou's stuff?
return buffer.toString();
}
- /**
- * @return
- */
- public RepositorySetSortContext getRepositorySetSortContext() {
- return m_repositorySetSortContext;
- }
-
- /**
- * @param context
- */
- public void setRepositorySetSortContext(RepositorySetSortContext context) {
- m_repositorySetSortContext = context;
- }
}
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/query/ArtifactResultHelper.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/query/ArtifactResultHelper.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/query/ArtifactResultHelper.java Fri Jun 25 12:59:12 2004
@@ -26,7 +26,7 @@
/**
* @author arb_jack
*
- * A ResourceResultHelper.
+ * A ArtifactResultHelper.
*
*/
public class ArtifactResultHelper {
@@ -35,25 +35,25 @@
return (
(null == result)
|| result.isEmpty()
- || (null == getResourceList(result))
- || getResourceList(result).isEmpty());
+ || (null == getArtifactList(result))
+ || getArtifactList(result).isEmpty());
}
public static int groupCount(ArtifactResult result) {
return (null == result) ? 0 : result.size();
}
- public static int resourceCount(ArtifactResult result) {
- int resources = 0;
+ public static int artifactCount(ArtifactResult result) {
+ int artifacts = 0;
for (Iterator i = result.iterator(); i.hasNext();) {
- resources += ((List) i.next()).size();
+ artifacts += ((List) i.next()).size();
}
- return resources;
+ return artifacts;
}
- public static List getResourceList(ArtifactResult result) {
+ public static List getArtifactList(ArtifactResult result) {
List list = null;
int size = result.size();
@@ -73,13 +73,13 @@
* @param result
* @return
*/
- public static List getAllResources(ArtifactResult result) {
+ public static List getAllArtifacts(ArtifactResult result) {
List list = new ArrayList();
for (Iterator j = result.iterator(); j.hasNext();) {
- List resources = (List) j.next();
+ List artifacts = (List) j.next();
- for (Iterator i = resources.iterator(); i.hasNext();) {
+ for (Iterator i = artifacts.iterator(); i.hasNext();) {
list.add(i.next());
}
}
@@ -94,16 +94,16 @@
* @param result
* @return
*/
- public static List getRemainderResources(ArtifactResult result) {
+ public static List getRemainderArtifacts(ArtifactResult result) {
List list = new ArrayList();
// Return contents of all, but last..
- List lists = getRemainderResourceLists(result);
+ List lists = getRemainderArtifactLists(result);
for (Iterator j = lists.iterator(); j.hasNext();) {
- List resources = (List) j.next();
+ List artifacts = (List) j.next();
- for (Iterator i = resources.iterator(); i.hasNext();) {
+ for (Iterator i = artifacts.iterator(); i.hasNext();) {
list.add(i.next());
}
}
@@ -117,7 +117,7 @@
* @param result
* @return
*/
- public static List getRemainderResourceLists(ArtifactResult result) {
+ public static List getRemainderArtifactLists(ArtifactResult result) {
List list = new ArrayList();
int size = result.size();
@@ -140,8 +140,8 @@
Comparator comp) {
int comparison = 0;
- List list1 = ArtifactResultHelper.getResourceList(result1);
- List list2 = ArtifactResultHelper.getResourceList(result2);
+ List list1 = ArtifactResultHelper.getArtifactList(result1);
+ List list2 = ArtifactResultHelper.getArtifactList(result2);
if (null != list1) {
if (null != list2) {
@@ -150,12 +150,12 @@
//:TODO: Hmm ... sort w/ comp?
- ArtifactInstance resource1 =
+ ArtifactInstance artifact1 =
(ArtifactInstance) list1.get(list1.size() - 1);
- ArtifactInstance resource2 =
+ ArtifactInstance artifact2 =
(ArtifactInstance) list2.get(list2.size() - 1);
- comparison = comp.compare(resource1, resource2);
+ comparison = comp.compare(artifact1, artifact2);
}
else
comparison = 1;
Added: incubator/depot/trunk/update/src/java/org/apache/depot/update/query/QueryEngine.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/query/QueryEngine.java Fri Jun 25 12:59:12 2004
@@ -0,0 +1,264 @@
+/*
+ * 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.query;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.depot.common.log.Logger;
+import org.apache.depot.common.util.debug.DebugUtils;
+import org.apache.depot.update.ArtifactInstance;
+import org.apache.depot.update.UpdateException;
+import org.apache.depot.update.artifact.ArtifactGroup;
+import org.apache.depot.update.artifact.compare.StandardArtifactComparisons;
+import org.apache.depot.update.impl.RepositorySetWrapper;
+import org.apache.depot.update.impl.RepositoryWrapper;
+import org.apache.depot.update.monitor.ArtifactEvent;
+import org.apache.depot.update.monitor.Monitor;
+import org.apache.depot.update.util.select.AllSelector;
+import org.apache.depot.update.util.select.ISelector;
+import org.apache.depot.update.util.text.MessageConstants;
+import org.apache.depot.update.util.text.Messages;
+
+/**
+ * @author arb_jack
+ */
+public class QueryEngine {
+
+ /**
+ * Run a query over a set of repositories.
+ *
+ * @param wrappers
+ * @param query
+ * @return
+ * @throws UpdateException
+ */
+ public ArtifactResult queryRepositories(
+ RepositorySetWrapper wrappers,
+ ArtifactQuery query)
+ throws UpdateException {
+
+ // Extract query components
+ List resourceGroups = query.getGroups();
+
+ //
+ // Trawl the repositories to gather resources
+ //
+ return queryArtifacts(
+ gatherArtifacts(wrappers, resourceGroups, query),
+ query);
+ }
+
+ /**
+ * Run a query over a set of resources:
+ *
+ * @param resources
+ * @param query
+ * @return
+ */
+ public ArtifactResult queryArtifacts(List resources, ArtifactQuery query) {
+ // if (Logger.getLog().isDebug()) {
+ // DebugUtils.printSeparator();
+ // DebugUtils.dump(query);
+ // }
+
+ // A result object, and the results (unpackaged) list
+ ArtifactResult result = new ArtifactResult();
+
+ // Package the results..
+ if (resources.isEmpty())
+ Logger.getLogger().warn(
+ Messages.getString(MessageConstants.NO_RESOURCES_FOUND));
+ else {
+ Logger.getLogger().info(
+ Messages.getString(MessageConstants.RESOURCES_FOUND));
+
+ Comparator groupBy = query.getGroupBy();
+ Comparator orderBy = query.getOrderBy();
+
+ // if (Logger.getLog().isDebug()) {
+ // DebugUtils.printSeparator();
+ // DebugUtils.dump("All Results", results);
+ // }
+ groupBy(result, resources, groupBy);
+
+ // if (Logger.getLog().isDebug()) {
+ // DebugUtils.printSeparator();
+ // DebugUtils.dump("Grouped Results", result);
+ // }
+
+ // Order the various groups
+ if (null == orderBy)
+ orderBy =
+ StandardArtifactComparisons
+ .getNameTypeVersionComparatorSequence();
+ orderBy(result, orderBy);
+
+ if (Logger.getLogger().isDebug()) {
+ DebugUtils.printSeparator();
+ DebugUtils.dump("Final (Grouped/Ordered) Results", result);
+
+ for (Iterator i =
+ ArtifactResultHelper.getArtifactList(result).iterator();
+ i.hasNext();
+ ) {
+ Monitor.getMonitor().notify(
+ new ArtifactEvent(
+ ArtifactEvent.RESULT,
+ (ArtifactInstance) i.next()));
+ }
+ }
+
+ }
+
+ return result;
+ }
+
+ private List gatherArtifacts(
+ RepositorySetWrapper wrappers,
+ List resourceGroups,
+ ArtifactQuery query) {
+ List results = new ArrayList();
+
+ ISelector whereClause = query.getWhere();
+
+ if (null == whereClause)
+ whereClause = AllSelector.getInstance();
+
+ //:TODO: Total Hack, just to allow something...
+ // Rework w/ correct configurable components
+
+ for (Iterator i = wrappers.getRepositoryWrappers().iterator();
+ i.hasNext();
+ ) {
+ RepositoryWrapper repo = (RepositoryWrapper) i.next();
+ try {
+ Logger.getLogger().debug(
+ Messages.getString(
+ MessageConstants.SEARCH_REPOSITORY,
+ repo));
+
+ for (Iterator ii = resourceGroups.iterator(); ii.hasNext();) {
+ ArtifactGroup resourceGroup = (ArtifactGroup) ii.next();
+
+ Logger.getLogger().debug(
+ Messages.getString(
+ MessageConstants.RESOURCE_GROUP,
+ resourceGroup));
+
+ // Look...
+ List resources =
+ repo.listInstances(resourceGroup, whereClause);
+
+ if (resources.isEmpty()) {
+ Logger.getLogger().info(
+ Messages.getString(
+ MessageConstants.NO_RESOURCES_FOUND_IN,
+ query,
+ repo,
+ resourceGroup));
+ }
+ else {
+ Logger.getLogger().info(
+ Messages.getString(
+ MessageConstants.RESOURCES_FOUND_IN,
+ query,
+ repo,
+ resourceGroup));
+
+ //
+ // Do the query
+ //
+ results.addAll(resources);
+ }
+ }
+ }
+ catch (Exception e) {
+ String message =
+ Messages.getString(MessageConstants.LIST_FAILED);
+
+ Logger.getLogger().warn(message, e);
+
+ // :TODO: results.getNotes().warning(message, e);
+ }
+ }
+
+ return results;
+ }
+
+ //
+ //
+ // Group into lists by comparator equality adn order the same,
+ // each group lists be same comparator.
+ //
+ //
+ private void groupBy(
+ ArtifactResult result,
+ List allResults,
+ Comparator groupBy) {
+
+ if (null != groupBy) {
+
+ // Sort by groupBy, to split into groups
+ //:TODO: If we sorted by a CominbationComparator
+ // of groupBy followed by orderBy we'd save a sort,
+ // no?
+ Collections.sort(allResults, groupBy);
+
+ ArtifactInstance currentResource = null;
+ List currentList = null;
+ for (Iterator i = allResults.iterator(); i.hasNext();) {
+ ArtifactInstance resource = (ArtifactInstance) i.next();
+
+ // Do we have a new group?
+ if ((null == currentList)
+ || (null == currentResource)
+ || (groupBy.compare(resource, currentResource) != 0)) {
+ currentList = new ArrayList();
+
+ // Add group to results
+ result.add(currentList);
+ }
+
+ // Stash this resource
+ currentList.add(resource);
+
+ // For comparing group changes..
+ currentResource = resource;
+ }
+ }
+ else {
+ // A single list (one group)...
+ result.add(allResults);
+ }
+ }
+
+ //
+ // Sort each sub-list by the order comparator
+ //
+ private void orderBy(ArtifactResult result, Comparator orderBy) {
+ if (null != orderBy)
+ for (Iterator i = result.iterator(); i.hasNext();) {
+ List currentList = (List) i.next();
+ Collections.sort(currentList, orderBy);
+ }
+ }
+
+}
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/AbstractHierarchicalRepository.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/AbstractHierarchicalRepository.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/AbstractHierarchicalRepository.java Fri Jun 25 12:59:12 2004
@@ -106,7 +106,7 @@
addCapability(RepositoryCapability.LISTABLE_GROUPS);
addCapability(RepositoryCapability.GROUP_MANIFEST);
- addCapability(RepositoryCapability.LISTABLE_SPECIFIERS);
+ addCapability(RepositoryCapability.LISTABLE_ARTIFACTS);
// Assuming credentials/protocol allow...
addCapability(RepositoryCapability.DELETABLE);
@@ -115,7 +115,7 @@
setRepositoryAttribute(RepositoryAttribute.ACTIVE, Flag.TRUE);
}
- public List listSpecifiers(
+ public List listArtifacts(
ArtifactUpdaterContext context,
ArtifactGroup group,
ISelector selector)
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/AbstractRepository.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/AbstractRepository.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/AbstractRepository.java Fri Jun 25 12:59:12 2004
@@ -153,7 +153,7 @@
return m_groupAnalyzer;
}
- public List listSpecifiers(
+ public List listArtifacts(
ArtifactUpdaterContext context,
ArtifactGroup group,
ISelector selector)
@@ -161,7 +161,7 @@
throw new RepositoryException(
this,
"Unsupported Capability: "
- + RepositoryCapability.LISTABLE_SPECIFIERS);
+ + RepositoryCapability.LISTABLE_ARTIFACTS);
}
public void deleteArtifact(
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/ApacheRepository.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/ApacheRepository.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/ApacheRepository.java Fri Jun 25 12:59:12 2004
@@ -32,7 +32,6 @@
*/
public ApacheRepository(String id) {
super(id);
- // TODO Auto-generated constructor stub
}
/**
* @param id
@@ -71,19 +70,19 @@
*/
public RepositoryManifest getManifest(ArtifactUpdaterContext context,
ArtifactGroup group, ISelector selector) throws Exception {
- // TODO Auto-generated method stub
+ // :TODO: Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
- * @see org.apache.depot.update.repository.IRepository#listResources(org.apache.depot.update.impl.ResourceUpdaterContext,
+ * @see org.apache.depot.update.repository.IRepository#listArtifacts(org.apache.depot.update.impl.ResourceUpdaterContext,
* org.apache.depot.update.resource.ResourceGroup,
* org.apache.depot.update.util.select.ISelector)
*/
- public List listArtifacts(ArtifactUpdaterContext context,
+ public List listInstances(ArtifactUpdaterContext context,
ArtifactGroup group, ISelector selector) throws Exception {
- // TODO Auto-generated method stub
+ // :TODO: Auto-generated method stub
return null;
}
}
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 Fri Jun 25 12:59:12 2004
@@ -100,7 +100,7 @@
return results;
}
- public List listArtifacts(final ArtifactUpdaterContext context,
+ public List listInstances(final ArtifactUpdaterContext context,
final ArtifactGroup group, final ISelector selector)
throws Exception {
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/MockRepository.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/MockRepository.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/MockRepository.java Fri Jun 25 12:59:12 2004
@@ -52,7 +52,7 @@
return groups;
}
- public List listArtifacts(final ArtifactUpdaterContext context,
+ public List listInstances(final ArtifactUpdaterContext context,
final ArtifactGroup group, final ISelector selector)
throws Exception {
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositoryAttribute.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositoryAttribute.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositoryAttribute.java Fri Jun 25 12:59:12 2004
@@ -25,7 +25,8 @@
*/
public class RepositoryAttribute extends Flag implements IXMLAttribute{
- public static final String REPOSITORY_ATTRIBUTE_CLASSNAME = RepositoryAttribute.class.getName();
+ public static final String REPOSITORY_ATTRIBUTE_CLASSNAME =
+ RepositoryAttribute.class.getName();
/**
* A is 'active' (not worth looking at it if not active).
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositoryCapability.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositoryCapability.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/repository/RepositoryCapability.java Fri Jun 25 12:59:12 2004
@@ -29,9 +29,9 @@
public static final RepositoryCapability LISTABLE_GROUPS = new RepositoryCapability("LISTABLE_GROUPS");
/**
- * A repository group's specifiers can be listed.
+ * A repository group's artifacts can be listed.
*/
- public static final RepositoryCapability LISTABLE_SPECIFIERS = new RepositoryCapability("LISTABLE_SPECIFIERS");
+ public static final RepositoryCapability LISTABLE_ARTIFACTS = new RepositoryCapability("LISTABLE_ARTIFACTS");
/**
* A repository group's manifest can be acquired.
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/sample/FileAssistant.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/sample/FileAssistant.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/sample/FileAssistant.java Fri Jun 25 12:59:12 2004
@@ -71,7 +71,7 @@
}
/**
- * TODO Add JavaDoc
+ * :TODO: Add JavaDoc
*
* @param files TODO
*
@@ -81,13 +81,13 @@
*/
public List getArtifactsForFiles(List files)
throws UpdateException {
- List specifiers = new ArrayList();
+ List artifacts = new ArrayList();
for (Iterator i = files.iterator(); i.hasNext();) {
- specifiers.add(getArtifactForFile(((File) i.next())));
+ artifacts.add(getArtifactForFile(((File) i.next())));
}
- return specifiers;
+ return artifacts;
}
/**
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/ArtifactTool.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/ArtifactTool.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/ArtifactTool.java Fri Jun 25 12:59:12 2004
@@ -18,21 +18,18 @@
import org.apache.depot.common.util.cli.CommandLine;
import org.apache.depot.common.util.cli.Option;
-import org.apache.depot.common.util.debug.DebugUtils;
import org.apache.depot.update.Artifact;
-import org.apache.depot.update.impl.ArtifactUpdaterEngine;
-import org.apache.depot.update.messaging.ResourceRequest;
-import org.apache.depot.update.query.ArtifactQueryHelper;
-import org.apache.depot.update.query.ArtifactResult;
+import org.apache.depot.update.ArtifactUpdater;
+import org.apache.depot.update.ArtifactUpdaterFactory;
/**
*/
public class ArtifactTool extends Tool {
- private static Option l_resourceOption = null;
+ private static Option l_artifactOption = null;
static {
- l_resourceOption =
+ l_artifactOption =
new Option("a", "artifact", true, "The artifact to work on");
}
@@ -41,28 +38,16 @@
}
protected void init() {
- getOptions().addOption(l_resourceOption);
+ getOptions().addOption(l_artifactOption);
}
public void execute(CommandLine cmdline) throws Exception {
- String resource = cmdline.getMandatoryOptionValue(l_resourceOption);
+ String artifact = cmdline.getMandatoryOptionValue(l_artifactOption);
- ArtifactUpdaterEngine ru = new ArtifactUpdaterEngine();
+ ArtifactUpdater au = ArtifactUpdaterFactory.getDefaultUpdater();
- Artifact artifact = new Artifact(resource);
-
- //
- // Generare a request from a query
- //
- ResourceRequest request =
- new ResourceRequest(
- ArtifactQueryHelper.getArtifactQuery(artifact));
-
- // :TODO: Hmm, ought request reply w/ Response (Query->Result)
- ArtifactResult result = ru.performRequest(request);
-
- DebugUtils.dump(result);
+ au.getInstance(new Artifact(artifact));
}
public static void main(String[] args) {
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/DownloaderTool.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/DownloaderTool.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/DownloaderTool.java Fri Jun 25 12:59:12 2004
@@ -69,16 +69,17 @@
{
RepositorySet repoSet = new RepositorySet("gump");
repoSet.addRepository(new DefaultRepository("gump",repoUrl));
- updater.setDefaultRepositorySet(repoSet);
+ updater.setRepositorySet(repoSet);
}
else
{
- updater.setDefaultRepositorySet(RepositorySet.getRepositorySet("gump",
- false));
+ updater.setRepositorySet(
+ RepositorySet.getRepositorySet("gump",
+ false));
}
// Assigned the target (to copy into)
- updater.setDefaultTargetRepository(getTargetRepository(targetDir));
+ updater.setTargetRepository(getTargetRepository(targetDir));
if (null != configName)
UpdateConfig.configure(configName);
@@ -87,7 +88,7 @@
ArtifactGroup group = new ArtifactGroup(groupName);
// Update...
- updater.updateResourceGroup(group);
+ updater.getArtifacts(group);
// Cleanup (to remove duplicates)
updater.cleanTarget(group);
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/RepositoryTool.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/RepositoryTool.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/RepositoryTool.java Fri Jun 25 12:59:12 2004
@@ -26,6 +26,7 @@
import org.apache.depot.common.util.debug.DebugUtils;
import org.apache.depot.update.ArtifactInstance;
import org.apache.depot.update.ArtifactUpdater;
+import org.apache.depot.update.ArtifactUpdaterFactory;
import org.apache.depot.update.Repository;
import org.apache.depot.update.artifact.ArtifactGroup;
import org.apache.depot.update.impl.ArtifactUpdaterContext;
@@ -47,9 +48,9 @@
static {
l_repoOption = new Option("r", "repo", true, "Repository");
l_groupOption =
- new Option("g", "group", true, "A specified resources group");
+ new Option("g", "group", true, "A specified artifact group");
l_listOption =
- new Option("l", "list", false, "List resources or groups");
+ new Option("l", "list", false, "List artifacts or groups");
l_manifestOption = new Option("m", "manifest", false, "Show manifest");
l_cleanOption =
new Option(
@@ -80,7 +81,7 @@
Repository repository = DefaultRepository.getRepository(repoId);
- ArtifactUpdater ruper = ArtifactUpdater.getDefaultResourceUpdater();
+ ArtifactUpdater updater = ArtifactUpdaterFactory.getDefaultUpdater();
if (null != repository) {
RepositoryWrapper repo =
@@ -98,7 +99,7 @@
cmdline.getMandatoryOptionValue(l_groupOption));
if (cmdline.isSet(l_cleanOption)) {
- ruper.cleanRepository(repository, group);
+ updater.cleanRepository(repository, group);
}
else if (cmdline.isSet(l_manifestOption)) {
DebugUtils.printSeparator();
@@ -108,7 +109,7 @@
else {
DebugUtils.printSeparator();
DebugUtils.dump(
- repo.listResources(group, AllSelector.getInstance()));
+ repo.listInstances(group, AllSelector.getInstance()));
}
}
else if (cmdline.isSet(l_listOption)) {
@@ -124,7 +125,7 @@
out.println("Group: " + group);
List resources =
- repo.listResources(group, AllSelector.getInstance());
+ repo.listInstances(group, AllSelector.getInstance());
for (Iterator ii = resources.iterator(); ii.hasNext();) {
ArtifactInstance resource = (ArtifactInstance) ii.next();
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/text/MessageConstants.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/text/MessageConstants.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/text/MessageConstants.java Fri Jun 25 12:59:12 2004
@@ -52,7 +52,7 @@
// Repository Operations..
public static final String LIST_GROUPS = "LIST_GROUPS";
public static final String LIST_RESOURCES = "LIST_RESOURCES";
- public static final String LIST_SPECIFIERS = "LIST_SPECIFIERS";
+ public static final String LIST_ARTIFACTS = "LIST_ARTIFACTS";
public static final String GET_GROUP_MANIFEST = "GET_GROUP_MANIFEST";
public static final String DELETE_RESOURCE = "DELETE_RESOURCE";
public static final String PUBLISH_RESOURCE = "PUBLISH_RESOURCE";
@@ -60,8 +60,8 @@
public static final String INITIALIZE_FAILED = "INITIALIZE_FAILED";
public static final String LIST_GROUPS_FAILED = "LIST_GROUPS_FAILED";
public static final String LIST_RESOURCES_FAILED = "LIST_RESOURCES_FAILED";
- public static final String LIST_SPECIFIERS_FAILED =
- "LIST_SPECIFIERS_FAILED";
+ public static final String LIST_ARTIFACTS_FAILED =
+ "LIST_ARTIFACTS_FAILED";
public static final String DELETE_RESOURCE_FAILED =
"DELETE_RESOURCE_FAILED";
public static final String PUBLISH_RESOURCE_FAILED =
Modified: incubator/depot/trunk/update/src/sample/CachedResourceSet/build.xml
==============================================================================
--- incubator/depot/trunk/update/src/sample/CachedResourceSet/build.xml (original)
+++ incubator/depot/trunk/update/src/sample/CachedResourceSet/build.xml Fri Jun 25 12:59:12 2004
@@ -28,7 +28,7 @@
<repository id="maven" url="http://www.ibiblio.org/maven/" remote="true" />
<cachedset id="jars">
- <resource name="regexp" ext="jar" version="1" repository="maven" />
+ <artifact name="regexp" ext="jar" version="1" repository="maven" />
</cachedset>
<path id="ruper.sample.libs">
<fileset refid="jars.fileset" />
Modified: incubator/depot/trunk/update/src/sample/export/build.xml
==============================================================================
--- incubator/depot/trunk/update/src/sample/export/build.xml (original)
+++ incubator/depot/trunk/update/src/sample/export/build.xml Fri Jun 25 12:59:12 2004
@@ -30,7 +30,7 @@
<repository id="maven" url="http://www.ibiblio.org/maven/" remote="true" />
<cachedset id="export-sample.dependent.jars">
- <resource name="regexp" ext="jar" version="1" repository="maven" />
+ <artifact name="regexp" ext="jar" version="1" repository="maven" />
</cachedset>
Added: incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/CachedArtifactSetTaskTest.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/CachedArtifactSetTaskTest.java Fri Jun 25 12:59:12 2004
@@ -0,0 +1,121 @@
+/*
+ * ========================================================================
+ * 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.ant;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.depot.common.log.Logger;
+import org.apache.tools.ant.BuildFileTest;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.xml.sax.SAXException;
+/**
+ * @author <a href="http://incubator.apache.org/depot" >The Apache Incubator
+ * Depot Project </a>
+ * @version $LastChangedRevision: 9844 $
+ */
+public class CachedArtifactSetTaskTest extends BuildFileTest {
+ private final String SANDBOX = "build/test/sandbox";
+ /**
+ * Constructor for RuperDependTaskTest.
+ *
+ * @param arg0
+ */
+ public CachedArtifactSetTaskTest(String arg0) {
+ super(arg0);
+ }
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(CachedArtifactSetTaskTest.class);
+ }
+ public void setUp() {
+ Logger.testInit();
+ configureProject("src/test/org/apache/depot/update/ant/build.xml");
+ }
+ public void test1() {
+ try {
+ executeTarget("test1");
+ File file = new File(SANDBOX
+ + "/helloworld/jars/helloworld-1.1.jar");
+ assertTrue("Expected " + file + " to exists", file.exists());
+ } finally {
+ System.out.println(getOutput());
+ }
+ }
+ public void test2() {
+ try {
+ executeTarget("test2");
+ File file = new File(SANDBOX
+ + "/helloworld/jars/helloworld-1.2.jar");
+ assertTrue("Expected " + file + " to exists", file.exists());
+ } finally {
+ System.out.println(getOutput());
+ }
+ }
+ public void test3() {
+ try {
+ expectSpecificBuildException("test3",
+ "Only helloworld 1.1 and 1.2 exist's",
+ "Unable to find helloworld-1.3.jar@localtest");
+ } finally {
+ System.out.println(getOutput());
+ }
+ }
+ public void test4() {
+ try {
+ executeTarget("test4");
+ File file = new File(SANDBOX
+ + "/helloworld/jars/helloworld-1.2.jar");
+ assertTrue("Expected " + file + " to exists", file.exists());
+ } finally {
+ System.out.println(getOutput());
+ }
+ }
+ public void testNotFound() {
+ try {
+ expectSpecificBuildException("testNotFound",
+ "notfound does not exist",
+ "Unable to find notfound-1.2.jar@localtest");
+ } finally {
+ System.out.println(getOutput());
+ }
+ }
+ /**
+ * Test the exporting of cached set test1.
+ *
+ */
+ public void testExport1() throws FileNotFoundException, SAXException,
+ IOException, ParserConfigurationException {
+ try {
+ executeTarget("testExport1");
+ File generatedFile = new File("build/test1-export.build.xml");
+ File expectedFile = new File(
+ "build/expected-test1-export.build.xml");
+ assertTrue("Expected " + generatedFile + " to exists",
+ generatedFile.exists());
+ XMLAssert
+ .assertXMLEqual("Exported cached set test1",
+ new FileReader(expectedFile), new FileReader(
+ generatedFile));
+ } finally {
+ System.out.println(getOutput());
+ }
+ }
+}
\ No newline at end of file
Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/build.xml
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/build.xml (original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/build.xml Fri Jun 25 12:59:12 2004
@@ -43,7 +43,7 @@
</fileset>
</copy>
<cachedset id="test1">
- <resource name="helloworld" ext="jar" version="1.1" repository="localtest" />
+ <artifact name="helloworld" ext="jar" version="1.1" repository="localtest" />
</cachedset>
<copy toDir="${sandbox.dir}">
<fileset refid="test1.fileset" />
@@ -52,7 +52,7 @@
<target name="test2" depends="clean-jars">
<!-- Since the local repo is cleaned this test should return the 1.2 jar downloaded for localtest -->
<cachedset id="test2">
- <resource name="helloworld" ext="jar" version="1.2" repository="localtest" />
+ <artifact name="helloworld" ext="jar" version="1.2" repository="localtest" />
</cachedset>
<copy toDir="${sandbox.dir}">
<fileset refid="test2.fileset" />
@@ -62,7 +62,7 @@
<!-- helloworld 1.3 does not exist this should fail. -->
<cachedset id="test3">
- <resource name="helloworld" ext="jar" version="1.3" repository="localtest" />
+ <artifact name="helloworld" ext="jar" version="1.3" repository="localtest" />
</cachedset>
<copy toDir="${sandbox.dir}">
<fileset refid="test3.fileset" />
@@ -77,7 +77,7 @@
</fileset>
</copy>
<cachedset id="test4">
- <resource name="helloworld" ext="jar" version="1.2" repository="localtest" />
+ <artifact name="helloworld" ext="jar" version="1.2" repository="localtest" />
</cachedset>
<copy toDir="${sandbox.dir}">
<fileset refid="test4.fileset" />
@@ -92,7 +92,7 @@
</target>
<target name="testNotFound">
<cachedset id="testNotFound">
- <resource name="notfound" ext="jar" version="1.2" repository="localtest" />
+ <artifact name="notfound" ext="jar" version="1.2" repository="localtest" />
</cachedset>
<!-- have to use the chaced set before it is used. -->
<copy toDir="${sandbox.dir}">
Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/cache/test1-export.build.xml
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/cache/test1-export.build.xml (original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/cache/test1-export.build.xml Fri Jun 25 12:59:12 2004
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE cachedresourceset PUBLIC "-//APACHE//DTD CachedResource V0.1//EN" "http://incubator.apache.org/depot/dtd/cachedresource-v01.dtd">
-<cachedresourceset id="test1">
- <resource name="helloworld"
+<cachedartifactset id="test1">
+ <artifact name="helloworld"
version="1.1"
href="file://@basedir@/src/resources/test/repo/helloworld/jars/helloworld-1.1.jar"/>
-</cachedresourceset>
+</cachedartifactset>
Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/test1-export.build.xml
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/test1-export.build.xml (original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/test1-export.build.xml Fri Jun 25 12:59:12 2004
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
-<!DOCTYPE cachedresourceset PUBLIC "-//APACHE//DTD CachedResource V0.1//EN" "http://incubator.apache.org/depot/dtd/cachedresource-v01.dtd">
-<cachedresourceset id="test1">
- <resource name="helloworld"
+<!DOCTYPE cachedartifactset PUBLIC "-//APACHE//DTD CachedResource V0.1//EN" "http://incubator.apache.org/depot/dtd/cachedartifact-v01.dtd">
+<cachedartifactset id="test1">
+ <artifact name="helloworld"
group="helloworld"
version="1.1"
- href="file://@basedir@/src/resources/test/repo/helloworld/jars/helloworld-1.1.jar"/>
-</cachedresourceset>
+ href="file://@basedir@/src/artifacts/test/repo/helloworld/jars/helloworld-1.1.jar"/>
+</cachedartifactset>
Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/artifact/ArtifactTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/artifact/ArtifactTests.java (original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/artifact/ArtifactTests.java Fri Jun 25 12:59:12 2004
@@ -39,31 +39,31 @@
}
public void testArtifactEquality1() throws Exception {
- ArtifactInstance r1 = ArtifactInstance.getTestArtifact();
- ArtifactInstance r2 = ArtifactInstance.getTestArtifact();
+ ArtifactInstance i1 = ArtifactInstance.getTestArtifact();
+ ArtifactInstance i2 = ArtifactInstance.getTestArtifact();
- assertEquals("Same are equal", r1, r2);
- assertTrue("Same are equal", r1.equals(r2));
- assertEquals("Same are same hash", r1.hashCode(), r2.hashCode());
+ assertEquals("Same are equal", i1, i2);
+ assertTrue("Same are equal", i1.equals(i2));
+ assertEquals("Same are same hash", i1.hashCode(), i2.hashCode());
}
public void testArtifactEquality2() throws Exception {
- ArtifactInstance r1 = ArtifactInstance.getTestArtifact();
- ArtifactInstance r2 = ArtifactInstance.getTestArtifact("bogus");
+ ArtifactInstance i1 = ArtifactInstance.getTestArtifact();
+ ArtifactInstance i2 = ArtifactInstance.getTestArtifact("bogus");
- assertFalse("Different are NOT equal", r1.equals(r2));
+ assertFalse("Different are NOT equal", i1.equals(i2));
assertFalse(
"Different are NOT equal hash",
- r1.hashCode() == r2.hashCode());
+ i1.hashCode() == i2.hashCode());
}
public void testArtifactEquality3() throws Exception {
- ArtifactInstance r1 = ArtifactInstance.getTestArtifact();
- ArtifactInstance r2 = new ArtifactInstance(r1);
+ ArtifactInstance i1 = ArtifactInstance.getTestArtifact();
+ ArtifactInstance i2 = new ArtifactInstance(i1);
- assertEquals("Clones are equal", r1, r2);
- assertTrue("Clones are equal", r1.equals(r2));
- assertEquals("Clones are same hash", r1.hashCode(), r2.hashCode());
+ assertEquals("Clones are equal", i1, i2);
+ assertTrue("Clones are equal", i1.equals(i2));
+ assertEquals("Clones are same hash", i1.hashCode(), i2.hashCode());
}
public void testArtifactEquality4() throws Exception {
Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/query/QueryTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/query/QueryTests.java (original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/query/QueryTests.java Fri Jun 25 12:59:12 2004
@@ -41,7 +41,7 @@
*/
public class QueryTests extends TestCase {
- private DefaultQueryEngine m_engine = null;
+ private QueryEngine m_engine = null;
private ArtifactUpdaterContext m_context = null;
private RepositorySetWrapper m_repoSet = null;
@@ -57,7 +57,7 @@
public void setUp() throws Exception {
m_context = ArtifactUpdaterContext.getTestContext();
- m_engine = new DefaultQueryEngine();
+ m_engine = new QueryEngine();
m_repoSet =
new RepositorySetWrapper(
@@ -151,7 +151,7 @@
private ArtifactResult performAndCount(
ArtifactQuery query,
int groups,
- int resources)
+ int artifacts)
throws UpdateException {
ArtifactResult result = perform(query);
@@ -161,9 +161,9 @@
ArtifactResultHelper.groupCount(result));
assertEquals(
- "Resources Expected",
- resources,
- ArtifactResultHelper.resourceCount(result));
+ "Artifacts Expected",
+ artifacts,
+ ArtifactResultHelper.artifactCount(result));
return result;
}
Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/repository/RepositoryTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/repository/RepositoryTests.java (original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/repository/RepositoryTests.java Fri Jun 25 12:59:12 2004
@@ -67,34 +67,34 @@
//DebugUtils.dump("Mock Groups", list2);
}
- public void testListResources1() throws Exception {
+ public void testListArtifacts1() throws Exception {
ArtifactGroup testGroup = new ArtifactGroup("junit");
- List list1 = m_repo1.listResources(testGroup, AllSelector.getInstance());
- assertNotNull("List Resources", list1);
- assertFalse("List Resources not Empty", list1.isEmpty());
-
- List list2 = m_repo2.listResources(testGroup, AllSelector.getInstance());
- assertNotNull("List Resources", list2);
- assertFalse("List Resources not Empty", list2.isEmpty());
+ List list1 = m_repo1.listArtifacts(testGroup, AllSelector.getInstance());
+ assertNotNull("List Artifacts", list1);
+ assertFalse("List Artifacts not Empty", list1.isEmpty());
+
+ List list2 = m_repo2.listArtifacts(testGroup, AllSelector.getInstance());
+ assertNotNull("List Artifacts", list2);
+ assertFalse("List Artifacts not Empty", list2.isEmpty());
- // DebugUtils.dump("Test Resources", list1);
- // DebugUtils.dump("Mock Resources", list2);
+ // DebugUtils.dump("Test Artifacts", list1);
+ // DebugUtils.dump("Mock Artifacts", list2);
}
- public void testListSpecifiers1() throws Exception {
+ public void testListArtifactInstances1() throws Exception {
ArtifactGroup testGroup = new ArtifactGroup("junit");
- List specifiers1 = m_repo1.listSpecifiers(testGroup,
+ List artifacts1 = m_repo1.listInstances(testGroup,
AllSelector.getInstance());
- assertNotNull("List Specifiers", specifiers1);
- assertFalse("List Specifiers Not Empty", specifiers1.isEmpty());
+ assertNotNull("List Artifacts", artifacts1);
+ assertFalse("List Artifacts Not Empty", artifacts1.isEmpty());
- List specifiers2 = m_repo2.listSpecifiers(testGroup,
+ List artifacts2 = m_repo2.listInstances(testGroup,
AllSelector.getInstance());
- assertNotNull("List Specifiers", specifiers2);
- assertFalse("List Specifiers Not Empty", specifiers2.isEmpty());
+ assertNotNull("List Artifacts", artifacts2);
+ assertFalse("List Artifacts Not Empty", artifacts2.isEmpty());
}
public static void main(String[] args) {
Added: incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/ArtifactTests.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/usecases/ArtifactTests.java Fri Jun 25 12:59:12 2004
@@ -0,0 +1,95 @@
+/*
+ * 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.usecases;
+
+import java.io.File;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.depot.update.Artifact;
+import org.apache.depot.update.ArtifactInstance;
+import org.apache.depot.update.ArtifactUpdater;
+import org.apache.depot.update.ArtifactUpdaterFactory;
+import org.apache.depot.update.Repository;
+import org.apache.depot.update.repository.DefaultRepository;
+import org.apache.depot.update.repository.RepositorySet;
+import org.apache.depot.update.util.io.ResolvedFile;
+import org.apache.depot.update.util.net.VirtualResourceLocator;
+
+public class ArtifactTests extends TestCase {
+ private ResolvedFile m_repoDir = ResolvedFile.resolve("src/artifacts/test/usecase/find/repo");
+ private FileHelper m_fileHelper = new FileHelper();
+
+ protected void setUp() {
+ if (!m_repoDir.exists()) {
+ m_repoDir.mkdirs();
+ }
+ m_fileHelper.setUp();
+ }
+
+ protected void tearDown() {
+ m_fileHelper.tearDown();
+ }
+
+ /**
+ * Start simple,
+ * Find a single jar in a repository
+ */
+ public void testFindSingleJar() throws Exception {
+ File artifactFile =
+ m_fileHelper.setupActualFile(
+ m_repoDir,
+ "gorilla/jars/gorilla-1.0.jar");
+
+ // 1. User configures Depot
+ ArtifactUpdater updater =
+ ArtifactUpdaterFactory.getDefaultUpdater();
+
+ Repository fileRepo =
+ new DefaultRepository("test", m_repoDir.toURL().toString());
+ RepositorySet repos = new RepositorySet();
+ repos.addRepository(fileRepo);
+
+ // 2. User supplies artifact query and asks Depot process it
+ Artifact artifact = new Artifact("gorilla");
+
+ ArtifactInstance instance = updater.getInstance(artifact);
+
+ // 3. Depot examines query to extract artifact information
+ // 4. Depot queries repositories for artifact
+ // 5. Depot reports results to User
+
+ assertNotNull("Should get a result", instance);
+
+ VirtualResourceLocator expected =
+ new VirtualResourceLocator(ResolvedFile.resolve(artifactFile));
+ assertEquals(
+ "Got unexpected location",
+ expected,
+ instance.getLocator().getLocation());
+ }
+
+ public static Test suite() {
+ return new TestSuite(ArtifactTests.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+}
Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/util/security/HashCodeManagerTest.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/util/security/HashCodeManagerTest.java (original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/util/security/HashCodeManagerTest.java Fri Jun 25 12:59:12 2004
@@ -59,8 +59,8 @@
* @throws Exception TODO
*/
public void testGetDigest() throws Exception {
- File hashFile = new File("src/resources/test/org/apache/depot/update/util/security/test.txt");
- File metaFile = new File("src/resources/test/org/apache/depot/update/util/security/test.txt.md5");
+ File hashFile = new File("src/artifacts/test/org/apache/depot/update/util/security/test.txt");
+ File metaFile = new File("src/artifacts/test/org/apache/depot/update/util/security/test.txt.md5");
byte[] firstByteArray = HashCodeManager.getDigest(hashFile, this.messageDigest, this.readBufferSize);
byte[] sameByteArray = HashCodeManager.getDigest(hashFile, this.messageDigest, this.readBufferSize);
@@ -121,7 +121,7 @@
}
public void testReadHashFromFile() throws Exception {
- File metaFile = new File("src/resources/test/org/apache/depot/update/util/security/test.txt.md5");
+ File metaFile = new File("src/artifacts/test/org/apache/depot/update/util/security/test.txt.md5");
byte[] digest = HashCodeManager.readHashFromFile(metaFile);
assertNotNull(digest);
@@ -143,7 +143,7 @@
* @throws Exception
*/
/*public void testGenerateHash() throws Exception {
- get classloader to load needed resources - should be done in a static way (utils class)
+ get classloader to load needed artifacts - should be done in a static way (utils class)
ClassLoader loader = this.getClass().getClassLoader();
InputStream stream = loader.getResourceAsStream("test.xml");