import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
+import org.apache.maven.repository.indexing.DefaultRepositoryIndexSearcher;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
-import org.apache.maven.repository.indexing.DefaultRepositoryIndexSearcher;
import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
import org.codehaus.classworlds.ClassWorld;
import org.codehaus.plexus.PlexusContainerException;
*/
public class IndexSearcherCli
{
+ private IndexSearcherCli()
+ {
+ }
+
public static void main( String[] args )
throws PlexusContainerException, ComponentLookupException, RepositoryIndexException, MalformedURLException,
RepositoryIndexSearchException
ArtifactRepositoryIndex index =
indexFactory.createArtifactRepositoryIndex( new File( args[0], ".index" ).getAbsolutePath(), repository );
-
+
DefaultRepositoryIndexSearcher searcher = indexFactory.createDefaultRepositoryIndexSearcher( index );
try
+<!--
+ ~ 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.
+ -->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
* 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 javax.swing.*;
public String generateMd5( final String file )
throws IOException, NoSuchAlgorithmException
{
- return (String) AccessController.doPrivileged( new PrivilegedAction()
+ Object o = AccessController.doPrivileged( new PrivilegedAction()
{
public Object run()
{
try
{
- MessageDigest digest = MessageDigest.getInstance( "MD5" );
-
- long total = new File( file ).length();
- InputStream fis = new FileInputStream( file );
- try
- {
- long totalRead = 0;
- byte[] buffer = new byte[CHECKSUM_BUFFER_SIZE];
- int numRead;
- do
- {
- numRead = fis.read( buffer );
- if ( numRead > 0 )
- {
- digest.update( buffer, 0, numRead );
- totalRead += numRead;
- progressBar.setValue( (int) ( totalRead * progressBar.getMaximum() / total ) );
- }
- }
- while ( numRead != -1 );
- }
- finally
- {
- fis.close();
- }
-
- return byteArrayToHexStr( digest.digest() );
+ return checksumFile( file );
}
catch ( NoSuchAlgorithmException e )
{
- throw new RuntimeException( e );
+ return e;
}
catch ( IOException e )
{
- throw new RuntimeException( e );
+ return e;
}
}
} );
+
+ //noinspection ChainOfInstanceofChecks
+ if ( o instanceof IOException )
+ {
+ throw (IOException) o;
+ }
+ else if ( o instanceof NoSuchAlgorithmException )
+ {
+ throw (NoSuchAlgorithmException) o;
+ }
+ else
+ {
+ return (String) o;
+ }
+ }
+
+ protected String checksumFile( String file )
+ throws NoSuchAlgorithmException, IOException
+ {
+ MessageDigest digest = MessageDigest.getInstance( "MD5" );
+
+ long total = new File( file ).length();
+ InputStream fis = new FileInputStream( file );
+ try
+ {
+ long totalRead = 0;
+ byte[] buffer = new byte[CHECKSUM_BUFFER_SIZE];
+ int numRead;
+ do
+ {
+ numRead = fis.read( buffer );
+ if ( numRead > 0 )
+ {
+ digest.update( buffer, 0, numRead );
+ totalRead += numRead;
+ progressBar.setValue( (int) ( totalRead * progressBar.getMaximum() / total ) );
+ }
+ }
+ while ( numRead != -1 );
+ }
+ finally
+ {
+ fis.close();
+ }
+
+ return byteArrayToHexStr( digest.digest() );
}
- private static String byteArrayToHexStr( byte[] data )
+ protected static String byteArrayToHexStr( byte[] data )
{
String output = "";
import org.apache.maven.model.Relocation;
import org.apache.maven.model.converter.ArtifactPomRewriter;
import org.apache.maven.model.converter.ModelConverter;
+import org.apache.maven.model.converter.PomTranslationException;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.model.v3_0_0.io.xpp3.MavenXpp3Reader;
import org.apache.maven.repository.converter.transaction.FileTransaction;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
fileReader = new FileReader( file );
metadata = reader.read( fileReader );
}
+ catch ( FileNotFoundException e )
+ {
+ throw new RepositoryConversionException( "Error reading target metadata", e );
+ }
catch ( IOException e )
{
throw new RepositoryConversionException( "Error reading target metadata", e );
reporter.addFailure( artifact, getI18NString( "failure.invalid.source.pom", e.getMessage() ) );
result = false;
}
- catch ( Exception e )
+ catch ( IOException e )
{
throw new RepositoryConversionException( "Unable to write converted POM", e );
}
+ catch ( PomTranslationException e )
+ {
+ // TODO! check handling, fix error message
+ reporter.addFailure( artifact, getI18NString( "failure.invalid.source.pom", e.getMessage() ) );
+ result = false;
+ }
finally
{
IOUtil.close( writer );
package org.apache.maven.repository.converter.transaction;
-import java.io.IOException;
-
/*
* Copyright 2005-2006 The Apache Software Foundation.
*
* limitations under the License.
*/
+import java.io.IOException;
+
/**
* Interface for individual events in a transaction.
*
exception.repositories.match=Source and target repositories are identical.
+# TODO! update definitions
failure.incorrect.groupMetadata.groupId=The group ID in the source group metadata is incorrect.
failure.incorrect.artifactMetadata.artifactId=The artifact ID in the source artifact metadata is incorrect.
File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) );
- SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+ SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd", Locale.getDefault() );
long origTime = dateFormat.parse( "2006-03-03" ).getTime();
- targetFile.setLastModified( origTime );
- targetPomFile.setLastModified( origTime );
+ targetFile.setLastModified( origTime );
+ targetPomFile.setLastModified( origTime );
sourceFile.setLastModified( dateFormat.parse( "2006-01-01" ).getTime() );
sourcePomFile.setLastModified( dateFormat.parse( "2006-02-02" ).getTime() );
}
else if ( file.isDirectory() )
{
- if ( !file.getName().equals( ".svn" ) )
+ if ( !".svn".equals( file.getName() ) )
{
if ( !destination.exists() && !destination.mkdirs() )
{
~ 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.
- ~
-->
<project>
~ 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.
- ~
-->
<project>
~ 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.
- ~
-->
<project>
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileReader;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
"**/*.MD5", "**/*.sha1", "**/*.SHA1", "**/*snapshot-version", "*/website/**", "*/licenses/**", "*/licences/**",
"**/.htaccess", "**/*.html", "**/*.asc", "**/*.txt", "**/*.xml", "**/README*", "**/CHANGELOG*", "**/KEYS*"};
- protected static final String POM = ".pom";
+ private static final String POM = ".pom";
/**
* Scan the repository for artifact paths.
*/
- protected String[] scanForArtifactPaths( File repositoryBase, String blacklistedPatterns )
+ private String[] scanForArtifactPaths( File repositoryBase, String blacklistedPatterns )
{
return scanForArtifactPaths( repositoryBase, blacklistedPatterns, null, STANDARD_DISCOVERY_EXCLUDES );
}
try
{
Model model = mavenReader.read( new FileReader( filename ) );
- if ( ( pomArtifact != null ) && ( "pom".equals( model.getPackaging() ) ) )
+ if ( pomArtifact != null && "pom".equals( model.getPackaging() ) )
{
if ( includeSnapshots || !pomArtifact.isSnapshot() )
{
}
}
}
- catch ( Exception e )
+ catch ( FileNotFoundException e )
{
- getLogger().info( "error reading file: " + filename );
- e.printStackTrace();
+ // this should never happen
+ getLogger().error( "Error finding file during POM discovery: " + filename, e );
+ }
+ catch ( IOException e )
+ {
+ getLogger().error( "Error reading file during POM discovery: " + filename + ": " + e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ getLogger().error(
+ "Parse error reading file during POM discovery: " + filename + ": " + e.getMessage() );
}
}
}
package org.apache.maven.repository.discovery;
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.DirectoryScanner;
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
-public class AbstractDiscoverer
+public abstract class AbstractDiscoverer
extends AbstractLogEnabled
{
private List kickedOutPaths = new ArrayList();
//}
Artifact artifact = null;
- if ( metaVersion != null && !metaVersion.equals( "" ) )
+ if ( metaVersion != null && !"".equals( metaVersion ) )
{
artifact = artifactFactory.createBuildArtifact( metaGroupId, metaArtifactId, metaVersion, "jar" );
}
*
* @param indexPath
* @param repository
- * @throws RepositoryIndexException
*/
protected AbstractRepositoryIndex( String indexPath, ArtifactRepository repository )
- throws RepositoryIndexException
{
this.repository = repository;
this.indexPath = indexPath;
* Check if the index already exists.
*
* @return true if the index already exists
- * @throws IOException
* @throws RepositoryIndexException
*/
protected boolean indexExists()
- throws IOException, RepositoryIndexException
+ throws RepositoryIndexException
{
File indexDir = new File( indexPath );
return isAdded;
}
- private class ArtifactRepositoryIndexAnalyzer
+ private static class ArtifactRepositoryIndexAnalyzer
extends Analyzer
{
private Analyzer defaultAnalyzer;
*
* @param defaultAnalyzer the analyzer to use as default for the general fields of the artifact indeces
*/
- public ArtifactRepositoryIndexAnalyzer( Analyzer defaultAnalyzer )
+ ArtifactRepositoryIndexAnalyzer( Analyzer defaultAnalyzer )
{
this.defaultAnalyzer = defaultAnalyzer;
}
return tokenStream;
}
+ }
+ /**
+ * Class used to tokenize an artifact's version.
+ */
+ private static class VersionTokenizer
+ extends CharTokenizer
+ {
/**
- * Class used to tokenize an artifact's version.
+ * Constructor with the required reader to the index stream
+ *
+ * @param reader the Reader object of the index stream
*/
- private class VersionTokenizer
- extends CharTokenizer
+ VersionTokenizer( Reader reader )
{
- /**
- * Constructor with the required reader to the index stream
- *
- * @param reader the Reader object of the index stream
- */
- VersionTokenizer( Reader reader )
- {
- super( reader );
- }
+ super( reader );
+ }
- /**
- * method that lucene calls to check tokenization of a stream character
- *
- * @param character char currently being processed
- * @return true if the char is a token, false if the char is a stop char
- */
- protected boolean isTokenChar( char character )
- {
- return character != '.' && character != '-';
- }
+ /**
+ * method that lucene calls to check tokenization of a stream character
+ *
+ * @param character char currently being processed
+ * @return true if the char is a token, false if the char is a stop char
+ */
+ protected boolean isTokenChar( char character )
+ {
+ return character != '.' && character != '-';
}
}
}
* @param indexPath the path where the lucene index will be created/updated.
* @param repository the repository where the indexed artifacts are located
* @param digester the digester object to generate the checksum strings
- * @throws RepositoryIndexException
*/
public ArtifactRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester )
- throws RepositoryIndexException
{
super( indexPath, repository );
this.digester = digester;
*
* @param name the complete path name of the class
* @param packages the packages buffer
- * @return true if the package is successfully added
*/
- private boolean addClassPackage( String name, StringBuffer packages )
+ private void addClassPackage( String name, StringBuffer packages )
{
- boolean isAdded = false;
-
int idx = name.lastIndexOf( '/' );
if ( idx > 0 )
{
{
packages.append( packageName ).append( "\n" );
}
- isAdded = true;
}
-
- return isAdded;
}
/**
*
* @param entry the zip entry to be added
* @param files the buffer of files to update
- * @return true if the file was successfully added
*/
- private boolean addFile( ZipEntry entry, StringBuffer files )
+ private void addFile( ZipEntry entry, StringBuffer files )
{
String name = entry.getName();
int idx = name.lastIndexOf( '/' );
name = name.substring( idx + 1 );
}
- boolean isAdded = false;
-
if ( files.indexOf( name + "\n" ) < 0 )
{
files.append( name ).append( "\n" );
- isAdded = true;
}
-
- return isAdded;
}
}
Hits hits = searcher.search( luceneQuery );\r
docs = buildList( hits );\r
}\r
+ catch ( MalformedURLException e )\r
+ {\r
+ throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e );\r
+ }\r
catch ( IOException e )\r
{\r
throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e );\r
protected RepositoryIndexSearchHit createSearchedObjectFromIndexDocument( Document doc )\r
throws MalformedURLException, IOException, XmlPullParserException\r
{\r
- String groupId, artifactId, version, name, packaging;\r
RepositoryIndexSearchHit searchHit = null;\r
\r
// the document is of type artifact\r
if ( doc.get( RepositoryIndex.FLD_DOCTYPE ).equals( RepositoryIndex.ARTIFACT ) )\r
{\r
- groupId = doc.get( RepositoryIndex.FLD_GROUPID );\r
- artifactId = doc.get( RepositoryIndex.FLD_ARTIFACTID );\r
- version = doc.get( RepositoryIndex.FLD_VERSION );\r
- name = doc.get( RepositoryIndex.FLD_NAME );\r
- packaging = doc.get( RepositoryIndex.FLD_PACKAGING );\r
+ String groupId = doc.get( RepositoryIndex.FLD_GROUPID );\r
+ String artifactId = doc.get( RepositoryIndex.FLD_ARTIFACTID );\r
+ String version = doc.get( RepositoryIndex.FLD_VERSION );\r
+ String packaging = doc.get( RepositoryIndex.FLD_PACKAGING );\r
Artifact artifact = factory.createBuildArtifact( groupId, artifactId, version, packaging );\r
\r
artifact.setFile(\r
String metadataFile = (String) it.next();\r
String tmpDir = (String) it.next();\r
\r
- String metadataType = "";\r
+ String metadataType;\r
if ( tmpDir.equals( doc.get( RepositoryIndex.FLD_VERSION ) ) )\r
{\r
metadataType = MetadataRepositoryIndex.SNAPSHOT_METADATA;\r
* @param filename the name of the metadata file\r
* @param metadataType the type of RepositoryMetadata object to be created (GROUP, ARTIFACT or SNAPSHOT)\r
* @return RepositoryMetadata\r
- * @throws MalformedURLException\r
* @throws IOException\r
* @throws XmlPullParserException\r
*/\r
private RepositoryMetadata getMetadata( String groupId, String artifactId, String version, String filename,\r
String metadataType )\r
- throws MalformedURLException, IOException, XmlPullParserException\r
+ throws IOException, XmlPullParserException\r
{\r
RepositoryMetadata repoMetadata = null;\r
- InputStream is = null;\r
+\r
+ // TODO! file handles left open\r
+ InputStream is;\r
MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();\r
\r
//group metadata\r
package org.apache.maven.repository.indexing;
/*
- * Copyright 2001-2005 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.
* 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,
* @param indexPath the path where the lucene index will be created/updated.
* @param repository the repository where the indexed artifacts are located
* @param digester the digester object to generate the checksum strings
- * @throws RepositoryIndexException
*/
public EclipseRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester )
- throws RepositoryIndexException
{
super( indexPath, repository );
*\r
* @param indexPath the path to the index\r
* @param repository the repository where the metadata to be indexed is located\r
- * @throws RepositoryIndexException\r
*/\r
public MetadataRepositoryIndex( String indexPath, ArtifactRepository repository )\r
- throws RepositoryIndexException\r
{\r
super( indexPath, repository );\r
}\r
repoMetadata.getBaseVersion() + "/";\r
}\r
\r
- if ( !repoMetadata.getRemoteFilename().equals( "" ) && repoMetadata.getRemoteFilename() != null )\r
+ if ( !"".equals( repoMetadata.getRemoteFilename() ) && repoMetadata.getRemoteFilename() != null )\r
{\r
path = path + repoMetadata.getRemoteFilename();\r
}\r
for ( Iterator iter = plugins.iterator(); iter.hasNext(); )\r
{\r
Plugin plugin = (Plugin) iter.next();\r
- if ( plugin.getPrefix() != null && !plugin.getPrefix().equals( "" ) )\r
+ if ( plugin.getPrefix() != null && !"".equals( plugin.getPrefix() ) )\r
{\r
pluginAppended = plugin.getPrefix() + "\n";\r
}\r
doc.add( Field.Text( FLD_PLUGINPREFIX, pluginAppended ) );\r
doc.add( Field.Text( FLD_GROUPID, metadata.getGroupId() ) );\r
\r
- if ( metadata.getArtifactId() != null && !metadata.getArtifactId().equals( "" ) )\r
+ if ( metadata.getArtifactId() != null && !"".equals( metadata.getArtifactId() ) )\r
{\r
doc.add( Field.Text( FLD_ARTIFACTID, metadata.getArtifactId() ) );\r
}\r
doc.add( Field.Text( FLD_ARTIFACTID, "" ) );\r
}\r
\r
- if ( metadata.getVersion() != null && !metadata.getVersion().equals( "" ) )\r
+ if ( metadata.getVersion() != null && !"".equals( metadata.getVersion() ) )\r
{\r
doc.add( Field.Text( FLD_VERSION, metadata.getVersion() ) );\r
}\r
package org.apache.maven.repository.indexing;
/*
- * Copyright 2001-2005 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.
* 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,
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
* @param repository the repository where objects indexed by this class resides
* @param digester the digester to be used for generating checksums
* @param artifactFactory the factory for building artifact objects
- * @throws RepositoryIndexException
*/
public PomRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester,
ArtifactFactory artifactFactory )
- throws RepositoryIndexException
{
super( indexPath, repository );
this.digester = digester;
{
return digester.createChecksum( new File( file ), algorithm );
}
+ catch ( FileNotFoundException e )
+ {
+ throw new RepositoryIndexException( e.getMessage(), e );
+ }
catch ( IOException e )
{
throw new RepositoryIndexException( e.getMessage(), e );
*/
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, 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};
+ 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, FLD_PLUGINS_BUILD, FLD_PLUGINS_REPORT, FLD_PLUGINS_ALL} );
+ 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};
/**
* Method used to query the index status
{\r
private Object obj;\r
\r
- private boolean isHashMap = false;\r
+ private boolean isHashMap;\r
\r
- private boolean isMetadata = false;\r
+ private boolean isMetadata;\r
\r
- private boolean isModel = false;\r
+ private boolean isModel;\r
\r
/**\r
* Class constructor\r
\r
import org.apache.maven.artifact.Artifact;\r
import org.apache.maven.artifact.factory.ArtifactFactory;\r
-import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;\r
import org.apache.maven.model.Dependency;\r
import org.apache.maven.model.License;\r
import org.apache.maven.model.Model;\r
else if ( hit.isMetadata() )\r
{\r
//@todo what about metadata objects?\r
- RepositoryMetadata metadata = (RepositoryMetadata) hit.getObject();\r
+// RepositoryMetadata metadata = (RepositoryMetadata) hit.getObject();\r
}\r
}\r
\r
}\r
}\r
\r
- if ( values != null && values.size() > 0 )\r
+ if ( !values.isEmpty() )\r
{\r
resultMap.put( key, values );\r
}\r
}\r
}\r
\r
- if ( values.size() > 0 && values != null )\r
+ if ( !values.isEmpty() )\r
{\r
map.put( field, values );\r
}\r
package org.apache.maven.repository.indexing;
/*
- * Copyright 2001-2005 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.
* 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,
package org.apache.maven.repository.indexing.query;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.maven.repository.indexing.RepositoryIndex;
-
/*
- * Copyright 2001-2005 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.
* 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,
* limitations under the License.
*/
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.maven.repository.indexing.RepositoryIndex;
+
/**
* Interface to label the query classes
*
package org.apache.maven.repository.indexing.query;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.TermQuery;
-import org.apache.maven.repository.indexing.RepositoryIndex;
-
/*
- * Copyright 2001-2005 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.
* 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,
* limitations under the License.
*/
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.TermQuery;
+import org.apache.maven.repository.indexing.RepositoryIndex;
+
/**
* Class to hold a single field search condition
*
try
{
Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_VERSION, "~~~~~" );
- List artifacts = repoSearchLayer.searchAdvanced( qry );
+ repoSearchLayer.searchAdvanced( qry );
fail( "Must throw an exception on unparseable query." );
}
catch ( RepositoryIndexSearchException re )
try
{
Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_VERSION, "1.0" );
- List artifacts = repoSearchLayer.searchAdvanced( qry );
+ repoSearchLayer.searchAdvanced( qry );
fail( "Must throw an exception on invalid index location." );
}
catch ( RepositoryIndexSearchException re )
RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_ID, RepositoryIndex.ARTIFACT + artifact.getId() );
List artifacts = repoSearcher.search( qry );
- assertEquals( artifacts.size(), 0 );
+ assertEquals( 0, artifacts.size() );
}
/**
package org.apache.maven.repository.indexing;
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
import org.apache.lucene.document.DateField;
import org.apache.lucene.document.Document;
import org.apache.lucene.queryParser.QueryParser;
import java.io.File;
-/*
- * 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.
- */
-
/**
* @author Edwin Punzalan
*/
private long artifactFileTime;
+ private static final long TIME_DIFFERENCE = 10000L;
+
protected void setUp()
throws Exception
{
indexer.optimize();
indexer.close();
- long historicTime = artifactFileTime - 10000L;
+ long historicTime = artifactFileTime - TIME_DIFFERENCE;
artifact = getArtifact( "org.apache.maven", "maven-model", "2.0" );
artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact ) ) );
\r
private String indexPath;\r
\r
- private MetadataRepositoryIndex indexer;\r
-\r
private ArtifactFactory artifactFactory;\r
\r
/**\r
throws Exception\r
{\r
RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );\r
- indexer = factory.createMetadataRepositoryIndex( indexPath, repository );\r
+ MetadataRepositoryIndex indexer = factory.createMetadataRepositoryIndex( indexPath, repository );\r
\r
RepositoryMetadata repoMetadata =\r
getMetadata( "org.apache.maven", null, null, "maven-metadata.xml", MetadataRepositoryIndex.GROUP_METADATA );\r
RepositoryIndexSearchLayer repoSearchLayer = factory.createRepositoryIndexSearchLayer( indexer );\r
\r
// search last update\r
- org.apache.maven.repository.indexing.query.Query qry =\r
- new SinglePhraseQuery( RepositoryIndex.FLD_LASTUPDATE, "20051212044643" );\r
+ Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_LASTUPDATE, "20051212044643" );\r
List metadataList = repoSearchLayer.searchAdvanced( qry );\r
//assertEquals( 1, metadataList.size() );\r
for ( Iterator iter = metadataList.iterator(); iter.hasNext(); )\r
rQry.addQuery( qry2 );\r
\r
metadataList = repoSearchLayer.searchAdvanced( rQry );\r
- assertEquals( metadataList.size(), 0 );\r
+ assertEquals( 0, metadataList.size() );\r
\r
indexer.close();\r
}\r
{\r
//test when the object passed in the index(..) method is not a RepositoryMetadata instance\r
RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );\r
- indexer = factory.createMetadataRepositoryIndex( indexPath, repository );\r
+ MetadataRepositoryIndex indexer = factory.createMetadataRepositoryIndex( indexPath, repository );\r
try\r
{\r
Artifact artifact = getArtifact( "org.apache.maven", "maven-artifact", "2.0.1" );\r
createTestIndex();\r
\r
RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );\r
- indexer = factory.createMetadataRepositoryIndex( indexPath, repository );\r
+ MetadataRepositoryIndex indexer = factory.createMetadataRepositoryIndex( indexPath, repository );\r
\r
RepositoryMetadata repoMetadata =\r
getMetadata( "org.apache.maven", null, null, "maven-metadata.xml", MetadataRepositoryIndex.GROUP_METADATA );\r
indexer.deleteDocument( RepositoryIndex.FLD_ID, (String) repoMetadata.getKey() );\r
\r
RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );\r
- org.apache.maven.repository.indexing.query.Query qry =\r
- new SinglePhraseQuery( RepositoryIndex.FLD_ID, (String) repoMetadata.getKey() );\r
+ Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_ID, (String) repoMetadata.getKey() );\r
List metadataList = repoSearcher.search( qry );\r
- assertEquals( metadataList.size(), 0 );\r
+ assertEquals( 0, metadataList.size() );\r
}\r
\r
/**\r
{\r
RepositoryMetadata repoMetadata = null;\r
URL url;\r
- InputStream is = null;\r
+ InputStream is;\r
MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();\r
\r
//group metadata\r
package org.apache.maven.repository.indexing;
-/**
+/*
* Copyright 2005-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
SearchResult result = (SearchResult) artifacts.next();
Map map = result.getFieldMatches();
Set mapEntry = map.entrySet();
- for ( Iterator it = mapEntry.iterator(); it.hasNext(); )
- {
- Map.Entry entry = (Map.Entry) it.next();
- }
assertEquals( "jar", (String) map.get( RepositoryIndex.FLD_PACKAGING ) );
}
SearchResult result = (SearchResult) artifacts.next();
Map map = result.getFieldMatches();
boolean depFound = false;
- Iterator dependencies = ( (List) map.get( RepositoryIndex.FLD_DEPENDENCIES ) ).iterator();
+ List list = (List) map.get( RepositoryIndex.FLD_DEPENDENCIES );
+ Iterator dependencies = list.iterator();
while ( dependencies.hasNext() )
{
String dep = (String) dependencies.next();
{
SearchResult result = (SearchResult) artifacts.next();
Map map = result.getFieldMatches();
- Iterator plugins = ( (List) map.get( RepositoryIndex.FLD_PLUGINS_BUILD ) ).iterator();
+ List list = (List) map.get( RepositoryIndex.FLD_PLUGINS_BUILD );
+ Iterator plugins = list.iterator();
boolean found = false;
while ( plugins.hasNext() )
{
{
SearchResult result = (SearchResult) artifacts.next();
Map map = result.getFieldMatches();
- Iterator plugins = ( (List) map.get( RepositoryIndex.FLD_PLUGINS_REPORT ) ).iterator();
+ List list = (List) map.get( RepositoryIndex.FLD_PLUGINS_REPORT );
+ Iterator plugins = list.iterator();
boolean found = false;
while ( plugins.hasNext() )
{
RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_ID, RepositoryIndex.POM + pom.getId() );
List artifactList = repoSearcher.search( qry );
- assertEquals( artifactList.size(), 0 );
+ assertEquals( 0, artifactList.size() );
}
private Model getPom( String groupId, String artifactId, String version )
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;\r
import org.apache.maven.model.Model;\r
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;\r
-import org.apache.maven.repository.digest.DefaultDigester;\r
-import org.apache.maven.repository.digest.Digester;\r
import org.codehaus.plexus.PlexusTestCase;\r
import org.codehaus.plexus.util.FileUtils;\r
\r
\r
private ArtifactFactory artifactFactory;\r
\r
- private Digester digester;\r
-\r
private String indexPath;\r
\r
/**\r
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );\r
ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );\r
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );\r
- digester = new DefaultDigester();\r
\r
indexPath = "target/index";\r
FileUtils.deleteDirectory( indexPath );\r
}\r
\r
- /**\r
- * Tear down method\r
- *\r
- * @throws Exception\r
- */\r
- protected void tearDown()\r
- throws Exception\r
- {\r
- super.tearDown();\r
- }\r
-\r
/**\r
* Method for creating the index used for testing\r
*\r
\r
MetadataRepositoryIndex metaIndexer = factory.createMetadataRepositoryIndex( indexPath, repository );\r
RepositoryMetadata repoMetadata =\r
- getMetadata( "org.apache.maven", null, null, "maven-metadata.xml", metaIndexer.GROUP_METADATA );\r
+ getMetadata( "org.apache.maven", null, null, "maven-metadata.xml", MetadataRepositoryIndex.GROUP_METADATA );\r
metaIndexer.index( repoMetadata );\r
metaIndexer.optimize();\r
metaIndexer.close();\r
\r
repoMetadata = getMetadata( "org.apache.maven", "maven-artifact", "2.0.1", "maven-metadata.xml",\r
- metaIndexer.ARTIFACT_METADATA );\r
+ MetadataRepositoryIndex.ARTIFACT_METADATA );\r
metaIndexer.index( repoMetadata );\r
metaIndexer.optimize();\r
metaIndexer.close();\r
\r
repoMetadata = getMetadata( "org.apache.maven", "maven-artifact", "2.0.1", "maven-metadata.xml",\r
- metaIndexer.SNAPSHOT_METADATA );\r
+ MetadataRepositoryIndex.SNAPSHOT_METADATA );\r
metaIndexer.index( repoMetadata );\r
metaIndexer.optimize();\r
metaIndexer.close();\r
\r
- repoMetadata = getMetadata( "test", null, null, "maven-metadata.xml", metaIndexer.GROUP_METADATA );\r
+ repoMetadata = getMetadata( "test", null, null, "maven-metadata.xml", MetadataRepositoryIndex.GROUP_METADATA );\r
metaIndexer.index( repoMetadata );\r
metaIndexer.optimize();\r
metaIndexer.close();\r
for ( Iterator iter = returnList.iterator(); iter.hasNext(); )\r
{\r
SearchResult result = (SearchResult) iter.next();\r
- assertEquals( result.getArtifact().getGroupId(), "test" );\r
+ assertEquals( "test", result.getArtifact().getGroupId() );\r
}\r
\r
returnList = searchLayer.searchGeneral( "test-artifactId" );\r
for ( Iterator iter = returnList.iterator(); iter.hasNext(); )\r
{\r
SearchResult result = (SearchResult) iter.next();\r
- assertEquals( result.getArtifact().getArtifactId(), "test-artifactId" );\r
+ assertEquals( "test-artifactId", result.getArtifact().getArtifactId() );\r
}\r
\r
}\r
{\r
RepositoryMetadata repoMetadata = null;\r
URL url;\r
- InputStream is = null;\r
+ InputStream is;\r
MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();\r
\r
//group metadata\r
package org.apache.maven.repository.indexing.query;
-import junit.framework.TestCase;
-
/*
- * Copyright 2001-2005 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.
* 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,
* limitations under the License.
*/
+import junit.framework.TestCase;
+
/**
* @author Edwin Punzalan
*/
-<?xml version="1.0"?><project>
+<?xml version="1.0"?>
+<!--
+ ~ 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.
+ -->
+
+<project>
<parent>
<artifactId>maven-repository-manager</artifactId>
<groupId>org.apache.maven.repository</groupId>
<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ 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.
+ -->
+
<project>
<body>
<links>
<item name="Maven" href="http://maven.apache.org/"/>
</links>
- <menu ref="reports" />
+ <menu ref="reports"/>
</body>
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-stylus-skin</artifactId>
</skin>
- <publishDate format="dd MMM yyyy" />
+ <publishDate format="dd MMM yyyy"/>
<bannerLeft>
<name>Maven</name>
<src>http://maven.apache.org/images/apache-maven-project-2.png</src>
*/
private Map failuresCache = new HashMap();
+ private static final int MS_PER_SEC = 1000;
+
public void setConfiguration( ProxyConfiguration config )
{
this.config = config;
}
else
{
- long repoTimestamp = target.lastModified() + repository.getCachePeriod() * 1000;
+ long repoTimestamp = target.lastModified() + repository.getCachePeriod() * MS_PER_SEC;
wagon.getIfNewer( path, temp, repoTimestamp );
}
*/
public interface ProxyManager
{
- static String ROLE = ProxyManager.class.getName();
+ String ROLE = ProxyManager.class.getName();
/**
* Used to retrieve a cached path or retrieve one if the cache does not contain it yet.
package org.apache.maven.repository.proxy.configuration;
/*
- * Copyright 2003-2004 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.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
config.setRepositoryCachePath( getMandatoryProperty( props, REPO_LOCAL_STORE ) );
- {//just get the first proxy and break
- String propertyList = props.getProperty( PROXY_LIST );
- if ( propertyList != null )
+ //just get the first proxy and break
+ String propertyList = props.getProperty( PROXY_LIST );
+ if ( propertyList != null )
+ {
+ StringTokenizer tok = new StringTokenizer( propertyList, "," );
+ while ( tok.hasMoreTokens() )
{
- StringTokenizer tok = new StringTokenizer( propertyList, "," );
- while ( tok.hasMoreTokens() )
+ String key = tok.nextToken();
+ if ( StringUtils.isNotEmpty( key ) )
{
- String key = tok.nextToken();
- if ( StringUtils.isNotEmpty( key ) )
+ String host = getMandatoryProperty( props, "proxy." + key + ".host" );
+ int port = Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) );
+
+ // the username and password isn't required
+ String username = props.getProperty( "proxy." + key + ".username" );
+ String password = props.getProperty( "proxy." + key + ".password" );
+
+ if ( StringUtils.isNotEmpty( username ) )
{
- String host = getMandatoryProperty( props, "proxy." + key + ".host" );
- int port = Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) );
-
- // the username and password isn't required
- String username = props.getProperty( "proxy." + key + ".username" );
- String password = props.getProperty( "proxy." + key + ".password" );
-
- if ( StringUtils.isNotEmpty( username ) )
- {
- config.setHttpProxy( host, port, username, password );
- }
- else
- {
- config.setHttpProxy( host, port );
- }
-
- //accept only one proxy configuration
- break;
+ config.setHttpProxy( host, port, username, password );
}
+ else
+ {
+ config.setHttpProxy( host, port );
+ }
+
+ //accept only one proxy configuration
+ break;
}
}
}
List repositories = new ArrayList();
- { //get the remote repository list
- String repoList = getMandatoryProperty( props, REPO_LIST );
- StringTokenizer tok = new StringTokenizer( repoList, "," );
- while ( tok.hasMoreTokens() )
- {
- String key = tok.nextToken();
+ //get the remote repository list
+ String repoList = getMandatoryProperty( props, REPO_LIST );
- Properties repoProps = getSubset( props, "repo." + key + "." );
- String url = getMandatoryProperty( props, "repo." + key + ".url" );
- String proxyKey = repoProps.getProperty( "proxy" );
+ StringTokenizer tok = new StringTokenizer( repoList, "," );
+ while ( tok.hasMoreTokens() )
+ {
+ String key = tok.nextToken();
- boolean cacheFailures =
- Boolean.valueOf( repoProps.getProperty( "cache.failures", "false" ) ).booleanValue();
- boolean hardFail = Boolean.valueOf( repoProps.getProperty( "hardfail", "true" ) ).booleanValue();
- long cachePeriod = Long.parseLong( repoProps.getProperty( "cache.period", "0" ) );
+ Properties repoProps = getSubset( props, "repo." + key + "." );
+ String url = getMandatoryProperty( props, "repo." + key + ".url" );
+ String proxyKey = repoProps.getProperty( "proxy" );
- ProxyRepository repository =
- new ProxyRepository( key, url, new DefaultRepositoryLayout(), cacheFailures, cachePeriod );
+ boolean cacheFailures =
+ Boolean.valueOf( repoProps.getProperty( "cache.failures", "false" ) ).booleanValue();
+ boolean hardFail = Boolean.valueOf( repoProps.getProperty( "hardfail", "true" ) ).booleanValue();
+ long cachePeriod = Long.parseLong( repoProps.getProperty( "cache.period", "0" ) );
- repository.setHardfail( hardFail );
+ ProxyRepository repository =
+ new ProxyRepository( key, url, new DefaultRepositoryLayout(), cacheFailures, cachePeriod );
- if ( StringUtils.isNotEmpty( proxyKey ) )
- {
- repository.setProxied( true );
- }
+ repository.setHardfail( hardFail );
- repositories.add( repository );
+ if ( StringUtils.isNotEmpty( proxyKey ) )
+ {
+ repository.setProxied( true );
}
+
+ repositories.add( repository );
}
+
config.setRepositories( repositories );
validateDirectories( config );
private String getMandatoryProperty( Properties props, String key )
throws ValidationException
{
- final String value = props.getProperty( key );
+ String value = props.getProperty( key );
if ( value == null )
{
proxyInfo.setHost( host );
proxyInfo.setPort( port );
- setHttpProxy( proxyInfo );
+ httpProxy = proxyInfo;
}
public void setHttpProxy( String host, int port, String username, String password )
package org.apache.maven.repository.proxy.configuration;
/*
- * Copyright 2003-2004 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.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
extends DefaultArtifactRepository
{
// zero caches forever
- private long cachePeriod = 0;
+ private long cachePeriod;
- private boolean cacheFailures = false;
+ private boolean cacheFailures;
private boolean hardfail = true;
- private boolean proxied = false;
+ private boolean proxied;
public ProxyRepository( String id, String url, ArtifactRepositoryLayout layout, boolean cacheFailures,
long cachePeriod )
{
this( id, url, layout );
- setCacheFailures( cacheFailures );
+ this.cacheFailures = cacheFailures;
- setCachePeriod( cachePeriod );
+ this.cachePeriod = cachePeriod;
}
public ProxyRepository( String id, String url, ArtifactRepositoryLayout layout )
package org.apache.maven.repository.proxy;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
-import org.apache.maven.repository.proxy.configuration.ProxyConfiguration;
-import org.apache.maven.repository.proxy.repository.ProxyRepository;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-
-import java.io.File;
-
/*
* Copyright 2005-2006 The Apache Software Foundation.
*
* limitations under the License.
*/
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.repository.proxy.configuration.ProxyConfiguration;
+import org.apache.maven.repository.proxy.repository.ProxyRepository;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+import java.io.File;
+
/**
* @author Edwin Punzalan
*/
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
//test cache
- file = proxy.get( "/commons-logging/commons-logging/1.0/commons-logging-1.0.jar" );
+ proxy.get( "/commons-logging/commons-logging/1.0/commons-logging-1.0.jar" );
try
{
- file = proxy.get( "/commons-logging/commons-logging/2.0/commons-logging-2.0.jar" );
+ proxy.get( "/commons-logging/commons-logging/2.0/commons-logging-2.0.jar" );
fail( "Expected ResourceDoesNotExistException exception not thrown" );
}
catch ( ResourceDoesNotExistException e )
file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
//test cache
- file = proxy.get( "/commons-logging/jars/commons-logging-1.0.jar" );
+ proxy.get( "/commons-logging/jars/commons-logging-1.0.jar" );
try
{
- file = proxy.get( "/commons-logging/jars/commons-logging-2.0.jar" );
+ proxy.get( "/commons-logging/jars/commons-logging-2.0.jar" );
fail( "Expected ResourceDoesNotExistException exception not thrown" );
}
catch ( ResourceDoesNotExistException e )
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.util.Iterator;
/**
public class MavenProxyPropertyLoaderTest
extends PlexusTestCase
{
+ private static final int DEFAULT_CACHE_PERIOD = 3600;
+
public void testLoadValidMavenProxyConfiguration()
throws ValidationException, IOException
{
assertEquals( "Count repositories", 4, config.getRepositories().size() );
- int idx = 0;
- for ( Iterator repos = config.getRepositories().iterator(); repos.hasNext(); )
- {
- idx++;
-
- ProxyRepository repo = (ProxyRepository) repos.next();
-
- //switch is made to check for ordering
- switch ( idx )
- {
- case 1:
- assertEquals( "Repository name not as expected", "local-repo", repo.getKey() );
- assertEquals( "Repository url does not match its name", "file://target", repo.getUrl() );
- assertEquals( "Repository cache period check failed", 0, repo.getCachePeriod() );
- assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
- break;
- case 2:
- assertEquals( "Repository name not as expected", "www-ibiblio-org", repo.getKey() );
- assertEquals( "Repository url does not match its name", "http://www.ibiblio.org/maven2",
- repo.getUrl() );
- assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() );
- assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
- break;
- case 3:
- assertEquals( "Repository name not as expected", "dist-codehaus-org", repo.getKey() );
- assertEquals( "Repository url does not match its name", "http://dist.codehaus.org",
- repo.getUrl() );
- assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() );
- assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
- break;
- case 4:
- assertEquals( "Repository name not as expected", "private-example-com", repo.getKey() );
- assertEquals( "Repository url does not match its name", "http://private.example.com/internal",
- repo.getUrl() );
- assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() );
- assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
- break;
- default:
- fail( "Unexpected order count" );
- }
- }
+ ProxyRepository repo = (ProxyRepository) config.getRepositories().get( 0 );
+ assertEquals( "Repository name not as expected", "local-repo", repo.getKey() );
+ assertEquals( "Repository url does not match its name", "file://target", repo.getUrl() );
+ assertEquals( "Repository cache period check failed", 0, repo.getCachePeriod() );
+ assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
+
+ repo = (ProxyRepository) config.getRepositories().get( 1 );
+ assertEquals( "Repository name not as expected", "www-ibiblio-org", repo.getKey() );
+ assertEquals( "Repository url does not match its name", "http://www.ibiblio.org/maven2", repo.getUrl() );
+ assertEquals( "Repository cache period check failed", DEFAULT_CACHE_PERIOD, repo.getCachePeriod() );
+ assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
+
+ repo = (ProxyRepository) config.getRepositories().get( 2 );
+ assertEquals( "Repository name not as expected", "dist-codehaus-org", repo.getKey() );
+ assertEquals( "Repository url does not match its name", "http://dist.codehaus.org", repo.getUrl() );
+ assertEquals( "Repository cache period check failed", DEFAULT_CACHE_PERIOD, repo.getCachePeriod() );
+ assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
+
+ repo = (ProxyRepository) config.getRepositories().get( 3 );
+ assertEquals( "Repository name not as expected", "private-example-com", repo.getKey() );
+ assertEquals( "Repository url does not match its name", "http://private.example.com/internal",
+ repo.getUrl() );
+ assertEquals( "Repository cache period check failed", DEFAULT_CACHE_PERIOD, repo.getCachePeriod() );
+ assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
}
- //make sure to delete the test directory after tests
finally
{
+ //make sure to delete the test directory after tests
FileUtils.deleteDirectory( "target/remote-repo1" );
}
}
{\r
private ProxyConfiguration config;\r
\r
+ private static final int DEFAULT_CACHE_PERIOD = 3600;\r
+\r
+ private static final int DEFAULT_PORT = 80;\r
+\r
protected void setUp()\r
throws Exception\r
{\r
ArtifactRepositoryLayout legacyLayout = new LegacyRepositoryLayout();\r
ProxyRepository repo2 = new ProxyRepository( "repo2", "http://www.ibiblio.org/maven", legacyLayout );\r
repo2.setCacheFailures( false );\r
- repo2.setCachePeriod( 3600 );\r
+ repo2.setCachePeriod( DEFAULT_CACHE_PERIOD );\r
repo2.setProxied( true );\r
- config.setHttpProxy( "some.local.proxy", 80, "username", "password" );\r
+ config.setHttpProxy( "some.local.proxy", DEFAULT_PORT, "username", "password" );\r
config.addRepository( repo2 );\r
assertEquals( 2, config.getRepositories().size() );\r
\r
assertEquals( "http://www.ibiblio.org/maven", repo.getUrl() );\r
assertFalse( repo.isCacheFailures() );\r
assertTrue( repo.isHardfail() );\r
- assertEquals( 3600, repo.getCachePeriod() );\r
+ assertEquals( DEFAULT_CACHE_PERIOD, repo.getCachePeriod() );\r
assertEquals( repo2, repo );\r
assertTrue( repo.isProxied() );\r
\r
ProxyInfo proxyInfo = config.getHttpProxy();\r
assertNotNull( proxyInfo );\r
assertEquals( "some.local.proxy", proxyInfo.getHost() );\r
- assertEquals( 80, proxyInfo.getPort() );\r
+ assertEquals( DEFAULT_PORT, proxyInfo.getPort() );\r
assertEquals( "username", proxyInfo.getUserName() );\r
assertEquals( "password", proxyInfo.getPassword() );\r
\r
repositories.add( new ProxyRepository( "repo", "url", defLayout ) );\r
fail( "Expected UnsupportedOperationException not thrown." );\r
}\r
- catch ( java.lang.UnsupportedOperationException e )\r
+ catch ( UnsupportedOperationException e )\r
{\r
assertTrue( true );\r
}\r
* @param key the object to map the valued object
* @param value the object to cache
*/
- public Object put( Object key, Object value )
+ public void put( Object key, Object value )
{
Object old = null;
}
manageCache();
-
- return old;
}
/**
*/
public class ArtifactUtils
{
+ private ArtifactUtils()
+ {
+ }
+
/**
* Method used to build an artifact and then set its repository and file fields with the proper values
*
// contains artifactId, version, classifier, and extension.
String avceGlob = tokens.nextToken();
+ //noinspection CollectionDeclaredAsConcreteClass
LinkedList avceTokenList = new LinkedList();
StringTokenizer avceTokenizer = new StringTokenizer( avceGlob, "-" );
package org.apache.maven.repository.digest;
-import org.codehaus.plexus.util.IOUtil;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
/*
* Copyright 2005-2006 The Apache Software Foundation.
*
* limitations under the License.
*/
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* Create a digest for a file.
*
package org.apache.maven.repository;
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.codehaus.plexus.PlexusTestCase;
+<!--
+ ~ 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.
+ -->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
*/\r
\r
import com.opensymphony.xwork.Action;\r
-import org.apache.maven.repository.manager.web.job.DiscovererScheduler;\r
import org.apache.maven.repository.manager.web.execution.DiscovererExecution;\r
+import org.apache.maven.repository.manager.web.job.DiscovererScheduler;\r
\r
/**\r
* This is the Action class of index.jsp, which is the initial page of the web application.\r
}\r
catch ( Exception e )\r
{\r
+ // TODO: better exception handling!\r
e.printStackTrace();\r
return ERROR;\r
}\r
package org.apache.maven.repository.manager.web.action;\r
\r
+/*\r
+ * Copyright 2005-2006 The Apache Software Foundation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
import com.opensymphony.xwork.Action;\r
import org.apache.maven.artifact.repository.ArtifactRepository;\r
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;\r
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
-import org.apache.maven.repository.indexing.DefaultRepositoryIndexSearcher;
+import org.apache.maven.repository.indexing.RepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
-import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
+import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
import org.apache.maven.repository.manager.web.job.Configuration;
-import org.apache.maven.repository.indexing.RepositoryIndex;
import java.io.File;
import java.net.MalformedURLException;
package org.apache.maven.repository.manager.web.action;\r
\r
+/*\r
+ * Copyright 2005-2006 The Apache Software Foundation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
import com.opensymphony.xwork.Action;\r
import org.apache.maven.artifact.Artifact;\r
import org.apache.maven.artifact.repository.ArtifactRepository;\r
import java.util.Collections;\r
import java.util.Iterator;\r
import java.util.List;\r
+import java.util.Map;\r
import java.util.TreeMap;\r
\r
/**\r
\r
private String group;\r
\r
- private TreeMap artifactMap;\r
+ private Map artifactMap;\r
\r
private String folder;\r
\r
private int idx;\r
\r
public String execute()\r
- throws Exception\r
{\r
+ // TODO! fix hardcoded path\r
String path = "E:/jeprox/maven-repository-manager/trunk/maven-repository-discovery/src/test/repository";\r
\r
ArtifactRepository repository =\r
\r
artifactMap = new TreeMap();\r
\r
- String groupId;\r
-\r
while ( iterator.hasNext() )\r
{\r
Artifact artifact = (Artifact) iterator.next();\r
\r
- groupId = artifact.getGroupId();\r
+ String groupId = artifact.getGroupId();\r
\r
String key = groupId.replace( '.', '/' ) + "/" + artifact.getArtifactId() + "/" + artifact.getVersion();\r
\r
- ArrayList artifactList;\r
+ List artifactList;\r
\r
if ( artifactMap.containsKey( key ) )\r
{\r
- artifactList = (ArrayList) artifactMap.get( key );\r
+ artifactList = (List) artifactMap.get( key );\r
}\r
else\r
{\r
}\r
\r
//set the index for folder level to be displayed\r
- setIdx( 1 );\r
+ idx = 1;\r
\r
- setFolder( "" );\r
+ folder = "";\r
\r
return SUCCESS;\r
}\r
\r
+ // TODO! is this method needed?\r
public String doEdit()\r
- throws Exception\r
{\r
- setIdx( getIdx() + 1 );\r
+ idx = idx + 1;\r
\r
//set folder to "" if we are at the root directory\r
- if ( getIdx() == 1 )\r
+ if ( idx == 1 )\r
{\r
- setFolder( "" );\r
+ folder = "";\r
}\r
\r
return SUCCESS;\r
}\r
\r
- public TreeMap getArtifactMap()\r
+ public Map getArtifactMap()\r
{\r
return artifactMap;\r
}\r
* limitations under the License.
*/
+import org.apache.lucene.index.IndexReader;
+import org.apache.maven.artifact.Artifact;
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.model.Model;
+import org.apache.maven.repository.discovery.ArtifactDiscoverer;
+import org.apache.maven.repository.discovery.MetadataDiscoverer;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.MetadataRepositoryIndex;
import org.apache.maven.repository.indexing.PomRepositoryIndex;
+import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.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;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
/**
* This is the class that executes the discoverer and indexer.
private ArtifactRepositoryLayout layout;
- private Properties props;
-
private String indexPath;
private String blacklistedPatterns;
public void executeDiscovererIfIndexDoesNotExist()
throws MalformedURLException, RepositoryIndexException
{
- props = config.getProperties();
+ Properties props = config.getProperties();
indexPath = props.getProperty( "index.path" );
File indexDir = new File( indexPath );
- boolean isExisting;
+ boolean isExisting = false;
if ( IndexReader.indexExists( indexDir ) )
{
isExisting = true;
}
- else if ( !indexDir.exists() )
- {
- isExisting = false;
- }
- else
- {
- isExisting = false;
- }
if ( !isExisting )
{
public void executeDiscoverer()
throws MalformedURLException, RepositoryIndexException
{
- props = config.getProperties();
+ Properties 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();
+ includeSnapshots = Boolean.valueOf( props.getProperty( "include.snapshots" ) ).booleanValue();
+ convertSnapshots = Boolean.valueOf( props.getProperty( "convert.snapshots" ) ).booleanValue();
try
{
}
getLogger().info( "[DiscovererExecution] Started discovery and indexing.." );
- if ( props.getProperty( "layout" ).equals( "default" ) )
+ if ( "default".equals( props.getProperty( "layout" ) ) )
{
executeDiscovererInDefaultRepo();
}
- else if ( props.getProperty( "layout" ).equals( "legacy" ) )
+ else if ( "legacy".equals( props.getProperty( "layout" ) ) )
{
executeDiscovererInLegacyRepo();
}
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;
- }
- }
+ artifactIndex.indexArtifact( artifact );
if ( artifactIndex.isOpen() )
{
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;
- }
- }
+ metadataIndex.index( repoMetadata );
+
if ( metadataIndex.isOpen() )
{
metadataIndex.optimize();
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;
- }
- }
+ pomIndex.indexPom( model );
if ( pomIndex.isOpen() )
{
package org.apache.maven.repository.manager.web.job;\r
\r
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;\r
-import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;\r
-import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;\r
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;\r
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;\r
-\r
-import java.util.Properties;\r
/*\r
* Copyright 2005-2006 The Apache Software Foundation.\r
*\r
* limitations under the License.\r
*/\r
\r
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;\r
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;\r
+import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;\r
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;\r
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;\r
+\r
+import java.util.Properties;\r
+\r
/**\r
* This class contains the configuration values to be used by the scheduler\r
*/\r
* limitations under the License.\r
*/\r
\r
-import org.apache.maven.artifact.Artifact;\r
-import org.apache.maven.artifact.repository.ArtifactRepository;\r
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;\r
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;\r
-import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;\r
-import org.apache.maven.model.Model;\r
-import org.apache.maven.repository.discovery.ArtifactDiscoverer;\r
-import org.apache.maven.repository.discovery.DefaultArtifactDiscoverer;\r
-import org.apache.maven.repository.discovery.DefaultMetadataDiscoverer;\r
-import org.apache.maven.repository.discovery.LegacyArtifactDiscoverer;\r
-import org.apache.maven.repository.discovery.MetadataDiscoverer;\r
-import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;\r
-import org.apache.maven.repository.indexing.MetadataRepositoryIndex;\r
-import org.apache.maven.repository.indexing.PomRepositoryIndex;\r
import org.apache.maven.repository.indexing.RepositoryIndexException;\r
-import org.apache.maven.repository.indexing.RepositoryIndexingFactory;\r
import org.apache.maven.repository.manager.web.execution.DiscovererExecution;\r
import org.codehaus.plexus.scheduler.AbstractJob;\r
import org.quartz.JobDataMap;\r
import org.quartz.JobExecutionContext;\r
import org.quartz.JobExecutionException;\r
\r
-import java.io.File;\r
import java.net.MalformedURLException;\r
-import java.util.Iterator;\r
-import java.util.List;\r
\r
/**\r
* This class is the discoverer job that is executed by the scheduler.\r
{\r
public static final String ROLE = DiscovererJob.class.getName();\r
\r
- public static String MAP_DISCOVERER_EXECUTION = "EXECUTION";\r
+ public static final String MAP_DISCOVERER_EXECUTION = "EXECUTION";\r
\r
/**\r
* Execute the discoverer and the indexer.\r
}\r
catch ( RepositoryIndexException e )\r
{\r
+ // TODO!\r
e.printStackTrace();\r
}\r
catch ( MalformedURLException me )\r
{\r
+ // TODO!\r
me.printStackTrace();\r
}\r
\r
* limitations under the License.\r
*/\r
\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.net.MalformedURLException;\r
-import java.text.ParseException;\r
-import java.util.Properties;\r
-\r
-import org.apache.maven.artifact.repository.ArtifactRepository;\r
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;\r
-import org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory;\r
-import org.apache.maven.repository.discovery.ArtifactDiscoverer;\r
-import org.apache.maven.repository.discovery.MetadataDiscoverer;\r
-import org.apache.maven.repository.indexing.RepositoryIndexingFactory;\r
import org.apache.maven.repository.manager.web.execution.DiscovererExecution;\r
import org.codehaus.plexus.logging.AbstractLogEnabled;\r
+import org.codehaus.plexus.scheduler.AbstractJob;\r
import org.codehaus.plexus.scheduler.Scheduler;\r
import org.quartz.CronTrigger;\r
import org.quartz.JobDataMap;\r
import org.quartz.JobDetail;\r
import org.quartz.SchedulerException;\r
\r
+import java.text.ParseException;\r
+import java.util.Properties;\r
+\r
/**\r
* This class sets the job to be executed in the plexus-quartz scheduler\r
*\r
*/\r
private Scheduler scheduler;\r
\r
- private Properties props;\r
-\r
/**\r
* @plexus.requirement\r
*/\r
/**\r
* Method that sets the schedule in the plexus-quartz scheduler\r
*\r
- * @throws IOException\r
* @throws ParseException\r
* @throws SchedulerException\r
*/\r
public void setSchedule()\r
- throws IOException, ParseException, SchedulerException\r
+ throws ParseException, SchedulerException\r
{\r
- props = config.getProperties();\r
+ Properties props = config.getProperties();\r
JobDetail jobDetail = new JobDetail( "discovererJob", "DISCOVERER", DiscovererJob.class );\r
JobDataMap dataMap = new JobDataMap();\r
- dataMap.put( DiscovererJob.LOGGER, getLogger() );\r
+ dataMap.put( AbstractJob.LOGGER, getLogger() );\r
dataMap.put( DiscovererJob.MAP_DISCOVERER_EXECUTION, execution );\r
jobDetail.setJobDataMap( dataMap );\r
\r
+<!--
+ ~ 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.
+ -->
+
<decorators defaultdir="/WEB-INF/jsp/decorators">
<decorator name="default" page="default.jsp">
<pattern>/*</pattern>
+<%--\r
+ ~ Copyright 2005-2006 The Apache Software Foundation.\r
+ ~\r
+ ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+ ~ you may not use this file except in compliance with the License.\r
+ ~ You may obtain a copy of the License at\r
+ ~\r
+ ~ http://www.apache.org/licenses/LICENSE-2.0\r
+ ~\r
+ ~ Unless required by applicable law or agreed to in writing, software\r
+ ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ ~ See the License for the specific language governing permissions and\r
+ ~ limitations under the License.\r
+ --%>\r
+\r
<%@ taglib uri="webwork" prefix="ww" %>\r
\r
<html>\r
\r
<body>\r
<h3><a href="<ww:url value="browse!edit.action"><ww:param name="idx" value="0"/></ww:url>">basedir</a> /\r
- <ww:set name="previousFolder" value="''"/>\r
- <ww:set name="counter" value="0"/>\r
+ <ww:set name="previousFolder" value="''" />\r
+ <ww:set name="counter" value="0" />\r
<ww:if test="folder != ''">\r
- <ww:set name="folderHeader" value="folder.split('/')"/>\r
+ <ww:set name="folderHeader" value="folder.split('/')" />\r
<ww:iterator value="#folderHeader">\r
- <ww:set name="counter" value="#counter + 1"/>\r
+ <ww:set name="counter" value="#counter + 1" />\r
<ww:if test="#previousFolder == ''">\r
- <ww:set name="previousFolder" value="top"/>\r
+ <ww:set name="previousFolder" value="top" />\r
</ww:if>\r
<ww:else>\r
- <ww:set name="previousFolder" value="#previousFolder + '/' + top"/>\r
+ <ww:set name="previousFolder" value="#previousFolder + '/' + top" />\r
</ww:else>\r
<ww:if test="idx > (#counter + 1)"><a href="<ww:url value="browse!edit.action"><ww:param name="idx"><ww:property\r
- value="#counter"/></ww:param><ww:param name="folder"></ww:param></ww:url>"></ww:if><ww:property/></a> /\r
+ value="#counter" /></ww:param><ww:param name="folder"></ww:param></ww:url>"></ww:if><ww:property /></a> /\r
</ww:iterator>\r
</ww:if>\r
</h3>\r
-<br/>\r
+<br />\r
\r
<ww:set name="previousFolder" value="'the previous folder'"/>\r
<ww:set name="in" value="idx" scope="page"/>\r
<ww:if test="idx == 1 || (folder != '' and #groupName.startsWith(folder))">\r
<%\r
\r
+\r
int ctr = 1;\r
\r
+\r
%>\r
<ww:set name="groupFolder" value="#groupName.split('/')"/>\r
<ww:iterator value="#groupFolder">\r
<%\r
\r
+\r
if (ctr == ((Integer)pageContext.getAttribute("in")).intValue()) {\r
+\r
%>\r
<ww:if test="top != #previousFolder">\r
<ww:set name="previousFolder" value="top"/>\r
</ww:iterator>\r
\r
<ww:if test="folder != ''">\r
- <ww:set name="previousFolder" value="''"/>\r
- <ww:set name="artifactList" value="artifactMap.get(folder)"/>\r
+ <ww:set name="previousFolder" value="''" />\r
+ <ww:set name="artifactList" value="artifactMap.get(folder)" />\r
<ww:iterator value="#artifactList">\r
<table border="1">\r
<tr align="left">\r
<th>Group ID</th>\r
- <td><ww:property value="groupId"/></td>\r
+ <td><ww:property value="groupId" /></td>\r
</tr>\r
<tr align="left">\r
<th>Artifact ID</th>\r
- <td><ww:property value="artifactId"/></td>\r
+ <td><ww:property value="artifactId" /></td>\r
</tr>\r
<tr align="left">\r
<th>Version</th>\r
- <td><ww:property value="version"/></td>\r
+ <td><ww:property value="version" /></td>\r
</tr>\r
<tr align="left">\r
<th>Derivatives</th>\r
- <td><ww:property value="groupId"/></td>\r
+ <td><ww:property value="groupId" /></td>\r
</tr>\r
<tr align="left">\r
<th>Parent</th>\r
- <td><ww:property value="folder"/></td>\r
+ <td><ww:property value="folder" /></td>\r
</tr>\r
</table>\r
- <br/>\r
+ <br />\r
</ww:iterator>\r
</ww:if>\r
</body>\r
+<%--
+ ~ 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.
+ --%>
+
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<html>
<head>
~ 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.
- ~
--%>
<script type="text/javascript">
+<%--
+ ~ 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.
+ --%>
+
<%@ taglib uri="webwork" prefix="ww" %>
<html>
<head>
+<!--
+ ~ 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.
+ -->
+
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
+/*
+ * 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.
+ */
+
body {
margin: 0px;
padding: 0px;
+/*
+ * 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.
+ */
+
body {
padding: 0px 0px 10px 0px;
}
+/*
+ * 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.
+ */
+
#banner, #footer, #leftcol, #breadcrumbs, .docs #toc, .docs .courtesylinks, #leftColumn, #navColumn {
display: none !important;
}
+/*
+ * 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.
+ */
+
#sidebar {
float: right;
font-size: small;
+<%--
+ ~ 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.
+ --%>
+
<%response.sendRedirect( request.getContextPath() + "/index.action" );%>
\ No newline at end of file