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
This commit is contained in:
Brett Porter 2006-06-28 05:45:08 +00:00
parent e0182bf24e
commit 7a5b4547af
15 changed files with 135 additions and 162 deletions

View File

@ -105,9 +105,7 @@ public class DefaultRepositoryConverter
*/ */
private I18N i18n; private I18N i18n;
public void convert( Artifact artifact, public void convert( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter )
ArtifactRepository targetRepository,
ArtifactReporter reporter )
throws RepositoryConversionException throws RepositoryConversionException
{ {
if ( artifact.getRepository().getUrl().equals( targetRepository.getUrl() ) ) if ( artifact.getRepository().getUrl().equals( targetRepository.getUrl() ) )
@ -165,15 +163,13 @@ public class DefaultRepositoryConverter
return metadata; return metadata;
} }
private void updateMetadata( RepositoryMetadata artifactMetadata, private void updateMetadata( RepositoryMetadata artifactMetadata, ArtifactRepository sourceRepository,
ArtifactRepository sourceRepository, ArtifactRepository targetRepository, Metadata newMetadata,
ArtifactRepository targetRepository,
Metadata newMetadata,
FileTransaction transaction ) FileTransaction transaction )
throws RepositoryConversionException throws RepositoryConversionException
{ {
Metadata metadata; Metadata metadata;
boolean changed = false; boolean changed;
//merge with target repository metadata //merge with target repository metadata
File file = new File( targetRepository.getBasedir(), File file = new File( targetRepository.getBasedir(),
@ -198,7 +194,7 @@ public class DefaultRepositoryConverter
if ( srcfile.exists() ) if ( srcfile.exists() )
{ {
Metadata sourceMetadata = readMetadata( srcfile ); Metadata sourceMetadata = readMetadata( srcfile );
changed = changed | metadata.merge( sourceMetadata ); changed = changed || metadata.merge( sourceMetadata );
} }
} }
@ -256,8 +252,7 @@ public class DefaultRepositoryConverter
return metadata; return metadata;
} }
private boolean validateMetadata( Artifact artifact, private boolean validateMetadata( Artifact artifact, ArtifactReporter reporter )
ArtifactReporter reporter )
throws RepositoryConversionException throws RepositoryConversionException
{ {
ArtifactRepository repository = artifact.getRepository(); ArtifactRepository repository = artifact.getRepository();
@ -284,9 +279,7 @@ public class DefaultRepositoryConverter
return result; return result;
} }
private boolean validateMetadata( Metadata metadata, private boolean validateMetadata( Metadata metadata, RepositoryMetadata repositoryMetadata, Artifact artifact,
RepositoryMetadata repositoryMetadata,
Artifact artifact,
ArtifactReporter reporter ) ArtifactReporter reporter )
{ {
String groupIdKey; String groupIdKey;
@ -388,9 +381,7 @@ public class DefaultRepositoryConverter
return result; return result;
} }
private boolean copyPom( Artifact artifact, private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter,
ArtifactRepository targetRepository,
ArtifactReporter reporter,
FileTransaction transaction ) FileTransaction transaction )
throws RepositoryConversionException throws RepositoryConversionException
{ {
@ -505,10 +496,8 @@ public class DefaultRepositoryConverter
return result; return result;
} }
private boolean doRelocation( Artifact artifact, private boolean doRelocation( Artifact artifact, org.apache.maven.model.v3_0_0.Model v3Model,
org.apache.maven.model.v3_0_0.Model v3Model, ArtifactRepository repository, FileTransaction transaction )
ArtifactRepository repository,
FileTransaction transaction )
throws IOException throws IOException
{ {
Properties properties = v3Model.getProperties(); Properties properties = v3Model.getProperties();
@ -551,15 +540,9 @@ public class DefaultRepositoryConverter
} }
} }
private void writeRelocationPom( String groupId, private void writeRelocationPom( String groupId, String artifactId, String version, String newGroupId,
String artifactId, String newArtifactId, String newVersion, String message,
String version, ArtifactRepository repository, FileTransaction transaction )
String newGroupId,
String newArtifactId,
String newVersion,
String message,
ArtifactRepository repository,
FileTransaction transaction )
throws IOException throws IOException
{ {
Model pom = new Model(); Model pom = new Model();
@ -592,8 +575,7 @@ public class DefaultRepositoryConverter
transaction.createFile( strWriter.toString(), pomFile ); transaction.createFile( strWriter.toString(), pomFile );
} }
private String getI18NString( String key, private String getI18NString( String key, String arg0 )
String arg0 )
{ {
return i18n.format( getClass().getName(), Locale.getDefault(), key, 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 ); return i18n.getString( getClass().getName(), Locale.getDefault(), key );
} }
private boolean testChecksums( Artifact artifact, private boolean testChecksums( Artifact artifact, File file, ArtifactReporter reporter )
File file, throws IOException
ArtifactReporter reporter )
throws IOException, RepositoryConversionException
{ {
boolean result;
result = verifyChecksum( file, file.getName() + ".md5", Digester.MD5, reporter, artifact, boolean result =
"failure.incorrect.md5" ); verifyChecksum( file, file.getName() + ".md5", Digester.MD5, reporter, artifact, "failure.incorrect.md5" );
result = result && verifyChecksum( file, file.getName() + ".sha1", Digester.SHA1, reporter, artifact, result = result && verifyChecksum( file, file.getName() + ".sha1", Digester.SHA1, reporter, artifact,
"failure.incorrect.sha1" ); "failure.incorrect.sha1" );
return result; return result;
} }
private boolean verifyChecksum( File file, private boolean verifyChecksum( File file, String fileName, String algorithm, ArtifactReporter reporter,
String fileName, Artifact artifact, String key )
String algorithm,
ArtifactReporter reporter,
Artifact artifact,
String key )
throws IOException throws IOException
{ {
boolean result = true; boolean result = true;
@ -644,9 +619,7 @@ public class DefaultRepositoryConverter
return result; return result;
} }
private boolean copyArtifact( Artifact artifact, private boolean copyArtifact( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter,
ArtifactRepository targetRepository,
ArtifactReporter reporter,
FileTransaction transaction ) FileTransaction transaction )
throws RepositoryConversionException throws RepositoryConversionException
{ {
@ -689,9 +662,7 @@ public class DefaultRepositoryConverter
return result; return result;
} }
public void convert( List artifacts, public void convert( List artifacts, ArtifactRepository targetRepository, ArtifactReporter reporter )
ArtifactRepository targetRepository,
ArtifactReporter reporter )
throws RepositoryConversionException throws RepositoryConversionException
{ {
for ( Iterator i = artifacts.iterator(); i.hasNext(); ) for ( Iterator i = artifacts.iterator(); i.hasNext(); )

View File

@ -1,16 +1,16 @@
package org.apache.maven.repository; 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.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.RepositoryConversionException;
import org.apache.maven.repository.converter.RepositoryConverter; import org.apache.maven.repository.converter.RepositoryConverter;
import org.apache.maven.repository.discovery.ArtifactDiscoverer; import org.apache.maven.repository.discovery.ArtifactDiscoverer;
import org.apache.maven.repository.reporting.ArtifactReporter; import org.apache.maven.repository.reporting.ArtifactReporter;
import java.io.File; import java.io.File;
import java.util.List;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.List;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
@ -49,8 +49,7 @@ public class DefaultRepositoryManager
*/ */
private ArtifactReporter reporter; private ArtifactReporter reporter;
public void convertLegacyRepository( File legacyRepositoryDirectory, public void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory,
File repositoryDirectory,
boolean includeSnapshots ) boolean includeSnapshots )
throws RepositoryConversionException throws RepositoryConversionException
{ {

View File

@ -59,9 +59,9 @@ public abstract class AbstractArtifactDiscoverer
/** /**
* Return a list of artifacts found in a specified repository * 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 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 * @return list of artifacts
*/ */
public List discoverArtifacts( ArtifactRepository repository, String blacklistedPatterns, boolean includeSnapshots ) public List discoverArtifacts( ArtifactRepository repository, String blacklistedPatterns, boolean includeSnapshots )
@ -81,10 +81,9 @@ public abstract class AbstractArtifactDiscoverer
{ {
String path = artifactPaths[i]; String path = artifactPaths[i];
Artifact artifact;
try try
{ {
artifact = buildArtifactFromPath( path, repository ); Artifact artifact = buildArtifactFromPath( path, repository );
if ( includeSnapshots || !artifact.isSnapshot() ) if ( includeSnapshots || !artifact.isSnapshot() )
{ {
@ -103,9 +102,9 @@ public abstract class AbstractArtifactDiscoverer
/** /**
* Returns a list of pom packaging artifacts found in a specified repository * 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 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 * @return list of pom artifacts
*/ */
public List discoverStandalonePoms( ArtifactRepository repository, String blacklistedPatterns, 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 * 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 * @param repository The repository of the artifact
* @return Artifact * @return Artifact
* @throws DiscovererException when the specified path does correspond to an artifact * @throws DiscovererException when the specified path does correspond to an artifact

View File

@ -49,7 +49,7 @@ public class DefaultArtifactDiscoverer
Collections.reverse( pathParts ); Collections.reverse( pathParts );
Artifact artifact = null; Artifact artifact;
if ( pathParts.size() >= 4 ) if ( pathParts.size() >= 4 )
{ {
// maven 2.x path // maven 2.x path
@ -111,13 +111,13 @@ public class DefaultArtifactDiscoverer
Artifact result; Artifact result;
if ( classifier == null ) if ( classifier == null )
{ {
result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, result =
type ); artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, type );
} }
else else
{ {
result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, result =
classifier ); artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
} }
if ( result.isSnapshot() ) if ( result.isSnapshot() )
@ -128,9 +128,8 @@ public class DefaultArtifactDiscoverer
{ {
classifier = remainingFilename.substring( classifierIndex + 1 ); classifier = remainingFilename.substring( classifierIndex + 1 );
remainingFilename = remainingFilename.substring( 0, classifierIndex ); remainingFilename = remainingFilename.substring( 0, classifierIndex );
result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, remainingFilename,
remainingFilename, type, type, classifier );
classifier );
} }
else else
{ {
@ -145,8 +144,8 @@ public class DefaultArtifactDiscoverer
} }
else if ( !result.getBaseVersion().equals( version ) ) else if ( !result.getBaseVersion().equals( version ) )
{ {
throw new DiscovererException( "Built snapshot artifact base version does not match " + throw new DiscovererException(
"path version" ); "Built snapshot artifact base version does not match " + "path version" );
} }
else else
{ {

View File

@ -21,17 +21,20 @@ package org.apache.maven.repository.discovery;
*/ */
public class DiscovererPath 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 ) public DiscovererPath( String path, String comment )
{ {
setPath( path ); this.path = path;
setComment( comment ); this.comment = comment;
} }
public String getPath() public String getPath()
@ -39,18 +42,8 @@ public class DiscovererPath
return path; return path;
} }
public void setPath( String path )
{
this.path = path;
}
public String getComment() public String getComment()
{ {
return comment; return comment;
} }
public void setComment( String comment )
{
this.comment = comment;
}
} }

View File

@ -20,19 +20,19 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.CharTokenizer; import org.apache.lucene.analysis.CharTokenizer;
import org.apache.lucene.analysis.SimpleAnalyzer; import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term; import org.apache.lucene.index.Term;
import org.apache.lucene.document.Document;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Iterator;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
/** /**
@ -71,8 +71,7 @@ public abstract class AbstractRepositoryIndex
} }
catch ( IOException e ) catch ( IOException e )
{ {
throw new RepositoryIndexException( "Failed to validate index path: " + throw new RepositoryIndexException( "Failed to validate index path: " + indexPath.getAbsolutePath(), e );
getIndexPath().getAbsolutePath(), e );
} }
} }
@ -148,7 +147,7 @@ public abstract class AbstractRepositoryIndex
/** /**
* @see RepositoryIndex#validate() * @see RepositoryIndex#validate()
*/ */
public void validate() public final void validate()
throws RepositoryIndexException, IOException throws RepositoryIndexException, IOException
{ {
if ( indexExists() ) 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 ) public void deleteDocuments( List termList )
throws RepositoryIndexException, IOException throws RepositoryIndexException, IOException

View File

@ -26,61 +26,62 @@ import java.util.List;
/** /**
* @author Edwin Punzalan * @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 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_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}; 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} ); 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(); ArtifactRepository getRepository();
@ -117,7 +118,7 @@ public interface RepositoryIndex
* *
* @throws RepositoryIndexException if the given indexPath is not valid for this type of RepositoryIndex * @throws RepositoryIndexException if the given indexPath is not valid for this type of RepositoryIndex
*/ */
public void validate() void validate()
throws RepositoryIndexException, IOException; throws RepositoryIndexException, IOException;
/** /**
@ -127,7 +128,7 @@ public interface RepositoryIndex
* @param docList List of Lucene Documents * @param docList List of Lucene Documents
* @throws RepositoryIndexException when an error occurred during the indexing of the documents * @throws RepositoryIndexException when an error occurred during the indexing of the documents
*/ */
public void addDocuments( List docList ) void addDocuments( List docList )
throws RepositoryIndexException; throws RepositoryIndexException;
/** /**
@ -137,6 +138,6 @@ public interface RepositoryIndex
* @throws RepositoryIndexException * @throws RepositoryIndexException
* @throws IOException * @throws IOException
*/ */
public void deleteDocuments( List termList ) void deleteDocuments( List termList )
throws RepositoryIndexException, IOException; throws RepositoryIndexException, IOException;
} }

View File

@ -155,7 +155,7 @@ public class ProxyConfiguration
validateDirectories(); validateDirectories();
} }
private void validateRemoteRepo( ) private void validateRemoteRepo()
throws ValidationException throws ValidationException
{ {
//Verify remote repository set //Verify remote repository set
@ -169,7 +169,7 @@ public class ProxyConfiguration
private void validateDirectories() private void validateDirectories()
throws ValidationException throws ValidationException
{ {
File f = new File( getRepositoryCachePath() ); File f = new File( cachePath );
if ( !f.exists() ) if ( !f.exists() )
{ {
throw new ValidationException( "Specified directory does not exist: " + f.getAbsolutePath() ); throw new ValidationException( "Specified directory does not exist: " + f.getAbsolutePath() );

View File

@ -134,14 +134,12 @@ public class Cache
*/ */
public void put( Object key, Object value ) 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 // remove and put: this promotes it to the top since we use a linked hash map
synchronized ( cache ) synchronized ( cache )
{ {
if ( cache.containsKey( key ) ) if ( cache.containsKey( key ) )
{ {
old = cache.remove( key ); cache.remove( key );
} }
cache.put( key, value ); cache.put( key, value );

View File

@ -21,9 +21,9 @@ import org.codehaus.plexus.util.StringUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.FileNotFoundException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -55,7 +55,7 @@ public class DefaultDigester
throw new DigesterException( "Specified algorithm not found: " + algorithm, e ); throw new DigesterException( "Specified algorithm not found: " + algorithm, e );
} }
InputStream fis = null; InputStream fis;
try try
{ {
fis = new FileInputStream( file ); fis = new FileInputStream( file );
@ -79,7 +79,7 @@ public class DefaultDigester
} }
while ( numRead != -1 ); while ( numRead != -1 );
} }
catch( IOException e ) catch ( IOException e )
{ {
throw new DigesterException( "Failed to read from file: " + file.getAbsolutePath(), e ); throw new DigesterException( "Failed to read from file: " + file.getAbsolutePath(), e );
} }

View File

@ -16,16 +16,16 @@ package org.apache.maven.repository.manager.web.action;
* limitations under the License. * limitations under the License.
*/ */
import com.opensymphony.xwork.ActionSupport;
import com.opensymphony.webwork.interceptor.ParameterAware; import com.opensymphony.webwork.interceptor.ParameterAware;
import com.opensymphony.xwork.ActionSupport;
import org.apache.maven.repository.configuration.Configuration; import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.manager.web.execution.DiscovererExecution; 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.job.DiscovererScheduler;
import org.apache.maven.repository.manager.web.utils.ConfigurationManager; import org.apache.maven.repository.manager.web.utils.ConfigurationManager;
import java.io.File; import java.io.File;
import java.util.Map;
import java.util.HashMap; 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. * 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.INDEXPATH, config.getIndexPath() );
parameters.put( ConfigurationManager.MIN_INDEXPATH, config.getMinimalIndexPath() ); parameters.put( ConfigurationManager.MIN_INDEXPATH, config.getMinimalIndexPath() );
parameters.put( ConfigurationManager.DISCOVERY_BLACKLIST_PATTERNS, config.getDiscoveryBlackListPatterns() ); 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() ); parameters.put( ConfigurationManager.DISCOVERY_CRON_EXPRESSION, config.getDiscoveryCronExpression() );
setParameters( parameters ); this.parameters = parameters;
//Configuration configuration = new Configuration(); // TODO! //Configuration configuration = new Configuration(); // TODO!
execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) ); execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );

