Browse Source

general clean up, addition of copyrights

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@412295 13f79535-47bb-0310-9956-ffa450edef68
tags/archiva-0.9-alpha-1
Brett Porter 18 years ago
parent
commit
8aad68cfe4
68 changed files with 737 additions and 515 deletions
  1. 6
    2
      maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java
  2. 16
    0
      maven-repository-artifact-applet/pom.xml
  3. 51
    32
      maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java
  4. 13
    1
      maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
  5. 2
    2
      maven-repository-converter/src/main/java/org/apache/maven/repository/converter/transaction/TransactionEvent.java
  6. 1
    0
      maven-repository-converter/src/main/resources/org/apache/maven/repository/converter/DefaultRepositoryConverter.properties
  7. 4
    4
      maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java
  8. 0
    1
      maven-repository-converter/src/test/source-repository/test/poms/newversion-artifact-1.0.1.pom
  9. 0
    1
      maven-repository-converter/src/test/source-repository/test/poms/v3-warnings-artifact-1.0.0.pom
  10. 0
    1
      maven-repository-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.pom
  11. 18
    6
      maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
  12. 17
    1
      maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
  13. 1
    1
      maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
  14. 25
    28
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndex.java
  15. 2
    16
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndex.java
  16. 13
    10
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexSearcher.java
  17. 1
    2
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexingFactory.java
  18. 0
    2
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java
  19. 4
    6
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java
  20. 6
    4
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/PomRepositoryIndex.java
  21. 28
    29
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java
  22. 3
    3
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchHit.java
  23. 3
    4
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayer.java
  24. 1
    2
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexingFactory.java
  25. 4
    5
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/query/Query.java
  26. 7
    8
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/query/SinglePhraseQuery.java
  27. 3
    3
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java
  28. 19
    17
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/EclipseRepositoryIndexTest.java
  29. 8
    12
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/MetadataRepositoryIndexingTest.java
  30. 8
    9
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/PomRepositoryIndexingTest.java
  31. 7
    23
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayerTest.java
  32. 3
    4
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/query/QueryTest.java
  33. 18
    1
      maven-repository-manager-site/pom.xml
  34. 18
    2
      maven-repository-manager-site/src/site/site.xml
  35. 3
    1
      maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java
  36. 1
    1
      maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/ProxyManager.java
  37. 49
    49
      maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java
  38. 1
    1
      maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/ProxyConfiguration.java
  39. 2
    2
      maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/ValidationException.java
  40. 5
    5
      maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java
  41. 12
    12
      maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/DefaultProxyManagerTest.java
  42. 2
    2
      maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/LegacyProxyManagerTest.java
  43. 27
    43
      maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java
  44. 9
    5
      maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java
  45. 1
    3
      maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/Cache.java
  46. 5
    0
      maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java
  47. 11
    11
      maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DefaultDigester.java
  48. 16
    0
      maven-repository-utils/src/test/java/org/apache/maven/repository/ArtifactUtilsLegacyTest.java
  49. 16
    0
      maven-repository-webapp/pom.xml
  50. 2
    1
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BaseAction.java
  51. 16
    0
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java
  52. 2
    3
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
  53. 29
    14
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/RepositoryBrowseAction.java
  54. 20
    59
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java
  55. 8
    7
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java
  56. 3
    19
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererJob.java
  57. 7
    18
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererScheduler.java
  58. 16
    0
      maven-repository-webapp/src/main/webapp/WEB-INF/decorators.xml
  59. 36
    16
      maven-repository-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp
  60. 16
    0
      maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp
  61. 0
    1
      maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf
  62. 16
    0
      maven-repository-webapp/src/main/webapp/WEB-INF/jsp/index.jsp
  63. 16
    0
      maven-repository-webapp/src/main/webapp/WEB-INF/web.xml
  64. 16
    0
      maven-repository-webapp/src/main/webapp/css/maven-base.css
  65. 16
    0
      maven-repository-webapp/src/main/webapp/css/maven-theme.css
  66. 16
    0
      maven-repository-webapp/src/main/webapp/css/print.css
  67. 16
    0
      maven-repository-webapp/src/main/webapp/css/site.css
  68. 16
    0
      maven-repository-webapp/src/main/webapp/index.jsp

+ 6
- 2
maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java View File

@@ -20,10 +20,10 @@ 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.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;
@@ -40,6 +40,10 @@ import java.net.MalformedURLException;
*/
public class IndexSearcherCli
{
private IndexSearcherCli()
{
}

public static void main( String[] args )
throws PlexusContainerException, ComponentLookupException, RepositoryIndexException, MalformedURLException,
RepositoryIndexSearchException
@@ -62,7 +66,7 @@ public class IndexSearcherCli

ArtifactRepositoryIndex index =
indexFactory.createArtifactRepositoryIndex( new File( args[0], ".index" ).getAbsolutePath(), repository );
DefaultRepositoryIndexSearcher searcher = indexFactory.createDefaultRepositoryIndexSearcher( index );

try

+ 16
- 0
maven-repository-artifact-applet/pom.xml View File

@@ -1,3 +1,19 @@
<!--
~ 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>

+ 51
- 32
maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java View File

@@ -14,7 +14,6 @@ package org.apache.maven.repository.applet;
* 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.*;
@@ -56,53 +55,73 @@ public class ChecksumApplet
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 = "";


+ 13
- 1
maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java View File

@@ -32,6 +32,7 @@ import org.apache.maven.model.Model;
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;
@@ -43,6 +44,7 @@ import org.codehaus.plexus.util.IOUtil;
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;
@@ -213,6 +215,10 @@ public class DefaultRepositoryConverter
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 );
@@ -443,10 +449,16 @@ public class DefaultRepositoryConverter
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 );

