From 7a5b4547afed45765c84495ad434a36fcba6352d Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 28 Jun 2006 05:45:08 +0000 Subject: [PATCH] clean up some issues and bugs highlighted by inspections git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@417674 13f79535-47bb-0310-9956-ffa450edef68 --- .../converter/DefaultRepositoryConverter.java | 73 ++++++------------- .../repository/DefaultRepositoryManager.java | 9 +-- .../discovery/AbstractArtifactDiscoverer.java | 13 ++-- .../discovery/DefaultArtifactDiscoverer.java | 19 +++-- .../repository/discovery/DiscovererPath.java | 27 +++---- .../indexing/AbstractRepositoryIndex.java | 13 ++-- .../repository/indexing/RepositoryIndex.java | 57 ++++++++------- .../configuration/ProxyConfiguration.java | 4 +- .../maven/repository/reporting/Cache.java | 4 +- .../repository/digest/DefaultDigester.java | 6 +- .../manager/web/action/BaseAction.java | 8 +- .../web/action/IndexConfigurationAction.java | 14 ++-- .../action/SchedulerConfigurationAction.java | 32 +++++--- .../web/execution/DiscovererExecution.java | 2 +- .../web/utils/ConfigurationManager.java | 12 +-- 15 files changed, 133 insertions(+), 160 deletions(-) diff --git a/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java b/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java index 28d398bee..f0cc1248c 100644 --- a/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java +++ b/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java @@ -105,9 +105,7 @@ public class DefaultRepositoryConverter */ private I18N i18n; - public void convert( Artifact artifact, - ArtifactRepository targetRepository, - ArtifactReporter reporter ) + public void convert( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter ) throws RepositoryConversionException { if ( artifact.getRepository().getUrl().equals( targetRepository.getUrl() ) ) @@ -165,15 +163,13 @@ public class DefaultRepositoryConverter return metadata; } - private void updateMetadata( RepositoryMetadata artifactMetadata, - ArtifactRepository sourceRepository, - ArtifactRepository targetRepository, - Metadata newMetadata, + private void updateMetadata( RepositoryMetadata artifactMetadata, ArtifactRepository sourceRepository, + ArtifactRepository targetRepository, Metadata newMetadata, FileTransaction transaction ) throws RepositoryConversionException { Metadata metadata; - boolean changed = false; + boolean changed; //merge with target repository metadata File file = new File( targetRepository.getBasedir(), @@ -198,7 +194,7 @@ public class DefaultRepositoryConverter if ( srcfile.exists() ) { Metadata sourceMetadata = readMetadata( srcfile ); - changed = changed | metadata.merge( sourceMetadata ); + changed = changed || metadata.merge( sourceMetadata ); } } @@ -256,8 +252,7 @@ public class DefaultRepositoryConverter return metadata; } - private boolean validateMetadata( Artifact artifact, - ArtifactReporter reporter ) + private boolean validateMetadata( Artifact artifact, ArtifactReporter reporter ) throws RepositoryConversionException { ArtifactRepository repository = artifact.getRepository(); @@ -284,9 +279,7 @@ public class DefaultRepositoryConverter return result; } - private boolean validateMetadata( Metadata metadata, - RepositoryMetadata repositoryMetadata, - Artifact artifact, + private boolean validateMetadata( Metadata metadata, RepositoryMetadata repositoryMetadata, Artifact artifact, ArtifactReporter reporter ) { String groupIdKey; @@ -388,9 +381,7 @@ public class DefaultRepositoryConverter return result; } - private boolean copyPom( Artifact artifact, - ArtifactRepository targetRepository, - ArtifactReporter reporter, + private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter, FileTransaction transaction ) throws RepositoryConversionException { @@ -505,10 +496,8 @@ public class DefaultRepositoryConverter return result; } - private boolean doRelocation( Artifact artifact, - org.apache.maven.model.v3_0_0.Model v3Model, - ArtifactRepository repository, - FileTransaction transaction ) + private boolean doRelocation( Artifact artifact, org.apache.maven.model.v3_0_0.Model v3Model, + ArtifactRepository repository, FileTransaction transaction ) throws IOException { Properties properties = v3Model.getProperties(); @@ -551,15 +540,9 @@ public class DefaultRepositoryConverter } } - private void writeRelocationPom( String groupId, - String artifactId, - String version, - String newGroupId, - String newArtifactId, - String newVersion, - String message, - ArtifactRepository repository, - FileTransaction transaction ) + private void writeRelocationPom( String groupId, String artifactId, String version, String newGroupId, + String newArtifactId, String newVersion, String message, + ArtifactRepository repository, FileTransaction transaction ) throws IOException { Model pom = new Model(); @@ -592,8 +575,7 @@ public class DefaultRepositoryConverter transaction.createFile( strWriter.toString(), pomFile ); } - private String getI18NString( String key, - String arg0 ) + private String getI18NString( String key, String arg0 ) { return i18n.format( getClass().getName(), Locale.getDefault(), key, arg0 ); } @@ -603,26 +585,19 @@ public class DefaultRepositoryConverter return i18n.getString( getClass().getName(), Locale.getDefault(), key ); } - private boolean testChecksums( Artifact artifact, - File file, - ArtifactReporter reporter ) - throws IOException, RepositoryConversionException + private boolean testChecksums( Artifact artifact, File file, ArtifactReporter reporter ) + throws IOException { - boolean result; - result = verifyChecksum( file, file.getName() + ".md5", Digester.MD5, reporter, artifact, - "failure.incorrect.md5" ); + boolean result = + verifyChecksum( file, file.getName() + ".md5", Digester.MD5, reporter, artifact, "failure.incorrect.md5" ); result = result && verifyChecksum( file, file.getName() + ".sha1", Digester.SHA1, reporter, artifact, "failure.incorrect.sha1" ); return result; } - private boolean verifyChecksum( File file, - String fileName, - String algorithm, - ArtifactReporter reporter, - Artifact artifact, - String key ) + private boolean verifyChecksum( File file, String fileName, String algorithm, ArtifactReporter reporter, + Artifact artifact, String key ) throws IOException { boolean result = true; @@ -644,9 +619,7 @@ public class DefaultRepositoryConverter return result; } - private boolean copyArtifact( Artifact artifact, - ArtifactRepository targetRepository, - ArtifactReporter reporter, + private boolean copyArtifact( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter, FileTransaction transaction ) throws RepositoryConversionException { @@ -689,9 +662,7 @@ public class DefaultRepositoryConverter return result; } - public void convert( List artifacts, - ArtifactRepository targetRepository, - ArtifactReporter reporter ) + public void convert( List artifacts, ArtifactRepository targetRepository, ArtifactReporter reporter ) throws RepositoryConversionException { for ( Iterator i = artifacts.iterator(); i.hasNext(); ) diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/DefaultRepositoryManager.java b/maven-repository-core/src/main/java/org/apache/maven/repository/DefaultRepositoryManager.java index e63620338..741718902 100644 --- a/maven-repository-core/src/main/java/org/apache/maven/repository/DefaultRepositoryManager.java +++ b/maven-repository-core/src/main/java/org/apache/maven/repository/DefaultRepositoryManager.java @@ -1,16 +1,16 @@ package org.apache.maven.repository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; 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.converter.RepositoryConversionException; import org.apache.maven.repository.converter.RepositoryConverter; import org.apache.maven.repository.discovery.ArtifactDiscoverer; import org.apache.maven.repository.reporting.ArtifactReporter; import java.io.File; -import java.util.List; import java.net.MalformedURLException; +import java.util.List; /** * @author Jason van Zyl @@ -49,8 +49,7 @@ public class DefaultRepositoryManager */ private ArtifactReporter reporter; - public void convertLegacyRepository( File legacyRepositoryDirectory, - File repositoryDirectory, + public void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory, boolean includeSnapshots ) throws RepositoryConversionException { diff --git a/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java b/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java index 70f17c9f8..0da2fabce 100644 --- a/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java +++ b/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java @@ -59,9 +59,9 @@ public abstract class AbstractArtifactDiscoverer /** * Return a list of artifacts found in a specified repository * - * @param repository The ArtifactRepository to discover artifacts + * @param repository The ArtifactRepository to discover artifacts * @param blacklistedPatterns Comma-delimited list of string paths that will be excluded in the discovery - * @param includeSnapshots if the repository contains snapshots which should also be included + * @param includeSnapshots if the repository contains snapshots which should also be included * @return list of artifacts */ public List discoverArtifacts( ArtifactRepository repository, String blacklistedPatterns, boolean includeSnapshots ) @@ -81,10 +81,9 @@ public abstract class AbstractArtifactDiscoverer { String path = artifactPaths[i]; - Artifact artifact; try { - artifact = buildArtifactFromPath( path, repository ); + Artifact artifact = buildArtifactFromPath( path, repository ); if ( includeSnapshots || !artifact.isSnapshot() ) { @@ -103,9 +102,9 @@ public abstract class AbstractArtifactDiscoverer /** * Returns a list of pom packaging artifacts found in a specified repository * - * @param repository The ArtifactRepository to discover artifacts + * @param repository The ArtifactRepository to discover artifacts * @param blacklistedPatterns Comma-delimited list of string paths that will be excluded in the discovery - * @param includeSnapshots if the repository contains snapshots which should also be included + * @param includeSnapshots if the repository contains snapshots which should also be included * @return list of pom artifacts */ public List discoverStandalonePoms( ArtifactRepository repository, String blacklistedPatterns, @@ -167,7 +166,7 @@ public abstract class AbstractArtifactDiscoverer /** * Returns an artifact object that is represented by the specified path in a repository * - * @param path The path that is pointing to an artifact + * @param path The path that is pointing to an artifact * @param repository The repository of the artifact * @return Artifact * @throws DiscovererException when the specified path does correspond to an artifact diff --git a/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java b/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java index e0fc3c21e..d3b472fbd 100644 --- a/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java +++ b/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java @@ -49,7 +49,7 @@ public class DefaultArtifactDiscoverer Collections.reverse( pathParts ); - Artifact artifact = null; + Artifact artifact; if ( pathParts.size() >= 4 ) { // maven 2.x path @@ -111,13 +111,13 @@ public class DefaultArtifactDiscoverer Artifact result; if ( classifier == null ) { - result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, - type ); + result = + artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, type ); } else { - result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, - classifier ); + result = + artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier ); } if ( result.isSnapshot() ) @@ -128,9 +128,8 @@ public class DefaultArtifactDiscoverer { classifier = remainingFilename.substring( classifierIndex + 1 ); remainingFilename = remainingFilename.substring( 0, classifierIndex ); - result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, - remainingFilename, type, - classifier ); + result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, remainingFilename, + type, classifier ); } else { @@ -145,8 +144,8 @@ public class DefaultArtifactDiscoverer } else if ( !result.getBaseVersion().equals( version ) ) { - throw new DiscovererException( "Built snapshot artifact base version does not match " + - "path version" ); + throw new DiscovererException( + "Built snapshot artifact base version does not match " + "path version" ); } else { diff --git a/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java b/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java index 20f621d6f..ae2ecee73 100644 --- a/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java +++ b/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java @@ -21,17 +21,20 @@ package org.apache.maven.repository.discovery; */ public class DiscovererPath { - private String path; - private String comment; + /** + * The path discovered. + */ + private final String path; - public DiscovererPath() - { - } + /** + * A comment about why the path is being processed. + */ + private final String comment; public DiscovererPath( String path, String comment ) { - setPath( path ); - setComment( comment ); + this.path = path; + this.comment = comment; } public String getPath() @@ -39,18 +42,8 @@ public class DiscovererPath return path; } - public void setPath( String path ) - { - this.path = path; - } - public String getComment() { return comment; } - - public void setComment( String comment ) - { - this.comment = comment; - } } diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndex.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndex.java index 30ea608b2..2b9af2822 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndex.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndex.java @@ -20,19 +20,19 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.CharTokenizer; import org.apache.lucene.analysis.SimpleAnalyzer; import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.Term; -import org.apache.lucene.document.Document; import org.apache.maven.artifact.repository.ArtifactRepository; import java.io.File; import java.io.IOException; import java.io.Reader; import java.util.Collection; -import java.util.List; -import java.util.Iterator; import java.util.Collections; +import java.util.Iterator; +import java.util.List; import java.util.zip.ZipEntry; /** @@ -71,8 +71,7 @@ public abstract class AbstractRepositoryIndex } catch ( IOException e ) { - throw new RepositoryIndexException( "Failed to validate index path: " + - getIndexPath().getAbsolutePath(), e ); + throw new RepositoryIndexException( "Failed to validate index path: " + indexPath.getAbsolutePath(), e ); } } @@ -148,7 +147,7 @@ public abstract class AbstractRepositoryIndex /** * @see RepositoryIndex#validate() */ - public void validate() + public final void validate() throws RepositoryIndexException, IOException { if ( indexExists() ) @@ -201,7 +200,7 @@ public abstract class AbstractRepositoryIndex } /** - * @see RepositoryIndex#deleteDocuments(java.util.List) + * @see RepositoryIndex#deleteDocuments(java.util.List) */ public void deleteDocuments( List termList ) throws RepositoryIndexException, IOException diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java index 8fb8ff73e..d77c70969 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java @@ -26,61 +26,62 @@ import java.util.List; /** * @author Edwin Punzalan + * @todo can we move all of these constants out of the interface? Perhaps they should be an enumerated type? */ public interface RepositoryIndex { - static final String POM = "POM"; + String POM = "POM"; - static final String METADATA = "METADATA"; + String METADATA = "METADATA"; - static final String ARTIFACT = "ARTIFACT"; + String ARTIFACT = "ARTIFACT"; - static final String FLD_ID = "id"; + String FLD_ID = "id"; - static final String FLD_NAME = "name"; + String FLD_NAME = "name"; - static final String FLD_DOCTYPE = "doctype"; + String FLD_DOCTYPE = "doctype"; - static final String FLD_GROUPID = "groupId"; + String FLD_GROUPID = "groupId"; - static final String FLD_ARTIFACTID = "artifactId"; + String FLD_ARTIFACTID = "artifactId"; - static final String FLD_VERSION = "version"; + String FLD_VERSION = "version"; - static final String FLD_PACKAGING = "packaging"; + String FLD_PACKAGING = "packaging"; - static final String FLD_SHA1 = "sha1"; + String FLD_SHA1 = "sha1"; - static final String FLD_MD5 = "md5"; + String FLD_MD5 = "md5"; - static final String FLD_LASTUPDATE = "last update"; + String FLD_LASTUPDATE = "last update"; - static final String FLD_PLUGINPREFIX = "plugin prefix"; + String FLD_PLUGINPREFIX = "plugin prefix"; - static final String FLD_CLASSES = "class"; + String FLD_CLASSES = "class"; - static final String FLD_PACKAGES = "package"; + String FLD_PACKAGES = "package"; - static final String FLD_FILES = "file"; + String FLD_FILES = "file"; - static final String FLD_LICENSE_URLS = "license url"; + String FLD_LICENSE_URLS = "license url"; - static final String FLD_DEPENDENCIES = "dependency"; + String FLD_DEPENDENCIES = "dependency"; - static final String FLD_PLUGINS_BUILD = "build plugin"; + String FLD_PLUGINS_BUILD = "build plugin"; - static final String FLD_PLUGINS_REPORT = "report plugin"; + String FLD_PLUGINS_REPORT = "report plugin"; - static final String FLD_PLUGINS_ALL = "plugins_all"; + String FLD_PLUGINS_ALL = "plugins_all"; - static final String[] FIELDS = {FLD_ID, FLD_NAME, FLD_DOCTYPE, FLD_GROUPID, FLD_ARTIFACTID, FLD_VERSION, FLD_PACKAGING, FLD_SHA1, + String[] FIELDS = {FLD_ID, FLD_NAME, FLD_DOCTYPE, FLD_GROUPID, FLD_ARTIFACTID, FLD_VERSION, FLD_PACKAGING, FLD_SHA1, FLD_MD5, FLD_LASTUPDATE, FLD_PLUGINPREFIX, FLD_CLASSES, FLD_PACKAGES, FLD_FILES, FLD_LICENSE_URLS, FLD_DEPENDENCIES, FLD_PLUGINS_BUILD, FLD_PLUGINS_REPORT, FLD_PLUGINS_ALL}; - static final List KEYWORD_FIELDS = Arrays.asList( new String[]{FLD_ID, FLD_PACKAGING, FLD_LICENSE_URLS, FLD_DEPENDENCIES, + List KEYWORD_FIELDS = Arrays.asList( new String[]{FLD_ID, FLD_PACKAGING, FLD_LICENSE_URLS, FLD_DEPENDENCIES, FLD_PLUGINS_BUILD, FLD_PLUGINS_REPORT, FLD_PLUGINS_ALL} ); - static final String[] MODEL_FIELDS = {FLD_PACKAGING, FLD_LICENSE_URLS, FLD_DEPENDENCIES, FLD_PLUGINS_BUILD, FLD_PLUGINS_REPORT}; + String[] MODEL_FIELDS = {FLD_PACKAGING, FLD_LICENSE_URLS, FLD_DEPENDENCIES, FLD_PLUGINS_BUILD, FLD_PLUGINS_REPORT}; ArtifactRepository getRepository(); @@ -117,7 +118,7 @@ public interface RepositoryIndex * * @throws RepositoryIndexException if the given indexPath is not valid for this type of RepositoryIndex */ - public void validate() + void validate() throws RepositoryIndexException, IOException; /** @@ -127,7 +128,7 @@ public interface RepositoryIndex * @param docList List of Lucene Documents * @throws RepositoryIndexException when an error occurred during the indexing of the documents */ - public void addDocuments( List docList ) + void addDocuments( List docList ) throws RepositoryIndexException; /** @@ -137,6 +138,6 @@ public interface RepositoryIndex * @throws RepositoryIndexException * @throws IOException */ - public void deleteDocuments( List termList ) + void deleteDocuments( List termList ) throws RepositoryIndexException, IOException; } diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/ProxyConfiguration.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/ProxyConfiguration.java index b23c89570..859c27700 100644 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/ProxyConfiguration.java +++ b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/ProxyConfiguration.java @@ -155,7 +155,7 @@ public class ProxyConfiguration validateDirectories(); } - private void validateRemoteRepo( ) + private void validateRemoteRepo() throws ValidationException { //Verify remote repository set @@ -169,7 +169,7 @@ public class ProxyConfiguration private void validateDirectories() throws ValidationException { - File f = new File( getRepositoryCachePath() ); + File f = new File( cachePath ); if ( !f.exists() ) { throw new ValidationException( "Specified directory does not exist: " + f.getAbsolutePath() ); diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/Cache.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/Cache.java index 1c894d6af..8f695f91d 100644 --- a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/Cache.java +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/Cache.java @@ -134,14 +134,12 @@ public class Cache */ public void put( Object key, Object value ) { - Object old = null; - // remove and put: this promotes it to the top since we use a linked hash map synchronized ( cache ) { if ( cache.containsKey( key ) ) { - old = cache.remove( key ); + cache.remove( key ); } cache.put( key, value ); diff --git a/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DefaultDigester.java b/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DefaultDigester.java index a342227a3..fc69f9045 100644 --- a/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DefaultDigester.java +++ b/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DefaultDigester.java @@ -21,9 +21,9 @@ import org.codehaus.plexus.util.StringUtils; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.io.FileNotFoundException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.regex.Matcher; @@ -55,7 +55,7 @@ public class DefaultDigester throw new DigesterException( "Specified algorithm not found: " + algorithm, e ); } - InputStream fis = null; + InputStream fis; try { fis = new FileInputStream( file ); @@ -79,7 +79,7 @@ public class DefaultDigester } while ( numRead != -1 ); } - catch( IOException e ) + catch ( IOException e ) { throw new DigesterException( "Failed to read from file: " + file.getAbsolutePath(), e ); } 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 3c64f210c..b2c3e0318 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 @@ -16,16 +16,16 @@ package org.apache.maven.repository.manager.web.action; * limitations under the License. */ -import com.opensymphony.xwork.ActionSupport; 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.manager.web.utils.ConfigurationManager; import java.io.File; -import java.util.Map; import java.util.HashMap; +import java.util.Map; /** * This is the Action class of index.jsp, which is the initial page of the web application. @@ -78,9 +78,9 @@ public class BaseAction 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, new Boolean( config.isDiscoverSnapshots() ) ); + parameters.put( ConfigurationManager.DISCOVER_SNAPSHOTS, Boolean.valueOf( config.isDiscoverSnapshots() ) ); parameters.put( ConfigurationManager.DISCOVERY_CRON_EXPRESSION, config.getDiscoveryCronExpression() ); - setParameters( parameters ); + this.parameters = parameters; //Configuration configuration = new Configuration(); // TODO! execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) ); diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/IndexConfigurationAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/IndexConfigurationAction.java index 4d7961be8..d3eb7d4ad 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/IndexConfigurationAction.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/IndexConfigurationAction.java @@ -1,7 +1,7 @@ package org.apache.maven.repository.manager.web.action; /* - * Copyright 2006 The Apache Software Foundation. + * 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. @@ -16,13 +16,13 @@ package org.apache.maven.repository.manager.web.action; * limitations under the License. */ -import com.opensymphony.xwork.Action; import com.opensymphony.webwork.interceptor.ParameterAware; +import com.opensymphony.xwork.Action; +import org.apache.maven.repository.manager.web.utils.ConfigurationManager; -import java.util.Map; +import java.io.IOException; import java.util.HashMap; - -import org.apache.maven.repository.manager.web.utils.ConfigurationManager; +import java.util.Map; /** * @author Maria Odea Ching @@ -52,10 +52,10 @@ public class IndexConfigurationAction * Method that is executed when the action is invoked. * * @return a String that specifies where to go to next - * @throws Exception + * @throws IOException */ public String execute() - throws Exception + throws IOException { String[] indexPath = (String[]) parameters.get( ConfigurationManager.INDEXPATH ); Map map = new HashMap(); diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SchedulerConfigurationAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SchedulerConfigurationAction.java index 17db63baf..b81cd02fb 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SchedulerConfigurationAction.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SchedulerConfigurationAction.java @@ -1,16 +1,30 @@ package org.apache.maven.repository.manager.web.action; -import com.opensymphony.xwork.Action; +/* + * 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.webwork.interceptor.ParameterAware; +import com.opensymphony.xwork.Action; +import org.apache.maven.repository.manager.web.utils.ConfigurationManager; -import java.util.Map; import java.util.HashMap; - -import org.apache.maven.repository.manager.web.utils.ConfigurationManager; +import java.util.Map; /** * @author Allan Ramirez - * * @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.SchedulerConfigurationAction" */ public class SchedulerConfigurationAction @@ -40,14 +54,13 @@ public class SchedulerConfigurationAction */ public String execute() { - Map map; try { - map = new HashMap(); + Map map = new HashMap(); String[] cronExpression = (String[]) parameters.get( ConfigurationManager.DISCOVERY_CRON_EXPRESSION ); - if( cronExpression[0] != null ) + if ( cronExpression[0] != null ) { map.put( ConfigurationManager.DISCOVERY_CRON_EXPRESSION, cronExpression[0] ); @@ -60,8 +73,9 @@ public class SchedulerConfigurationAction return ERROR; } } - catch( Exception e ) + catch ( Exception e ) { + // TODO: fix error handling! e.printStackTrace(); return ERROR; } 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 index c059cd7cb..f2d6b0279 100644 --- 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 @@ -145,7 +145,7 @@ public class DiscovererExecution * @param indexPath the path to the index file */ protected void indexMetadata( List metadataList, File indexPath, ArtifactRepository repository ) - throws RepositoryIndexException, MalformedURLException + throws RepositoryIndexException { MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository ); metadataIndex.indexMetadata( metadataList ); 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 315d3a882..362308bd4 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 @@ -17,17 +17,17 @@ package org.apache.maven.repository.manager.web.utils; */ import org.apache.maven.repository.configuration.Configuration; -import org.apache.maven.repository.configuration.io.xpp3.ConfigurationXpp3Writer; import org.apache.maven.repository.configuration.io.xpp3.ConfigurationXpp3Reader; +import org.apache.maven.repository.configuration.io.xpp3.ConfigurationXpp3Writer; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.io.Writer; import java.io.Reader; -import java.io.FileReader; -import java.io.FileNotFoundException; +import java.io.Writer; import java.net.URL; import java.util.Iterator; import java.util.Map; @@ -99,7 +99,7 @@ public class ConfigurationManager } if ( name.equals( DISCOVER_SNAPSHOTS ) ) { - config.setDiscoverSnapshots( Boolean.getBoolean( value ) ); + config.setDiscoverSnapshots( Boolean.valueOf( value ).booleanValue() ); } if ( name.equals( REPOSITORY_DIRECTORY ) ) { @@ -131,7 +131,6 @@ public class ConfigurationManager public Configuration getConfiguration() throws IOException { - Map map = null; File file = getConfigFile(); config = new Configuration(); @@ -147,6 +146,7 @@ public class ConfigurationManager } catch ( XmlPullParserException xe ) { + // TODO: fix error handling! xe.printStackTrace(); } } -- 2.39.5