View File

@ -1,7 +1,7 @@
package org.apache.maven.repository.manager.web.action; 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,14 +16,14 @@ package org.apache.maven.repository.manager.web.action;
* limitations under the License. * limitations under the License.
*/ */
import com.opensymphony.xwork.Action;
import com.opensymphony.webwork.interceptor.ParameterAware; import com.opensymphony.webwork.interceptor.ParameterAware;
import com.opensymphony.xwork.Action;
import java.util.Map;
import java.util.HashMap;
import org.apache.maven.repository.manager.web.utils.ConfigurationManager; import org.apache.maven.repository.manager.web.utils.ConfigurationManager;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/** /**
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a> * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.IndexConfigurationAction" * @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.IndexConfigurationAction"
@ -52,10 +52,10 @@ public class IndexConfigurationAction
* Method that is executed when the action is invoked. * Method that is executed when the action is invoked.
* *
* @return a String that specifies where to go to next * @return a String that specifies where to go to next
* @throws Exception * @throws IOException
*/ */
public String execute() public String execute()
throws Exception throws IOException
{ {
String[] indexPath = (String[]) parameters.get( ConfigurationManager.INDEXPATH ); String[] indexPath = (String[]) parameters.get( ConfigurationManager.INDEXPATH );
Map map = new HashMap(); Map map = new HashMap();

View File

@ -1,16 +1,30 @@
package org.apache.maven.repository.manager.web.action; 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.webwork.interceptor.ParameterAware;
import com.opensymphony.xwork.Action;
import java.util.Map;
import java.util.HashMap;
import org.apache.maven.repository.manager.web.utils.ConfigurationManager; import org.apache.maven.repository.manager.web.utils.ConfigurationManager;
import java.util.HashMap;
import java.util.Map;
/** /**
* @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a> * @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a>
*
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.SchedulerConfigurationAction" * @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.SchedulerConfigurationAction"
*/ */
public class SchedulerConfigurationAction public class SchedulerConfigurationAction
@ -40,14 +54,13 @@ public class SchedulerConfigurationAction
*/ */
public String execute() public String execute()
{ {
Map map;
try try
{ {
map = new HashMap(); Map map = new HashMap();
String[] cronExpression = (String[]) parameters.get( ConfigurationManager.DISCOVERY_CRON_EXPRESSION ); 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] ); map.put( ConfigurationManager.DISCOVERY_CRON_EXPRESSION, cronExpression[0] );
@ -60,8 +73,9 @@ public class SchedulerConfigurationAction
return ERROR; return ERROR;
} }
} }
catch( Exception e ) catch ( Exception e )
{ {
// TODO: fix error handling!
e.printStackTrace(); e.printStackTrace();
return ERROR; return ERROR;
} }