+ 2
- 2
maven-repository-converter/src/main/java/org/apache/maven/repository/converter/transaction/TransactionEvent.java View File

@@ -1,7 +1,5 @@
package org.apache.maven.repository.converter.transaction;

import java.io.IOException;

/*
* Copyright 2005-2006 The Apache Software Foundation.
*
@@ -18,6 +16,8 @@ import java.io.IOException;
* limitations under the License.
*/

import java.io.IOException;

/**
* Interface for individual events in a transaction.
*

+ 1
- 0
maven-repository-converter/src/main/resources/org/apache/maven/repository/converter/DefaultRepositoryConverter.properties View File

@@ -23,6 +23,7 @@ warning.missing.pom=The artifact had no POM in the source repository.

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.

+ 4
- 4
maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java View File

@@ -581,10 +581,10 @@ public class RepositoryConverterTest
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() );
@@ -954,7 +954,7 @@ public class RepositoryConverterTest
}
else if ( file.isDirectory() )
{
if ( !file.getName().equals( ".svn" ) )
if ( !".svn".equals( file.getName() ) )
{
if ( !destination.exists() && !destination.mkdirs() )
{

+ 0
- 1
maven-repository-converter/src/test/source-repository/test/poms/newversion-artifact-1.0.1.pom View File

@@ -12,7 +12,6 @@
~ 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>

+ 0
- 1
maven-repository-converter/src/test/source-repository/test/poms/v3-warnings-artifact-1.0.0.pom View File

@@ -12,7 +12,6 @@
~ 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>

+ 0
- 1
maven-repository-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.pom View File

@@ -12,7 +12,6 @@
~ 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>

+ 18
- 6
maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java View File

@@ -20,9 +20,12 @@ import org.apache.maven.artifact.Artifact;
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;

@@ -42,12 +45,12 @@ public abstract class AbstractArtifactDiscoverer
"**/*.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 );
}
@@ -114,7 +117,7 @@ public abstract class AbstractArtifactDiscoverer
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() )
{
@@ -122,10 +125,19 @@ public abstract class AbstractArtifactDiscoverer
}
}
}
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() );
}
}
}

+ 17
- 1
maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java View File

@@ -1,5 +1,21 @@
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;
@@ -16,7 +32,7 @@ import java.util.List;
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
public class AbstractDiscoverer
public abstract class AbstractDiscoverer
extends AbstractLogEnabled
{
private List kickedOutPaths = new ArrayList();

+ 1
- 1
maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java View File

@@ -129,7 +129,7 @@ public class DefaultMetadataDiscoverer
//}

Artifact artifact = null;
if ( metaVersion != null && !metaVersion.equals( "" ) )
if ( metaVersion != null && !"".equals( metaVersion ) )
{
artifact = artifactFactory.createBuildArtifact( metaGroupId, metaArtifactId, metaVersion, "jar" );
}

+ 25
- 28
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndex.java View File

@@ -54,10 +54,8 @@ public abstract class AbstractRepositoryIndex
*
* @param indexPath
* @param repository
* @throws RepositoryIndexException
*/
protected AbstractRepositoryIndex( String indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
this.repository = repository;
this.indexPath = indexPath;
@@ -237,11 +235,10 @@ public abstract class AbstractRepositoryIndex
* 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 );

@@ -332,7 +329,7 @@ public abstract class AbstractRepositoryIndex
return isAdded;
}

private class ArtifactRepositoryIndexAnalyzer
private static class ArtifactRepositoryIndexAnalyzer
extends Analyzer
{
private Analyzer defaultAnalyzer;
@@ -342,7 +339,7 @@ public abstract class AbstractRepositoryIndex
*
* @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;
}
@@ -369,33 +366,33 @@ public abstract class AbstractRepositoryIndex

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 != '-';
}
}
}

+ 2
- 16
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndex.java View File

@@ -47,10 +47,8 @@ public class ArtifactRepositoryIndex
* @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;
@@ -179,12 +177,9 @@ public class ArtifactRepositoryIndex
*
* @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 )
{
@@ -193,10 +188,7 @@ public class ArtifactRepositoryIndex
{
packages.append( packageName ).append( "\n" );
}
isAdded = true;
}

return isAdded;
}

