You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by og...@apache.org on 2009/04/23 00:57:04 UTC
svn commit: r767705 [7/31] - in /maven/mercury/trunk/mercury-core: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/maven/ src/main/java/org/apache/maven/mercury/
src/main/java/org/apache/maven/merc...
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatHelper.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatHelper.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatHelper.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatHelper.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,147 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.metadata.sat;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.sat4j.core.ReadOnlyVec;
+import org.sat4j.core.ReadOnlyVecInt;
+import org.sat4j.core.Vec;
+import org.sat4j.core.VecInt;
+import org.sat4j.specs.IConstr;
+import org.sat4j.specs.IVec;
+import org.sat4j.specs.IVecInt;
+
+/**
+ * @author <a href="oleg@codehaus.org">Oleg Gusakov</a>
+ */
+public class SatHelper
+{
+ //-----------------------------------------------------------------------
+ public static final List<ArtifactMetadata> createList( String... uris )
+ {
+ List<ArtifactMetadata> aml = new ArrayList<ArtifactMetadata>( uris.length );
+ for( String uri : uris )
+ {
+ aml.add( new ArtifactMetadata(uri) );
+ }
+ return aml;
+ }
+ //-----------------------------------------------------------------------
+ public static final IVecInt getSmallOnes( int... ints )
+ {
+ VecInt res = new VecInt( ints );
+ return new ReadOnlyVecInt(res);
+ }
+ //-----------------------------------------------------------------------
+ public static final IVecInt getSmallOnes( int first, int second )
+ {
+ return getSmallOnes( new int [] {first, second} );
+ }
+ //-----------------------------------------------------------------------
+ public static int [] toIntArray( int first, int... ints )
+ {
+ int [] lits = new int[ ints.length+1 ];
+ lits[0] = first;
+ int ptr = 1;
+
+ for( int i : ints )
+ lits[ptr++] = i;
+
+ return lits;
+ }
+ //-----------------------------------------------------------------------
+ private static final IVec<BigInteger> toVec( BigInteger... bis )
+ {
+ return new ReadOnlyVec<BigInteger>( new Vec<BigInteger>( bis ) );
+ }
+ //-----------------------------------------------------------------------
+ public static final IVec<BigInteger> getBigOnes( int... ones )
+ {
+ BigInteger [] res = new BigInteger[ ones.length ];
+
+ for( int i=0; i<ones.length; i++ )
+ res[ i ] = BigInteger.valueOf( ones[i] );
+
+ return toVec( res );
+ }
+ //-----------------------------------------------------------------------
+ public static final IVec<BigInteger> getBigOnes( int nOnes, boolean negate )
+ {
+ BigInteger [] res = new BigInteger[ nOnes ];
+ BigInteger bi = negate ? BigInteger.ONE.negate() : BigInteger.ONE;
+
+ for( int i=0; i<nOnes; i++ )
+ res[i] = bi;
+
+ return toVec(res);
+ }
+ //-----------------------------------------------------------------------
+ public static final IVec<BigInteger> getBigOnes( int first, int nOnes, boolean negateOnes )
+ {
+ int len = nOnes + 1;
+
+ BigInteger [] res = new BigInteger[ len ];
+ res[ 0 ] = BigInteger.valueOf(first);
+
+ BigInteger bi = negateOnes ? BigInteger.ONE.negate() : BigInteger.ONE;
+
+ for( int i=0; i<nOnes; i++ )
+ res[i+1] = bi;
+
+ return toVec(res);
+ }
+ //-----------------------------------------------------------------------
+ public static final String vectorToString( IVecInt vec )
+ {
+ if( vec == null || vec.size() < 1 )
+ return "[]";
+
+ StringBuilder sb = new StringBuilder();
+ String comma = "";
+
+ for( int i=0; i<vec.size(); i++ )
+ {
+ sb.append( comma+"x"+vec.get( i ) );
+ comma = ", ";
+ }
+ return "["+sb.toString()+"]";
+ }
+ //-----------------------------------------------------------------------
+ public static final String vectorToString( IConstr vec )
+ {
+ if( vec == null || vec.size() < 1 )
+ return "[]";
+
+ StringBuilder sb = new StringBuilder();
+ String comma = "";
+
+ for( int i=0; i<vec.size(); i++ )
+ {
+ sb.append( comma+"x"+vec.get( i ) );
+ comma = ", ";
+ }
+ return "["+sb.toString()+"]";
+ }
+ //-----------------------------------------------------------------------
+ //-----------------------------------------------------------------------
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatHelper.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatOptimizer.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatOptimizer.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatOptimizer.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatOptimizer.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.metadata.sat;
+
+import org.apache.maven.mercury.artifact.MetadataTreeNode;
+import org.sat4j.pb.ObjectiveFunction;
+
+/**
+ * Sat solver optimizer - calculates and returns the minimization function
+ *
+ * @author Oleg Gusakov
+ *
+ */
+public interface SatOptimizer
+{
+ /**
+ * returns the function to be minimized
+ *
+ * @param tn
+ * @param context
+ * @return
+ * @throws SatException
+ */
+ public ObjectiveFunction getOptimizer( MetadataTreeNode tn, SatContext context )
+ throws SatException
+ ;
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatOptimizer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatOptimizer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatSolver.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatSolver.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatSolver.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatSolver.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.metadata.sat;
+
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.apache.maven.mercury.artifact.MetadataTreeNode;
+import org.apache.maven.mercury.event.EventGenerator;
+
+/**
+ * @author <a href="oleg@codehaus.org">Oleg Gusakov</a>
+ */
+public interface SatSolver
+extends EventGenerator
+{
+ public static final int DEFAULT_TREE_SIZE = 128; //nodes
+
+ public static final String EVENT_SOLVE = "solve";
+ public static final String EVENT_CREATE_SOLVER = "create.sat.solver";
+
+ /**
+ *
+ * @param sorts - policies expressed as sorted list of node sorters - from most important to the least
+ * @throws SatException
+ */
+ public void applyPolicies( List< Comparator<MetadataTreeNode> > comparators )
+ throws SatException;
+
+ /**
+ *
+ * @return list of ArtifactMetedata's in the solution
+ * @throws SatException
+ */
+ public List<ArtifactMetadata> solve()
+ throws SatException;
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatSolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatSolver.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatVar.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatVar.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatVar.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatVar.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.metadata.sat;
+
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.apache.maven.mercury.artifact.MetadataTreeNode;
+
+/**
+ * @author <a href="oleg@codehaus.org">Oleg Gusakov</a>
+ */
+class SatVar
+{
+ MetadataTreeNode _node;
+ int _literal;
+ boolean _optional;
+ //---------------------------------------------------------------------
+ public SatVar( MetadataTreeNode n )
+ throws SatException
+ {
+ if( n == null
+ || n.getMd() == null
+ )
+ throw new SatException("Cannot create SatVar from a null MetadataTreeNode: "+n);
+
+ ArtifactMetadata md = n.getMd();
+ if(
+ md == null
+ || md.getGroupId() == null
+ || md.getArtifactId() == null
+ || md.getVersion() == null
+ )
+ throw new SatException("Cannot create SatVar from a null Metadata: "+md);
+
+ this._node = n;
+ this._literal = n.getId();
+ }
+ //---------------------------------------------------------------------
+ public ArtifactMetadata getMd()
+ {
+ return _node.getMd();
+ }
+
+ public int getLiteral()
+ {
+ return _literal;
+ }
+ //---------------------------------------------------------------------
+ @Override
+ public String toString()
+ {
+ return _node.toString()+" -> X"+_literal;
+ }
+
+ //---------------------------------------------------------------------
+ //---------------------------------------------------------------------
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatVar.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/metadata/sat/SatVar.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstracRepositoryReader.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstracRepositoryReader.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstracRepositoryReader.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstracRepositoryReader.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.apache.maven.mercury.builder.api.DependencyProcessor;
+import org.apache.maven.mercury.builder.api.MetadataReader;
+import org.apache.maven.mercury.builder.api.MetadataReaderException;
+
+/**
+ * This is to keep MetadataProcessor for all readers
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public abstract class AbstracRepositoryReader
+ implements RepositoryReader, MetadataReader
+{
+ protected DependencyProcessor _mdProcessor;
+
+ protected MetadataReader _mdReader;
+
+ protected RepositoryMetadataCache _mdCache;
+
+ public void setDependencyProcessor( DependencyProcessor mdProcessor )
+ {
+ _mdProcessor = mdProcessor;
+ }
+
+ public DependencyProcessor getDependencyProcessor()
+ {
+ return _mdProcessor;
+ }
+
+ public void setMetadataReader( MetadataReader mdReader )
+ {
+ _mdReader = mdReader;
+ }
+
+ public MetadataReader getMetadataReader()
+ {
+ return _mdReader;
+ }
+
+ public void setMetadataCache( RepositoryMetadataCache mdCache )
+ {
+ this._mdCache = mdCache;
+ }
+
+ public RepositoryMetadataCache getMetadataCache()
+ {
+ return _mdCache;
+ }
+
+ public boolean hasMetadataCache()
+ {
+ return _mdCache != null;
+ }
+
+ public byte[] readMetadata( ArtifactMetadata bmd, boolean exempt )
+ throws MetadataReaderException
+ {
+ return readRawData( bmd, "", "pom", exempt );
+ }
+
+ public byte[] readMetadata( ArtifactMetadata bmd )
+ throws MetadataReaderException
+ {
+ return readMetadata( bmd, false );
+ }
+
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstracRepositoryReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstracRepositoryReader.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+
+/**
+ * generic repository operation result. Represents a Map of query object to AbstractRepositoryOperationResult
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public abstract class AbstractRepOpResult
+{
+ private Map<ArtifactMetadata, Exception> _exceptions;
+
+ public AbstractRepOpResult()
+ {
+ }
+
+ public Map<ArtifactMetadata, Exception> getExceptions()
+ {
+ return _exceptions;
+ }
+
+ public abstract boolean hasResults();
+
+ public abstract boolean hasResults( ArtifactMetadata key );
+
+ public boolean hasExceptions()
+ {
+ return _exceptions != null && !_exceptions.isEmpty();
+ }
+
+ public void addError( ArtifactMetadata key, Exception error )
+ {
+ if ( _exceptions == null )
+ _exceptions = new HashMap<ArtifactMetadata, Exception>( 8 );
+
+ _exceptions.put( key, error );
+ }
+
+ public void addError( Map<ArtifactMetadata, Exception> error )
+ {
+ if ( _exceptions == null )
+ _exceptions = new HashMap<ArtifactMetadata, Exception>( 8 );
+
+ _exceptions.putAll( error );
+ }
+
+ public void addError( ArtifactResults res )
+ {
+ if ( res == null || !res.hasExceptions() )
+ return;
+
+ if ( _exceptions == null )
+ _exceptions = new HashMap<ArtifactMetadata, Exception>( 8 );
+
+ for ( ArtifactMetadata bmd : res.getExceptions().keySet() )
+ _exceptions.put( bmd, res.getError( bmd ) );
+ }
+
+ public Exception getError( ArtifactMetadata key )
+ {
+ if ( _exceptions == null )
+ return null;
+
+ return _exceptions.get( key );
+ }
+
+ public String toString()
+ {
+ return _exceptions.toString();
+ }
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepOpResult.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,302 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.mercury.artifact.Quality;
+import org.apache.maven.mercury.artifact.QualityRange;
+import org.apache.maven.mercury.builder.api.DependencyProcessor;
+import org.apache.maven.mercury.transport.api.Server;
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+
+/**
+ * parent of all repositories and also a helper class for registration of readers/writers
+ */
+public abstract class AbstractRepository
+ implements Repository
+{
+ private static final Language LANG = new DefaultLanguage( AbstractRepository.class );
+
+ // ---------------------------------------------------------------------------
+ public static final String DEFAULT_REMOTE_READ_PROTOCOL = "http";
+
+ public static final String DEFAULT_REMOTE_WRITE_PROTOCOL = "http";
+
+ public static final String DEFAULT_LOCAL_READ_PROTOCOL = "file";
+
+ public static final String DEFAULT_LOCAL_WRITE_PROTOCOL = "file";
+
+ public static final String DEFAULT_REPOSITORY_TYPE = "m2";
+
+ private String id;
+
+ private String defaultReadProtocol = DEFAULT_REMOTE_READ_PROTOCOL;
+
+ private String defaultWriteProtocol = DEFAULT_REMOTE_WRITE_PROTOCOL;
+
+ // ---------------------------------------------------------------------------
+ private static Map<String, RepositoryReaderFactory> readerRegistry =
+ Collections.synchronizedMap( new HashMap<String, RepositoryReaderFactory>( 4 ) );
+
+ private static Map<String, RepositoryWriterFactory> writerRegistry =
+ Collections.synchronizedMap( new HashMap<String, RepositoryWriterFactory>( 4 ) );
+
+ // ---------------------------------------------------------------------------
+ protected String type = DEFAULT_REPOSITORY_TYPE;
+
+ protected QualityRange repositoryQualityRange = QualityRange.ALL;
+
+ protected QualityRange versionRangeQualityRange = QualityRange.ALL;
+
+ protected DependencyProcessor dependencyProcessor;
+
+ protected Server server;
+
+ private static final byte[] __HEX_DIGITS = "0123456789abcdef".getBytes();
+
+ // ---------------------------------------------------------------------------
+ public AbstractRepository( String id, String type )
+ {
+ this.id = hashId( id );
+
+ this.type = type;
+ }
+
+ // ---------------------------------------------------------------------------
+ public static String hashId( String id )
+ {
+ try
+ {
+ if ( id == null || ( id.indexOf( '/' ) == -1 && id.indexOf( '\\' ) == -1 ) )
+ return id;
+
+ MessageDigest digest = MessageDigest.getInstance( "SHA-1" );
+
+ digest.update( id.getBytes() );
+
+ byte[] bytes = digest.digest();
+
+ int len = bytes.length;
+
+ byte[] raw = new byte[len * 2];
+
+ for ( int i = 0, j = 0; i < len; i++ )
+ {
+ raw[j++] = __HEX_DIGITS[( 0xF0 & bytes[i] ) >>> 4];
+ raw[j++] = __HEX_DIGITS[0x0F & bytes[i]];
+ }
+
+ return new String( raw );
+ }
+ catch ( NoSuchAlgorithmException e )
+ {
+ throw new IllegalArgumentException( e );
+ }
+ }
+
+ // ---------------------------------------------------------------------------
+ public String getId()
+ {
+ return id;
+ }
+
+ // ---------------------------------------------------------------------------
+ public QualityRange getRepositoryQualityRange()
+ {
+ return repositoryQualityRange == null ? QualityRange.ALL : repositoryQualityRange;
+ }
+
+ // ---------------------------------------------------------------------------
+ public void setRepositoryQualityRange( QualityRange repositoryQualityRange )
+ {
+ this.repositoryQualityRange = repositoryQualityRange;
+ }
+
+ // ---------------------------------------------------------------------------
+ public QualityRange getVersionRangeQualityRange()
+ {
+ return versionRangeQualityRange;
+ }
+
+ // ---------------------------------------------------------------------------
+ public void setVersionRangeQualityRange( QualityRange versionRangeQualityRange )
+ {
+ this.versionRangeQualityRange = versionRangeQualityRange;
+ }
+
+ // ---------------------------------------------------------------------------
+ public String getDefaultReadProtocol()
+ {
+ return defaultReadProtocol;
+ }
+
+ // ---------------------------------------------------------------------------
+ public void setDefaultReadProtocol( String defaultReadProtocol )
+ {
+ this.defaultReadProtocol = defaultReadProtocol;
+ }
+
+ // ---------------------------------------------------------------------------
+ public String getDefaultWriteProtocol()
+ {
+ return defaultWriteProtocol;
+ }
+
+ // ---------------------------------------------------------------------------
+ public void setDefaultWriteProtocol( String defaultWriteProtocol )
+ {
+ this.defaultWriteProtocol = defaultWriteProtocol;
+ }
+
+ // ---------------------------------------------------------------------------
+ public static void register( String type, RepositoryReaderFactory readerFactory )
+ throws IllegalArgumentException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.reader.type" ) );
+
+ if ( readerFactory == null )
+ throw new IllegalArgumentException( LANG.getMessage( "null.reader.factory" ) );
+
+ readerRegistry.put( type, readerFactory );
+ }
+
+ // ---------------------------------------------------------------------------
+ public static void register( String type, RepositoryWriterFactory writerFactory )
+ throws IllegalArgumentException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.writer.type" ) );
+
+ if ( writerFactory == null )
+ throw new IllegalArgumentException( LANG.getMessage( "null.writer.factory" ) );
+
+ writerRegistry.put( type, writerFactory );
+ }
+
+ // ---------------------------------------------------------------------------
+ public static void unregisterReader( String type )
+ throws IllegalArgumentException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.reader.type" ) );
+
+ readerRegistry.remove( type );
+ }
+
+ // ---------------------------------------------------------------------------
+ public static void unregisterWriter( String type )
+ throws IllegalArgumentException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.writer.type" ) );
+
+ writerRegistry.remove( type );
+ }
+
+ // ---------------------------------------------------------------------------
+ public static RepositoryReader getReader( String type, Repository repo, DependencyProcessor mdProcessor )
+ throws IllegalArgumentException, RepositoryException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.reader.type" ) );
+
+ if ( repo == null )
+ throw new IllegalArgumentException( LANG.getMessage( "null.reader.repo" ) );
+
+ RepositoryReaderFactory rf = readerRegistry.get( type );
+
+ if ( rf == null )
+ throw new RepositoryException( LANG.getMessage( "null.reader.factory.found" ) );
+
+ return rf.getReader( repo, mdProcessor );
+ }
+
+ // ---------------------------------------------------------------------------
+ public static RepositoryWriter getWriter( String type, Repository repo )
+ throws IllegalArgumentException, RepositoryException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.writer.type" ) );
+
+ if ( repo == null )
+ throw new IllegalArgumentException( LANG.getMessage( "null.writer.repo" ) );
+
+ RepositoryWriterFactory wf = writerRegistry.get( type );
+
+ if ( wf == null )
+ throw new RepositoryException( LANG.getMessage( "null.writer.factory.found" ) );
+
+ return wf.getWriter( repo );
+ }
+
+ // ---------------------------------------------------------------------------
+ public boolean isSnapshots()
+ {
+ return repositoryQualityRange.isAcceptedQuality( Quality.SNAPSHOT_QUALITY );
+ }
+
+ // ---------------------------------------------------------------------------
+ public boolean isReleases()
+ {
+ return repositoryQualityRange.isAcceptedQuality( Quality.RELEASE_QUALITY );
+ }
+
+ // ---------------------------------------------------------------------------
+ public boolean isAcceptedQuality( Quality quality )
+ {
+ return repositoryQualityRange.isAcceptedQuality( quality );
+ }
+
+ // ---------------------------------------------------------------------------
+ public boolean hasServer()
+ {
+ return server != null;
+ }
+
+ // ---------------------------------------------------------------------------
+ public Server getServer()
+ {
+ return server;
+ }
+
+ // ---------------------------------------------------------------------------
+ public boolean hasDependencyProcessor()
+ {
+ return dependencyProcessor == null;
+ }
+
+ public DependencyProcessor getDependencyProcessor()
+ {
+ return dependencyProcessor;
+ }
+
+ public void setDependencyProcessor( DependencyProcessor dependencyProcessor )
+ {
+ this.dependencyProcessor = dependencyProcessor;
+ }
+ // ---------------------------------------------------------------------------
+ // ---------------------------------------------------------------------------
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepositoryWriter.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepositoryWriter.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepositoryWriter.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepositoryWriter.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+/**
+ * helper class for writing repository writers
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class AbstractRepositoryWriter
+ extends Thread
+{
+
+ protected RepositoryMetadataCache _mdCache;
+
+ public void setMetadataCache( RepositoryMetadataCache mdCache )
+ {
+ this._mdCache = mdCache;
+ }
+
+ public RepositoryMetadataCache getMetadataCache()
+ {
+ return _mdCache;
+ }
+
+ public boolean hasMetadataCache()
+ {
+ return _mdCache != null;
+ }
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepositoryWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepositoryWriter.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/ArtifactResults.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/ArtifactResults.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/ArtifactResults.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/ArtifactResults.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.mercury.artifact.Artifact;
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class ArtifactResults
+ extends AbstractRepOpResult
+{
+ Map<ArtifactMetadata, List<Artifact>> _result = new HashMap<ArtifactMetadata, List<Artifact>>( 8 );
+
+ public ArtifactResults()
+ {
+ }
+
+ public ArtifactResults( ArtifactMetadata query, List<Artifact> result )
+ {
+ this._result.put( query, result );
+ }
+
+ public void add( ArtifactMetadata query, Artifact result )
+ {
+ List<Artifact> res = _result.get( query );
+ if ( res == null )
+ {
+ res = new ArrayList<Artifact>( 8 );
+ _result.put( query, res );
+ }
+
+ res.add( result );
+ }
+
+ public void addAll( ArtifactMetadata query, List<Artifact> result )
+ {
+ List<Artifact> res = _result.get( query );
+ if ( res == null )
+ {
+ res = new ArrayList<Artifact>( 8 );
+ _result.put( query, res );
+ }
+
+ res.addAll( result );
+ }
+
+ public Map<ArtifactMetadata, List<Artifact>> getResults()
+ {
+ return _result;
+ }
+
+ public List<Artifact> getResults( ArtifactMetadata query )
+ {
+ return _result.get( query );
+ }
+
+ @Override
+ public boolean hasResults()
+ {
+ return !_result.isEmpty();
+ }
+
+ @Override
+ public boolean hasResults( ArtifactMetadata key )
+ {
+ return !_result.isEmpty() && _result.containsKey( key ) && !_result.get( key ).isEmpty();
+ }
+
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/ArtifactResults.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/ArtifactResults.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/LocalRepository.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/LocalRepository.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/LocalRepository.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/LocalRepository.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,30 @@
+package org.apache.maven.mercury.repository.api;
+
+import java.io.File;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ */
+public interface LocalRepository
+ extends Repository
+{
+ File getDirectory();
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/LocalRepository.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/LocalRepository.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Messages.properties
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Messages.properties?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Messages.properties (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Messages.properties Wed Apr 22 22:56:48 2009
@@ -0,0 +1,32 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+null.reader.type=reader factory type cannot be null
+null.reader.factory=reader factory cannot be null
+null.writer.type=writer factory type cannot be null
+null.writer.factory=writer factory cannot be null
+null.reader.repo=reader repository cannot be null
+null.reader.processor=reader processor cannot be null
+null.writer.repo=writer repository cannot be null
+null.writer.processor=writer processor cannot be null
+
+empty.policy=repository update policy cannot be empty: {0}
+bad.policy=cannot parse repository update policy: {0}
+bad.interval.policy=cannot parse interval repository update policy: {0}
+
+empty.md=cannot initialize metadata object from null
\ No newline at end of file
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Messages.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Messages.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCacheException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCacheException.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCacheException.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCacheException.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class MetadataCacheException
+ extends Exception
+{
+
+ /**
+ *
+ */
+ public MetadataCacheException()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public MetadataCacheException( String message )
+ {
+ super( message );
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public MetadataCacheException( Throwable cause )
+ {
+ super( cause );
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public MetadataCacheException( String message, Throwable cause )
+ {
+ super( message, cause );
+ // TODO Auto-generated constructor stub
+ }
+
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCacheException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCacheException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCorruptionException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCorruptionException.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCorruptionException.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCorruptionException.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class MetadataCorruptionException
+ extends Exception
+{
+
+ /**
+ *
+ */
+ public MetadataCorruptionException()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public MetadataCorruptionException( String message )
+ {
+ super( message );
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public MetadataCorruptionException( Throwable cause )
+ {
+ super( cause );
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public MetadataCorruptionException( String message, Throwable cause )
+ {
+ super( message, cause );
+ // TODO Auto-generated constructor stub
+ }
+
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCorruptionException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataCorruptionException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataResults.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataResults.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataResults.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataResults.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,151 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class MetadataResults
+ extends AbstractRepOpResult
+{
+ Map<ArtifactMetadata, List<ArtifactMetadata>> _result = new HashMap<ArtifactMetadata, List<ArtifactMetadata>>( 8 );
+
+ /**
+ * first result is ready
+ */
+ public MetadataResults( ArtifactMetadata query, List<ArtifactMetadata> result )
+ {
+ this._result.put( query, result );
+ }
+
+ /**
+ * optimization opportunity
+ *
+ * @param size
+ */
+ public MetadataResults( int size )
+ {
+ }
+
+ private MetadataResults()
+ {
+ }
+
+ public static MetadataResults add( final MetadataResults res, final ArtifactMetadata key,
+ final Exception err )
+ {
+ MetadataResults ret = res;
+ if ( res == null )
+ ret = new MetadataResults();
+
+ ret.addError( key, err );
+
+ return ret;
+ }
+
+ public static MetadataResults add( final MetadataResults res, final ArtifactMetadata key,
+ final List<ArtifactMetadata> result )
+ {
+ MetadataResults ret = res;
+ if ( res == null )
+ ret = new MetadataResults();
+
+ ret.add( key, result );
+
+ return ret;
+ }
+
+ public static MetadataResults add( final MetadataResults res, final ArtifactMetadata key,
+ final ArtifactMetadata result )
+ {
+ MetadataResults ret = res;
+ if ( res == null )
+ ret = new MetadataResults();
+
+ ret.add( key, result );
+
+ return ret;
+ }
+
+ private List<ArtifactMetadata> getOrCreate( ArtifactMetadata query )
+ {
+ List<ArtifactMetadata> res = _result.get( query );
+ if ( res == null )
+ {
+ res = new ArrayList<ArtifactMetadata>( 8 );
+ _result.put( query, res );
+ }
+ return res;
+ }
+
+ /**
+ * add results if they are not there yet
+ *
+ * @param query
+ * @param result
+ */
+ public void add( ArtifactMetadata query, List<ArtifactMetadata> result )
+ {
+ List<ArtifactMetadata> res = getOrCreate( query );
+ for ( ArtifactMetadata r : result )
+ {
+ if ( res.contains( r ) )
+ continue;
+
+ res.add( r );
+ }
+ }
+
+ public void add( ArtifactMetadata query, ArtifactMetadata result )
+ {
+ List<ArtifactMetadata> res = getOrCreate( query );
+ res.add( result );
+ }
+
+ public Map<ArtifactMetadata, List<ArtifactMetadata>> getResults()
+ {
+ return _result;
+ }
+
+ public List<ArtifactMetadata> getResult( ArtifactMetadata query )
+ {
+ return _result.get( query );
+ }
+
+ @Override
+ public boolean hasResults()
+ {
+ return !_result.isEmpty();
+ }
+
+ @Override
+ public boolean hasResults( ArtifactMetadata key )
+ {
+ return !_result.isEmpty() && _result.containsKey( key ) && !_result.get( key ).isEmpty();
+ }
+
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataResults.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/MetadataResults.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/NonExistentProtocolException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/NonExistentProtocolException.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/NonExistentProtocolException.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/NonExistentProtocolException.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+public class NonExistentProtocolException
+ extends RepositoryException
+{
+
+ public NonExistentProtocolException()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ public NonExistentProtocolException( String message )
+ {
+ super( message );
+ // TODO Auto-generated constructor stub
+ }
+
+ public NonExistentProtocolException( Throwable cause )
+ {
+ super( cause );
+ // TODO Auto-generated constructor stub
+ }
+
+ public NonExistentProtocolException( String message, Throwable cause )
+ {
+ super( message, cause );
+ // TODO Auto-generated constructor stub
+ }
+
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/NonExistentProtocolException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/NonExistentProtocolException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RemoteRepository.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RemoteRepository.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RemoteRepository.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RemoteRepository.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,45 @@
+package org.apache.maven.mercury.repository.api;
+
+import org.apache.maven.mercury.transport.api.Server;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ */
+public interface RemoteRepository
+ extends Repository
+{
+ /**
+ * this is the Server with many useful fields to describe the home of this remote repo
+ */
+ Server getServer();
+
+ /**
+ * get the update policy configured for this remote repository
+ *
+ * @return the policy or null, if it does not exist
+ */
+ RepositoryUpdatePolicy getUpdatePolicy();
+
+ /**
+ * set the update policy configured for this remote repository
+ */
+ void setUpdatePolicy( RepositoryUpdatePolicy updatePolicy );
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RemoteRepository.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RemoteRepository.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,152 @@
+package org.apache.maven.mercury.repository.api;
+
+import org.apache.maven.mercury.artifact.Quality;
+import org.apache.maven.mercury.artifact.QualityRange;
+import org.apache.maven.mercury.builder.api.DependencyProcessor;
+import org.apache.maven.mercury.transport.api.Server;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ */
+public interface Repository
+{
+ String getId();
+
+ /**
+ * repository type - m2, nexus, ivy, p2 - to name a few. It defines the RepositoryReader/Writer that will be
+ * searched for in the registry.
+ */
+ public String getType();
+
+ /**
+ * Indicates whether this is local Repository. This flag defines the necessity to download the artifact, if it was
+ * cleared by the conflict resolver but not read from a localRepo.
+ */
+ public boolean isLocal();
+
+ /**
+ * Indicates whether it's possible to read from this Repository.
+ */
+ public boolean isReadable();
+
+ /**
+ * Indicates whether it's possible to write to this Repository. Good example is the flat repo, which is used to only
+ * collect dependencies for some 3rd party reasons, but not read them. If there are multiple localRepo's and
+ * Artifact needs to be downloaded - it will be "written" to all "local" repositories that are writeable.
+ */
+ public boolean isWriteable();
+
+ /**
+ * Indicates whether this repository contains releases
+ */
+ public boolean isReleases();
+
+ /**
+ * Indicates whether this repository contains snapshots
+ */
+ public boolean isSnapshots();
+
+ /**
+ * indicates if the supplied code quality is served by this repository
+ */
+ public boolean isAcceptedQuality( Quality quality );
+
+ /**
+ * defines the code quality range for this repository
+ */
+ public QualityRange getRepositoryQualityRange();
+ void setRepositoryQualityRange( QualityRange qualityRange );
+
+ /**
+ * defines how VersionRnage treats upper boundary - which Artifacts should be treated as belonging to the vicinity -
+ * http://docs.codehaus.org/x/twDPBQ
+ *
+ * note: don't mix this with repository quality range - this one is for version range calculations only!
+ *
+ */
+ public QualityRange getVersionRangeQualityRange();
+ public void setVersionRangeQualityRange( QualityRange qualityRange );
+
+ /**
+ * get default reader, if any
+ *
+ * @return default reader or null, if none exists
+ * @throws RepositoryException
+ */
+ RepositoryReader getReader()
+ throws RepositoryException;
+
+ /**
+ * get protocol specific reader, if any
+ *
+ * @param protocol
+ * @return reader instance for the specified protocol
+ * @throws NonExistentProtocolException if protocol not supported
+ */
+ RepositoryReader getReader( String protocol )
+ throws RepositoryException;
+
+ /**
+ * get default writer, if any
+ *
+ * @return default writer or null, if none exists
+ * @throws RepositoryException
+ */
+ RepositoryWriter getWriter()
+ throws RepositoryException;
+
+ /**
+ * @param protocol
+ * @return writer instance for the specified protocol
+ * @throws NonExistentProtocolException if protocol not supported
+ * @throws RepositoryException
+ */
+ RepositoryWriter getWriter( String protocol )
+ throws NonExistentProtocolException, RepositoryException;
+
+ /**
+ * server where this repo resides. For local repo - folder as URL and stream verifiers are important.
+ *
+ * @return server
+ */
+ boolean hasServer();
+
+ Server getServer();
+
+ /**
+ * DependencyProcessor used by this repo resides
+ *
+ * @return server
+ */
+ boolean hasDependencyProcessor();
+
+ DependencyProcessor getDependencyProcessor();
+
+ void setDependencyProcessor( DependencyProcessor dependencyProcessor );
+
+ /**
+ * maven-metadata.xml file name for this repository. This is internal to repository and should never be used outside
+ * of readers and wrters
+ *
+ * @return server
+ */
+ String getMetadataName();
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryCallback.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryCallback.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryCallback.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryCallback.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+/**
+ * This is a generic repository event callback. Used by all repository operations to signal end of operation and
+ * represents a list of exceptions plus a list of ArtifactBasicMetadata derivatives
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public interface RepositoryCallback
+{
+ public void done( AbstractRepOpResult results );
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryCallback.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryCallback.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryException.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryException.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryException.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class RepositoryException
+ extends Exception
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1193169088723411771L;
+
+ /**
+ *
+ */
+ public RepositoryException()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public RepositoryException( String message )
+ {
+ super( message );
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public RepositoryException( Throwable cause )
+ {
+ super( cause );
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public RepositoryException( String message, Throwable cause )
+ {
+ super( message, cause );
+ // TODO Auto-generated constructor stub
+ }
+
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,150 @@
+package org.apache.maven.mercury.repository.api;
+
+import java.text.ParseException;
+import java.util.Collection;
+import java.util.List;
+import java.util.TreeSet;
+
+import org.apache.maven.mercury.artifact.ArtifactCoordinates;
+import org.apache.maven.mercury.artifact.version.VersionComparator;
+import org.apache.maven.mercury.repository.metadata.Metadata;
+import org.apache.maven.mercury.repository.metadata.MetadataException;
+import org.apache.maven.mercury.util.TimeUtil;
+import org.apache.maven.mercury.util.Util;
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+
+/**
+ * This is a data object to carry GA level repository metadata, namely - a list of versions and last check timestamp
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class RepositoryGAMetadata
+{
+ private static final Language LANG = new DefaultLanguage( RepositoryGAVMetadata.class );
+
+ protected ArtifactCoordinates ga;
+
+ /** a list of last discovered versions, ordered ascending */
+ protected TreeSet<String> versions = new TreeSet<String>( new VersionComparator() );
+
+ /** GMT timestamp of the last metadata check */
+ protected long lastCheck;
+
+ /** is set true by cache implementation when determined that it's time to refresh */
+ protected transient boolean expired = false;
+
+ /** negative yes */
+ protected transient boolean negativeResult = false;
+
+ protected RepositoryGAMetadata()
+ {
+ }
+
+ /**
+ * @param versions
+ * @param lastCheck
+ */
+ public RepositoryGAMetadata( ArtifactCoordinates ga, Collection<String> versions )
+ {
+ this.ga = ga;
+
+ if ( !Util.isEmpty( versions ) )
+ this.versions.addAll( versions );
+
+ this.lastCheck = TimeUtil.getUTCTimestampAsLong();
+ }
+
+ /**
+ * construct from maven 2.x maven-metadata.xml object
+ *
+ * @param md
+ * @throws MetadataException
+ */
+ public RepositoryGAMetadata( Metadata md )
+ throws MetadataException
+ {
+ if ( md == null )
+ throw new IllegalArgumentException( LANG.getMessage( "empty.md" ) );
+
+ this.ga = new ArtifactCoordinates( md.getGroupId(), md.getArtifactId(), md.getVersion() );
+
+ List<String> vers = null;
+
+ if ( md.getVersioning() != null )
+ {
+ vers = md.getVersioning().getVersions();
+ this.versions.addAll( vers );
+ }
+
+ this.lastCheck = TimeUtil.getUTCTimestampAsLong();
+ }
+
+ /**
+ * copy constructor
+ *
+ * @param md
+ * @throws MetadataException
+ */
+ public RepositoryGAMetadata( RepositoryGAMetadata md )
+ throws MetadataException
+ {
+ this.ga = md.getGA();
+
+ if ( !Util.isEmpty( md.getVersions() ) )
+ {
+ this.versions.addAll( md.getVersions() );
+ }
+
+ this.lastCheck = TimeUtil.getUTCTimestampAsLong();
+ }
+
+ public TreeSet<String> getVersions()
+ {
+ return versions;
+ }
+
+ public long getLastCheckTs()
+ {
+ return lastCheck;
+ }
+
+ public long getLastCheckMillis()
+ throws ParseException
+ {
+ return TimeUtil.toMillis( lastCheck );
+ }
+
+ public void update( Collection<String> versions )
+ {
+ this.versions.addAll( versions );
+ this.lastCheck = TimeUtil.getUTCTimestampAsLong();
+ }
+
+ public ArtifactCoordinates getGA()
+ {
+ return ga;
+ }
+
+ public boolean isExpired()
+ {
+ return expired;
+ }
+
+ public void setExpired( boolean expired )
+ {
+ this.expired = expired;
+ }
+
+ public boolean isNegativeResult()
+ {
+ return negativeResult;
+ }
+
+ public void setNegativeResult( boolean negativeResult )
+ {
+ this.negativeResult = negativeResult;
+ }
+
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAMetadata.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,196 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+import java.text.ParseException;
+import java.util.Collection;
+import java.util.List;
+import java.util.TreeSet;
+
+import org.apache.maven.mercury.artifact.Artifact;
+import org.apache.maven.mercury.artifact.ArtifactCoordinates;
+import org.apache.maven.mercury.artifact.version.VersionComparator;
+import org.apache.maven.mercury.repository.metadata.Metadata;
+import org.apache.maven.mercury.repository.metadata.MetadataException;
+import org.apache.maven.mercury.repository.metadata.Snapshot;
+import org.apache.maven.mercury.util.TimeUtil;
+import org.apache.maven.mercury.util.Util;
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+
+/**
+ * This is a data object to carry GA level repository metadata, namely - a list of versions and last check timestamp
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class RepositoryGAVMetadata
+{
+ private static final Language LANG = new DefaultLanguage( RepositoryGAVMetadata.class );
+
+ protected ArtifactCoordinates gav;
+
+ /** a list of last discovered snapshots, ordered descending */
+ protected TreeSet<String> snapshots = new TreeSet<String>( new VersionComparator() );
+
+ /** a list of last discovered versions, ordered ascending */
+ protected Collection<String> classifiers;
+
+ /** GMT timestamp of the last metadata check */
+ protected long lastCheck;
+
+ /** is set true by cache implementation when determined that it's time to refresh */
+ protected transient boolean expired = false;
+
+ /** negative yes */
+ protected transient boolean negativeResult = false;
+
+ protected RepositoryGAVMetadata()
+ {
+ }
+
+ /**
+ * construct from maven 2.x maven-metadata.xml object
+ *
+ * @param md
+ * @throws MetadataException
+ */
+ public RepositoryGAVMetadata( Metadata md )
+ throws MetadataException
+ {
+ if ( md == null )
+ throw new IllegalArgumentException( LANG.getMessage( "empty.mdbytes" ) );
+
+ this.gav = new ArtifactCoordinates( md.getGroupId(), md.getArtifactId(), md.getVersion() );
+
+ List<String> versions = null;
+
+ if ( md.getVersioning() != null )
+ versions = md.getVersioning().getVersions();
+
+ if ( !Util.isEmpty( versions ) )
+ this.snapshots.addAll( versions );
+
+ String version = md.getVersion();
+
+ if ( version != null && version.endsWith( Artifact.SNAPSHOT_VERSION ) )
+ {
+ Snapshot sn = md.getVersioning().getSnapshot();
+
+ if ( sn != null && !Util.isEmpty( sn.getTimestamp() ) && !Util.isEmpty( sn.getBuildNumber() ) )
+ {
+ String ts =
+ version.replaceAll( Artifact.SNAPSHOT_VERSION, sn.getTimestamp() + '-' + sn.getBuildNumber() );
+ snapshots.add( ts );
+ }
+ }
+
+ this.lastCheck = TimeUtil.getUTCTimestampAsLong();
+ }
+
+ /**
+ * copy constructor
+ *
+ * @param md
+ * @throws MetadataException
+ */
+ public RepositoryGAVMetadata( RepositoryGAVMetadata md )
+ throws MetadataException
+ {
+ this.gav = md.getGAV();
+
+ if ( !Util.isEmpty( md.getSnapshots() ) )
+ this.snapshots.addAll( md.getSnapshots() );
+
+ this.lastCheck = TimeUtil.getUTCTimestampAsLong();
+ }
+
+ public TreeSet<String> getSnapshots()
+ {
+ return snapshots;
+ }
+
+ public Collection<String> getClassifiers()
+ {
+ return classifiers;
+ }
+
+ /**
+ * find the most recent snapshot timestamp
+ *
+ * @return
+ */
+ public String getSnapshot()
+ {
+ return snapshots.last();
+ }
+
+ public long getLastCheck()
+ {
+ return lastCheck;
+ }
+
+ public long getLastCheckMillis()
+ throws ParseException
+ {
+ return TimeUtil.toMillis( lastCheck );
+ }
+
+ public void updateSnapshots( Collection<String> snapshots )
+ {
+ this.snapshots.clear();
+
+ if ( !Util.isEmpty( snapshots ) )
+ this.snapshots.addAll( snapshots );
+
+ this.lastCheck = TimeUtil.getUTCTimestampAsLong();
+ }
+
+ public void updateClassifiers( Collection<String> classifiers )
+ {
+ this.classifiers = classifiers;
+ this.lastCheck = TimeUtil.getUTCTimestampAsLong();
+ }
+
+ public ArtifactCoordinates getGAV()
+ {
+ return gav;
+ }
+
+ public boolean isExpired()
+ {
+ return expired;
+ }
+
+ public void setExpired( boolean expired )
+ {
+ this.expired = expired;
+ }
+
+ public boolean isNegativeResult()
+ {
+ return negativeResult;
+ }
+
+ public void setNegativeResult( boolean negativeResult )
+ {
+ this.negativeResult = negativeResult;
+ }
+
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryGAVMetadata.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryManager.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryManager.java?rev=767705&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryManager.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryManager.java Wed Apr 22 22:56:48 2009
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.mercury.repository.api;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.mercury.artifact.Quality;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class RepositoryManager
+{
+ protected static transient List<Repository> _repoList =
+ Collections.synchronizedList( new ArrayList<Repository>( 8 ) );
+
+ void setRepositories()
+ {
+
+ }
+
+ List<Repository> getRepositories()
+ {
+ return _repoList;
+ }
+
+ LocalRepository findLocal( Quality aq )
+ {
+ for ( Repository r : _repoList )
+ {
+ if ( r.isLocal() && r.isWriteable() && r.isAcceptedQuality( aq ) )
+ return (LocalRepository) r;
+ }
+ return null;
+ }
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/RepositoryManager.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision