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/28 01:12:32 UTC
svn commit: r769199 [10/19] - in /maven/mercury/trunk:
mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/
mercury-ant-tasks/src/test/java/org/apache/maven/mercury/ant/tasks/
mercury-core/src/main/java/org/apache/maven/mercury/artifact/...
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/FileGetExchange.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/FileGetExchange.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/FileGetExchange.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/FileGetExchange.java Mon Apr 27 23:12:25 2009
@@ -43,40 +43,43 @@
import org.mortbay.jetty.HttpMethods;
import org.mortbay.jetty.client.HttpClient;
-
/**
* FileGetExchange
* <p/>
- * Make an asynchronous request to download a file and stream its bytes to a file.
- * When all bytes have been received onFileComplete will be called.
+ * Make an asynchronous request to download a file and stream its bytes to a file. When all bytes have been received
+ * onFileComplete will be called.
* <p/>
- * As an optimization, the file that is being downloaded can have it's
- * SHA-1 digest calculated as it is being streamed down.
+ * As an optimization, the file that is being downloaded can have it's SHA-1 digest calculated as it is being streamed
+ * down.
*/
-public abstract class FileGetExchange extends FileExchange
+public abstract class FileGetExchange
+ extends FileExchange
{
- private static final IMercuryLogger log = MercuryLoggerManager.getLogger(FileGetExchange.class);
+ private static final IMercuryLogger log = MercuryLoggerManager.getLogger( FileGetExchange.class );
+
private OutputStream _outputStream;
+
private Set<StreamObserver> _observers = new HashSet<StreamObserver>();
+
int _contentLength = -1;
-
+
/**
* Constructor.
- *
- * @param binding the remote file to fetch
- * @param localFile the local file location to store the remote file
- * @param observers observers of the io stream
- * @param client async http client
+ *
+ * @param binding the remote file to fetch
+ * @param localFile the local file location to store the remote file
+ * @param observers observers of the io stream
+ * @param client async http client
*/
- public FileGetExchange( Server server, Binding binding, File localFile, Set<StreamObserver> observers, HttpClient client )
+ public FileGetExchange( Server server, Binding binding, File localFile, Set<StreamObserver> observers,
+ HttpClient client )
{
super( server, binding, localFile, client );
- if( observers != null && ! observers.isEmpty() )
- _observers.addAll(observers);
+ if ( observers != null && !observers.isEmpty() )
+ _observers.addAll( observers );
}
-
/** Start the retrieval. */
public void send()
{
@@ -84,38 +87,38 @@
super.send();
}
- protected void onResponseHeader(Buffer name, Buffer value) throws IOException
+ protected void onResponseHeader( Buffer name, Buffer value )
+ throws IOException
{
- int header = HttpHeaders.CACHE.getOrdinal(value);
- switch (header)
+ int header = HttpHeaders.CACHE.getOrdinal( value );
+ switch ( header )
{
case HttpHeaders.CONTENT_LENGTH_ORDINAL:
- _contentLength = BufferUtil.toInt(value);
- for (StreamObserver o:_observers)
+ _contentLength = BufferUtil.toInt( value );
+ for ( StreamObserver o : _observers )
{
- o.setLength(_contentLength);
+ o.setLength( _contentLength );
}
- if (log.isDebugEnabled())
- log.debug("GET of "+_contentLength +" bytes");
+ if ( log.isDebugEnabled() )
+ log.debug( "GET of " + _contentLength + " bytes" );
break;
case HttpHeaders.LAST_MODIFIED_ORDINAL:
- for (StreamObserver o:_observers)
+ for ( StreamObserver o : _observers )
{
- o.setLastModified(BufferUtil.to8859_1_String(value));
+ o.setLastModified( BufferUtil.to8859_1_String( value ) );
}
break;
}
}
-
protected void onResponseComplete()
{
- //All bytes of file have been received
+ // All bytes of file have been received
try
{
- if (_outputStream != null)
+ if ( _outputStream != null )
_outputStream.close();
-
+
if ( _status == HttpServletResponse.SC_NOT_FOUND )
{
onFileError( _url, new FileNotFoundException( "File not found on remote server" ) );
@@ -135,10 +138,9 @@
}
}
-
/**
* Stream the downloaded bytes to a file
- *
+ *
* @see org.mortbay.jetty.client.HttpExchange$ContentExchange#onResponseContent(org.sonatype.io.Buffer)
*/
protected void onResponseContent( Buffer content )
@@ -155,13 +157,12 @@
}
}
-
/**
- * Get an output stream for the file contents. A digest can be optionally calculated
- * for the file contents as they are being streamed.
- *
+ * Get an output stream for the file contents. A digest can be optionally calculated for the file contents as they
+ * are being streamed.
+ *
* @return OutputStream for file contents
- * @throws IOException if io error occurs
+ * @throws IOException if io error occurs
* @throws NoSuchAlgorithmException if the SHA-1 algorithm is not supported
*/
protected OutputStream getOutputStream()
@@ -170,13 +171,13 @@
if ( _outputStream == null )
{
OutputStream os = null;
- if (_binding.isFile())
+ if ( _binding.isFile() )
os = new FileOutputStream( _localFile );
- else if (_binding.isInMemory())
+ else if ( _binding.isInMemory() )
os = _binding.getLocalOutputStream();
-
+
ObservableOutputStream oos = new ObservableOutputStream( os );
- oos.addObservers(_observers);
+ oos.addObservers( _observers );
_outputStream = oos;
}
return _outputStream;
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalCallback.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalCallback.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalCallback.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalCallback.java Mon Apr 27 23:12:25 2009
@@ -20,14 +20,13 @@
package org.apache.maven.mercury.spi.http.client.retrieve;
/**
- * Classes that implement this method will be notified when a given job has
- * been completed and validated.
+ * Classes that implement this method will be notified when a given job has been completed and validated.
*/
public interface RetrievalCallback
{
/**
* Callback for asynchronous version of Retriever.retrieve.
- *
+ *
* @param response empty if all artifacts retrieved ok, list of exceptions otherwise
*/
public abstract void onComplete( RetrievalResponse response );
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalRequest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalRequest.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalRequest.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalRequest.java Mon Apr 27 23:12:25 2009
@@ -24,18 +24,16 @@
import org.apache.maven.mercury.spi.http.validate.Validator;
import org.apache.maven.mercury.transport.api.Binding;
-
/**
* RetrievalRequest
* <p/>
- * A set of files to retrieve from remote locations
- * and a set of validators to apply to them.
+ * A set of files to retrieve from remote locations and a set of validators to apply to them.
*/
public interface RetrievalRequest
-{
+{
Set<Binding> getBindings();
boolean isFailFast();
-
+
Set<Validator> getValidators();
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalResponse.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalResponse.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalResponse.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalResponse.java Mon Apr 27 23:12:25 2009
@@ -23,7 +23,6 @@
import org.apache.maven.mercury.spi.http.client.HttpClientException;
-
/**
* RetrievalResponse
* <p/>
@@ -32,13 +31,12 @@
public interface RetrievalResponse
{
/**
- * The set will be empty if the operation completed successfully,
- * or will contain a single entry if the Request is failFast, otherwise
- * there will be one exception for every Binding in the Request.
- *
+ * The set will be empty if the operation completed successfully, or will contain a single entry if the Request is
+ * failFast, otherwise there will be one exception for every Binding in the Request.
+ *
* @return
*/
Set<HttpClientException> getExceptions();
-
+
boolean hasExceptions();
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalTarget.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalTarget.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalTarget.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/RetrievalTarget.java Mon Apr 27 23:12:25 2009
@@ -19,7 +19,6 @@
package org.apache.maven.mercury.spi.http.client.retrieve;
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -45,57 +44,69 @@
import org.mortbay.jetty.HttpHeaders;
import org.mortbay.jetty.client.HttpExchange;
-
-
/**
* RetrievalTarget
* <p/>
- * A RetrievalTarget is a remote file that must be downloaded locally, checksummed
- * and then atomically moved to its final location. The RetrievalTarget encapsulates
- * the temporary local file to which the remote file is downloaded, and also the
- * retrieval of the checksum file(s) and the checksum calculation(s).
+ * A RetrievalTarget is a remote file that must be downloaded locally, checksummed and then atomically moved to its
+ * final location. The RetrievalTarget encapsulates the temporary local file to which the remote file is downloaded, and
+ * also the retrieval of the checksum file(s) and the checksum calculation(s).
*/
public abstract class RetrievalTarget
{
private static final IMercuryLogger log = MercuryLoggerManager.getLogger( RetrievalTarget.class );
+
public static final String __PREFIX = "JTY_";
+
public static final String __TEMP_SUFFIX = ".tmp";
+
public static final int __START_STATE = 1;
+
public static final int __REQUESTED_STATE = 2;
+
public static final int __READY_STATE = 3;
protected int _checksumState;
+
protected int _targetState;
-
+
protected Server _server;
+
protected HttpClientException _exception;
+
protected Binding _binding;
+
protected File _tempFile;
+
protected DefaultRetriever _retriever;
+
protected boolean _complete;
+
protected HttpExchange _exchange;
+
protected Set<Validator> _validators;
+
protected Set<StreamObserver> _observers = new HashSet<StreamObserver>();
+
protected List<StreamVerifier> _verifiers = new ArrayList<StreamVerifier>();
+
protected Map<StreamVerifier, String> _verifierMap = new HashMap<StreamVerifier, String>();
-
-
+
public abstract void onComplete();
public abstract void onError( HttpClientException exception );
/**
* Constructor
- *
+ *
* @param binding
* @param callback
*/
- public RetrievalTarget( Server server, DefaultRetriever retriever, Binding binding, Set<Validator> validators, Set<StreamObserver> observers )
+ public RetrievalTarget( Server server, DefaultRetriever retriever, Binding binding, Set<Validator> validators,
+ Set<StreamObserver> observers )
{
- if ( binding == null ||
- (binding.getRemoteResource() == null) ||
- (binding.isFile() && (binding.getLocalFile() == null)) ||
- (binding.isInMemory() && (binding.getLocalOutputStream() == null)))
+ if ( binding == null || ( binding.getRemoteResource() == null )
+ || ( binding.isFile() && ( binding.getLocalFile() == null ) )
+ || ( binding.isInMemory() && ( binding.getLocalOutputStream() == null ) ) )
{
throw new IllegalArgumentException( "Nothing to retrieve" );
}
@@ -103,20 +114,21 @@
_retriever = retriever;
_binding = binding;
_validators = validators;
-
- //sift out the potential checksum verifiers
- for (StreamObserver o: observers)
+
+ // sift out the potential checksum verifiers
+ for ( StreamObserver o : observers )
{
- if (StreamVerifier.class.isAssignableFrom(o.getClass()))
- _verifiers.add((StreamVerifier)o);
+ if ( StreamVerifier.class.isAssignableFrom( o.getClass() ) )
+ _verifiers.add( (StreamVerifier) o );
else
- _observers.add(o);
+ _observers.add( o );
}
-
- if (_binding.isFile())
+
+ if ( _binding.isFile() )
{
- _tempFile = new File( _binding.getLocalFile().getParentFile(),
- __PREFIX + _binding.getLocalFile().getName() + __TEMP_SUFFIX );
+ _tempFile =
+ new File( _binding.getLocalFile().getParentFile(), __PREFIX + _binding.getLocalFile().getName()
+ + __TEMP_SUFFIX );
_tempFile.deleteOnExit();
if ( !_tempFile.getParentFile().exists() )
{
@@ -129,14 +141,12 @@
}
else if ( !_tempFile.getParentFile().canWrite() )
{
- onError( new HttpClientException( binding,
- "Unable to write to dir " + _tempFile.getParentFile().getAbsolutePath() ) );
+ onError( new HttpClientException( binding, "Unable to write to dir "
+ + _tempFile.getParentFile().getAbsolutePath() ) );
}
}
}
-
-
public File getTempFile()
{
return _tempFile;
@@ -147,32 +157,31 @@
return _binding.getRemoteResource().toExternalForm();
}
-
/** Start by getting the appropriate checksums */
public void retrieve()
{
- //if there are no checksum verifiers configured, proceed directly to get the file
- if (_verifiers.size() == 0)
+ // if there are no checksum verifiers configured, proceed directly to get the file
+ if ( _verifiers.size() == 0 )
{
_checksumState = __READY_STATE;
- updateTargetState(__START_STATE, null);
+ updateTargetState( __START_STATE, null );
}
else
{
_checksumState = __START_STATE;
- updateChecksumState(-1, null);
+ updateChecksumState( -1, null );
}
}
-
/** Move the temporary file to its final location */
public boolean move()
{
- if (_binding.isFile())
+ if ( _binding.isFile() )
{
boolean ok = _tempFile.renameTo( _binding.getLocalFile() );
- if (log.isDebugEnabled())
- log.debug("Renaming "+_tempFile.getAbsolutePath()+" to "+_binding.getLocalFile().getAbsolutePath()+": "+ok);
+ if ( log.isDebugEnabled() )
+ log.debug( "Renaming " + _tempFile.getAbsolutePath() + " to "
+ + _binding.getLocalFile().getAbsolutePath() + ": " + ok );
return ok;
}
else
@@ -199,7 +208,7 @@
return "T:" + _binding.getRemoteResource() + ":" + _targetState + ":" + _checksumState + ":" + _complete;
}
- private void updateChecksumState (int index, Throwable ex)
+ private void updateChecksumState( int index, Throwable ex )
{
if ( _exception == null && ex != null )
{
@@ -212,72 +221,66 @@
_exception = new HttpClientException( _binding, ex );
}
}
-
- if (ex != null)
+
+ if ( ex != null )
{
_checksumState = __READY_STATE;
- onError(_exception);
+ onError( _exception );
}
else
- {
+ {
boolean proceedWithTargetFile = false;
- if (index >= 0)
+ if ( index >= 0 )
{
- //check if the just-completed retrieval means that we can stop trying to download checksums
- StreamVerifier v = _verifiers.get(index);
- if (_verifierMap.containsKey(v) && v.getAttributes().isSufficient())
+ // check if the just-completed retrieval means that we can stop trying to download checksums
+ StreamVerifier v = _verifiers.get( index );
+ if ( _verifierMap.containsKey( v ) && v.getAttributes().isSufficient() )
proceedWithTargetFile = true;
}
index++;
-
- if ((index < _verifiers.size()) && !proceedWithTargetFile)
+
+ if ( ( index < _verifiers.size() ) && !proceedWithTargetFile )
{
- retrieveChecksum(index);
+ retrieveChecksum( index );
}
else
{
_checksumState = __READY_STATE;
- //finished retrieving all possible checksums. Add all verifiers
- //that had matching checksums into the observers list
- _observers.addAll(_verifierMap.keySet());
+ // finished retrieving all possible checksums. Add all verifiers
+ // that had matching checksums into the observers list
+ _observers.addAll( _verifierMap.keySet() );
- //now get the file now we have the checksum sorted out
+ // now get the file now we have the checksum sorted out
updateTargetState( __START_STATE, null );
}
}
}
-
-
-
-
/**
* Check the actual checksum against the expected checksum
- *
+ *
* @return
- * @throws StreamVerifierException
+ * @throws StreamVerifierException
*/
public boolean verifyChecksum()
- throws StreamVerifierException
+ throws StreamVerifierException
{
boolean ok = true;
-
- synchronized (_verifierMap)
+
+ synchronized ( _verifierMap )
{
Iterator<Map.Entry<StreamVerifier, String>> itor = _verifierMap.entrySet().iterator();
- while (itor.hasNext() && ok)
- {
+ while ( itor.hasNext() && ok )
+ {
Map.Entry<StreamVerifier, String> e = itor.next();
ok = e.getKey().verifySignature();
}
}
-
+
return ok;
}
-
-
public boolean validate( List<String> errors )
{
@@ -286,10 +289,10 @@
return true;
}
- String ext = _binding.getRemoteResource().toString();
- if (ext.endsWith("/"))
- ext = ext.substring(0, ext.length()-1);
-
+ String ext = _binding.getRemoteResource().toString();
+ if ( ext.endsWith( "/" ) )
+ ext = ext.substring( 0, ext.length() - 1 );
+
int i = ext.lastIndexOf( "." );
ext = ( i > 0 ? ext.substring( i + 1 ) : "" );
@@ -300,17 +303,17 @@
{
try
{
- if (_binding.isFile())
+ if ( _binding.isFile() )
{
if ( !v.validate( _tempFile.getCanonicalPath(), errors ) )
{
return false;
}
}
- else if (_binding.isInMemory())
+ else if ( _binding.isInMemory() )
{
- //TODO Validation on in memory content?
- //v.validate(_binding.getInboundContent())
+ // TODO Validation on in memory content?
+ // v.validate(_binding.getInboundContent())
}
}
catch ( IOException e )
@@ -323,8 +326,6 @@
return true;
}
-
-
protected synchronized void updateTargetState( int state, Throwable ex )
{
_targetState = state;
@@ -344,8 +345,8 @@
{
_exchange = retrieveTargetFile();
}
- //if both checksum and target file are ready, we're ready to return callback
- else if (_targetState == __READY_STATE )
+ // if both checksum and target file are ready, we're ready to return callback
+ else if ( _targetState == __READY_STATE )
{
_complete = true;
if ( _exception == null )
@@ -360,110 +361,112 @@
}
/** Asynchronously fetch the checksum for the target file. */
- private HttpExchange retrieveChecksum(final int index)
- {
+ private HttpExchange retrieveChecksum( final int index )
+ {
HttpExchange exchange = new HttpExchange.ContentExchange()
{
protected void onException( Throwable ex )
{
- //if the checksum is mandatory, then propagate the exception and stop processing
- if (!_verifiers.get(index).getAttributes().isLenient())
+ // if the checksum is mandatory, then propagate the exception and stop processing
+ if ( !_verifiers.get( index ).getAttributes().isLenient() )
{
- updateChecksumState(index, ex);
+ updateChecksumState( index, ex );
}
else
- updateChecksumState(index, null);
-
+ updateChecksumState( index, null );
+
}
- protected void onResponseComplete() throws IOException
+ protected void onResponseComplete()
+ throws IOException
{
super.onResponseComplete();
- StreamVerifier v = _verifiers.get(index);
-
+ StreamVerifier v = _verifiers.get( index );
+
if ( getResponseStatus() == HttpServletResponse.SC_OK )
{
- //We got a checksum so match it up with the verifier it is for
- synchronized (_verifierMap)
+ // We got a checksum so match it up with the verifier it is for
+ synchronized ( _verifierMap )
{
- if( v.getAttributes().isSufficient() )
- _verifierMap.clear(); //remove all other entries, we only need one checksum
-
- String actualSignature = getResponseContent().trim();
+ if ( v.getAttributes().isSufficient() )
+ _verifierMap.clear(); // remove all other entries, we only need one checksum
+
+ String actualSignature = getResponseContent().trim();
try
{ // Oleg: verifier need to be loaded upfront
- v.initSignature( actualSignature );
+ v.initSignature( actualSignature );
}
- catch( StreamVerifierException e )
+ catch ( StreamVerifierException e )
{
- throw new IOException(e.getMessage());
+ throw new IOException( e.getMessage() );
}
_verifierMap.put( v, actualSignature );
}
- updateChecksumState(index, null);
+ updateChecksumState( index, null );
}
- else
+ else
{
- if (!v.getAttributes().isLenient())
+ if ( !v.getAttributes().isLenient() )
{
- //checksum file MUST be present, fail
- updateChecksumState(index, new Exception ("Mandatory checksum file not found "+this.getURI()));
+ // checksum file MUST be present, fail
+ updateChecksumState( index,
+ new Exception( "Mandatory checksum file not found " + this.getURI() ) );
}
else
- updateChecksumState(index, null);
+ updateChecksumState( index, null );
}
}
};
-
- exchange.setURL( getChecksumFileURLAsString( _verifiers.get(index)) );
+
+ exchange.setURL( getChecksumFileURLAsString( _verifiers.get( index ) ) );
try
{
- SecureSender.send(_server, _retriever.getHttpClient(), exchange);
+ SecureSender.send( _server, _retriever.getHttpClient(), exchange );
}
catch ( Exception ex )
{
- updateChecksumState(index, ex);
+ updateChecksumState( index, ex );
}
return exchange;
}
-
/** Asynchronously fetch the target file. */
private HttpExchange retrieveTargetFile()
{
updateTargetState( __REQUESTED_STATE, null );
- //get the file, calculating the digest for it on the fly
- FileExchange exchange = new FileGetExchange( _server, _binding, getTempFile(), _observers, _retriever.getHttpClient() )
- {
- public void onFileComplete( String url, File localFile )
+ // get the file, calculating the digest for it on the fly
+ FileExchange exchange =
+ new FileGetExchange( _server, _binding, getTempFile(), _observers, _retriever.getHttpClient() )
{
- //we got the target file ok, so tell our main callback
- _targetState = __READY_STATE;
- updateTargetState( __READY_STATE, null );
- }
+ public void onFileComplete( String url, File localFile )
+ {
+ // we got the target file ok, so tell our main callback
+ _targetState = __READY_STATE;
+ updateTargetState( __READY_STATE, null );
+ }
- public void onFileError( String url, Exception e )
- {
- //an error occurred whilst fetching the file, return an error
- _targetState = __READY_STATE;
- updateTargetState( __READY_STATE, e );
- }
- };
+ public void onFileError( String url, Exception e )
+ {
+ // an error occurred whilst fetching the file, return an error
+ _targetState = __READY_STATE;
+ updateTargetState( __READY_STATE, e );
+ }
+ };
- if( _server != null && _server.hasUserAgent() )
- exchange.setRequestHeader( HttpHeaders.USER_AGENT, _server.getUserAgent() );
+ if ( _server != null && _server.hasUserAgent() )
+ exchange.setRequestHeader( HttpHeaders.USER_AGENT, _server.getUserAgent() );
exchange.send();
return exchange;
}
- private String getChecksumFileURLAsString (StreamVerifier verifier)
+ private String getChecksumFileURLAsString( StreamVerifier verifier )
{
String extension = verifier.getAttributes().getExtension();
- if (extension.charAt(0) != '.')
- extension = "."+extension;
+ if ( extension.charAt( 0 ) != '.' )
+ extension = "." + extension;
return _binding.getRemoteResource().toString() + extension;
}
@@ -471,12 +474,12 @@
{
if ( _tempFile != null && _tempFile.exists() )
{
- boolean ok = _tempFile.delete();
- if (log.isDebugEnabled())
- log.debug("Deleting file "+_tempFile.getAbsolutePath()+" : "+ok);
+ boolean ok = _tempFile.delete();
+ if ( log.isDebugEnabled() )
+ log.debug( "Deleting file " + _tempFile.getAbsolutePath() + " : " + ok );
return ok;
}
return false;
}
-
+
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/Retriever.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/Retriever.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/Retriever.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/Retriever.java Mon Apr 27 23:12:25 2009
@@ -27,31 +27,29 @@
public interface Retriever
{
/**
- * Retrieve a set of artifacts and wait until all retrieved successfully
- * or an error occurs.
+ * Retrieve a set of artifacts and wait until all retrieved successfully or an error occurs.
* <p/>
- * Note: whilst this method is synchronous for the caller, the implementation
- * will be asynchronous so many artifacts are fetched in parallel.
- *
+ * Note: whilst this method is synchronous for the caller, the implementation will be asynchronous so many artifacts
+ * are fetched in parallel.
+ *
* @param request
* @return
*/
RetrievalResponse retrieve( RetrievalRequest request );
-
/**
- * Retrieve a set of artifacts without waiting for the results.
- * When all results have been obtained (or an error occurs) the
- * RetrievalResponse will be called.
- *
+ * Retrieve a set of artifacts without waiting for the results. When all results have been obtained (or an error
+ * occurs) the RetrievalResponse will be called.
+ *
* @param request
* @param callback
*/
void retrieve( RetrievalRequest request, RetrievalCallback callback );
-
+
/**
* stop and release all resources
- * @throws Exception
+ *
+ * @throws Exception
*/
void stop();
}
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/server/PlaceHolder.txt
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/server/PlaceHolder.txt?rev=769199&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/server/PlaceHolder.txt (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/server/PlaceHolder.txt Mon Apr 27 23:12:25 2009
@@ -0,0 +1,5 @@
+this package contains the server side transaction support. Had to move it out to
+tests because it depends on jetty server.
+
+In jetty-6.1.15 there is a special assembly to avoid this dependency, in jetty-7 the
+code is refactored and we can change dependencies and bring this code back in.
\ No newline at end of file
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/server/PlaceHolder.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/server/PlaceHolder.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/validate/PomValidator.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/validate/PomValidator.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/validate/PomValidator.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/validate/PomValidator.java Mon Apr 27 23:12:25 2009
@@ -24,14 +24,15 @@
import org.codehaus.plexus.util.FileUtils;
-public class PomValidator implements Validator
+public class PomValidator
+ implements Validator
{
public String getFileExtension()
{
return "pom";
}
- public boolean validate(String stagedFile, List<String> errors)
+ public boolean validate( String stagedFile, List<String> errors )
{
try
{
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/validate/Validator.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/validate/Validator.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/validate/Validator.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/spi/http/validate/Validator.java Mon Apr 27 23:12:25 2009
@@ -30,14 +30,14 @@
{
/**
* The file extension the validator will process
- *
+ *
* @return String file extension
*/
public String getFileExtension();
/**
* validation for a given file target with errors being able to be logged in the list
- *
+ *
* @param stagedFile
* @param errors
* @return true if target file is valid
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/AbstractTransport.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/AbstractTransport.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/AbstractTransport.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/AbstractTransport.java Mon Apr 27 23:12:25 2009
@@ -24,24 +24,22 @@
/**
* Helper parent of transport implementations. Common for read and write transports
- *
+ *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public abstract class AbstractTransport
{
- private Collection<Server> _servers = Collections.synchronizedSet( new HashSet< Server >() );
-
- public void setServers( Collection<Server> servers )
- {
- _servers = servers;
- }
-
- public Collection<Server> getServers()
- {
- return _servers;
- }
-
+ private Collection<Server> _servers = Collections.synchronizedSet( new HashSet<Server>() );
+
+ public void setServers( Collection<Server> servers )
+ {
+ _servers = servers;
+ }
+
+ public Collection<Server> getServers()
+ {
+ return _servers;
+ }
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Binding.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Binding.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Binding.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Binding.java Mon Apr 27 23:12:25 2009
@@ -29,176 +29,177 @@
import org.apache.maven.mercury.logging.MercuryLoggerManager;
/**
- * Binding <p/> A Binding represents a remote uri whose contents are to be
- * downloaded and stored in a locally, or a local resource whose contents are to
- * be uploaded to the remote uri.
+ * Binding
+ * <p/>
+ * A Binding represents a remote uri whose contents are to be downloaded and stored in a locally, or a local resource
+ * whose contents are to be uploaded to the remote uri.
*/
public class Binding
{
- private static final IMercuryLogger LOG = MercuryLoggerManager.getLogger( Binding.class );
-
- protected URL remoteResource;
-
- protected File localFile;
-
- /**
- * inbound in-memory binding for reading remote content.
- * It is created by the constructor
- */
- protected ByteArrayOutputStream localOS;
-
- /**
- * this is outbound in-memory binding. IS is passed by the client
- */
- protected InputStream localIS;
-
- /** indicates that this transfer is exempt from stream verification */
- boolean exempt = false;
-
- protected Exception error;
-
- public Binding()
- {
- }
-
- public Binding( URL remoteUrl, File localFile)
- {
- this.remoteResource = remoteUrl;
- this.localFile = localFile;
- }
-
- public Binding( URL remoteUrl, File localFile, boolean exempt )
- {
- this( remoteUrl,localFile );
- this.exempt = exempt;
- }
-
- /**
- * this is in-memory binding for writing remote content into localOS
- *
- * @param remoteUrl
- * @param lenientChecksum
- */
- public Binding( URL remoteUrl )
- {
- this.remoteResource = remoteUrl;
- // let's assume 4k on average
- this.localOS = new ByteArrayOutputStream( 4*1024 );
- }
-
- public Binding( URL remoteUrl, boolean exempt )
- {
- this( remoteUrl );
- this.exempt = exempt;
- }
-
- /**
- * outbound constructor - send contents of the stream to remoteUrl
- *
- * @param remoteUrl
- * @param is
- */
- public Binding( URL remoteUrl, InputStream is )
- {
- this.remoteResource = remoteUrl;
- this.localIS = is;
- }
- public Binding( URL remoteUrl, InputStream is, boolean exempt )
- {
- this( remoteUrl, is );
- this.exempt = exempt;
- }
-
- /**
- * inbound constructor - read contents of the remoteUrl to the stream
- *
- * @param remoteUrl
- * @param is
- */
- public Binding( URL remoteUrl, ByteArrayOutputStream os )
- {
- this.remoteResource = remoteUrl;
- this.localOS = os;
- }
-
- public Binding( URL remoteUrl, ByteArrayOutputStream os, boolean exempt )
- {
- this( remoteUrl, os );
- this.exempt = exempt;
- }
-
- public URL getRemoteResource()
- {
- return remoteResource;
- }
-
- public void setRemoteResource( URL remoteResource )
- {
- this.remoteResource = remoteResource;
- }
-
- public Exception getError()
- {
- return error;
- }
-
- public void setError( Exception error )
- {
- this.error = error;
- }
-
- public boolean isInMemory()
- {
- return (!isFile() && (localIS != null || localOS != null));
- }
-
- public boolean isFile()
- {
- return localFile != null;
- }
-
- public boolean isExempt()
- {
- return exempt;
- }
-
- public void setExempt( boolean exempt )
- {
- this.exempt = exempt;
- }
-
- public byte [] getInboundContent()
- {
- if( localOS != null )
- return localOS.toByteArray();
-
- return null;
- }
-
- public OutputStream getLocalOutputStream()
- {
- return localOS;
- }
-
- public InputStream getLocalInputStream()
- {
- return localIS;
- }
-
- public File getLocalFile ()
- {
- return localFile;
- }
-
- @Override
- public String toString()
- {
- return '['
- + (exempt ? "(exempt)" : "")
- + (remoteResource == null ? "null URL" : remoteResource.toString() )+" <=> "
- + (localFile == null ? ( localIS == null ? (localOS == null ? "null local Res" : localOS) : "localIS" ) : localFile.getAbsolutePath() )
- +']'
- ;
- }
+ private static final IMercuryLogger LOG = MercuryLoggerManager.getLogger( Binding.class );
+
+ protected URL remoteResource;
+
+ protected File localFile;
+
+ /**
+ * inbound in-memory binding for reading remote content. It is created by the constructor
+ */
+ protected ByteArrayOutputStream localOS;
+
+ /**
+ * this is outbound in-memory binding. IS is passed by the client
+ */
+ protected InputStream localIS;
+
+ /** indicates that this transfer is exempt from stream verification */
+ boolean exempt = false;
+
+ protected Exception error;
+
+ public Binding()
+ {
+ }
+
+ public Binding( URL remoteUrl, File localFile )
+ {
+ this.remoteResource = remoteUrl;
+ this.localFile = localFile;
+ }
+
+ public Binding( URL remoteUrl, File localFile, boolean exempt )
+ {
+ this( remoteUrl, localFile );
+ this.exempt = exempt;
+ }
+
+ /**
+ * this is in-memory binding for writing remote content into localOS
+ *
+ * @param remoteUrl
+ * @param lenientChecksum
+ */
+ public Binding( URL remoteUrl )
+ {
+ this.remoteResource = remoteUrl;
+ // let's assume 4k on average
+ this.localOS = new ByteArrayOutputStream( 4 * 1024 );
+ }
+
+ public Binding( URL remoteUrl, boolean exempt )
+ {
+ this( remoteUrl );
+ this.exempt = exempt;
+ }
+
+ /**
+ * outbound constructor - send contents of the stream to remoteUrl
+ *
+ * @param remoteUrl
+ * @param is
+ */
+ public Binding( URL remoteUrl, InputStream is )
+ {
+ this.remoteResource = remoteUrl;
+ this.localIS = is;
+ }
+
+ public Binding( URL remoteUrl, InputStream is, boolean exempt )
+ {
+ this( remoteUrl, is );
+ this.exempt = exempt;
+ }
+
+ /**
+ * inbound constructor - read contents of the remoteUrl to the stream
+ *
+ * @param remoteUrl
+ * @param is
+ */
+ public Binding( URL remoteUrl, ByteArrayOutputStream os )
+ {
+ this.remoteResource = remoteUrl;
+ this.localOS = os;
+ }
+
+ public Binding( URL remoteUrl, ByteArrayOutputStream os, boolean exempt )
+ {
+ this( remoteUrl, os );
+ this.exempt = exempt;
+ }
+
+ public URL getRemoteResource()
+ {
+ return remoteResource;
+ }
+
+ public void setRemoteResource( URL remoteResource )
+ {
+ this.remoteResource = remoteResource;
+ }
+
+ public Exception getError()
+ {
+ return error;
+ }
+
+ public void setError( Exception error )
+ {
+ this.error = error;
+ }
+
+ public boolean isInMemory()
+ {
+ return ( !isFile() && ( localIS != null || localOS != null ) );
+ }
+
+ public boolean isFile()
+ {
+ return localFile != null;
+ }
+
+ public boolean isExempt()
+ {
+ return exempt;
+ }
+
+ public void setExempt( boolean exempt )
+ {
+ this.exempt = exempt;
+ }
+
+ public byte[] getInboundContent()
+ {
+ if ( localOS != null )
+ return localOS.toByteArray();
+
+ return null;
+ }
+
+ public OutputStream getLocalOutputStream()
+ {
+ return localOS;
+ }
+
+ public InputStream getLocalInputStream()
+ {
+ return localIS;
+ }
+
+ public File getLocalFile()
+ {
+ return localFile;
+ }
+
+ @Override
+ public String toString()
+ {
+ return '['
+ + ( exempt ? "(exempt)" : "" )
+ + ( remoteResource == null ? "null URL" : remoteResource.toString() )
+ + " <=> "
+ + ( localFile == null ? ( localIS == null ? ( localOS == null ? "null local Res" : localOS ) : "localIS" )
+ : localFile.getAbsolutePath() ) + ']';
+ }
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Credentials.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Credentials.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Credentials.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Credentials.java Mon Apr 27 23:12:25 2009
@@ -20,69 +20,68 @@
/**
* supplies credentials to the server
- *
+ *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public class Credentials
{
- private String user;
- private String pass;
-
- private byte [] cert;
-
- public Credentials( String user, String pass )
- {
- this.user = user;
- this.pass = pass;
- }
-
- public Credentials( byte [] cert, String user, String pass )
- {
- this( user, pass );
- this.cert = cert;
- }
-
- public Credentials( byte [] cert )
- {
- this.cert = cert;
- }
-
- public String getUser()
- {
- return user;
- }
-
- public void setUser( String user )
- {
- this.user = user;
- }
-
- public String getPass()
- {
- return pass;
- }
-
- public void setPass( String pass )
- {
- this.pass = pass;
- }
-
- public byte [] getCertificate()
- {
- return cert;
- }
-
- public boolean isCertificate()
- {
- return cert != null && cert.length > 1;
- }
-
- public void setCertificate( byte [] cert )
- {
- this.cert = cert;
- }
-
-
+ private String user;
+
+ private String pass;
+
+ private byte[] cert;
+
+ public Credentials( String user, String pass )
+ {
+ this.user = user;
+ this.pass = pass;
+ }
+
+ public Credentials( byte[] cert, String user, String pass )
+ {
+ this( user, pass );
+ this.cert = cert;
+ }
+
+ public Credentials( byte[] cert )
+ {
+ this.cert = cert;
+ }
+
+ public String getUser()
+ {
+ return user;
+ }
+
+ public void setUser( String user )
+ {
+ this.user = user;
+ }
+
+ public String getPass()
+ {
+ return pass;
+ }
+
+ public void setPass( String pass )
+ {
+ this.pass = pass;
+ }
+
+ public byte[] getCertificate()
+ {
+ return cert;
+ }
+
+ public boolean isCertificate()
+ {
+ return cert != null && cert.length > 1;
+ }
+
+ public void setCertificate( byte[] cert )
+ {
+ this.cert = cert;
+ }
+
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Initializable.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Initializable.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Initializable.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Initializable.java Mon Apr 27 23:12:25 2009
@@ -19,15 +19,11 @@
package org.apache.maven.mercury.transport.api;
/**
- *
- *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public interface Initializable
{
- public void init()
- throws InitializationException
- ;
+ public void init()
+ throws InitializationException;
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/InitializationException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/InitializationException.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/InitializationException.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/InitializationException.java Mon Apr 27 23:12:25 2009
@@ -19,54 +19,47 @@
package org.apache.maven.mercury.transport.api;
/**
- *
- *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public class InitializationException
extends Exception
{
- /**
+ /**
*
*/
- public InitializationException()
- {
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param message
- */
- public InitializationException(
- String message )
- {
- super( message );
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param cause
- */
- public InitializationException(
- Throwable cause )
- {
- super( cause );
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param message
- * @param cause
- */
- public InitializationException(
- String message,
- Throwable cause )
- {
- super( message, cause );
- // TODO Auto-generated constructor stub
- }
+ public InitializationException()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public InitializationException( String message )
+ {
+ super( message );
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public InitializationException( Throwable cause )
+ {
+ super( cause );
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public InitializationException( String message, Throwable cause )
+ {
+ super( message, cause );
+ // TODO Auto-generated constructor stub
+ }
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/ReaderTransport.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/ReaderTransport.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/ReaderTransport.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/ReaderTransport.java Mon Apr 27 23:12:25 2009
@@ -22,18 +22,17 @@
/**
* generic Transport interface - allows client to read data from a remote repository
- *
+ *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public interface ReaderTransport
-extends Initializable
+ extends Initializable
{
- public TransportTransaction read( TransportTransaction trx )
- throws TransportException;
-
- public void setServers( Collection<Server> servers );
-
- public Collection<Server> getServers();
+ public TransportTransaction read( TransportTransaction trx )
+ throws TransportException;
+
+ public void setServers( Collection<Server> servers );
+
+ public Collection<Server> getServers();
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Server.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Server.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Server.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/Server.java Mon Apr 27 23:12:25 2009
@@ -95,9 +95,9 @@
}
else
this.url = url;
-
+
this.id = normalizeUrl( url.toString() );
-
+
}
public Server( String id, URL url )
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/ServerContainer.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/ServerContainer.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/ServerContainer.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/ServerContainer.java Mon Apr 27 23:12:25 2009
@@ -20,12 +20,11 @@
/**
* common interface for transports to obtain their servers from Collection's
- *
+ *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public interface ServerContainer
{
- public Server getServer();
+ public Server getServer();
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/TransportException.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/TransportException.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/TransportException.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/TransportException.java Mon Apr 27 23:12:25 2009
@@ -19,54 +19,47 @@
package org.apache.maven.mercury.transport.api;
/**
- *
- *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public class TransportException
extends Exception
{
- /**
+ /**
*
*/
- public TransportException()
- {
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param message
- */
- public TransportException(
- String message )
- {
- super( message );
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param cause
- */
- public TransportException(
- Throwable cause )
- {
- super( cause );
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param message
- * @param cause
- */
- public TransportException(
- String message,
- Throwable cause )
- {
- super( message, cause );
- // TODO Auto-generated constructor stub
- }
+ public TransportException()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public TransportException( String message )
+ {
+ super( message );
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public TransportException( Throwable cause )
+ {
+ super( cause );
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public TransportException( String message, Throwable cause )
+ {
+ super( message, cause );
+ // TODO Auto-generated constructor stub
+ }
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/TransportTransaction.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/TransportTransaction.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/TransportTransaction.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/TransportTransaction.java Mon Apr 27 23:12:25 2009
@@ -29,125 +29,134 @@
/**
* Repository access transaction. Consists of a collection of bindings
- *
+ *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public class TransportTransaction
{
- public static final int DEFAULT_SIZE = 32;
-
- protected Collection<Binding> _bindings;
-
- //------------------------------------------------------------------------------------------------
- private void init()
- {
- init( DEFAULT_SIZE );
- }
- //------------------------------------------------------------------------------------------------
- private void init( int n )
- {
- if( _bindings == null )
- _bindings = new ArrayList<Binding>( n );
- }
- //------------------------------------------------------------------------------------------------
- /**
+ public static final int DEFAULT_SIZE = 32;
+
+ protected Collection<Binding> _bindings;
+
+ // ------------------------------------------------------------------------------------------------
+ private void init()
+ {
+ init( DEFAULT_SIZE );
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ private void init( int n )
+ {
+ if ( _bindings == null )
+ _bindings = new ArrayList<Binding>( n );
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ /**
*
*/
- public TransportTransaction()
- {
- init();
- }
- //------------------------------------------------------------------------------------------------
- /**
+ public TransportTransaction()
+ {
+ init();
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ /**
*
*/
- public TransportTransaction add( Binding binding )
- {
- init();
-
- _bindings.add( binding );
-
- return this;
- }
- //------------------------------------------------------------------------------------------------
- public TransportTransaction add( URL remoteResource, File localResource )
- {
- init();
-
- _bindings.add( new Binding( remoteResource, localResource ) );
-
- return this;
- }
- //------------------------------------------------------------------------------------------------
- public TransportTransaction add( URL remoteResource )
- {
- init();
-
- _bindings.add( new Binding( remoteResource ) );
-
- return this;
- }
- //------------------------------------------------------------------------------------------------
- public TransportTransaction add( URL remoteResource, InputStream is )
- {
- init();
-
- _bindings.add( new Binding( remoteResource, is ) );
-
- return this;
- }
-
- //------------------------------------------------------------------------------------------------
- public TransportTransaction add( URL remoteResource, byte [] localResource )
- {
- init();
-
- _bindings.add( new Binding( remoteResource, new ByteArrayInputStream(localResource)) );
-
- return this;
- }
- //------------------------------------------------------------------------------------------------
- @SuppressWarnings("unchecked")
- public Collection<Binding> getBindings()
- {
- return _bindings == null ? (List<Binding>)Collections.EMPTY_LIST : _bindings;
- }
-
- public void setBindings( List<Binding> bindings )
- {
- this._bindings = bindings;
- }
- //------------------------------------------------------------------------------------------------
- public boolean isEmpty()
- {
- if( _bindings == null || _bindings.size() < 1 )
- return true;
-
- return false;
- }
- //------------------------------------------------------------------------------------------------
- public boolean hasErrors()
- {
- if( _bindings == null )
- return false;
-
- for( Binding b : _bindings )
- if( b.getError() != null )
- return true;
-
- return false;
- }
- //------------------------------------------------------------------------------------------------
- public void clearErrors()
- {
- if( _bindings == null )
- return;
-
- for( Binding b : _bindings )
- b.setError( null );
- }
- //------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------
+ public TransportTransaction add( Binding binding )
+ {
+ init();
+
+ _bindings.add( binding );
+
+ return this;
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ public TransportTransaction add( URL remoteResource, File localResource )
+ {
+ init();
+
+ _bindings.add( new Binding( remoteResource, localResource ) );
+
+ return this;
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ public TransportTransaction add( URL remoteResource )
+ {
+ init();
+
+ _bindings.add( new Binding( remoteResource ) );
+
+ return this;
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ public TransportTransaction add( URL remoteResource, InputStream is )
+ {
+ init();
+
+ _bindings.add( new Binding( remoteResource, is ) );
+
+ return this;
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ public TransportTransaction add( URL remoteResource, byte[] localResource )
+ {
+ init();
+
+ _bindings.add( new Binding( remoteResource, new ByteArrayInputStream( localResource ) ) );
+
+ return this;
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ @SuppressWarnings( "unchecked" )
+ public Collection<Binding> getBindings()
+ {
+ return _bindings == null ? (List<Binding>) Collections.EMPTY_LIST : _bindings;
+ }
+
+ public void setBindings( List<Binding> bindings )
+ {
+ this._bindings = bindings;
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ public boolean isEmpty()
+ {
+ if ( _bindings == null || _bindings.size() < 1 )
+ return true;
+
+ return false;
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ public boolean hasErrors()
+ {
+ if ( _bindings == null )
+ return false;
+
+ for ( Binding b : _bindings )
+ if ( b.getError() != null )
+ return true;
+
+ return false;
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ public void clearErrors()
+ {
+ if ( _bindings == null )
+ return;
+
+ for ( Binding b : _bindings )
+ b.setError( null );
+ }
+ // ------------------------------------------------------------------------------------------------
+ // ------------------------------------------------------------------------------------------------
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/WriterTransport.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/WriterTransport.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/WriterTransport.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/api/WriterTransport.java Mon Apr 27 23:12:25 2009
@@ -20,15 +20,13 @@
/**
* generic Transport interface - allows client to write data to a remote repository
- *
- *
+ *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public interface WriterTransport
-extends Initializable
+ extends Initializable
{
- public TransportTransaction write( TransportTransaction trx )
- throws TransportException;
+ public TransportTransaction write( TransportTransaction trx )
+ throws TransportException;
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/http/HttpReaderTransport.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/http/HttpReaderTransport.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/http/HttpReaderTransport.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/http/HttpReaderTransport.java Mon Apr 27 23:12:25 2009
@@ -28,34 +28,33 @@
/**
* HTTP retriever adaptor: adopts DefaultRetriever to ReaderTransport API
- *
+ *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public class HttpReaderTransport
-extends AbstractTransport
-implements ReaderTransport
+ extends AbstractTransport
+ implements ReaderTransport
{
- private DefaultRetriever _retriever;
-
- public TransportTransaction read( TransportTransaction trx )
- throws TransportException
- {
- return null;
- }
+ private DefaultRetriever _retriever;
- public void init()
- throws InitializationException
- {
- try
+ public TransportTransaction read( TransportTransaction trx )
+ throws TransportException
{
- _retriever = new DefaultRetriever();
+ return null;
}
- catch( HttpClientException e )
+
+ public void init()
+ throws InitializationException
{
- throw new InitializationException(e);
+ try
+ {
+ _retriever = new DefaultRetriever();
+ }
+ catch ( HttpClientException e )
+ {
+ throw new InitializationException( e );
+ }
}
- }
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/http/HttpWriterTransport.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/http/HttpWriterTransport.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/http/HttpWriterTransport.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/transport/http/HttpWriterTransport.java Mon Apr 27 23:12:25 2009
@@ -28,39 +28,36 @@
import org.apache.maven.mercury.transport.api.WriterTransport;
/**
- *
- *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public class HttpWriterTransport
-extends AbstractTransport
-implements WriterTransport
+ extends AbstractTransport
+ implements WriterTransport
{
-
- DefaultDeployer _deployer;
- public TransportTransaction write( TransportTransaction trx )
- throws TransportException
- {
- DefaultDeployRequest req = new DefaultDeployRequest();
-// req.setBindings( trx.getBindings() );
-
- return null;
- }
-
- public void init()
- throws InitializationException
- {
- try
+ DefaultDeployer _deployer;
+
+ public TransportTransaction write( TransportTransaction trx )
+ throws TransportException
{
- _deployer = new DefaultDeployer();
+ DefaultDeployRequest req = new DefaultDeployRequest();
+ // req.setBindings( trx.getBindings() );
+
+ return null;
}
- catch( HttpClientException e )
+
+ public void init()
+ throws InitializationException
{
- throw new InitializationException(e);
+ try
+ {
+ _deployer = new DefaultDeployer();
+ }
+ catch ( HttpClientException e )
+ {
+ throw new InitializationException( e );
+ }
}
- }
}
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java Mon Apr 27 23:12:25 2009
@@ -33,9 +33,10 @@
implements Monitor
{
Writer _writer;
+
boolean _timestamp = true;
- private static final SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
+
+ private static final SimpleDateFormat fmt = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
public DefaultMonitor( boolean timestamp )
{
@@ -64,7 +65,7 @@
{
if ( _writer != null )
{
- if( _timestamp )
+ if ( _timestamp )
{
_writer.write( fmt.format( new Date() ) );
_writer.write( ": " );
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/util/FileLockBundle.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/util/FileLockBundle.java?rev=769199&r1=769198&r2=769199&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/util/FileLockBundle.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/util/FileLockBundle.java Mon Apr 27 23:12:25 2009
@@ -23,62 +23,59 @@
import java.nio.channels.FileLock;
/**
- *
- *
* @author Oleg Gusakov
* @version $Id$
- *
*/
public class FileLockBundle
{
- String dir;
- FileChannel channel;
- FileLock lock;
-
- boolean fileLock = false;
-
- /**
- * @param dir
- * @param channel
- * @param lock
- */
- public FileLockBundle(
- String dir,
- FileChannel channel,
- FileLock lock
- )
- {
- this.dir = dir;
- this.channel = channel;
- this.lock = lock;
- }
-
- /**
- * @param dir
- * @param channel
- * @param lock
- */
- public FileLockBundle( String dir )
- {
- this.dir = dir;
- this.fileLock = true;
- }
-
- public void release()
- {
- if( lock == null )
+ String dir;
+
+ FileChannel channel;
+
+ FileLock lock;
+
+ boolean fileLock = false;
+
+ /**
+ * @param dir
+ * @param channel
+ * @param lock
+ */
+ public FileLockBundle( String dir, FileChannel channel, FileLock lock )
{
- if( fileLock )
- FileUtil.unlockDir( dir );
+ this.dir = dir;
+ this.channel = channel;
+ this.lock = lock;
+ }
- return;
+ /**
+ * @param dir
+ * @param channel
+ * @param lock
+ */
+ public FileLockBundle( String dir )
+ {
+ this.dir = dir;
+ this.fileLock = true;
}
-
- try
+
+ public void release()
{
- lock.release();
- channel.close();
+ if ( lock == null )
+ {
+ if ( fileLock )
+ FileUtil.unlockDir( dir );
+
+ return;
+ }
+
+ try
+ {
+ lock.release();
+ channel.close();
+ }
+ catch ( IOException any )
+ {
+ }
}
- catch( IOException any ){}
- }
}