/**
@@ -204,9 +196,8 @@ public class ArtifactRepositoryIndex
*
* @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( '/' );
@@ -215,14 +206,9 @@ public class ArtifactRepositoryIndex
name = name.substring( idx + 1 );
}

boolean isAdded = false;

if ( files.indexOf( name + "\n" ) < 0 )
{
files.append( name ).append( "\n" );
isAdded = true;
}

return isAdded;
}
}

+ 13
- 10
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexSearcher.java View File

@@ -103,6 +103,10 @@ public class DefaultRepositoryIndexSearcher
Hits hits = searcher.search( luceneQuery );
docs = buildList( hits );
}
catch ( MalformedURLException e )
{
throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e );
}
catch ( IOException e )
{
throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e );
@@ -168,17 +172,15 @@ public class DefaultRepositoryIndexSearcher
protected RepositoryIndexSearchHit createSearchedObjectFromIndexDocument( Document doc )
throws MalformedURLException, IOException, XmlPullParserException
{
String groupId, artifactId, version, name, packaging;
RepositoryIndexSearchHit searchHit = null;
// the document is of type artifact
if ( doc.get( RepositoryIndex.FLD_DOCTYPE ).equals( RepositoryIndex.ARTIFACT ) )
{
groupId = doc.get( RepositoryIndex.FLD_GROUPID );
artifactId = doc.get( RepositoryIndex.FLD_ARTIFACTID );
version = doc.get( RepositoryIndex.FLD_VERSION );
name = doc.get( RepositoryIndex.FLD_NAME );
packaging = doc.get( RepositoryIndex.FLD_PACKAGING );
String groupId = doc.get( RepositoryIndex.FLD_GROUPID );
String artifactId = doc.get( RepositoryIndex.FLD_ARTIFACTID );
String version = doc.get( RepositoryIndex.FLD_VERSION );
String packaging = doc.get( RepositoryIndex.FLD_PACKAGING );
Artifact artifact = factory.createBuildArtifact( groupId, artifactId, version, packaging );
artifact.setFile(
@@ -224,7 +226,7 @@ public class DefaultRepositoryIndexSearcher
String metadataFile = (String) it.next();
String tmpDir = (String) it.next();
String metadataType = "";
String metadataType;
if ( tmpDir.equals( doc.get( RepositoryIndex.FLD_VERSION ) ) )
{
metadataType = MetadataRepositoryIndex.SNAPSHOT_METADATA;
@@ -258,16 +260,17 @@ public class DefaultRepositoryIndexSearcher
* @param filename the name of the metadata file
* @param metadataType the type of RepositoryMetadata object to be created (GROUP, ARTIFACT or SNAPSHOT)
* @return RepositoryMetadata
* @throws MalformedURLException
* @throws IOException
* @throws XmlPullParserException
*/
private RepositoryMetadata getMetadata( String groupId, String artifactId, String version, String filename,
String metadataType )
throws MalformedURLException, IOException, XmlPullParserException
throws IOException, XmlPullParserException
{
RepositoryMetadata repoMetadata = null;
InputStream is = null;
// TODO! file handles left open
InputStream is;
MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();
//group metadata

+ 1
- 2
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexingFactory.java View File

@@ -1,14 +1,13 @@
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,

+ 0
- 2
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java View File

@@ -67,10 +67,8 @@ public class EclipseRepositoryIndex
* @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 );


+ 4
- 6
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java View File

@@ -45,10 +45,8 @@ public class MetadataRepositoryIndex
*
* @param indexPath the path to the index
* @param repository the repository where the metadata to be indexed is located
* @throws RepositoryIndexException
*/
public MetadataRepositoryIndex( String indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
super( indexPath, repository );
}
@@ -105,7 +103,7 @@ public class MetadataRepositoryIndex
repoMetadata.getBaseVersion() + "/";
}
if ( !repoMetadata.getRemoteFilename().equals( "" ) && repoMetadata.getRemoteFilename() != null )
if ( !"".equals( repoMetadata.getRemoteFilename() ) && repoMetadata.getRemoteFilename() != null )
{
path = path + repoMetadata.getRemoteFilename();
}
@@ -130,7 +128,7 @@ public class MetadataRepositoryIndex
for ( Iterator iter = plugins.iterator(); iter.hasNext(); )
{
Plugin plugin = (Plugin) iter.next();
if ( plugin.getPrefix() != null && !plugin.getPrefix().equals( "" ) )
if ( plugin.getPrefix() != null && !"".equals( plugin.getPrefix() ) )
{
pluginAppended = plugin.getPrefix() + "\n";
}
@@ -138,7 +136,7 @@ public class MetadataRepositoryIndex
doc.add( Field.Text( FLD_PLUGINPREFIX, pluginAppended ) );
doc.add( Field.Text( FLD_GROUPID, metadata.getGroupId() ) );
if ( metadata.getArtifactId() != null && !metadata.getArtifactId().equals( "" ) )
if ( metadata.getArtifactId() != null && !"".equals( metadata.getArtifactId() ) )
{
doc.add( Field.Text( FLD_ARTIFACTID, metadata.getArtifactId() ) );
}
@@ -147,7 +145,7 @@ public class MetadataRepositoryIndex
doc.add( Field.Text( FLD_ARTIFACTID, "" ) );
}
if ( metadata.getVersion() != null && !metadata.getVersion().equals( "" ) )
if ( metadata.getVersion() != null && !"".equals( metadata.getVersion() ) )
{
doc.add( Field.Text( FLD_VERSION, metadata.getVersion() ) );
}

+ 6
- 4
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/PomRepositoryIndex.java View File

@@ -1,14 +1,13 @@
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,
@@ -31,6 +30,7 @@ import org.apache.maven.repository.digest.Digester;
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;
@@ -55,11 +55,9 @@ public class PomRepositoryIndex
* @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;
@@ -266,6 +264,10 @@ public class PomRepositoryIndex
{
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 );

+ 28
- 29
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java View File

@@ -27,59 +27,58 @@ import java.util.List;
*/
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

+ 3
- 3
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchHit.java View File