View File

@ -145,7 +145,7 @@ public class DiscovererExecution
* @param indexPath the path to the index file * @param indexPath the path to the index file
*/ */
protected void indexMetadata( List metadataList, File indexPath, ArtifactRepository repository ) protected void indexMetadata( List metadataList, File indexPath, ArtifactRepository repository )
throws RepositoryIndexException, MalformedURLException throws RepositoryIndexException
{ {
MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository ); MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository );
metadataIndex.indexMetadata( metadataList ); metadataIndex.indexMetadata( metadataList );

View File

@ -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.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.ConfigurationXpp3Reader;
import org.apache.maven.repository.configuration.io.xpp3.ConfigurationXpp3Writer;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.Writer;
import java.io.Reader; import java.io.Reader;
import java.io.FileReader; import java.io.Writer;
import java.io.FileNotFoundException;
import java.net.URL; import java.net.URL;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -99,7 +99,7 @@ public class ConfigurationManager
} }
if ( name.equals( DISCOVER_SNAPSHOTS ) ) if ( name.equals( DISCOVER_SNAPSHOTS ) )
{ {
config.setDiscoverSnapshots( Boolean.getBoolean( value ) ); config.setDiscoverSnapshots( Boolean.valueOf( value ).booleanValue() );
} }
if ( name.equals( REPOSITORY_DIRECTORY ) ) if ( name.equals( REPOSITORY_DIRECTORY ) )
{ {
@ -131,7 +131,6 @@ public class ConfigurationManager
public Configuration getConfiguration() public Configuration getConfiguration()
throws IOException throws IOException
{ {
Map map = null;
File file = getConfigFile(); File file = getConfigFile();
config = new Configuration(); config = new Configuration();
@ -147,6 +146,7 @@ public class ConfigurationManager
} }
catch ( XmlPullParserException xe ) catch ( XmlPullParserException xe )
{ {
// TODO: fix error handling!
xe.printStackTrace(); xe.printStackTrace();
} }
} }