From c4364eebeadb84fce1f5d5cf3e01149090d7a557 Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Tue, 6 Jun 2006 02:09:38 +0000 Subject: [PATCH] PR: MRM-116 Created a class (DiscovererExecution) that would be executed when the repository webapp is accessed and no index exists yet. It would also be invoked by the DiscovererJob once it is executed by the scheduler. git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@411971 13f79535-47bb-0310-9956-ffa450edef68 --- .../manager/web/action/BaseAction.java | 6 + .../web/execution/DiscovererExecution.java | 339 ++++++++++++++++++ .../manager/web/job/DiscovererJob.java | 182 +--------- .../manager/web/job/DiscovererScheduler.java | 58 +-- 4 files changed, 357 insertions(+), 228 deletions(-) create mode 100644 maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java 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 eaedb6342..e05cf20b4 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 @@ -18,6 +18,7 @@ package org.apache.maven.repository.manager.web.action; import com.opensymphony.xwork.Action; import org.apache.maven.repository.manager.web.job.DiscovererScheduler; +import org.apache.maven.repository.manager.web.execution.DiscovererExecution; /** * This is the Action class of index.jsp, which is the initial page of the web application. @@ -28,6 +29,10 @@ import org.apache.maven.repository.manager.web.job.DiscovererScheduler; public class BaseAction implements Action { + /** + * @plexus.requirement + */ + private DiscovererExecution execution; /** * @plexus.requirement @@ -43,6 +48,7 @@ public class BaseAction { try { + execution.executeDiscovererIfIndexDoesNotExist(); discovererScheduler.setSchedule(); } catch ( Exception e ) 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 new file mode 100644 index 000000000..7b3de21a3 --- /dev/null +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java @@ -0,0 +1,339 @@ +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.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.artifact.repository.metadata.RepositoryMetadata; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.repository.indexing.RepositoryIndexException; +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.RepositoryIndexingFactory; +import org.apache.maven.repository.manager.web.job.Configuration; +import org.apache.maven.repository.discovery.ArtifactDiscoverer; +import org.apache.maven.repository.discovery.MetadataDiscoverer; +import org.apache.maven.model.Model; +import org.apache.lucene.index.IndexReader; +import org.codehaus.plexus.logging.AbstractLogEnabled; + +import java.util.List; +import java.util.Iterator; +import java.util.Properties; +import java.io.File; +import java.net.MalformedURLException; + +/** + * This is the class that executes the discoverer and indexer. + * + * @plexus.component role="org.apache.maven.repository.manager.web.execution.DiscovererExecution" + */ +public class DiscovererExecution + extends AbstractLogEnabled +{ + /** + * @plexus.requirement + */ + private Configuration config; + + /** + * @plexus.requirement role="org.apache.maven.repository.discovery.ArtifactDiscoverer" role-hint="org.apache.maven.repository.discovery.DefaultArtifactDiscoverer" + */ + private ArtifactDiscoverer defaultArtifactDiscoverer; + + /** + * @plexus.requirement role="org.apache.maven.repository.discovery.ArtifactDiscoverer" role-hint="org.apache.maven.repository.discovery.LegacyArtifactDiscoverer" + */ + private ArtifactDiscoverer legacyArtifactDiscoverer; + + /** + * @plexus.requirement role="org.apache.maven.repository.discovery.MetadataDiscoverer" role-hint="org.apache.maven.repository.discovery.DefaultMetadataDiscoverer" + */ + private MetadataDiscoverer defaultMetadataDiscoverer; + + /** + * @plexus.requirement + */ + private RepositoryIndexingFactory indexFactory; + + /** + * @plexus.requirement + */ + private ArtifactRepositoryFactory repoFactory; + + private ArtifactRepositoryLayout layout; + + private Properties props; + + private String indexPath; + + private String blacklistedPatterns; + + private boolean includeSnapshots; + + private boolean convertSnapshots; + + private ArtifactRepository defaultRepository; + + /** + * Executes discoverer and indexer if an index does not exist yet + * + * @throws MalformedURLException + * @throws RepositoryIndexException + */ + public void executeDiscovererIfIndexDoesNotExist() + throws MalformedURLException, RepositoryIndexException + { + props = config.getProperties(); + indexPath = props.getProperty( "index.path" ); + + File indexDir = new File( indexPath ); + boolean isExisting; + + if ( IndexReader.indexExists( indexDir ) ) + { + isExisting = true; + } + else if ( !indexDir.exists() ) + { + isExisting = false; + } + else + { + isExisting = false; + } + + if ( !isExisting ) + { + executeDiscoverer(); + } + } + + /** + * Method that executes the discoverer and indexer + */ + public void executeDiscoverer() + throws MalformedURLException, RepositoryIndexException + { + props = config.getProperties(); + indexPath = props.getProperty( "index.path" ); + layout = config.getLayout(); + blacklistedPatterns = props.getProperty( "blacklist.patterns" ); + includeSnapshots = new Boolean( props.getProperty( "include.snapshots" ) ).booleanValue(); + convertSnapshots = new Boolean( props.getProperty( "convert.snapshots" ) ).booleanValue(); + + try + { + defaultRepository = getDefaultRepository(); + } + catch ( MalformedURLException me ) + { + getLogger().error( me.getMessage() ); + } + + getLogger().info( "[DiscovererExecution] Started discovery and indexing.." ); + if ( props.getProperty( "layout" ).equals( "default" ) ) + { + executeDiscovererInDefaultRepo(); + } + else if ( props.getProperty( "layout" ).equals( "legacy" ) ) + { + executeDiscovererInLegacyRepo(); + } + getLogger().info( "[DiscovererExecution] Finished discovery and indexing." ); + } + + /** + * Method that discovers and indexes artifacts, poms and metadata in a default + * m2 repository structure + * + * @throws MalformedURLException + * @throws RepositoryIndexException + */ + protected void executeDiscovererInDefaultRepo() + throws MalformedURLException, RepositoryIndexException + { + List artifacts = + defaultArtifactDiscoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, includeSnapshots ); + indexArtifact( artifacts, indexPath, defaultRepository ); + + List models = defaultArtifactDiscoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, + convertSnapshots ); + indexPom( models, indexPath, defaultRepository ); + + List metadataList = defaultMetadataDiscoverer.discoverMetadata( new File( defaultRepository + .getBasedir() ), blacklistedPatterns ); + indexMetadata( metadataList, indexPath, new File( defaultRepository.getBasedir() ) ); + } + + /** + * Method that discovers and indexes artifacts in a legacy type repository + * + * @throws RepositoryIndexException + */ + protected void executeDiscovererInLegacyRepo() + throws RepositoryIndexException + { + List artifacts = + legacyArtifactDiscoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, includeSnapshots ); + indexArtifact( artifacts, indexPath, defaultRepository ); + } + + /** + * 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, String indexPath, ArtifactRepository repository ) + throws RepositoryIndexException + { + ArtifactRepositoryIndex artifactIndex = indexFactory.createArtifactRepositoryIndex( indexPath, repository ); + for ( Iterator iter = artifacts.iterator(); iter.hasNext(); ) + { + Artifact artifact = (Artifact) iter.next(); + try + { + artifactIndex.indexArtifact( artifact ); + } + catch ( Exception e ) + { + if ( e instanceof RepositoryIndexException ) + { + throw (RepositoryIndexException) e; + } + } + + if ( artifactIndex.isOpen() ) + { + artifactIndex.optimize(); + artifactIndex.close(); + } + } + } + + /** + * Index the metadata in the list + * + * @param metadataList the metadata to be indexed + * @param indexPath the path to the index file + * @param repositoryBase the repository where the metadata are located + */ + protected void indexMetadata( List metadataList, String indexPath, File repositoryBase ) + throws RepositoryIndexException, MalformedURLException + { + String repoDir = repositoryBase.toURL().toString(); + ArtifactRepository repository = repoFactory + .createArtifactRepository( "repository", repoDir, layout, null, null ); + + MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository ); + for ( Iterator iter = metadataList.iterator(); iter.hasNext(); ) + { + RepositoryMetadata repoMetadata = (RepositoryMetadata) iter.next(); + try + { + metadataIndex.index( repoMetadata ); + } + catch ( Exception e ) + { + if ( e instanceof RepositoryIndexException ) + { + throw (RepositoryIndexException) e; + } + } + if ( metadataIndex.isOpen() ) + { + metadataIndex.optimize(); + metadataIndex.close(); + } + } + } + + /** + * 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, String indexPath, ArtifactRepository repository ) + throws RepositoryIndexException + { + PomRepositoryIndex pomIndex = indexFactory.createPomRepositoryIndex( indexPath, repository ); + for ( Iterator iter = models.iterator(); iter.hasNext(); ) + { + Model model = (Model) iter.next(); + try + { + pomIndex.indexPom( model ); + } + catch ( Exception e ) + { + if ( e instanceof RepositoryIndexException ) + { + throw (RepositoryIndexException) e; + } + } + + if ( pomIndex.isOpen() ) + { + pomIndex.optimize(); + pomIndex.close(); + } + } + } + + /** + * Method that creates the artifact repository + * + * @return an ArtifactRepository instance + * @throws java.net.MalformedURLException + */ + protected ArtifactRepository getDefaultRepository() + throws MalformedURLException + { + File repositoryDirectory = new File( config.getRepositoryDirectory() ); + String repoDir = repositoryDirectory.toURL().toString(); + ArtifactRepositoryFactory repoFactory = new DefaultArtifactRepositoryFactory(); + + return repoFactory.createArtifactRepository( "test", repoDir, config.getLayout(), null, null ); + } + + /** + * Method that sets the configuration object + * + * @param config + */ + public void setConfiguration( Configuration config ) + { + this.config = config; + } + + /** + * Returns the cofiguration + * + * @return a Configuration object that contains the configuration values + */ + public Configuration getConfiguration() + { + return config; + } +} 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 index 7e98023e9..f7a27ce5d 100644 --- 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 @@ -32,6 +32,7 @@ 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.apache.maven.repository.manager.web.execution.DiscovererExecution; import org.codehaus.plexus.scheduler.AbstractJob; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; @@ -43,7 +44,7 @@ import java.util.Iterator; import java.util.List; /** - * This class executes the discoverer and the indexer. + * This class is the discoverer job that is executed by the scheduler. * * @plexus.component role="org.apache.maven.repository.manager.web.job.DiscovererJob" */ @@ -52,41 +53,7 @@ public class DiscovererJob { public static final String ROLE = DiscovererJob.class.getName(); - private ArtifactDiscoverer defaultArtifactDiscoverer; - - private ArtifactDiscoverer legacyArtifactDiscoverer; - - private MetadataDiscoverer defaultMetadataDiscoverer; - - private RepositoryIndexingFactory indexFactory; - - private ArtifactRepositoryLayout layout; - - private ArtifactRepositoryFactory repoFactory; - - public static String MAP_INDEXPATH = "INDEXPATH"; - - public static String MAP_LAYOUT = "LAYOUT"; - - public static String MAP_DEFAULT_REPOSITORY = "DEFAULT_REPOSITORY"; - - public static String MAP_BLACKLIST = "BLACKLISTED_PATTERNS"; - - public static String MAP_SNAPSHOTS = "INCLUDE_SNAPSHOTS"; - - public static String MAP_CONVERT = "CONVERT_SNAPSHOTS"; - - public static String MAP_DEF_ARTIFACT_DISCOVERER = "DEFAULT_ARTIFACT_DISCOVERER"; - - public static String MAP_LEG_ARTIFACT_DISCOVERER = "LEGACY_ARTIFACT_DISCOVERER"; - - public static String MAP_DEF_METADATA_DISCOVERER = "DEFAULT_METADATA_DISCOVERER"; - - public static String MAP_IDX_FACTORY = "INDEX_FACTORY"; - - public static String MAP_REPO_LAYOUT = "REPOSITORY_LAYOUT"; - - public static String MAP_REPO_FACTORY = "REPOSITORY_FACTORY"; + public static String MAP_DISCOVERER_EXECUTION = "EXECUTION"; /** * Execute the discoverer and the indexer. @@ -99,47 +66,13 @@ public class DiscovererJob throws JobExecutionException { JobDataMap dataMap = context.getJobDetail().getJobDataMap(); - setJobDataMap( dataMap ); getLogger().info( "[DiscovererJob] Start execution of DiscovererJob.." ); - //configuration values specified in properties file - String indexPath = (String) dataMap.get( MAP_INDEXPATH ); - ArtifactRepository defaultRepository = (ArtifactRepository) dataMap.get( MAP_DEFAULT_REPOSITORY ); - String blacklistedPatterns = (String) dataMap.get( MAP_BLACKLIST ); - boolean includeSnapshots = ( (Boolean) dataMap.get( MAP_SNAPSHOTS ) ).booleanValue(); - boolean convertSnapshots = ( (Boolean) dataMap.get( MAP_CONVERT ) ).booleanValue(); - - //plexus components created in BaseAction - defaultArtifactDiscoverer = (DefaultArtifactDiscoverer) dataMap.get( MAP_DEF_ARTIFACT_DISCOVERER ); - legacyArtifactDiscoverer = (LegacyArtifactDiscoverer) dataMap.get( MAP_LEG_ARTIFACT_DISCOVERER ); - defaultMetadataDiscoverer = (DefaultMetadataDiscoverer) dataMap.get( MAP_DEF_METADATA_DISCOVERER ); - indexFactory = (RepositoryIndexingFactory) dataMap.get( MAP_IDX_FACTORY ); - layout = (ArtifactRepositoryLayout) dataMap.get( MAP_REPO_LAYOUT ); - repoFactory = (ArtifactRepositoryFactory) dataMap.get( MAP_REPO_FACTORY ); try { - List artifacts; - if ( dataMap.get( MAP_LAYOUT ).equals( "default" ) ) - { - artifacts = defaultArtifactDiscoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, - includeSnapshots ); - indexArtifact( artifacts, indexPath, defaultRepository ); - - List models = defaultArtifactDiscoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, - convertSnapshots ); - indexPom( models, indexPath, defaultRepository ); - - List metadataList = defaultMetadataDiscoverer.discoverMetadata( new File( defaultRepository - .getBasedir() ), blacklistedPatterns ); - indexMetadata( metadataList, indexPath, new File( defaultRepository.getBasedir() ) ); - } - else if ( dataMap.get( MAP_LAYOUT ).equals( "legacy" ) ) - { - artifacts = legacyArtifactDiscoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, - includeSnapshots ); - indexArtifact( artifacts, indexPath, defaultRepository ); - } + DiscovererExecution execution = (DiscovererExecution) dataMap.get( MAP_DISCOVERER_EXECUTION ); + execution.executeDiscoverer(); } catch ( RepositoryIndexException e ) { @@ -153,109 +86,4 @@ public class DiscovererJob getLogger().info( "[DiscovererJob] DiscovererJob has finished executing." ); } - /** - * 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 - */ - private void indexArtifact( List artifacts, String indexPath, ArtifactRepository repository ) - throws RepositoryIndexException - { - ArtifactRepositoryIndex artifactIndex = indexFactory.createArtifactRepositoryIndex( indexPath, repository ); - for ( Iterator iter = artifacts.iterator(); iter.hasNext(); ) - { - Artifact artifact = (Artifact) iter.next(); - try - { - artifactIndex.indexArtifact( artifact ); - } - catch ( Exception e ) - { - if ( e instanceof RepositoryIndexException ) - { - throw (RepositoryIndexException) e; - } - } - - if ( artifactIndex.isOpen() ) - { - artifactIndex.optimize(); - artifactIndex.close(); - } - } - } - - /** - * Index the metadata in the list - * - * @param metadataList the metadata to be indexed - * @param indexPath the path to the index file - * @param repositoryBase the repository where the metadata are located - */ - private void indexMetadata( List metadataList, String indexPath, File repositoryBase ) - throws RepositoryIndexException, MalformedURLException - { - String repoDir = repositoryBase.toURL().toString(); - ArtifactRepository repository = repoFactory - .createArtifactRepository( "repository", repoDir, layout, null, null ); - - MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository ); - for ( Iterator iter = metadataList.iterator(); iter.hasNext(); ) - { - RepositoryMetadata repoMetadata = (RepositoryMetadata) iter.next(); - try - { - metadataIndex.index( repoMetadata ); - } - catch ( Exception e ) - { - if ( e instanceof RepositoryIndexException ) - { - throw (RepositoryIndexException) e; - } - } - if ( metadataIndex.isOpen() ) - { - metadataIndex.optimize(); - metadataIndex.close(); - } - } - } - - /** - * 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 - */ - private void indexPom( List models, String indexPath, ArtifactRepository repository ) - throws RepositoryIndexException - { - PomRepositoryIndex pomIndex = indexFactory.createPomRepositoryIndex( indexPath, repository ); - for ( Iterator iter = models.iterator(); iter.hasNext(); ) - { - Model model = (Model) iter.next(); - try - { - pomIndex.indexPom( model ); - } - catch ( Exception e ) - { - if ( e instanceof RepositoryIndexException ) - { - throw (RepositoryIndexException) e; - } - } - - if ( pomIndex.isOpen() ) - { - pomIndex.optimize(); - pomIndex.close(); - } - } - } - } 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 index acf062e95..bc708234c 100644 --- 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 @@ -28,6 +28,7 @@ import org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory; import org.apache.maven.repository.discovery.ArtifactDiscoverer; import org.apache.maven.repository.discovery.MetadataDiscoverer; import org.apache.maven.repository.indexing.RepositoryIndexingFactory; +import org.apache.maven.repository.manager.web.execution.DiscovererExecution; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.scheduler.Scheduler; import org.quartz.CronTrigger; @@ -53,32 +54,12 @@ public class DiscovererScheduler */ private Scheduler scheduler; - /** - * @plexus.requirement role="org.apache.maven.repository.discovery.ArtifactDiscoverer" role-hint="org.apache.maven.repository.discovery.DefaultArtifactDiscoverer" - */ - private ArtifactDiscoverer defaultArtifactDiscoverer; - - /** - * @plexus.requirement role="org.apache.maven.repository.discovery.ArtifactDiscoverer" role-hint="org.apache.maven.repository.discovery.LegacyArtifactDiscoverer" - */ - private ArtifactDiscoverer legacyArtifactDiscoverer; - - /** - * @plexus.requirement role="org.apache.maven.repository.discovery.MetadataDiscoverer" role-hint="org.apache.maven.repository.discovery.DefaultMetadataDiscoverer" - */ - private MetadataDiscoverer defaultMetadataDiscoverer; - - /** - * @plexus.requirement - */ - private RepositoryIndexingFactory indexFactory; + private Properties props; /** * @plexus.requirement */ - private ArtifactRepositoryFactory repoFactory; - - private Properties props; + private DiscovererExecution execution; /** * Method that sets the schedule in the plexus-quartz scheduler @@ -94,40 +75,14 @@ public class DiscovererScheduler JobDetail jobDetail = new JobDetail( "discovererJob", "DISCOVERER", DiscovererJob.class ); JobDataMap dataMap = new JobDataMap(); dataMap.put( DiscovererJob.LOGGER, getLogger() ); - dataMap.put( DiscovererJob.MAP_INDEXPATH, props.getProperty( "index.path" ) ); - dataMap.put( DiscovererJob.MAP_BLACKLIST, props.getProperty( "blacklist.patterns" ) ); - dataMap.put( DiscovererJob.MAP_DEFAULT_REPOSITORY, getDefaultRepository() ); - dataMap.put( DiscovererJob.MAP_LAYOUT, props.getProperty( "layout" ) ); - dataMap.put( DiscovererJob.MAP_SNAPSHOTS, new Boolean( props.getProperty( "include.snapshots" ) ) ); - dataMap.put( DiscovererJob.MAP_CONVERT, new Boolean( props.getProperty( "convert.snapshots" ) ) ); - dataMap.put( DiscovererJob.MAP_DEF_ARTIFACT_DISCOVERER, defaultArtifactDiscoverer ); - dataMap.put( DiscovererJob.MAP_LEG_ARTIFACT_DISCOVERER, legacyArtifactDiscoverer ); - dataMap.put( DiscovererJob.MAP_DEF_METADATA_DISCOVERER, defaultMetadataDiscoverer ); - dataMap.put( DiscovererJob.MAP_IDX_FACTORY, indexFactory ); - dataMap.put( DiscovererJob.MAP_REPO_LAYOUT, config.getLayout() ); - dataMap.put( DiscovererJob.MAP_REPO_FACTORY, repoFactory ); + dataMap.put( DiscovererJob.MAP_DISCOVERER_EXECUTION, execution ); jobDetail.setJobDataMap( dataMap ); - CronTrigger trigger = new CronTrigger( "DiscovererTrigger", "DISCOVERER", props.getProperty( "cron.expression" ) ); + CronTrigger trigger = + new CronTrigger( "DiscovererTrigger", "DISCOVERER", props.getProperty( "cron.expression" ) ); scheduler.scheduleJob( jobDetail, trigger ); } - /** - * Method that creates the artifact repository - * - * @return an ArtifactRepository instance - * @throws java.net.MalformedURLException - */ - private ArtifactRepository getDefaultRepository() - throws MalformedURLException - { - File repositoryDirectory = new File( config.getRepositoryDirectory() ); - String repoDir = repositoryDirectory.toURL().toString(); - ArtifactRepositoryFactory repoFactory = new DefaultArtifactRepositoryFactory(); - - return repoFactory.createArtifactRepository( "test", repoDir, config.getLayout(), null, null ); - } - /** * Method that sets the configuration object * @@ -148,4 +103,5 @@ public class DiscovererScheduler return config; } + } -- 2.39.5