@@ -23,11 +23,11 @@ public class RepositoryIndexSearchHit
{
private Object obj;
private boolean isHashMap = false;
private boolean isHashMap;
private boolean isMetadata = false;
private boolean isMetadata;
private boolean isModel = false;
private boolean isModel;
/**
* Class constructor

+ 3
- 4
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayer.java View File

@@ -18,7 +18,6 @@ package org.apache.maven.repository.indexing;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.License;
import org.apache.maven.model.Model;
@@ -144,7 +143,7 @@ public class RepositoryIndexSearchLayer
else if ( hit.isMetadata() )
{
//@todo what about metadata objects?
RepositoryMetadata metadata = (RepositoryMetadata) hit.getObject();
// RepositoryMetadata metadata = (RepositoryMetadata) hit.getObject();
}
}
@@ -212,7 +211,7 @@ public class RepositoryIndexSearchLayer
}
}
if ( values != null && values.size() > 0 )
if ( !values.isEmpty() )
{
resultMap.put( key, values );
}
@@ -351,7 +350,7 @@ public class RepositoryIndexSearchLayer
}
}
if ( values.size() > 0 && values != null )
if ( !values.isEmpty() )
{
map.put( field, values );
}

+ 1
- 2
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexingFactory.java View File

@@ -1,14 +1,13 @@
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,

+ 4
- 5
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/query/Query.java View File

@@ -1,17 +1,13 @@
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,
@@ -20,6 +16,9 @@ import org.apache.maven.repository.indexing.RepositoryIndex;
* limitations under the License.
*/

import org.apache.lucene.queryParser.ParseException;
import org.apache.maven.repository.indexing.RepositoryIndex;

/**
* Interface to label the query classes
*

+ 7
- 8
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/query/SinglePhraseQuery.java View File

@@ -1,20 +1,13 @@
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,
@@ -23,6 +16,12 @@ import org.apache.maven.repository.indexing.RepositoryIndex;
* 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
*

+ 3
- 3
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java View File

@@ -422,7 +422,7 @@ public class ArtifactRepositoryIndexingTest
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 )
@@ -436,7 +436,7 @@ public class ArtifactRepositoryIndexingTest
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 )
@@ -466,7 +466,7 @@ public class ArtifactRepositoryIndexingTest
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() );
}

/**

+ 19
- 17
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/EclipseRepositoryIndexTest.java View File

@@ -1,5 +1,21 @@
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;
@@ -17,22 +33,6 @@ import org.codehaus.plexus.util.FileUtils;

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
*/
@@ -49,6 +49,8 @@ public class EclipseRepositoryIndexTest

private long artifactFileTime;

private static final long TIME_DIFFERENCE = 10000L;

protected void setUp()
throws Exception
{
@@ -84,7 +86,7 @@ public class EclipseRepositoryIndexTest
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 ) ) );

+ 8
- 12
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/MetadataRepositoryIndexingTest.java View File

