From: Brett Porter
Date: Thu, 20 Jul 2006 03:10:39 +0000 (+0000)
Subject: starting to move the discoverer (indexer) over to the core
X-Git-Tag: archiva-0.9-alpha-1~777
X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c4f50c7f1074118273c6c156d73de675dbbb6a9c;p=archiva.git
starting to move the discoverer (indexer) over to the core
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@423734 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeException.java b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeException.java
new file mode 100644
index 000000000..547bff7a4
--- /dev/null
+++ b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeException.java
@@ -0,0 +1,31 @@
+package org.apache.maven.repository.configuration;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * An error changing the configuration
+ *
+ * @author Brett Porter
+ */
+public class ConfigurationChangeException
+ extends Exception
+{
+ public ConfigurationChangeException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
diff --git a/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java
index b02717df2..ca01a493f 100644
--- a/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java
+++ b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java
@@ -28,6 +28,9 @@ public interface ConfigurationChangeListener
* Notify the object that there has been a configuration change.
*
* @param configuration the new configuration
+ * @throws InvalidConfigurationException if there is a problem with the new configuration
+ * @throws ConfigurationChangeException if there is a problem changing the configuration, but the configuration is valid
*/
- void notifyOfConfigurationChange( Configuration configuration );
+ void notifyOfConfigurationChange( Configuration configuration )
+ throws InvalidConfigurationException, ConfigurationChangeException;
}
diff --git a/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
index 432062c53..2fa116d0f 100644
--- a/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
+++ b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
@@ -43,5 +43,12 @@ public interface ConfigurationStore
* @param configuration the configuration to store
*/
void storeConfiguration( Configuration configuration )
- throws ConfigurationStoreException;
+ throws ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException;
+
+ /**
+ * Add a configuration change listener.
+ *
+ * @param listener the listener
+ */
+ void addChangeListener( ConfigurationChangeListener listener );
}
diff --git a/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
index 2eb858d2a..5ac90a8ef 100644
--- a/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
+++ b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
@@ -106,7 +106,7 @@ public class DefaultConfigurationStore
}
public void storeConfiguration( Configuration configuration )
- throws ConfigurationStoreException
+ throws ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException
{
for ( Iterator i = listeners.iterator(); i.hasNext(); )
{
@@ -133,4 +133,9 @@ public class DefaultConfigurationStore
IOUtil.close( fileWriter );
}
}
+
+ public void addChangeListener( ConfigurationChangeListener listener )
+ {
+ listeners.add( listener );
+ }
}
diff --git a/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/InvalidConfigurationException.java b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/InvalidConfigurationException.java
new file mode 100644
index 000000000..b88d4f3f9
--- /dev/null
+++ b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/InvalidConfigurationException.java
@@ -0,0 +1,40 @@
+package org.apache.maven.repository.configuration;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * An error in the configuration.
+ *
+ * @author Brett Porter
+ */
+public class InvalidConfigurationException
+ extends Exception
+{
+ private final String name;
+
+ public InvalidConfigurationException( String name, String message, Throwable cause )
+ {
+ super( message, cause );
+
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
diff --git a/maven-repository-configuration/src/main/mdo/configuration.mdo b/maven-repository-configuration/src/main/mdo/configuration.mdo
index 189a3f6af..80583cab4 100644
--- a/maven-repository-configuration/src/main/mdo/configuration.mdo
+++ b/maven-repository-configuration/src/main/mdo/configuration.mdo
@@ -55,11 +55,18 @@
- discoveryCronExpression
+ indexerCronExpression
1.0.0
String
- When to run the discovery mechanism.
- 0 0 8 * * ?
+ When to run the indexing mechanism. Default is every hour on the hour.
+ 0 0 * * * ?
+
+
+ converterCronExpression
+ 1.0.0
+ String
+ When to run the converter mechanism. Default is every 4 hours, on the half hour.
+ 0 30 0/4 * * ?
discoverSnapshots
diff --git a/maven-repository-core/pom.xml b/maven-repository-core/pom.xml
index be593d8cc..ea3da3de3 100644
--- a/maven-repository-core/pom.xml
+++ b/maven-repository-core/pom.xml
@@ -10,6 +10,10 @@
maven-repository-core
Maven Repository Manager Core
+
+ org.apache.maven.repository
+ maven-repository-configuration
+
org.apache.maven.repository
maven-repository-converter
@@ -21,7 +25,12 @@
org.apache.maven.repository
maven-repository-reports-standard
-
+
+
+ org.codehaus.plexus
+ plexus-quartz
+ 1.0-alpha-2
+
junit
diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java b/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java
new file mode 100644
index 000000000..c71b219bb
--- /dev/null
+++ b/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java
@@ -0,0 +1,36 @@
+package org.apache.maven.repository.configuration;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+
+/**
+ * Create an artifact repository from the given configuration.
+ *
+ * @author Brett Porter
+ */
+public interface ConfiguredRepositoryFactory
+{
+ String ROLE = ConfiguredRepositoryFactory.class.getName();
+
+ /**
+ * Create an artifact repository from the given configuration.
+ *
+ * @param configuration the configuration
+ */
+ ArtifactRepository createRepository( Configuration configuration );
+}
diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java b/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java
new file mode 100644
index 000000000..5e41e308c
--- /dev/null
+++ b/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java
@@ -0,0 +1,55 @@
+package org.apache.maven.repository.configuration;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+
+import java.io.File;
+import java.util.Map;
+
+/**
+ * Create artifact repositories from a configuration.
+ *
+ * @author Brett Porter
+ * @plexus.component role="org.apache.maven.repository.configuration.ConfiguredRepositoryFactory"
+ */
+public class DefaultConfiguredRepositoryFactory
+ implements ConfiguredRepositoryFactory
+{
+ /**
+ * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
+ */
+ private Map repositoryLayouts;
+
+ /**
+ * @plexus.requirement
+ */
+ private ArtifactRepositoryFactory repoFactory;
+
+ public ArtifactRepository createRepository( Configuration configuration )
+ {
+ File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
+ String repoDir = repositoryDirectory.toURI().toString();
+
+ ArtifactRepositoryLayout layout =
+ (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
+ // TODO: real ID
+ return repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
+ }
+}
diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java
new file mode 100644
index 000000000..2e31e56b5
--- /dev/null
+++ b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/DefaultRepositoryTaskScheduler.java
@@ -0,0 +1,164 @@
+package org.apache.maven.repository.scheduler;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+import org.apache.maven.repository.configuration.Configuration;
+import org.apache.maven.repository.configuration.ConfigurationChangeException;
+import org.apache.maven.repository.configuration.ConfigurationChangeListener;
+import org.apache.maven.repository.configuration.ConfigurationStore;
+import org.apache.maven.repository.configuration.ConfigurationStoreException;
+import org.apache.maven.repository.configuration.InvalidConfigurationException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
+import org.codehaus.plexus.scheduler.AbstractJob;
+import org.codehaus.plexus.scheduler.Scheduler;
+import org.quartz.CronTrigger;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+import org.quartz.SchedulerException;
+
+import java.text.ParseException;
+
+/**
+ * Default implementation of a scheduling component for the application.
+ *
+ * @author Brett Porter
+ * @todo should we use plexus-taskqueue instead of or in addition to this?
+ * @plexus.component role="org.apache.maven.repository.scheduler.RepositoryTaskScheduler"
+ */
+public class DefaultRepositoryTaskScheduler
+ extends AbstractLogEnabled
+ implements RepositoryTaskScheduler, Startable, ConfigurationChangeListener
+{
+ /**
+ * @plexus.requirement
+ */
+ private Scheduler scheduler;
+
+ /**
+ * @plexus.requirement
+ */
+ private ConfigurationStore configurationStore;
+
+ private static final String DISCOVERER_GROUP = "DISCOVERER";
+
+ private static final String INDEXER_JOB = "indexerTask";
+
+ /**
+ * @plexus.requirement role-hint="indexer"
+ */
+ private RepositoryTask indexerTask;
+
+ public void start()
+ throws StartingException
+ {
+ Configuration configuration;
+ try
+ {
+ configuration = configurationStore.getConfigurationFromStore();
+ configurationStore.addChangeListener( this );
+ }
+ catch ( ConfigurationStoreException e )
+ {
+ throw new StartingException( "Unable to read configuration from the store", e );
+ }
+
+ try
+ {
+ scheduleJobs( configuration );
+ }
+ catch ( ParseException e )
+ {
+ throw new StartingException( "Invalid configuration: " + configuration.getIndexerCronExpression(), e );
+ }
+ catch ( SchedulerException e )
+ {
+ throw new StartingException( "Unable to start scheduler: " + e.getMessage(), e );
+ }
+ }
+
+ private void scheduleJobs( Configuration configuration )
+ throws ParseException, SchedulerException
+ {
+ JobDetail jobDetail = new JobDetail( INDEXER_JOB, DISCOVERER_GROUP, RepositoryTaskJob.class );
+ JobDataMap dataMap = new JobDataMap();
+ dataMap.put( AbstractJob.LOGGER, getLogger() );
+ dataMap.put( RepositoryTaskJob.TASK_KEY, indexerTask );
+ jobDetail.setJobDataMap( dataMap );
+
+ getLogger().info( "Scheduling indexer: " + configuration.getIndexerCronExpression() );
+ CronTrigger trigger =
+ new CronTrigger( INDEXER_JOB + "Trigger", DISCOVERER_GROUP, configuration.getIndexerCronExpression() );
+ scheduler.scheduleJob( jobDetail, trigger );
+
+ try
+ {
+ indexerTask.executeNowIfNeeded();
+ }
+ catch ( TaskExecutionException e )
+ {
+ getLogger().error( "Error executing task first time, continuing anyway: " + e.getMessage(), e );
+ }
+
+ // TODO: wire in the converter
+ }
+
+ public void stop()
+ throws StoppingException
+ {
+ try
+ {
+ scheduler.unscheduleJob( INDEXER_JOB, DISCOVERER_GROUP );
+ }
+ catch ( SchedulerException e )
+ {
+ throw new StoppingException( "Unable to unschedule tasks", e );
+ }
+ }
+
+ public void notifyOfConfigurationChange( Configuration configuration )
+ throws InvalidConfigurationException, ConfigurationChangeException
+ {
+ try
+ {
+ stop();
+
+ scheduleJobs( configuration );
+ }
+ catch ( StoppingException e )
+ {
+ throw new ConfigurationChangeException( "Unable to unschedule previous tasks", e );
+ }
+ catch ( ParseException e )
+ {
+ throw new InvalidConfigurationException( "discoveryCronExpression", "Invalid cron expression", e );
+ }
+ catch ( SchedulerException e )
+ {
+ throw new ConfigurationChangeException( "Unable to schedule new tasks", e );
+ }
+ }
+
+ public void runIndexer()
+ throws TaskExecutionException
+ {
+ indexerTask.execute();
+
+ }
+}
diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/IndexerTask.java b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/IndexerTask.java
new file mode 100644
index 000000000..724f93e43
--- /dev/null
+++ b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/IndexerTask.java
@@ -0,0 +1,210 @@
+package org.apache.maven.repository.scheduler;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.repository.configuration.Configuration;
+import org.apache.maven.repository.configuration.ConfigurationStore;
+import org.apache.maven.repository.configuration.ConfigurationStoreException;
+import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
+import org.apache.maven.repository.discovery.ArtifactDiscoverer;
+import org.apache.maven.repository.discovery.MetadataDiscoverer;
+import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
+import org.apache.maven.repository.indexing.MetadataRepositoryIndex;
+import org.apache.maven.repository.indexing.PomRepositoryIndex;
+import org.apache.maven.repository.indexing.RepositoryIndexException;
+import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Task for discovering changes in the repository.
+ *
+ * @author Brett Porter
+ * @plexus.component role="org.apache.maven.repository.scheduler.RepositoryTask" role-hint="indexer"
+ */
+public class IndexerTask
+ extends AbstractLogEnabled
+ implements RepositoryTask
+{
+ /**
+ * Configuration store.
+ *
+ * @plexus.requirement
+ */
+ private ConfigurationStore configurationStore;
+
+ /**
+ * @plexus.requirement
+ */
+ private RepositoryIndexingFactory indexFactory;
+
+ /**
+ * @plexus.requirement
+ */
+ private ConfiguredRepositoryFactory repoFactory;
+
+ /**
+ * @plexus.requirement role="org.apache.maven.repository.discovery.ArtifactDiscoverer"
+ */
+ private Map artifactDiscoverers;
+
+ /**
+ * @plexus.requirement role="org.apache.maven.repository.discovery.MetadataDiscoverer"
+ */
+ private Map metadataDiscoverers;
+
+ public void execute()
+ throws TaskExecutionException
+ {
+ Configuration configuration;
+ try
+ {
+ configuration = configurationStore.getConfigurationFromStore();
+ }
+ catch ( ConfigurationStoreException e )
+ {
+ throw new TaskExecutionException( e.getMessage(), e );
+ }
+
+ File indexPath = new File( configuration.getIndexPath() );
+
+ execute( configuration, indexPath );
+ }
+
+ private void execute( Configuration configuration, File indexPath )
+ throws TaskExecutionException
+ {
+ getLogger().info( "Starting repository discovery process" );
+
+ try
+ {
+ String blacklistedPatterns = configuration.getDiscoveryBlackListPatterns();
+ boolean includeSnapshots = configuration.isDiscoverSnapshots();
+
+ ArtifactRepository defaultRepository = repoFactory.createRepository( configuration );
+
+ String layoutProperty = configuration.getRepositoryLayout();
+ ArtifactDiscoverer discoverer = (ArtifactDiscoverer) artifactDiscoverers.get( layoutProperty );
+ List artifacts = discoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, includeSnapshots );
+ if ( !artifacts.isEmpty() )
+ {
+ getLogger().info( "Indexing " + artifacts.size() + " new artifacts" );
+ indexArtifact( artifacts, indexPath, defaultRepository );
+ }
+
+ List models = discoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, includeSnapshots );
+ if ( !models.isEmpty() )
+ {
+ getLogger().info( "Indexing " + models.size() + " new POMs" );
+ indexPom( models, indexPath, defaultRepository );
+ }
+
+ MetadataDiscoverer metadataDiscoverer = (MetadataDiscoverer) metadataDiscoverers.get( layoutProperty );
+ List metadataList =
+ metadataDiscoverer.discoverMetadata( new File( defaultRepository.getBasedir() ), blacklistedPatterns );
+ if ( !metadataList.isEmpty() )
+ {
+ getLogger().info( "Indexing " + metadataList.size() + " new metadata files" );
+ indexMetadata( metadataList, indexPath, defaultRepository );
+ }
+ }
+ catch ( RepositoryIndexException e )
+ {
+ throw new TaskExecutionException( e.getMessage(), e );
+ }
+
+ getLogger().info( "Finished repository indexing process" );
+ }
+
+ public void executeNowIfNeeded()
+ throws TaskExecutionException
+ {
+ Configuration configuration;
+ try
+ {
+ configuration = configurationStore.getConfigurationFromStore();
+ }
+ catch ( ConfigurationStoreException e )
+ {
+ throw new TaskExecutionException( e.getMessage(), e );
+ }
+
+ File indexPath = new File( configuration.getIndexPath() );
+
+ try
+ {
+ ArtifactRepository repository = repoFactory.createRepository( configuration );
+ ArtifactRepositoryIndex artifactIndex = indexFactory.createArtifactRepositoryIndex( indexPath, repository );
+ if ( !artifactIndex.indexExists() )
+ {
+ execute( configuration, indexPath );
+ }
+ }
+ catch ( RepositoryIndexException e )
+ {
+ throw new TaskExecutionException( e.getMessage(), e );
+ }
+ }
+
+ /**
+ * Index the artifacts in the list
+ *
+ * @param artifacts the artifacts to be indexed
+ * @param indexPath the path to the index file
+ * @param repository the repository where the artifacts are located
+ */
+ protected void indexArtifact( List artifacts, File indexPath, ArtifactRepository repository )
+ throws RepositoryIndexException
+ {
+ ArtifactRepositoryIndex artifactIndex = indexFactory.createArtifactRepositoryIndex( indexPath, repository );
+ artifactIndex.indexArtifacts( artifacts );
+ artifactIndex.optimize();
+ }
+
+ /**
+ * Index the metadata in the list
+ *
+ * @param metadataList the metadata to be indexed
+ * @param indexPath the path to the index file
+ */
+ protected void indexMetadata( List metadataList, File indexPath, ArtifactRepository repository )
+ throws RepositoryIndexException
+ {
+ MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository );
+ metadataIndex.indexMetadata( metadataList );
+ metadataIndex.optimize();
+ }
+
+ /**
+ * Index the poms in the list
+ *
+ * @param models list of poms that will be indexed
+ * @param indexPath the path to the index
+ * @param repository the artifact repository where the poms were discovered
+ */
+ protected void indexPom( List models, File indexPath, ArtifactRepository repository )
+ throws RepositoryIndexException
+ {
+ PomRepositoryIndex pomIndex = indexFactory.createPomRepositoryIndex( indexPath, repository );
+ pomIndex.indexPoms( models );
+ pomIndex.optimize();
+ }
+}
diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/RepositoryTask.java b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/RepositoryTask.java
new file mode 100644
index 000000000..92b6f93cd
--- /dev/null
+++ b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/RepositoryTask.java
@@ -0,0 +1,37 @@
+package org.apache.maven.repository.scheduler;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * A repository task.
+ *
+ * @author Brett Porter
+ */
+public interface RepositoryTask
+{
+ /**
+ * Execute the task.
+ */
+ void execute()
+ throws TaskExecutionException;
+
+ /**
+ * Execute the task now if needed because the target doesn't exist.
+ */
+ void executeNowIfNeeded()
+ throws TaskExecutionException;
+}
diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/RepositoryTaskJob.java b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/RepositoryTaskJob.java
new file mode 100644
index 000000000..874f6bcf2
--- /dev/null
+++ b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/RepositoryTaskJob.java
@@ -0,0 +1,56 @@
+package org.apache.maven.repository.scheduler;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+import org.codehaus.plexus.scheduler.AbstractJob;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+/**
+ * This class is the discoverer job that is executed by the scheduler.
+ */
+public class RepositoryTaskJob
+ extends AbstractJob
+{
+ static final String TASK_KEY = "EXECUTION";
+
+ /**
+ * Execute the discoverer and the indexer.
+ *
+ * @param context
+ * @throws org.quartz.JobExecutionException
+ *
+ */
+ public void execute( JobExecutionContext context )
+ throws JobExecutionException
+ {
+ JobDataMap dataMap = context.getJobDetail().getJobDataMap();
+ setJobDataMap( dataMap );
+
+ RepositoryTask executor = (RepositoryTask) dataMap.get( TASK_KEY );
+ try
+ {
+ executor.execute();
+ }
+ catch ( TaskExecutionException e )
+ {
+ throw new JobExecutionException( e );
+ }
+ }
+
+}
diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/RepositoryTaskScheduler.java b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/RepositoryTaskScheduler.java
new file mode 100644
index 000000000..46db976b3
--- /dev/null
+++ b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/RepositoryTaskScheduler.java
@@ -0,0 +1,33 @@
+package org.apache.maven.repository.scheduler;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * The component that takes care of scheduling in the application.
+ *
+ * @author Brett Porter
+ */
+public interface RepositoryTaskScheduler
+{
+ /**
+ * The Plexus component role.
+ */
+ String ROLE = RepositoryTaskScheduler.class.getName();
+
+ void runIndexer()
+ throws TaskExecutionException;
+}
diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/TaskExecutionException.java b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/TaskExecutionException.java
new file mode 100644
index 000000000..7ab229021
--- /dev/null
+++ b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/TaskExecutionException.java
@@ -0,0 +1,31 @@
+package org.apache.maven.repository.scheduler;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+/**
+ * Exception occurring during task execution.
+ *
+ * @author Brett Porter
+ */
+public class TaskExecutionException
+ extends Exception
+{
+ public TaskExecutionException( String message, Throwable t )
+ {
+ super( message, t );
+ }
+}
diff --git a/maven-repository-webapp/pom.xml b/maven-repository-webapp/pom.xml
index 39f89081f..7d6d2433a 100644
--- a/maven-repository-webapp/pom.xml
+++ b/maven-repository-webapp/pom.xml
@@ -37,6 +37,16 @@
sitemesh
2.2.1
+
+ taglibs
+ standard
+ 1.1.2
+
+
+ jstl
+ jstl
+ 1.1.2
+
org.codehaus.plexus
plexus-xwork-integration-single
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BaseAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BaseAction.java
index f9e5f223d..26b0bf863 100644
--- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BaseAction.java
+++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BaseAction.java
@@ -19,8 +19,7 @@ package org.apache.maven.repository.manager.web.action;
import com.opensymphony.webwork.interceptor.ParameterAware;
import com.opensymphony.xwork.ActionSupport;
import org.apache.maven.repository.configuration.Configuration;
-import org.apache.maven.repository.manager.web.execution.DiscovererExecution;
-import org.apache.maven.repository.manager.web.job.DiscovererScheduler;
+import org.apache.maven.repository.configuration.ConfigurationStore;
import org.apache.maven.repository.manager.web.utils.ConfigurationManager;
import java.util.HashMap;
@@ -31,25 +30,17 @@ import java.util.Map;
* It invokes the DiscovererScheduler to set the DiscoverJob in the scheduler.
*
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="baseAction"
+ * @todo don't like this as a base and as a forwarding action!
*/
public class BaseAction
extends ActionSupport
implements ParameterAware
{
- /**
- * @plexus.requirement
- */
- private DiscovererExecution execution;
-
- /**
- * @plexus.requirement
- */
- private DiscovererScheduler discovererScheduler;
/**
* @plexus.requirement
*/
- private ConfigurationManager configManager;
+ private ConfigurationStore configurationStore;
private Map parameters;
@@ -72,18 +63,17 @@ public class BaseAction
{
try
{
- Configuration config = configManager.getConfiguration();
+ Configuration config = configurationStore.getConfigurationFromStore();
Map parameters = new HashMap();
parameters.put( ConfigurationManager.INDEXPATH, config.getIndexPath() );
parameters.put( ConfigurationManager.MIN_INDEXPATH, config.getMinimalIndexPath() );
parameters.put( ConfigurationManager.DISCOVERY_BLACKLIST_PATTERNS, config.getDiscoveryBlackListPatterns() );
parameters.put( ConfigurationManager.DISCOVER_SNAPSHOTS, Boolean.valueOf( config.isDiscoverSnapshots() ) );
- parameters.put( ConfigurationManager.DISCOVERY_CRON_EXPRESSION, config.getDiscoveryCronExpression() );
+ parameters.put( ConfigurationManager.DISCOVERY_CRON_EXPRESSION, config.getIndexerCronExpression() );
this.parameters = parameters;
//Configuration configuration = new Configuration(); // TODO!
// execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );
- discovererScheduler.setSchedule( config.getDiscoveryCronExpression() );
}
catch ( Exception e )
{
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java
index a0927b660..900da9b8e 100644
--- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java
+++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java
@@ -18,9 +18,8 @@ package org.apache.maven.repository.manager.web.action;
import com.opensymphony.xwork.Action;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.repository.configuration.Configuration;
+import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
@@ -30,7 +29,6 @@ import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import java.io.File;
import java.net.MalformedURLException;
import java.util.List;
-import java.util.Map;
/**
* Searches for searchString in all indexed fields.
@@ -57,12 +55,7 @@ public class GeneralSearchAction
/**
* @plexus.requirement
*/
- private ArtifactRepositoryFactory repositoryFactory;
-
- /**
- * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
- */
- private Map repositoryLayouts;
+ private ConfiguredRepositoryFactory repositoryFactory;
public String execute()
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
@@ -72,14 +65,7 @@ public class GeneralSearchAction
Configuration configuration = new Configuration(); // TODO!
File indexPath = new File( configuration.getIndexPath() );
- // TODO: [!] repository should only have been instantiated once
- File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
- String repoDir = repositoryDirectory.toURL().toString();
-
- ArtifactRepositoryLayout layout =
- (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
- ArtifactRepository repository =
- repositoryFactory.createArtifactRepository( "test", repoDir, layout, null, null );
+ ArtifactRepository repository = repositoryFactory.createRepository( configuration );
ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
index cbd28f1e0..6f64bd904 100644
--- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
+++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
@@ -18,9 +18,8 @@ package org.apache.maven.repository.manager.web.action;
import com.opensymphony.xwork.Action;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.repository.configuration.Configuration;
+import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
@@ -32,7 +31,6 @@ import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
import java.io.File;
import java.net.MalformedURLException;
import java.util.List;
-import java.util.Map;
/**
* Search by package name.
@@ -54,15 +52,10 @@ public class PackageSearchAction
*/
private RepositoryIndexingFactory factory;
- /**
- * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
- */
- private Map repositoryLayouts;
-
/**
* @plexus.requirement
*/
- private ArtifactRepositoryFactory repositoryFactory;
+ private ConfiguredRepositoryFactory repositoryFactory;
/**
* @plexus.requirement
@@ -93,13 +86,7 @@ public class PackageSearchAction
Configuration configuration = new Configuration();
File indexPath = new File( configuration.getIndexPath() );
- File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
- String repoDir = repositoryDirectory.toURL().toString();
-
- ArtifactRepositoryLayout layout =
- (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
- ArtifactRepository repository =
- repositoryFactory.createArtifactRepository( "repository", repoDir, layout, null, null );
+ ArtifactRepository repository = repositoryFactory.createRepository( configuration );
ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java
index c480af4b6..8db744554 100644
--- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java
+++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java
@@ -18,11 +18,10 @@ package org.apache.maven.repository.manager.web.action;
import com.opensymphony.xwork.ActionSupport;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.configuration.ConfigurationStore;
import org.apache.maven.repository.configuration.ConfigurationStoreException;
+import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
@@ -50,7 +49,7 @@ public class QuickSearchAction
/**
* Search results.
*/
- private List searchResult;
+ private List searchResults;
/**
* @plexus.requirement
@@ -65,7 +64,7 @@ public class QuickSearchAction
/**
* @plexus.requirement
*/
- private ArtifactRepositoryFactory repositoryFactory;
+ private ConfiguredRepositoryFactory repositoryFactory;
/**
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
@@ -88,7 +87,7 @@ public class QuickSearchAction
Configuration configuration = configurationStore.getConfigurationFromStore();
File indexPath = new File( configuration.getIndexPath() );
- ArtifactRepository repository = getDefaultRepository( configuration );
+ ArtifactRepository repository = repositoryFactory.createRepository( configuration );
ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );
@@ -98,23 +97,11 @@ public class QuickSearchAction
return ERROR;
}
- searchResult = searchLayer.searchGeneral( q, index );
+ searchResults = searchLayer.searchGeneral( q, index );
return SUCCESS;
}
- private ArtifactRepository getDefaultRepository( Configuration configuration )
- throws MalformedURLException
- {
- // TODO: [!] repository should only have been instantiated once
- File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
- String repoDir = repositoryDirectory.toURI().toURL().toString();
-
- ArtifactRepositoryLayout layout =
- (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
- return repositoryFactory.createArtifactRepository( "test", repoDir, layout, null, null );
- }
-
public String doInput()
{
return INPUT;
@@ -130,9 +117,9 @@ public class QuickSearchAction
this.q = q;
}
- public List getSearchResult()
+ public List getSearchResults()
{
- return searchResult;
+ return searchResults;
}
}
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java
index 6ccb922a3..2e8955957 100644
--- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java
+++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java
@@ -20,8 +20,10 @@ import com.opensymphony.xwork.ActionSupport;
import com.opensymphony.xwork.ModelDriven;
import com.opensymphony.xwork.Preparable;
import org.apache.maven.repository.configuration.Configuration;
+import org.apache.maven.repository.configuration.ConfigurationChangeException;
import org.apache.maven.repository.configuration.ConfigurationStore;
import org.apache.maven.repository.configuration.ConfigurationStoreException;
+import org.apache.maven.repository.configuration.InvalidConfigurationException;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
import org.codehaus.plexus.util.StringUtils;
@@ -49,7 +51,8 @@ public class ConfigureAction
private Configuration configuration;
public String execute()
- throws IOException, RepositoryIndexException, RepositoryIndexSearchException, ConfigurationStoreException
+ throws IOException, RepositoryIndexException, RepositoryIndexSearchException, ConfigurationStoreException,
+ InvalidConfigurationException, ConfigurationChangeException
{
// TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
@@ -98,7 +101,7 @@ public class ConfigureAction
}
public void prepare()
- throws Exception
+ throws ConfigurationStoreException
{
configuration = configurationStore.getConfigurationFromStore();
}
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/RunIndexerAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/RunIndexerAction.java
new file mode 100644
index 000000000..244346081
--- /dev/null
+++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/RunIndexerAction.java
@@ -0,0 +1,43 @@
+package org.apache.maven.repository.manager.web.action.admin;
+
+/*
+ * Copyright 2005-2006 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.
+ */
+
+import com.opensymphony.xwork.ActionSupport;
+import org.apache.maven.repository.scheduler.RepositoryTaskScheduler;
+import org.apache.maven.repository.scheduler.TaskExecutionException;
+
+/**
+ * Configures the application.
+ *
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="runIndexerAction"
+ */
+public class RunIndexerAction
+ extends ActionSupport
+{
+ /**
+ * @plexus.requirement
+ */
+ private RepositoryTaskScheduler taskScheduler;
+
+ public String execute()
+ throws TaskExecutionException
+ {
+ taskScheduler.runIndexer();
+
+ return SUCCESS;
+ }
+}
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java
deleted file mode 100644
index f2d6b0279..000000000
--- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package org.apache.maven.repository.manager.web.execution;
-
-/*
- * Copyright 2006 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.
- */
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.repository.configuration.Configuration;
-import org.apache.maven.repository.discovery.ArtifactDiscoverer;
-import org.apache.maven.repository.discovery.MetadataDiscoverer;
-import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
-import org.apache.maven.repository.indexing.MetadataRepositoryIndex;
-import org.apache.maven.repository.indexing.PomRepositoryIndex;
-import org.apache.maven.repository.indexing.RepositoryIndexException;
-import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This is the class that executes the discoverer and indexer.
- *
- * @plexus.component role="org.apache.maven.repository.manager.web.execution.DiscovererExecution"
- * @todo note that a legacy repository will fail due to lack of metadata discoverer
- */
-public class DiscovererExecution
- extends AbstractLogEnabled
-{
-
- /**
- * @plexus.requirement role="org.apache.maven.repository.discovery.ArtifactDiscoverer"
- */
- private Map artifactDiscoverers;
-
- /**
- * @plexus.requirement role="org.apache.maven.repository.discovery.MetadataDiscoverer"
- */
- private Map metadataDiscoverers;
-
- /**
- * @plexus.requirement
- */
- private RepositoryIndexingFactory indexFactory;
-
- /**
- * @plexus.requirement
- */
- private ArtifactRepositoryFactory repoFactory;
-
- /**
- * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
- */
- private Map repositoryLayouts;
-
- /**
- * Executes discoverer and indexer if an index does not exist yet
- *
- * @param indexDir
- * @throws MalformedURLException
- * @throws RepositoryIndexException
- */
- public void executeDiscovererIfIndexDoesNotExist( File indexDir )
- throws MalformedURLException, RepositoryIndexException
- {
- boolean isExisting = false;
-
- if ( IndexReader.indexExists( indexDir ) )
- {
- isExisting = true;
- }
-
- if ( !isExisting )
- {
- executeDiscoverer();
- }
- }
-
- /**
- * Method that executes the discoverer and indexer
- */
- public void executeDiscoverer()
- throws MalformedURLException, RepositoryIndexException
- {
- Configuration configuration = new Configuration(); // TODO!
- File indexPath = new File( configuration.getIndexPath() );
- String blacklistedPatterns = configuration.getDiscoveryBlackListPatterns();
- boolean includeSnapshots = configuration.isDiscoverSnapshots();
-
- ArtifactRepository defaultRepository = getDefaultRepository( configuration );
-
- getLogger().info( "[DiscovererExecution] Started discovery and indexing.." );
- String layoutProperty = configuration.getRepositoryLayout();
- ArtifactDiscoverer discoverer = (ArtifactDiscoverer) artifactDiscoverers.get( layoutProperty );
- List artifacts = discoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, includeSnapshots );
- indexArtifact( artifacts, indexPath, defaultRepository );
-
- List models = discoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, includeSnapshots );
- indexPom( models, indexPath, defaultRepository );
-
- MetadataDiscoverer metadataDiscoverer = (MetadataDiscoverer) metadataDiscoverers.get( layoutProperty );
- List metadataList =
- metadataDiscoverer.discoverMetadata( new File( defaultRepository.getBasedir() ), blacklistedPatterns );
- indexMetadata( metadataList, indexPath, defaultRepository );
- getLogger().info( "[DiscovererExecution] Finished discovery and indexing." );
- }
-
- /**
- * Index the artifacts in the list
- *
- * @param artifacts the artifacts to be indexed
- * @param indexPath the path to the index file
- * @param repository the repository where the artifacts are located
- */
- protected void indexArtifact( List artifacts, File indexPath, ArtifactRepository repository )
- throws RepositoryIndexException
- {
- ArtifactRepositoryIndex artifactIndex = indexFactory.createArtifactRepositoryIndex( indexPath, repository );
- artifactIndex.indexArtifacts( artifacts );
- artifactIndex.optimize();
- }
-
- /**
- * Index the metadata in the list
- *
- * @param metadataList the metadata to be indexed
- * @param indexPath the path to the index file
- */
- protected void indexMetadata( List metadataList, File indexPath, ArtifactRepository repository )
- throws RepositoryIndexException
- {
- MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository );
- metadataIndex.indexMetadata( metadataList );
- metadataIndex.optimize();
- }
-
- /**
- * Index the poms in the list
- *
- * @param models list of poms that will be indexed
- * @param indexPath the path to the index
- * @param repository the artifact repository where the poms were discovered
- */
- protected void indexPom( List models, File indexPath, ArtifactRepository repository )
- throws RepositoryIndexException
- {
- PomRepositoryIndex pomIndex = indexFactory.createPomRepositoryIndex( indexPath, repository );
- pomIndex.indexPoms( models );
- pomIndex.optimize();
- }
-
- /**
- * Method that creates the artifact repository
- *
- * @return an ArtifactRepository instance
- * @throws java.net.MalformedURLException
- */
- protected ArtifactRepository getDefaultRepository( Configuration configuration )
- throws MalformedURLException
- {
- // TODO! share with general search action, should only instantiate once
- File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
- String repoDir = repositoryDirectory.toURL().toString();
- ArtifactRepositoryFactory repoFactory = new DefaultArtifactRepositoryFactory();
-
- ArtifactRepositoryLayout layout =
- (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
- return repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
- }
-}
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererJob.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererJob.java
deleted file mode 100644
index af350dced..000000000
--- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererJob.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.apache.maven.repository.manager.web.job;
-
-/*
- * Copyright 2005-2006 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.
- */
-
-import org.apache.maven.repository.indexing.RepositoryIndexException;
-import org.apache.maven.repository.manager.web.execution.DiscovererExecution;
-import org.codehaus.plexus.scheduler.AbstractJob;
-import org.quartz.JobDataMap;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-
-import java.net.MalformedURLException;
-
-/**
- * This class is the discoverer job that is executed by the scheduler.
- *
- * @plexus.component role="org.apache.maven.repository.manager.web.job.DiscovererJob"
- */
-public class DiscovererJob
- extends AbstractJob
-{
- public static final String ROLE = DiscovererJob.class.getName();
-
- public static final String MAP_DISCOVERER_EXECUTION = "EXECUTION";
-
- /**
- * Execute the discoverer and the indexer.
- *
- * @param context
- * @throws org.quartz.JobExecutionException
- *
- */
- public void execute( JobExecutionContext context )
- throws JobExecutionException
- {
- JobDataMap dataMap = context.getJobDetail().getJobDataMap();
- setJobDataMap( dataMap );
- getLogger().info( "[DiscovererJob] Start execution of DiscovererJob.." );
-
- try
- {
- DiscovererExecution execution = (DiscovererExecution) dataMap.get( MAP_DISCOVERER_EXECUTION );
- execution.executeDiscoverer();
- }
- catch ( RepositoryIndexException e )
- {
- getLogger().error( "Error indexing: " + e.getMessage(), e );
- }
- catch ( MalformedURLException me )
- {
- getLogger().error( "Error indexing: " + me.getMessage(), me );
- }
-
- getLogger().info( "[DiscovererJob] DiscovererJob has finished executing." );
- }
-
-}
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererScheduler.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererScheduler.java
deleted file mode 100644
index bad9471a2..000000000
--- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererScheduler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.apache.maven.repository.manager.web.job;
-
-/*
- * Copyright 2005-2006 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.
- */
-
-import org.apache.maven.repository.manager.web.execution.DiscovererExecution;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.scheduler.AbstractJob;
-import org.codehaus.plexus.scheduler.Scheduler;
-import org.quartz.CronTrigger;
-import org.quartz.JobDataMap;
-import org.quartz.JobDetail;
-import org.quartz.SchedulerException;
-
-import java.text.ParseException;
-
-/**
- * This class sets the job to be executed in the plexus-quartz scheduler
- *
- * @plexus.component role="org.apache.maven.repository.manager.web.job.DiscovererScheduler"
- */
-public class DiscovererScheduler
- extends AbstractLogEnabled
-{
- /**
- * @plexus.requirement
- */
- private Scheduler scheduler;
-
- /**
- * @plexus.requirement
- */
- private DiscovererExecution execution;
-
- /**
- * Method that sets the schedule in the plexus-quartz scheduler
- *
- * @param cronExpression
- * @throws ParseException
- * @throws SchedulerException
- */
- public void setSchedule( String cronExpression )
- throws ParseException, SchedulerException
- {
- JobDetail jobDetail = new JobDetail( "discovererJob", "DISCOVERER", DiscovererJob.class );
- JobDataMap dataMap = new JobDataMap();
- dataMap.put( AbstractJob.LOGGER, getLogger() );
- dataMap.put( DiscovererJob.MAP_DISCOVERER_EXECUTION, execution );
- jobDetail.setJobDataMap( dataMap );
-
- CronTrigger trigger = new CronTrigger( "DiscovererTrigger", "DISCOVERER", cronExpression );
- scheduler.scheduleJob( jobDetail, trigger );
- }
-}
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/utils/ConfigurationManager.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/utils/ConfigurationManager.java
index 793967ddc..f055590a2 100644
--- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/utils/ConfigurationManager.java
+++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/utils/ConfigurationManager.java
@@ -90,7 +90,7 @@ public class ConfigurationManager
if ( name.equals( DISCOVERY_CRON_EXPRESSION ) )
{
- config.setDiscoveryCronExpression( value );
+ config.setIndexerCronExpression( value );
}
if ( name.equals( REPOSITORY_LAYOUT ) )
{
diff --git a/maven-repository-webapp/src/main/plexus/plexus.xml b/maven-repository-webapp/src/main/plexus/plexus.xml
index d8d3b78c1..d16efcc31 100644
--- a/maven-repository-webapp/src/main/plexus/plexus.xml
+++ b/maven-repository-webapp/src/main/plexus/plexus.xml
@@ -91,4 +91,10 @@
+
+
+
+ org.apache.maven.repository.scheduler.RepositoryTaskScheduler
+
+
diff --git a/maven-repository-webapp/src/main/resources/xwork.xml b/maven-repository-webapp/src/main/resources/xwork.xml
index 9a71a8c4c..a29c0da59 100644
--- a/maven-repository-webapp/src/main/resources/xwork.xml
+++ b/maven-repository-webapp/src/main/resources/xwork.xml
@@ -101,6 +101,10 @@
/WEB-INF/jsp/admin/configure.jsp
/WEB-INF/jsp/admin/configure.jsp
+
+
+
+
diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp
index 2e6ffec66..8f70c1194 100644
--- a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp
+++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp
@@ -30,7 +30,7 @@
-
+
diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/include/quickSearchForm.jspf b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/include/quickSearchForm.jspf
new file mode 100644
index 000000000..b40dcd7be
--- /dev/null
+++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/include/quickSearchForm.jspf
@@ -0,0 +1,28 @@
+<%@ taglib prefix="ww" uri="/webwork" %>
+<%--
+ ~ Copyright 2005-2006 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.
+ --%>
+
+
+
+
+
+
+
+
+ Enter your search terms. A variety of data will be searched for your keywords.
+
+
+
\ No newline at end of file
diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/quickSearch.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/quickSearch.jsp
index aacb872a8..8cc2e22fb 100644
--- a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/quickSearch.jsp
+++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/quickSearch.jsp
@@ -26,16 +26,7 @@
Search
-
-
-
-
-
-
- Enter your search terms. A variety of data will be searched for your keywords.
-
-
-
+ <%@ include file="/WEB-INF/jsp/include/quickSearchForm.jspf" %>
-Maven Repository Manager
+Search Results
-<%@ include file="form.jspf" %>
+
+
+ <%@ include file="/WEB-INF/jsp/include/quickSearchForm.jspf" %>
-
-
- Group ID |
- Artifact ID |
- Version |
-
-
-
-
-
- |
-
-
- |
-
-
- |
-
-
-
+
+
+
+ Group |
+ Artifact |
+ Version |
+ <%-- TODO
+ Hits |
+ |
+ --%>
+
+
+
+
+ |
+ |
+ |
+ <%-- TODO: hits
+
+ org.apache.maven
+ (package)
+
+ org.apache.maven.model
+ (package)
+ |
+
+ Details
+ |
+ --%>
+
+
+
+
+
+
diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
index 4be180a5e..9ebbdd070 100644
--- a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
+++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
@@ -1,3 +1,5 @@
+<%@ taglib uri="/webwork" prefix="ww" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%--
~ Copyright 2005-2006 The Apache Software Foundation.
~
@@ -14,38 +16,55 @@
~ limitations under the License.
--%>
-<%@ taglib uri="webwork" prefix="ww" %>