1 package org.apache.archiva.admin.mock;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.admin.model.RepositoryAdminException;
23 import org.apache.archiva.admin.model.beans.NetworkProxy;
24 import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
25 import org.apache.archiva.common.utils.FileUtils;
26 import org.apache.archiva.common.utils.PathUtil;
27 import org.apache.archiva.configuration.ArchivaConfiguration;
28 import org.apache.archiva.indexer.*;
29 import org.apache.archiva.proxy.common.WagonFactory;
30 import org.apache.archiva.proxy.common.WagonFactoryException;
31 import org.apache.archiva.proxy.common.WagonFactoryRequest;
32 import org.apache.archiva.repository.*;
33 import org.apache.archiva.repository.features.IndexCreationFeature;
34 import org.apache.archiva.repository.features.RemoteIndexFeature;
35 import org.apache.commons.lang.StringUtils;
36 import org.apache.maven.index.*;
37 import org.apache.maven.index.context.IndexCreator;
38 import org.apache.maven.index.context.IndexingContext;
39 import org.apache.maven.index.packer.IndexPacker;
40 import org.apache.maven.index.packer.IndexPackingRequest;
41 import org.apache.maven.index.updater.IndexUpdateRequest;
42 import org.apache.maven.index.updater.ResourceFetcher;
43 import org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException;
44 import org.apache.maven.wagon.*;
45 import org.apache.maven.wagon.authentication.AuthenticationException;
46 import org.apache.maven.wagon.authentication.AuthenticationInfo;
47 import org.apache.maven.wagon.authorization.AuthorizationException;
48 import org.apache.maven.wagon.events.TransferEvent;
49 import org.apache.maven.wagon.events.TransferListener;
50 import org.apache.maven.wagon.proxy.ProxyInfo;
51 import org.apache.maven.wagon.shared.http.AbstractHttpClientWagon;
52 import org.apache.maven.wagon.shared.http.HttpConfiguration;
53 import org.apache.maven.wagon.shared.http.HttpMethodConfiguration;
54 import org.slf4j.Logger;
55 import org.slf4j.LoggerFactory;
56 import org.springframework.stereotype.Service;
58 import javax.inject.Inject;
59 import java.io.FileNotFoundException;
60 import java.io.IOException;
61 import java.io.InputStream;
62 import java.net.MalformedURLException;
64 import java.nio.file.Files;
65 import java.nio.file.Path;
66 import java.nio.file.Paths;
67 import java.util.Collection;
68 import java.util.List;
70 import java.util.concurrent.ConcurrentSkipListSet;
71 import java.util.stream.Collectors;
73 @Service("archivaIndexManager#maven")
74 public class ArchivaIndexManagerMock implements ArchivaIndexManager {
76 private static final Logger log = LoggerFactory.getLogger( ArchivaIndexManagerMock.class );
79 private Indexer indexer;
82 private IndexerEngine indexerEngine;
85 private List<? extends IndexCreator> indexCreators;
88 private IndexPacker indexPacker;
91 private Scanner scanner;
94 private ArchivaConfiguration archivaConfiguration;
97 private WagonFactory wagonFactory;
100 private NetworkProxyAdmin networkProxyAdmin;
104 private ArtifactContextProducer artifactContextProducer;
106 private ConcurrentSkipListSet<Path> activeContexts = new ConcurrentSkipListSet<>( );
108 private static final int WAIT_TIME = 100;
109 private static final int MAX_WAIT = 10;
112 public static IndexingContext getMvnContext(ArchivaIndexingContext context ) throws UnsupportedBaseContextException
114 if ( !context.supports( IndexingContext.class ) )
116 log.error( "The provided archiva index context does not support the maven IndexingContext" );
117 throw new UnsupportedBaseContextException( "The context does not support the Maven IndexingContext" );
119 return context.getBaseContext( IndexingContext.class );
122 private Path getIndexPath( ArchivaIndexingContext ctx )
124 return PathUtil.getPathFromUri( ctx.getPath( ) );
128 interface IndexUpdateConsumer
131 void accept( IndexingContext indexingContext ) throws IndexUpdateFailedException;
135 * This method is used to do some actions around the update execution code. And to make sure, that no other
136 * method is running on the same index.
138 private void executeUpdateFunction( ArchivaIndexingContext context, IndexUpdateConsumer function ) throws IndexUpdateFailedException
140 IndexingContext indexingContext = null;
143 indexingContext = getMvnContext( context );
145 catch ( UnsupportedBaseContextException e )
147 throw new IndexUpdateFailedException( "Maven index is not supported by this context", e );
149 final Path ctxPath = getIndexPath( context );
151 boolean active = false;
152 while ( loop-- > 0 && !active )
154 active = activeContexts.add( ctxPath );
157 Thread.currentThread( ).sleep( WAIT_TIME );
159 catch ( InterruptedException e )
168 function.accept( indexingContext );
172 activeContexts.remove( ctxPath );
177 throw new IndexUpdateFailedException( "Timeout while waiting for index release on context " + context.getId( ) );
182 public void pack( final ArchivaIndexingContext context ) throws IndexUpdateFailedException
184 executeUpdateFunction( context, indexingContext -> {
187 IndexPackingRequest request = new IndexPackingRequest( indexingContext,
188 indexingContext.acquireIndexSearcher( ).getIndexReader( ),
189 indexingContext.getIndexDirectoryFile( ) );
190 indexPacker.packIndex( request );
191 indexingContext.updateTimestamp( true );
193 catch ( IOException e )
195 log.error( "IOException while packing index of context " + context.getId( ) + ( StringUtils.isNotEmpty( e.getMessage( ) ) ? ": " + e.getMessage( ) : "" ) );
196 throw new IndexUpdateFailedException( "IOException during update of " + context.getId( ), e );
204 public void scan(final ArchivaIndexingContext context) throws IndexUpdateFailedException
206 executeUpdateFunction( context, indexingContext -> {
207 DefaultScannerListener listener = new DefaultScannerListener( indexingContext, indexerEngine, true, null );
208 ScanningRequest request = new ScanningRequest( indexingContext, listener );
209 ScanningResult result = scanner.scan( request );
210 if ( result.hasExceptions( ) )
212 log.error( "Exceptions occured during index scan of " + context.getId( ) );
213 result.getExceptions( ).stream( ).map( e -> e.getMessage( ) ).distinct( ).limit( 5 ).forEach(
214 s -> log.error( "Message: " + s )
222 public void update(final ArchivaIndexingContext context, final boolean fullUpdate) throws IndexUpdateFailedException
224 log.info( "start download remote index for remote repository {}", context.getRepository( ).getId( ) );
226 if ( !( context.getRepository( ) instanceof RemoteRepository) || !(context.getRepository().supportsFeature(RemoteIndexFeature.class)) )
228 throw new IndexUpdateFailedException( "The context is not associated to a remote repository with remote index " + context.getId( ) );
230 RemoteIndexFeature rif = context.getRepository().getFeature(RemoteIndexFeature.class).get();
231 remoteUpdateUri = context.getRepository().getLocation().resolve(rif.getIndexUri());
233 final RemoteRepository remoteRepository = (RemoteRepository) context.getRepository( );
235 executeUpdateFunction( context,
239 // create a temp directory to download files
240 Path tempIndexDirectory = Paths.get( indexingContext.getIndexDirectoryFile( ).getParent( ), ".tmpIndex" );
241 Path indexCacheDirectory = Paths.get( indexingContext.getIndexDirectoryFile( ).getParent( ), ".indexCache" );
242 Files.createDirectories( indexCacheDirectory );
243 if ( Files.exists( tempIndexDirectory ) )
245 org.apache.archiva.common.utils.FileUtils.deleteDirectory( tempIndexDirectory );
247 Files.createDirectories( tempIndexDirectory );
248 tempIndexDirectory.toFile( ).deleteOnExit( );
249 String baseIndexUrl = indexingContext.getIndexUpdateUrl( );
251 String wagonProtocol = remoteUpdateUri.toURL( ).getProtocol( );
253 NetworkProxy networkProxy = null;
254 if ( remoteRepository.supportsFeature( RemoteIndexFeature.class ) )
256 RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( );
257 if ( StringUtils.isNotBlank( rif.getProxyId( ) ) )
261 networkProxy = networkProxyAdmin.getNetworkProxy( rif.getProxyId( ) );
263 catch ( RepositoryAdminException e )
265 log.error( "Error occured while retrieving proxy {}", e.getMessage( ) );
267 if ( networkProxy == null )
270 "your remote repository is configured to download remote index trought a proxy we cannot find id:{}",
275 final StreamWagon wagon = (StreamWagon) wagonFactory.getWagon(
276 new WagonFactoryRequest( wagonProtocol, remoteRepository.getExtraHeaders( ) ).networkProxy(
279 int readTimeout = (int) rif.getDownloadTimeout( ).toMillis( ) * 1000;
280 wagon.setReadTimeout( readTimeout );
281 wagon.setTimeout( (int) remoteRepository.getTimeout( ).toMillis( ) * 1000 );
283 if ( wagon instanceof AbstractHttpClientWagon)
285 HttpConfiguration httpConfiguration = new HttpConfiguration( );
286 HttpMethodConfiguration httpMethodConfiguration = new HttpMethodConfiguration( );
287 httpMethodConfiguration.setUsePreemptive( true );
288 httpMethodConfiguration.setReadTimeout( readTimeout );
289 httpConfiguration.setGet( httpMethodConfiguration );
290 AbstractHttpClientWagon.class.cast( wagon ).setHttpConfiguration( httpConfiguration );
293 wagon.addTransferListener( new DownloadListener( ) );
294 ProxyInfo proxyInfo = null;
295 if ( networkProxy != null )
297 proxyInfo = new ProxyInfo( );
298 proxyInfo.setType( networkProxy.getProtocol( ) );
299 proxyInfo.setHost( networkProxy.getHost( ) );
300 proxyInfo.setPort( networkProxy.getPort( ) );
301 proxyInfo.setUserName( networkProxy.getUsername( ) );
302 proxyInfo.setPassword( networkProxy.getPassword( ) );
304 AuthenticationInfo authenticationInfo = null;
305 if ( remoteRepository.getLoginCredentials( ) != null && ( remoteRepository.getLoginCredentials( ) instanceof PasswordCredentials) )
307 PasswordCredentials creds = (PasswordCredentials) remoteRepository.getLoginCredentials( );
308 authenticationInfo = new AuthenticationInfo( );
309 authenticationInfo.setUserName( creds.getUsername( ) );
310 authenticationInfo.setPassword( new String( creds.getPassword( ) ) );
312 wagon.connect( new org.apache.maven.wagon.repository.Repository( remoteRepository.getId( ), baseIndexUrl ), authenticationInfo,
315 Path indexDirectory = indexingContext.getIndexDirectoryFile( ).toPath( );
316 if ( !Files.exists( indexDirectory ) )
318 Files.createDirectories( indexDirectory );
321 ResourceFetcher resourceFetcher =
322 new WagonResourceFetcher( log, tempIndexDirectory, wagon, remoteRepository );
323 IndexUpdateRequest request = new IndexUpdateRequest( indexingContext, resourceFetcher );
324 request.setForceFullUpdate( fullUpdate );
325 request.setLocalIndexCacheDir( indexCacheDirectory.toFile( ) );
327 // indexUpdater.fetchAndUpdateIndex( request );
329 indexingContext.updateTimestamp( true );
333 catch ( AuthenticationException e )
335 log.error( "Could not login to the remote proxy for updating index of {}", remoteRepository.getId( ), e );
336 throw new IndexUpdateFailedException( "Login in to proxy failed while updating remote repository " + remoteRepository.getId( ), e );
338 catch ( ConnectionException e )
340 log.error( "Connection error during index update for remote repository {}", remoteRepository.getId( ), e );
341 throw new IndexUpdateFailedException( "Connection error during index update for remote repository " + remoteRepository.getId( ), e );
343 catch ( MalformedURLException e )
345 log.error( "URL for remote index update of remote repository {} is not correct {}", remoteRepository.getId( ), remoteUpdateUri, e );
346 throw new IndexUpdateFailedException( "URL for remote index update of repository is not correct " + remoteUpdateUri, e );
348 catch ( IOException e )
350 log.error( "IOException during index update of remote repository {}: {}", remoteRepository.getId( ), e.getMessage( ), e );
351 throw new IndexUpdateFailedException( "IOException during index update of remote repository " + remoteRepository.getId( )
352 + ( StringUtils.isNotEmpty( e.getMessage( ) ) ? ": " + e.getMessage( ) : "" ), e );
354 catch ( WagonFactoryException e )
356 log.error( "Wagon for remote index download of {} could not be created: {}", remoteRepository.getId( ), e.getMessage( ), e );
357 throw new IndexUpdateFailedException( "Error while updating the remote index of " + remoteRepository.getId( ), e );
364 public void addArtifactsToIndex( final ArchivaIndexingContext context, final Collection<URI> artifactReference ) throws IndexUpdateFailedException
366 final URI ctxUri = context.getPath();
367 executeUpdateFunction(context, indexingContext -> {
368 Collection<ArtifactContext> artifacts = artifactReference.stream().map(r -> artifactContextProducer.getArtifactContext(indexingContext, Paths.get(ctxUri.resolve(r)).toFile())).collect(Collectors.toList());
370 indexer.addArtifactsToIndex(artifacts, indexingContext);
371 } catch (IOException e) {
372 log.error("IOException while adding artifact {}", e.getMessage(), e);
373 throw new IndexUpdateFailedException("Error occured while adding artifact to index of "+context.getId()
374 + (StringUtils.isNotEmpty(e.getMessage()) ? ": "+e.getMessage() : ""));
380 public void removeArtifactsFromIndex( ArchivaIndexingContext context, Collection<URI> artifactReference ) throws IndexUpdateFailedException
382 final URI ctxUri = context.getPath();
383 executeUpdateFunction(context, indexingContext -> {
384 Collection<ArtifactContext> artifacts = artifactReference.stream().map(r -> artifactContextProducer.getArtifactContext(indexingContext, Paths.get(ctxUri.resolve(r)).toFile())).collect(Collectors.toList());
386 indexer.deleteArtifactsFromIndex(artifacts, indexingContext);
387 } catch (IOException e) {
388 log.error("IOException while removing artifact {}", e.getMessage(), e);
389 throw new IndexUpdateFailedException("Error occured while removing artifact from index of "+context.getId()
390 + (StringUtils.isNotEmpty(e.getMessage()) ? ": "+e.getMessage() : ""));
397 public boolean supportsRepository( RepositoryType type )
399 return type == RepositoryType.MAVEN;
403 public ArchivaIndexingContext createContext( Repository repository ) throws IndexCreationFailedException
405 log.debug("Creating context for repo {}, type: {}", repository.getId(), repository.getType());
406 if ( repository.getType( ) != RepositoryType.MAVEN )
408 throw new UnsupportedRepositoryTypeException( repository.getType( ) );
410 IndexingContext mvnCtx = null;
413 if ( repository instanceof RemoteRepository )
415 mvnCtx = createRemoteContext( (RemoteRepository) repository );
417 else if ( repository instanceof ManagedRepository )
419 mvnCtx = createManagedContext( (ManagedRepository) repository );
422 catch ( IOException e )
424 log.error( "IOException during context creation " + e.getMessage( ), e );
425 throw new IndexCreationFailedException( "Could not create index context for repository " + repository.getId( )
426 + ( StringUtils.isNotEmpty( e.getMessage( ) ) ? ": " + e.getMessage( ) : "" ), e );
428 MavenIndexContextMock context = new MavenIndexContextMock( repository, mvnCtx );
434 public ArchivaIndexingContext reset(ArchivaIndexingContext context) throws IndexUpdateFailedException {
435 ArchivaIndexingContext ctx;
436 executeUpdateFunction(context, indexingContext -> {
438 indexingContext.close(true);
439 } catch (IOException e) {
440 log.warn("Index close failed");
443 FileUtils.deleteDirectory(Paths.get(context.getPath()));
444 } catch (IOException e) {
445 throw new IndexUpdateFailedException("Could not delete index files");
449 Repository repo = context.getRepository();
450 ctx = createContext(context.getRepository());
451 if (repo instanceof EditableRepository) {
452 ((EditableRepository)repo).setIndexingContext(ctx);
454 } catch (IndexCreationFailedException e) {
455 throw new IndexUpdateFailedException("Could not create index");
461 public ArchivaIndexingContext move(ArchivaIndexingContext context, Repository repo) throws IndexCreationFailedException {
465 if (context.supports(IndexingContext.class)) {
467 Path newPath = getIndexPath(repo);
468 IndexingContext ctx = context.getBaseContext(IndexingContext.class);
469 Path oldPath = ctx.getIndexDirectoryFile().toPath();
470 if (oldPath.equals(newPath)) {
471 // Nothing to do, if path does not change
474 if (!Files.exists(oldPath)) {
475 return createContext(repo);
476 } else if (context.isEmpty()) {
478 return createContext(repo);
480 context.close(false);
481 Files.move(oldPath, newPath);
482 return createContext(repo);
484 } catch (IOException e) {
485 log.error("IOException while moving index directory {}", e.getMessage(), e);
486 throw new IndexCreationFailedException("Could not recreated the index.", e);
487 } catch (UnsupportedBaseContextException e) {
488 throw new IndexCreationFailedException("The given context, is not a maven context.");
491 throw new IndexCreationFailedException("Bad context type. This is not a maven context.");
495 private Path getIndexPath(Repository repo) throws IOException {
496 IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
497 Path repoDir = repo.getLocalPath();
498 URI indexDir = icf.getIndexPath();
499 Path indexDirectory = null;
500 if ( ! StringUtils.isEmpty(indexDir.toString( ) ) )
503 indexDirectory = PathUtil.getPathFromUri( indexDir );
504 // not absolute so create it in repository directory
505 if ( !indexDirectory.isAbsolute( ) )
507 indexDirectory = repoDir.resolve( indexDirectory );
512 indexDirectory = repoDir.resolve( ".index" );
515 if ( !Files.exists( indexDirectory ) )
517 Files.createDirectories( indexDirectory );
519 return indexDirectory;
522 private IndexingContext createRemoteContext(RemoteRepository remoteRepository ) throws IOException
524 Path appServerBase = archivaConfiguration.getAppServerBaseDir( );
526 String contextKey = "remote-" + remoteRepository.getId( );
529 // create remote repository path
530 Path repoDir = remoteRepository.getLocalPath();
531 if ( !Files.exists( repoDir ) )
533 Files.createDirectories( repoDir );
536 Path indexDirectory = null;
538 // is there configured indexDirectory ?
539 if ( remoteRepository.supportsFeature( RemoteIndexFeature.class ) )
541 RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( );
542 indexDirectory = getIndexPath(remoteRepository);
543 String remoteIndexUrl = calculateIndexRemoteUrl( remoteRepository.getLocation( ), rif );
547 return getIndexingContext( remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl );
549 catch ( IndexFormatTooOldException e )
551 // existing index with an old lucene format so we need to delete it!!!
552 // delete it first then recreate it.
553 log.warn( "the index of repository {} is too old we have to delete and recreate it", //
554 remoteRepository.getId( ) );
555 org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
556 return getIndexingContext( remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl );
562 throw new IOException( "No remote index defined" );
566 private IndexingContext getIndexingContext( Repository repository, String contextKey, Path repoDir, Path indexDirectory, String indexUrl ) throws IOException
568 return indexer.createIndexingContext( contextKey, repository.getId( ), repoDir.toFile( ), indexDirectory.toFile( ),
569 repository.getLocation( ) == null ? null : repository.getLocation( ).toString( ),
575 private IndexingContext createManagedContext( ManagedRepository repository ) throws IOException
578 IndexingContext context;
579 // take care first about repository location as can be relative
580 Path repositoryDirectory = repository.getLocalPath();
582 if ( !Files.exists( repositoryDirectory ) )
586 Files.createDirectories( repositoryDirectory );
588 catch ( IOException e )
590 log.error( "Could not create directory {}", repositoryDirectory );
594 Path indexDirectory = null;
596 if ( repository.supportsFeature( IndexCreationFeature.class ) )
598 indexDirectory = getIndexPath(repository);
600 String indexUrl = repositoryDirectory.toUri( ).toURL( ).toExternalForm( );
603 context = getIndexingContext( repository, repository.getId( ), repositoryDirectory, indexDirectory, indexUrl );
604 context.setSearchable( repository.isScanned( ) );
606 catch ( IndexFormatTooOldException e )
608 // existing index with an old lucene format so we need to delete it!!!
609 // delete it first then recreate it.
610 log.warn( "the index of repository {} is too old we have to delete and recreate it", //
611 repository.getId( ) );
612 org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
613 context = getIndexingContext( repository, repository.getId( ), repositoryDirectory, indexDirectory, indexUrl );
614 context.setSearchable( repository.isScanned( ) );
620 throw new IOException( "No repository index defined" );
624 private String calculateIndexRemoteUrl( URI baseUri, RemoteIndexFeature rif )
626 if ( rif.getIndexUri( ) == null )
628 return baseUri.resolve( ".index" ).toString( );
632 return baseUri.resolve( rif.getIndexUri( ) ).toString( );
636 private static final class DownloadListener
637 implements TransferListener
639 private Logger log = LoggerFactory.getLogger( getClass( ) );
641 private String resourceName;
643 private long startTime;
645 private int totalLength = 0;
648 public void transferInitiated( TransferEvent transferEvent )
650 startTime = System.currentTimeMillis( );
651 resourceName = transferEvent.getResource( ).getName( );
652 log.debug( "initiate transfer of {}", resourceName );
656 public void transferStarted( TransferEvent transferEvent )
658 this.totalLength = 0;
659 resourceName = transferEvent.getResource( ).getName( );
660 log.info( "start transfer of {}", transferEvent.getResource( ).getName( ) );
664 public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length )
666 log.debug( "transfer of {} : {}/{}", transferEvent.getResource( ).getName( ), buffer.length, length );
667 this.totalLength += length;
671 public void transferCompleted( TransferEvent transferEvent )
673 resourceName = transferEvent.getResource( ).getName( );
674 long endTime = System.currentTimeMillis( );
675 log.info( "end of transfer file {} {} kb: {}s", transferEvent.getResource( ).getName( ),
676 this.totalLength / 1024, ( endTime - startTime ) / 1000 );
680 public void transferError( TransferEvent transferEvent )
682 log.info( "error of transfer file {}: {}", transferEvent.getResource( ).getName( ),
683 transferEvent.getException( ).getMessage( ), transferEvent.getException( ) );
687 public void debug( String message )
689 log.debug( "transfer debug {}", message );
693 private static class WagonResourceFetcher
694 implements ResourceFetcher
699 Path tempIndexDirectory;
703 RemoteRepository remoteRepository;
705 private WagonResourceFetcher( Logger log, Path tempIndexDirectory, Wagon wagon,
706 RemoteRepository remoteRepository )
709 this.tempIndexDirectory = tempIndexDirectory;
711 this.remoteRepository = remoteRepository;
715 public void connect( String id, String url )
722 public void disconnect( )
729 public InputStream retrieve(String name )
730 throws IOException, FileNotFoundException
734 log.info( "index update retrieve file, name:{}", name );
735 Path file = tempIndexDirectory.resolve( name );
736 Files.deleteIfExists( file );
737 file.toFile( ).deleteOnExit( );
738 wagon.get( addParameters( name, remoteRepository ), file.toFile( ) );
739 return Files.newInputStream( file );
741 catch ( AuthorizationException | TransferFailedException e )
743 throw new IOException( e.getMessage( ), e );
745 catch ( ResourceDoesNotExistException e )
747 FileNotFoundException fnfe = new FileNotFoundException( e.getMessage( ) );
753 // FIXME remove crappy copy/paste
754 protected String addParameters( String path, RemoteRepository remoteRepository )
756 if ( remoteRepository.getExtraParameters( ).isEmpty( ) )
761 boolean question = false;
763 StringBuilder res = new StringBuilder( path == null ? "" : path );
765 for ( Map.Entry<String, String> entry : remoteRepository.getExtraParameters( ).entrySet( ) )
769 res.append( '?' ).append( entry.getKey( ) ).append( '=' ).append( entry.getValue( ) );
773 return res.toString( );