@@ -52,8 +52,6 @@ public class MetadataRepositoryIndexingTest
private String indexPath;
private MetadataRepositoryIndex indexer;
private ArtifactFactory artifactFactory;
/**
@@ -98,7 +96,7 @@ public class MetadataRepositoryIndexingTest
throws Exception
{
RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );
indexer = factory.createMetadataRepositoryIndex( indexPath, repository );
MetadataRepositoryIndex indexer = factory.createMetadataRepositoryIndex( indexPath, repository );
RepositoryMetadata repoMetadata =
getMetadata( "org.apache.maven", null, null, "maven-metadata.xml", MetadataRepositoryIndex.GROUP_METADATA );
@@ -140,8 +138,7 @@ public class MetadataRepositoryIndexingTest
RepositoryIndexSearchLayer repoSearchLayer = factory.createRepositoryIndexSearchLayer( indexer );
// search last update
org.apache.maven.repository.indexing.query.Query qry =
new SinglePhraseQuery( RepositoryIndex.FLD_LASTUPDATE, "20051212044643" );
Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_LASTUPDATE, "20051212044643" );
List metadataList = repoSearchLayer.searchAdvanced( qry );
//assertEquals( 1, metadataList.size() );
for ( Iterator iter = metadataList.iterator(); iter.hasNext(); )
@@ -204,7 +201,7 @@ public class MetadataRepositoryIndexingTest
rQry.addQuery( qry2 );
metadataList = repoSearchLayer.searchAdvanced( rQry );
assertEquals( metadataList.size(), 0 );
assertEquals( 0, metadataList.size() );
indexer.close();
}
@@ -219,7 +216,7 @@ public class MetadataRepositoryIndexingTest
{
//test when the object passed in the index(..) method is not a RepositoryMetadata instance
RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );
indexer = factory.createMetadataRepositoryIndex( indexPath, repository );
MetadataRepositoryIndex indexer = factory.createMetadataRepositoryIndex( indexPath, repository );
try
{
Artifact artifact = getArtifact( "org.apache.maven", "maven-artifact", "2.0.1" );
@@ -255,17 +252,16 @@ public class MetadataRepositoryIndexingTest
createTestIndex();
RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );
indexer = factory.createMetadataRepositoryIndex( indexPath, repository );
MetadataRepositoryIndex indexer = factory.createMetadataRepositoryIndex( indexPath, repository );
RepositoryMetadata repoMetadata =
getMetadata( "org.apache.maven", null, null, "maven-metadata.xml", MetadataRepositoryIndex.GROUP_METADATA );
indexer.deleteDocument( RepositoryIndex.FLD_ID, (String) repoMetadata.getKey() );
RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
org.apache.maven.repository.indexing.query.Query qry =
new SinglePhraseQuery( RepositoryIndex.FLD_ID, (String) repoMetadata.getKey() );
Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_ID, (String) repoMetadata.getKey() );
List metadataList = repoSearcher.search( qry );
assertEquals( metadataList.size(), 0 );
assertEquals( 0, metadataList.size() );
}
/**
@@ -285,7 +281,7 @@ public class MetadataRepositoryIndexingTest
{
RepositoryMetadata repoMetadata = null;
URL url;
InputStream is = null;
InputStream is;
MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();
//group metadata

+ 8
- 9
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/PomRepositoryIndexingTest.java View File

@@ -1,6 +1,6 @@
package org.apache.maven.repository.indexing;

/**
/*
* Copyright 2005-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -180,10 +180,6 @@ public class PomRepositoryIndexingTest
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 ) );
}

@@ -212,7 +208,8 @@ public class PomRepositoryIndexingTest
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();
@@ -234,7 +231,8 @@ public class PomRepositoryIndexingTest
{
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() )
{
@@ -257,7 +255,8 @@ public class PomRepositoryIndexingTest
{
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() )
{
@@ -485,7 +484,7 @@ public class PomRepositoryIndexingTest
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 )

+ 7
- 23
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayerTest.java View File

@@ -28,8 +28,6 @@ import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryM
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.repository.digest.DefaultDigester;
import org.apache.maven.repository.digest.Digester;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
@@ -54,8 +52,6 @@ public class RepositoryIndexSearchLayerTest
private ArtifactFactory artifactFactory;
private Digester digester;
private String indexPath;
/**
@@ -72,23 +68,11 @@ public class RepositoryIndexSearchLayerTest
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
digester = new DefaultDigester();
indexPath = "target/index";
FileUtils.deleteDirectory( indexPath );
}
/**
* Tear down method
*
* @throws Exception
*/
protected void tearDown()
throws Exception
{
super.tearDown();
}
/**
* Method for creating the index used for testing
*
@@ -126,24 +110,24 @@ public class RepositoryIndexSearchLayerTest
MetadataRepositoryIndex metaIndexer = factory.createMetadataRepositoryIndex( indexPath, repository );
RepositoryMetadata repoMetadata =
getMetadata( "org.apache.maven", null, null, "maven-metadata.xml", metaIndexer.GROUP_METADATA );
getMetadata( "org.apache.maven", null, null, "maven-metadata.xml", MetadataRepositoryIndex.GROUP_METADATA );
metaIndexer.index( repoMetadata );
metaIndexer.optimize();
metaIndexer.close();
repoMetadata = getMetadata( "org.apache.maven", "maven-artifact", "2.0.1", "maven-metadata.xml",
metaIndexer.ARTIFACT_METADATA );
MetadataRepositoryIndex.ARTIFACT_METADATA );
metaIndexer.index( repoMetadata );
metaIndexer.optimize();
metaIndexer.close();
repoMetadata = getMetadata( "org.apache.maven", "maven-artifact", "2.0.1", "maven-metadata.xml",
metaIndexer.SNAPSHOT_METADATA );
MetadataRepositoryIndex.SNAPSHOT_METADATA );
metaIndexer.index( repoMetadata );
metaIndexer.optimize();
metaIndexer.close();
repoMetadata = getMetadata( "test", null, null, "maven-metadata.xml", metaIndexer.GROUP_METADATA );
repoMetadata = getMetadata( "test", null, null, "maven-metadata.xml", MetadataRepositoryIndex.GROUP_METADATA );
metaIndexer.index( repoMetadata );
metaIndexer.optimize();
metaIndexer.close();
@@ -345,14 +329,14 @@ public class RepositoryIndexSearchLayerTest
for ( Iterator iter = returnList.iterator(); iter.hasNext(); )
{
SearchResult result = (SearchResult) iter.next();
assertEquals( result.getArtifact().getGroupId(), "test" );
assertEquals( "test", result.getArtifact().getGroupId() );
}
returnList = searchLayer.searchGeneral( "test-artifactId" );
for ( Iterator iter = returnList.iterator(); iter.hasNext(); )
{
SearchResult result = (SearchResult) iter.next();
assertEquals( result.getArtifact().getArtifactId(), "test-artifactId" );
assertEquals( "test-artifactId", result.getArtifact().getArtifactId() );
}
}
@@ -375,7 +359,7 @@ public class RepositoryIndexSearchLayerTest
{
RepositoryMetadata repoMetadata = null;
URL url;
InputStream is = null;
InputStream is;
MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();
//group metadata

+ 3
- 4
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/query/QueryTest.java View File

@@ -1,16 +1,13 @@
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,
@@ -19,6 +16,8 @@ import junit.framework.TestCase;
* limitations under the License.
*/

import junit.framework.TestCase;

/**
* @author Edwin Punzalan
*/

+ 18
- 1
maven-repository-manager-site/pom.xml View File

@@ -1,4 +1,21 @@
<?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>

+ 18
- 2
maven-repository-manager-site/src/site/site.xml View File

@@ -1,18 +1,34 @@
<?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>

+ 3
- 1
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java View File

@@ -89,6 +89,8 @@ public class DefaultProxyManager
*/
private Map failuresCache = new HashMap();

private static final int MS_PER_SEC = 1000;

public void setConfiguration( ProxyConfiguration config )
{
this.config = config;
@@ -413,7 +415,7 @@ public class DefaultProxyManager
}
else
{
long repoTimestamp = target.lastModified() + repository.getCachePeriod() * 1000;
long repoTimestamp = target.lastModified() + repository.getCachePeriod() * MS_PER_SEC;
wagon.getIfNewer( path, temp, repoTimestamp );
}


+ 1
- 1
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/ProxyManager.java View File

@@ -29,7 +29,7 @@ import java.io.File;
*/
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.

+ 49
- 49
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java View File

@@ -1,13 +1,13 @@
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,
@@ -50,70 +50,70 @@ public class MavenProxyPropertyLoader

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 );
@@ -161,7 +161,7 @@ public class MavenProxyPropertyLoader
private String getMandatoryProperty( Properties props, String key )
throws ValidationException
{
final String value = props.getProperty( key );
String value = props.getProperty( key );

if ( value == null )
{

+ 1
- 1
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/ProxyConfiguration.java View File

@@ -74,7 +74,7 @@ public class ProxyConfiguration
proxyInfo.setHost( host );
proxyInfo.setPort( port );

setHttpProxy( proxyInfo );
httpProxy = proxyInfo;
}

public void setHttpProxy( String host, int port, String username, String password )

+ 2
- 2
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/ValidationException.java View File

@@ -1,13 +1,13 @@
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,

+ 5
- 5
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java View File

@@ -29,22 +29,22 @@ public class ProxyRepository
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 )

