--- /dev/null
+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 <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ConfigurationChangeException
+ extends Exception
+{
+ public ConfigurationChangeException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
* 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;
}
* @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 );
}
}
public void storeConfiguration( Configuration configuration )
- throws ConfigurationStoreException
+ throws ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException
{
for ( Iterator i = listeners.iterator(); i.hasNext(); )
{
IOUtil.close( fileWriter );
}
}
+
+ public void addChangeListener( ConfigurationChangeListener listener )
+ {
+ listeners.add( listener );
+ }
}
--- /dev/null
+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 <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+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;
+ }
+}
</description>
</field>
<field>
- <name>discoveryCronExpression</name>
+ <name>indexerCronExpression</name>
<version>1.0.0</version>
<type>String</type>
- <description>When to run the discovery mechanism.</description>
- <defaultValue>0 0 8 * * ?</defaultValue>
+ <description>When to run the indexing mechanism. Default is every hour on the hour.</description>
+ <defaultValue>0 0 * * * ?</defaultValue>
+ </field>
+ <field>
+ <name>converterCronExpression</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>When to run the converter mechanism. Default is every 4 hours, on the half hour.</description>
+ <defaultValue>0 30 0/4 * * ?</defaultValue>
</field>
<field>
<name>discoverSnapshots</name>
<artifactId>maven-repository-core</artifactId>
<name>Maven Repository Manager Core</name>
<dependencies>
+ <dependency>
+ <groupId>org.apache.maven.repository</groupId>
+ <artifactId>maven-repository-configuration</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-converter</artifactId>
<dependency>
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-reports-standard</artifactId>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-quartz</artifactId>
+ <version>1.0-alpha-2</version>
+ </dependency>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
--- /dev/null
+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 <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public interface ConfiguredRepositoryFactory
+{
+ String ROLE = ConfiguredRepositoryFactory.class.getName();
+
+ /**
+ * Create an artifact repository from the given configuration.
+ *
+ * @param configuration the configuration
+ */
+ ArtifactRepository createRepository( Configuration configuration );
+}
--- /dev/null
+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 <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @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 );
+ }
+}
--- /dev/null
+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 <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @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();
+
+ }
+}
--- /dev/null
+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 <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @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();
+ }
+}
--- /dev/null
+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 <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+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;
+}
--- /dev/null
+package org.apache.maven.repository.scheduler;\r
+\r
+/*\r
+ * Copyright 2005-2006 The Apache Software Foundation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+import org.codehaus.plexus.scheduler.AbstractJob;\r
+import org.quartz.JobDataMap;\r
+import org.quartz.JobExecutionContext;\r
+import org.quartz.JobExecutionException;\r
+\r
+/**\r
+ * This class is the discoverer job that is executed by the scheduler.\r
+ */\r
+public class RepositoryTaskJob\r
+ extends AbstractJob\r
+{\r
+ static final String TASK_KEY = "EXECUTION";\r
+\r
+ /**\r
+ * Execute the discoverer and the indexer.\r
+ *\r
+ * @param context\r
+ * @throws org.quartz.JobExecutionException\r
+ *\r
+ */\r
+ public void execute( JobExecutionContext context )\r
+ throws JobExecutionException\r
+ {\r
+ JobDataMap dataMap = context.getJobDetail().getJobDataMap();\r
+ setJobDataMap( dataMap );\r
+\r
+ RepositoryTask executor = (RepositoryTask) dataMap.get( TASK_KEY );\r
+ try\r
+ {\r
+ executor.execute();\r
+ }\r
+ catch ( TaskExecutionException e )\r
+ {\r
+ throw new JobExecutionException( e );\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+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 <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public interface RepositoryTaskScheduler
+{
+ /**
+ * The Plexus component role.
+ */
+ String ROLE = RepositoryTaskScheduler.class.getName();
+
+ void runIndexer()
+ throws TaskExecutionException;
+}
--- /dev/null
+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 <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class TaskExecutionException
+ extends Exception
+{
+ public TaskExecutionException( String message, Throwable t )
+ {
+ super( message, t );
+ }
+}
<artifactId>sitemesh</artifactId>
<version>2.2.1</version>
</dependency>
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>jstl</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.1.2</version>
+ </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xwork-integration-single</artifactId>
import com.opensymphony.webwork.interceptor.ParameterAware;\r
import com.opensymphony.xwork.ActionSupport;\r
import org.apache.maven.repository.configuration.Configuration;\r
-import org.apache.maven.repository.manager.web.execution.DiscovererExecution;\r
-import org.apache.maven.repository.manager.web.job.DiscovererScheduler;\r
+import org.apache.maven.repository.configuration.ConfigurationStore;\r
import org.apache.maven.repository.manager.web.utils.ConfigurationManager;\r
\r
import java.util.HashMap;\r
* It invokes the DiscovererScheduler to set the DiscoverJob in the scheduler.\r
*\r
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="baseAction"\r
+ * @todo don't like this as a base and as a forwarding action!\r
*/\r
public class BaseAction\r
extends ActionSupport\r
implements ParameterAware\r
{\r
- /**\r
- * @plexus.requirement\r
- */\r
- private DiscovererExecution execution;\r
-\r
- /**\r
- * @plexus.requirement\r
- */\r
- private DiscovererScheduler discovererScheduler;\r
\r
/**\r
* @plexus.requirement\r
*/\r
- private ConfigurationManager configManager;\r
+ private ConfigurationStore configurationStore;\r
\r
private Map parameters;\r
\r
{\r
try\r
{\r
- Configuration config = configManager.getConfiguration();\r
+ Configuration config = configurationStore.getConfigurationFromStore();\r
Map parameters = new HashMap();\r
parameters.put( ConfigurationManager.INDEXPATH, config.getIndexPath() );\r
parameters.put( ConfigurationManager.MIN_INDEXPATH, config.getMinimalIndexPath() );\r
parameters.put( ConfigurationManager.DISCOVERY_BLACKLIST_PATTERNS, config.getDiscoveryBlackListPatterns() );\r
parameters.put( ConfigurationManager.DISCOVER_SNAPSHOTS, Boolean.valueOf( config.isDiscoverSnapshots() ) );\r
- parameters.put( ConfigurationManager.DISCOVERY_CRON_EXPRESSION, config.getDiscoveryCronExpression() );\r
+ parameters.put( ConfigurationManager.DISCOVERY_CRON_EXPRESSION, config.getIndexerCronExpression() );\r
this.parameters = parameters;\r
\r
//Configuration configuration = new Configuration(); // TODO!\r
// execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );\r
- discovererScheduler.setSchedule( config.getDiscoveryCronExpression() );\r
}\r
catch ( Exception e )\r
{\r
\r
import com.opensymphony.xwork.Action;\r
import org.apache.maven.artifact.repository.ArtifactRepository;\r
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;\r
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;\r
import org.apache.maven.repository.configuration.Configuration;\r
+import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;\r
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;\r
import org.apache.maven.repository.indexing.RepositoryIndexException;\r
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;\r
import java.io.File;\r
import java.net.MalformedURLException;\r
import java.util.List;\r
-import java.util.Map;\r
\r
/**\r
* Searches for searchString in all indexed fields.\r
/**\r
* @plexus.requirement\r
*/\r
- private ArtifactRepositoryFactory repositoryFactory;\r
-\r
- /**\r
- * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"\r
- */\r
- private Map repositoryLayouts;\r
+ private ConfiguredRepositoryFactory repositoryFactory;\r
\r
public String execute()\r
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException\r
Configuration configuration = new Configuration(); // TODO!\r
File indexPath = new File( configuration.getIndexPath() );\r
\r
- // TODO: [!] repository should only have been instantiated once\r
- File repositoryDirectory = new File( configuration.getRepositoryDirectory() );\r
- String repoDir = repositoryDirectory.toURL().toString();\r
-\r
- ArtifactRepositoryLayout layout =\r
- (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );\r
- ArtifactRepository repository =\r
- repositoryFactory.createArtifactRepository( "test", repoDir, layout, null, null );\r
+ ArtifactRepository repository = repositoryFactory.createRepository( configuration );\r
\r
ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );\r
\r
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;
import java.io.File;
import java.net.MalformedURLException;
import java.util.List;
-import java.util.Map;
/**
* Search by package name.
*/
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
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 );
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;
/**
* Search results.
*/
- private List searchResult;
+ private List searchResults;
/**
* @plexus.requirement
/**
* @plexus.requirement
*/
- private ArtifactRepositoryFactory repositoryFactory;
+ private ConfiguredRepositoryFactory repositoryFactory;
/**
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
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 );
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;
this.q = q;
}
- public List getSearchResult()
+ public List getSearchResults()
{
- return searchResult;
+ return searchResults;
}
}
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;
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
}
public void prepare()
- throws Exception
+ throws ConfigurationStoreException
{
configuration = configurationStore.getConfigurationFromStore();
}
--- /dev/null
+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;
+ }
+}
+++ /dev/null
-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 );
- }
-}
+++ /dev/null
-package org.apache.maven.repository.manager.web.job;\r
-\r
-/*\r
- * Copyright 2005-2006 The Apache Software Foundation.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-import org.apache.maven.repository.indexing.RepositoryIndexException;\r
-import org.apache.maven.repository.manager.web.execution.DiscovererExecution;\r
-import org.codehaus.plexus.scheduler.AbstractJob;\r
-import org.quartz.JobDataMap;\r
-import org.quartz.JobExecutionContext;\r
-import org.quartz.JobExecutionException;\r
-\r
-import java.net.MalformedURLException;\r
-\r
-/**\r
- * This class is the discoverer job that is executed by the scheduler.\r
- *\r
- * @plexus.component role="org.apache.maven.repository.manager.web.job.DiscovererJob"\r
- */\r
-public class DiscovererJob\r
- extends AbstractJob\r
-{\r
- public static final String ROLE = DiscovererJob.class.getName();\r
-\r
- public static final String MAP_DISCOVERER_EXECUTION = "EXECUTION";\r
-\r
- /**\r
- * Execute the discoverer and the indexer.\r
- *\r
- * @param context\r
- * @throws org.quartz.JobExecutionException\r
- *\r
- */\r
- public void execute( JobExecutionContext context )\r
- throws JobExecutionException\r
- {\r
- JobDataMap dataMap = context.getJobDetail().getJobDataMap();\r
- setJobDataMap( dataMap );\r
- getLogger().info( "[DiscovererJob] Start execution of DiscovererJob.." );\r
-\r
- try\r
- {\r
- DiscovererExecution execution = (DiscovererExecution) dataMap.get( MAP_DISCOVERER_EXECUTION );\r
- execution.executeDiscoverer();\r
- }\r
- catch ( RepositoryIndexException e )\r
- {\r
- getLogger().error( "Error indexing: " + e.getMessage(), e );\r
- }\r
- catch ( MalformedURLException me )\r
- {\r
- getLogger().error( "Error indexing: " + me.getMessage(), me );\r
- }\r
-\r
- getLogger().info( "[DiscovererJob] DiscovererJob has finished executing." );\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.apache.maven.repository.manager.web.job;\r
-\r
-/*\r
- * Copyright 2005-2006 The Apache Software Foundation.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-import org.apache.maven.repository.manager.web.execution.DiscovererExecution;\r
-import org.codehaus.plexus.logging.AbstractLogEnabled;\r
-import org.codehaus.plexus.scheduler.AbstractJob;\r
-import org.codehaus.plexus.scheduler.Scheduler;\r
-import org.quartz.CronTrigger;\r
-import org.quartz.JobDataMap;\r
-import org.quartz.JobDetail;\r
-import org.quartz.SchedulerException;\r
-\r
-import java.text.ParseException;\r
-\r
-/**\r
- * This class sets the job to be executed in the plexus-quartz scheduler\r
- *\r
- * @plexus.component role="org.apache.maven.repository.manager.web.job.DiscovererScheduler"\r
- */\r
-public class DiscovererScheduler\r
- extends AbstractLogEnabled\r
-{\r
- /**\r
- * @plexus.requirement\r
- */\r
- private Scheduler scheduler;\r
-\r
- /**\r
- * @plexus.requirement\r
- */\r
- private DiscovererExecution execution;\r
-\r
- /**\r
- * Method that sets the schedule in the plexus-quartz scheduler\r
- *\r
- * @param cronExpression\r
- * @throws ParseException\r
- * @throws SchedulerException\r
- */\r
- public void setSchedule( String cronExpression )\r
- throws ParseException, SchedulerException\r
- {\r
- JobDetail jobDetail = new JobDetail( "discovererJob", "DISCOVERER", DiscovererJob.class );\r
- JobDataMap dataMap = new JobDataMap();\r
- dataMap.put( AbstractJob.LOGGER, getLogger() );\r
- dataMap.put( DiscovererJob.MAP_DISCOVERER_EXECUTION, execution );\r
- jobDetail.setJobDataMap( dataMap );\r
-\r
- CronTrigger trigger = new CronTrigger( "DiscovererTrigger", "DISCOVERER", cronExpression );\r
- scheduler.scheduleJob( jobDetail, trigger );\r
- }\r
-}\r
if ( name.equals( DISCOVERY_CRON_EXPRESSION ) )
{
- config.setDiscoveryCronExpression( value );
+ config.setIndexerCronExpression( value );
}
if ( name.equals( REPOSITORY_LAYOUT ) )
{
</lifecycle-handler>
</lifecycle-handlers>
</lifecycle-handler-manager>
+
+ <load-on-start>
+ <component>
+ <role>org.apache.maven.repository.scheduler.RepositoryTaskScheduler</role>
+ </component>
+ </load-on-start>
</plexus>
<result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
<result>/WEB-INF/jsp/admin/configure.jsp</result>
</action>
+
+ <action name="runIndexer" class="runIndexerAction">
+ <!-- TODO: back to page where this comes from! -->
+ </action>
</package>
</xwork>
<ww:actionmessage />
<ww:form method="post" action="saveConfiguration" namespace="/admin" validate="true">
<ww:textfield name="repositoryDirectory" label="Repository Directory" size="100" />
- <ww:textfield name="discoveryCronExpression" label="Discovery Cron Expression" />
+ <ww:textfield name="indexerCronExpression" label="Indexing Cron Expression" />
<ww:submit value="Save Configuration" />
</ww:form>
</div>
--- /dev/null
+<%@ 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.
+ --%>
+
+<div id="searchBox">
+ <ww:form method="post" action="quickSearch" validate="true">
+ <ww:textfield label="Search for" size="50" name="q" />
+ <ww:submit label="Go!" />
+ </ww:form>
+
+ <p>
+ Enter your search terms. A variety of data will be searched for your keywords.
+ <ww:actionerror />
+ </p>
+</div>
\ No newline at end of file
<h1>Search</h1>
<div id="contentArea">
- <div id="searchBox">
- <ww:form method="post" action="quickSearch" validate="true">
- <ww:textfield label="Search for" size="50" name="q" />
- <ww:submit label="Go!" />
- </ww:form>
- <p>
- Enter your search terms. A variety of data will be searched for your keywords.
- <ww:actionerror />
- </p>
- </div>
+ <%@ include file="/WEB-INF/jsp/include/quickSearchForm.jspf" %>
</div>
</body>
+<%@ taglib uri="/webwork" prefix="ww" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%--
~ Copyright 2005-2006 The Apache Software Foundation.
~
~ limitations under the License.
--%>
-<%@ taglib uri="webwork" prefix="ww" %>
<html>
<head>
- <title>Maven Repository Manager</title>
+ <title>Search Results</title>
+ <ww:head />
</head>
<body>
-<h1>Maven Repository Manager</h1>
+<h1>Search Results</h1>
-<%@ include file="form.jspf" %>
+<div id="contentArea">
+ <div id="searchBox">
+ <%@ include file="/WEB-INF/jsp/include/quickSearchForm.jspf" %>
-<table border="1px" cellspacing="0">
- <tr>
- <th>Group ID</th>
- <th>Artifact ID</th>
- <th>Version</th>
- </tr>
- <ww:iterator value="searchResult">
- <tr>
- <td valign="top">
- <ww:property value="Artifact.getGroupId()"/>
- </td>
- <td valign="top">
- <ww:property value="Artifact.getArtifactId()"/>
- </td>
- <td valign="top">
- <ww:property value="Artifact.getVersion()"/>
- </td>
- </tr>
- </ww:iterator>
-</table>
+ <div id="resultsBox">
+ <table class="bodyTable">
+ <tr class="a">
+ <th>Group</th>
+ <th>Artifact</th>
+ <th>Version</th>
+ <%-- TODO
+ <th>Hits</th>
+ <th></th>
+ --%>
+ </tr>
+ <ww:set name="searchResults" scope="request" value="searchResults" />
+ <c:forEach items="${searchResults}" var="result" varStatus="i">
+ <tr class="${i.index % 2 == 0 ? "b" : "a"}">
+ <td><c:out value="${result.artifact.groupId}" /></td>
+ <td><c:out value="${result.artifact.artifactId}" /></td>
+ <td><c:out value="${result.artifact.version}" /></td>
+ <%-- TODO: hits
+ <td>
+ <code>org.apache.maven</code>
+ (package)
+ <br/>
+ <code>org.apache.maven.model</code>
+ (package)
+ </td>
+ <td>
+ <a href="artifact.html">Details</a>
+ </td>
+ --%>
+ </tr>
+ </c:forEach>
+ </table>
+ </div>
+ </div>
+</div>
</body>
</html>