+ 12
- 12
maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/DefaultProxyManagerTest.java View File

@@ -1,15 +1,5 @@
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.
*
@@ -26,6 +16,16 @@ import java.io.File;
* 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
*/
@@ -73,11 +73,11 @@ public class DefaultProxyManagerTest
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 )

+ 2
- 2
maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/LegacyProxyManagerTest.java View File

@@ -73,11 +73,11 @@ public class LegacyProxyManagerTest
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 )

+ 27
- 43
maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java View File

@@ -23,7 +23,6 @@ import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Iterator;


/**
@@ -32,6 +31,8 @@ import java.util.Iterator;
public class MavenProxyPropertyLoaderTest
extends PlexusTestCase
{
private static final int DEFAULT_CACHE_PERIOD = 3600;

public void testLoadValidMavenProxyConfiguration()
throws ValidationException, IOException
{
@@ -50,51 +51,34 @@ public class MavenProxyPropertyLoaderTest

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" );
}
}

+ 9
- 5
maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java View File

@@ -32,6 +32,10 @@ public class ProxyConfigurationTest
{
private ProxyConfiguration config;
private static final int DEFAULT_CACHE_PERIOD = 3600;
private static final int DEFAULT_PORT = 80;
protected void setUp()
throws Exception
{
@@ -60,9 +64,9 @@ public class ProxyConfigurationTest
ArtifactRepositoryLayout legacyLayout = new LegacyRepositoryLayout();
ProxyRepository repo2 = new ProxyRepository( "repo2", "http://www.ibiblio.org/maven", legacyLayout );
repo2.setCacheFailures( false );
repo2.setCachePeriod( 3600 );
repo2.setCachePeriod( DEFAULT_CACHE_PERIOD );
repo2.setProxied( true );
config.setHttpProxy( "some.local.proxy", 80, "username", "password" );
config.setHttpProxy( "some.local.proxy", DEFAULT_PORT, "username", "password" );
config.addRepository( repo2 );
assertEquals( 2, config.getRepositories().size() );
@@ -80,14 +84,14 @@ public class ProxyConfigurationTest
assertEquals( "http://www.ibiblio.org/maven", repo.getUrl() );
assertFalse( repo.isCacheFailures() );
assertTrue( repo.isHardfail() );
assertEquals( 3600, repo.getCachePeriod() );
assertEquals( DEFAULT_CACHE_PERIOD, repo.getCachePeriod() );
assertEquals( repo2, repo );
assertTrue( repo.isProxied() );
ProxyInfo proxyInfo = config.getHttpProxy();
assertNotNull( proxyInfo );
assertEquals( "some.local.proxy", proxyInfo.getHost() );
assertEquals( 80, proxyInfo.getPort() );
assertEquals( DEFAULT_PORT, proxyInfo.getPort() );
assertEquals( "username", proxyInfo.getUserName() );
assertEquals( "password", proxyInfo.getPassword() );
@@ -96,7 +100,7 @@ public class ProxyConfigurationTest
repositories.add( new ProxyRepository( "repo", "url", defLayout ) );
fail( "Expected UnsupportedOperationException not thrown." );
}
catch ( java.lang.UnsupportedOperationException e )
catch ( UnsupportedOperationException e )
{
assertTrue( true );
}

+ 1
- 3
maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/Cache.java View File

@@ -132,7 +132,7 @@ public class Cache
* @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;

@@ -148,8 +148,6 @@ public class Cache
}

manageCache();

return old;
}

/**

+ 5
- 0
maven-repository-utils/src/main/java/org/apache/maven/repository/ArtifactUtils.java View File

@@ -37,6 +37,10 @@ import java.util.StringTokenizer;
*/
public class ArtifactUtils
{
private ArtifactUtils()
{
}

/**
* Method used to build an artifact and then set its repository and file fields with the proper values
*
@@ -245,6 +249,7 @@ public class ArtifactUtils
// contains artifactId, version, classifier, and extension.
String avceGlob = tokens.nextToken();

//noinspection CollectionDeclaredAsConcreteClass
LinkedList avceTokenList = new LinkedList();

StringTokenizer avceTokenizer = new StringTokenizer( avceGlob, "-" );

+ 11
- 11
maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DefaultDigester.java View File

@@ -1,16 +1,5 @@
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.
*
@@ -27,6 +16,17 @@ import java.util.regex.Pattern;
* 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.
*

+ 16
- 0
maven-repository-utils/src/test/java/org/apache/maven/repository/ArtifactUtilsLegacyTest.java View File

@@ -1,5 +1,21 @@
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;

+ 16
- 0
maven-repository-webapp/pom.xml View File

@@ -1,3 +1,19 @@
<!--
~ 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>

+ 2
- 1
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BaseAction.java View File

@@ -17,8 +17,8 @@ package org.apache.maven.repository.manager.web.action;
*/
import com.opensymphony.xwork.Action;
import org.apache.maven.repository.manager.web.job.DiscovererScheduler;
import org.apache.maven.repository.manager.web.execution.DiscovererExecution;
import org.apache.maven.repository.manager.web.job.DiscovererScheduler;
/**
* This is the Action class of index.jsp, which is the initial page of the web application.
@@ -53,6 +53,7 @@ public class BaseAction
}
catch ( Exception e )
{
// TODO: better exception handling!
e.printStackTrace();
return ERROR;
}

+ 16
- 0
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java View File

@@ -1,5 +1,21 @@
package org.apache.maven.repository.manager.web.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.xwork.Action;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;

+ 2
- 3
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java View File

@@ -20,14 +20,13 @@ import com.opensymphony.xwork.Action;
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;

+ 29
- 14
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/RepositoryBrowseAction.java View File

@@ -1,5 +1,21 @@
package org.apache.maven.repository.manager.web.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.xwork.Action;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -11,6 +27,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
@@ -38,15 +55,15 @@ public class RepositoryBrowseAction
private String group;
private TreeMap artifactMap;
private Map artifactMap;
private String folder;
private int idx;
public String execute()
throws Exception
{
// TODO! fix hardcoded path
String path = "E:/jeprox/maven-repository-manager/trunk/maven-repository-discovery/src/test/repository";
ArtifactRepository repository =
@@ -58,21 +75,19 @@ public class RepositoryBrowseAction
artifactMap = new TreeMap();
String groupId;
while ( iterator.hasNext() )
{
Artifact artifact = (Artifact) iterator.next();
groupId = artifact.getGroupId();
String groupId = artifact.getGroupId();
String key = groupId.replace( '.', '/' ) + "/" + artifact.getArtifactId() + "/" + artifact.getVersion();
ArrayList artifactList;
List artifactList;
if ( artifactMap.containsKey( key ) )
{
artifactList = (ArrayList) artifactMap.get( key );
artifactList = (List) artifactMap.get( key );
}
else
{
@@ -87,28 +102,28 @@ public class RepositoryBrowseAction
}
//set the index for folder level to be displayed
setIdx( 1 );
idx = 1;
setFolder( "" );
folder = "";
return SUCCESS;
}
// TODO! is this method needed?
public String doEdit()
throws Exception
{
setIdx( getIdx() + 1 );
idx = idx + 1;
//set folder to "" if we are at the root directory
if ( getIdx() == 1 )
if ( idx == 1 )
{
setFolder( "" );
folder = "";
}
return SUCCESS;
}
public TreeMap getArtifactMap()
public Map getArtifactMap()
{
return artifactMap;
}

+ 20
- 59
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java View File

@@ -16,29 +16,29 @@ package org.apache.maven.repository.manager.web.execution;
* 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.
@@ -80,8 +80,6 @@ public class DiscovererExecution

private ArtifactRepositoryLayout layout;

private Properties props;

private String indexPath;

private String blacklistedPatterns;
@@ -101,24 +99,16 @@ public class DiscovererExecution
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 )
{
@@ -132,12 +122,12 @@ public class DiscovererExecution
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
{
@@ -149,11 +139,11 @@ public class DiscovererExecution
}

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();
}
@@ -210,17 +200,7 @@ public class DiscovererExecution
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() )
{
@@ -248,17 +228,8 @@ public class DiscovererExecution
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();
@@ -281,17 +252,7 @@ public class DiscovererExecution
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() )
{

+ 8
- 7
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java View File

@@ -1,12 +1,5 @@
package org.apache.maven.repository.manager.web.job;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import java.util.Properties;
/*
* Copyright 2005-2006 The Apache Software Foundation.
*
@@ -23,6 +16,14 @@ import java.util.Properties;
* limitations under the License.
*/
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import java.util.Properties;
/**
* This class contains the configuration values to be used by the scheduler
*/

+ 3
- 19
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererJob.java View File

@@ -16,32 +16,14 @@ package org.apache.maven.repository.manager.web.job;
* limitations under the License.
*/
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.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.model.Model;
import org.apache.maven.repository.discovery.ArtifactDiscoverer;
import org.apache.maven.repository.discovery.DefaultArtifactDiscoverer;
import org.apache.maven.repository.discovery.DefaultMetadataDiscoverer;
import org.apache.maven.repository.discovery.LegacyArtifactDiscoverer;
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.execution.DiscovererExecution;
import org.codehaus.plexus.scheduler.AbstractJob;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.io.File;
import java.net.MalformedURLException;
import java.util.Iterator;
import java.util.List;
/**
* This class is the discoverer job that is executed by the scheduler.
@@ -53,7 +35,7 @@ public class DiscovererJob
{
public static final String ROLE = DiscovererJob.class.getName();
public static String MAP_DISCOVERER_EXECUTION = "EXECUTION";
public static final String MAP_DISCOVERER_EXECUTION = "EXECUTION";
/**
* Execute the discoverer and the indexer.
@@ -76,10 +58,12 @@ public class DiscovererJob
}
catch ( RepositoryIndexException e )
{
// TODO!
e.printStackTrace();
}
catch ( MalformedURLException me )
{
// TODO!
me.printStackTrace();
}

+ 7
- 18
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererScheduler.java View File

@@ -16,26 +16,18 @@ package org.apache.maven.repository.manager.web.job;
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.text.ParseException;
import java.util.Properties;
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.repository.discovery.ArtifactDiscoverer;
import org.apache.maven.repository.discovery.MetadataDiscoverer;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.manager.web.execution.DiscovererExecution;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.scheduler.AbstractJob;
import org.codehaus.plexus.scheduler.Scheduler;
import org.quartz.CronTrigger;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import java.text.ParseException;
import java.util.Properties;
/**
* This class sets the job to be executed in the plexus-quartz scheduler
*
@@ -54,8 +46,6 @@ public class DiscovererScheduler
*/
private Scheduler scheduler;
private Properties props;
/**
* @plexus.requirement
*/
@@ -64,17 +54,16 @@ public class DiscovererScheduler
/**
* Method that sets the schedule in the plexus-quartz scheduler
*
* @throws IOException
* @throws ParseException
* @throws SchedulerException
*/
public void setSchedule()
throws IOException, ParseException, SchedulerException
throws ParseException, SchedulerException
{
props = config.getProperties();
Properties props = config.getProperties();
JobDetail jobDetail = new JobDetail( "discovererJob", "DISCOVERER", DiscovererJob.class );
JobDataMap dataMap = new JobDataMap();
dataMap.put( DiscovererJob.LOGGER, getLogger() );
dataMap.put( AbstractJob.LOGGER, getLogger() );
dataMap.put( DiscovererJob.MAP_DISCOVERER_EXECUTION, execution );
jobDetail.setJobDataMap( dataMap );

+ 16
- 0
maven-repository-webapp/src/main/webapp/WEB-INF/decorators.xml View File

@@ -1,3 +1,19 @@
<!--
~ 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>

+ 36
- 16
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp View File

@@ -1,3 +1,19 @@
<%--
~ 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>
@@ -7,24 +23,24 @@
<body>
<h3><a href="<ww:url value="browse!edit.action"><ww:param name="idx" value="0"/></ww:url>">basedir</a> /
<ww:set name="previousFolder" value="''"/>
<ww:set name="counter" value="0"/>
<ww:set name="previousFolder" value="''" />
<ww:set name="counter" value="0" />
<ww:if test="folder != ''">
<ww:set name="folderHeader" value="folder.split('/')"/>
<ww:set name="folderHeader" value="folder.split('/')" />
<ww:iterator value="#folderHeader">
<ww:set name="counter" value="#counter + 1"/>
<ww:set name="counter" value="#counter + 1" />
<ww:if test="#previousFolder == ''">
<ww:set name="previousFolder" value="top"/>
<ww:set name="previousFolder" value="top" />
</ww:if>
<ww:else>
<ww:set name="previousFolder" value="#previousFolder + '/' + top"/>
<ww:set name="previousFolder" value="#previousFolder + '/' + top" />
</ww:else>
<ww:if test="idx > (#counter + 1)"><a href="<ww:url value="browse!edit.action"><ww:param name="idx"><ww:property
value="#counter"/></ww:param><ww:param name="folder"></ww:param></ww:url>"></ww:if><ww:property/></a> /
value="#counter" /></ww:param><ww:param name="folder"></ww:param></ww:url>"></ww:if><ww:property /></a> /
</ww:iterator>
</ww:if>
</h3>
<br/>
<br />
<ww:set name="previousFolder" value="'the previous folder'"/>
<ww:set name="in" value="idx" scope="page"/>
@@ -33,14 +49,18 @@
<ww:if test="idx == 1 || (folder != '' and #groupName.startsWith(folder))">
<%
int ctr = 1;
%>
<ww:set name="groupFolder" value="#groupName.split('/')"/>
<ww:iterator value="#groupFolder">
<%
if (ctr == ((Integer)pageContext.getAttribute("in")).intValue()) {
%>
<ww:if test="top != #previousFolder">
<ww:set name="previousFolder" value="top"/>
@@ -57,32 +77,32 @@ if (ctr == ((Integer)pageContext.getAttribute("in")).intValue()) {
</ww:iterator>
<ww:if test="folder != ''">
<ww:set name="previousFolder" value="''"/>
<ww:set name="artifactList" value="artifactMap.get(folder)"/>
<ww:set name="previousFolder" value="''" />
<ww:set name="artifactList" value="artifactMap.get(folder)" />
<ww:iterator value="#artifactList">
<table border="1">
<tr align="left">
<th>Group ID</th>
<td><ww:property value="groupId"/></td>
<td><ww:property value="groupId" /></td>
</tr>
<tr align="left">
<th>Artifact ID</th>
<td><ww:property value="artifactId"/></td>
<td><ww:property value="artifactId" /></td>
</tr>
<tr align="left">
<th>Version</th>
<td><ww:property value="version"/></td>
<td><ww:property value="version" /></td>
</tr>
<tr align="left">
<th>Derivatives</th>
<td><ww:property value="groupId"/></td>
<td><ww:property value="groupId" /></td>
</tr>
<tr align="left">
<th>Parent</th>
<td><ww:property value="folder"/></td>
<td><ww:property value="folder" /></td>
</tr>
</table>
<br/>
<br />
</ww:iterator>
</ww:if>
</body>

+ 16
- 0
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp View File

@@ -1,3 +1,19 @@
<%--
~ 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>

+ 0
- 1
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf View File

@@ -12,7 +12,6 @@
~ 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">

+ 16
- 0
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/index.jsp View File

@@ -1,3 +1,19 @@
<%--
~ 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>

+ 16
- 0
maven-repository-webapp/src/main/webapp/WEB-INF/web.xml View File

@@ -1,3 +1,19 @@
<!--
~ 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" >

+ 16
- 0
maven-repository-webapp/src/main/webapp/css/maven-base.css View File

@@ -1,3 +1,19 @@
/*
* 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;

+ 16
- 0
maven-repository-webapp/src/main/webapp/css/maven-theme.css View File

@@ -1,3 +1,19 @@
/*
* 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;
}

+ 16
- 0
maven-repository-webapp/src/main/webapp/css/print.css View File

@@ -1,3 +1,19 @@
/*
* 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;
}

+ 16
- 0
maven-repository-webapp/src/main/webapp/css/site.css View File

@@ -1,3 +1,19 @@
/*
* 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;

+ 16
- 0
maven-repository-webapp/src/main/webapp/index.jsp View File

@@ -1 +1,17 @@
<%--
~ 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" );%>

Loading…
Cancel
Save