org.apache.maven.wagon.TransferFailedException Java Examples
The following examples show how to use
org.apache.maven.wagon.TransferFailedException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractWagon.java From lambadaframework with MIT License | 6 votes |
@Override public final void get(String resourceName, File destination) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Resource resource = new Resource(resourceName); this.transferListenerSupport.fireTransferInitiated(resource, TransferEvent.REQUEST_GET); this.transferListenerSupport.fireTransferStarted(resource, TransferEvent.REQUEST_GET); try { getResource(resourceName, destination, new StandardTransferProgress(resource, TransferEvent.REQUEST_GET, this.transferListenerSupport)); this.transferListenerSupport.fireTransferCompleted(resource, TransferEvent.REQUEST_GET); } catch (TransferFailedException | ResourceDoesNotExistException | AuthorizationException e) { this.transferListenerSupport.fireTransferError(resource, TransferEvent.REQUEST_GET, e); throw e; } }
Example #2
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 6 votes |
@Test public void putTransferFailedException() throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { TransferFailedException exception = new TransferFailedException(""); doThrow(exception).when(this.wagon).putResource(eq(new File("foo")), eq("bar"), any(TransferProgress.class)); try { this.wagon.put(new File("foo"), "bar"); fail(); } catch (TransferFailedException e) { verify(this.transferListenerSupport).fireTransferInitiated(new Resource("bar"), TransferEvent.REQUEST_PUT); verify(this.transferListenerSupport).fireTransferStarted(new Resource("bar"), TransferEvent.REQUEST_PUT); verify(this.transferListenerSupport).fireTransferError(new Resource("bar"), TransferEvent.REQUEST_PUT, exception); } }
Example #3
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 6 votes |
@Test public void putResourceDoesNotExistException() throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { ResourceDoesNotExistException exception = new ResourceDoesNotExistException(""); doThrow(exception).when(this.wagon).putResource(eq(new File("foo")), eq("bar"), any(TransferProgress.class)); try { this.wagon.put(new File("foo"), "bar"); fail(); } catch (ResourceDoesNotExistException e) { verify(this.transferListenerSupport).fireTransferInitiated(new Resource("bar"), TransferEvent.REQUEST_PUT); verify(this.transferListenerSupport).fireTransferStarted(new Resource("bar"), TransferEvent.REQUEST_PUT); verify(this.transferListenerSupport).fireTransferError(new Resource("bar"), TransferEvent.REQUEST_PUT, exception); } }
Example #4
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 6 votes |
@Test public void putAuthorizationException() throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { AuthorizationException exception = new AuthorizationException(""); doThrow(exception).when(this.wagon).putResource(eq(new File("foo")), eq("bar"), any(TransferProgress.class)); try { this.wagon.put(new File("foo"), "bar"); fail(); } catch (AuthorizationException e) { verify(this.transferListenerSupport).fireTransferInitiated(new Resource("bar"), TransferEvent.REQUEST_PUT); verify(this.transferListenerSupport).fireTransferStarted(new Resource("bar"), TransferEvent.REQUEST_PUT); verify(this.transferListenerSupport).fireTransferError(new Resource("bar"), TransferEvent.REQUEST_PUT, exception); } }
Example #5
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 6 votes |
@Test public void putDirectory() throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { File directory = new File("target/test"); directory.mkdirs(); File file = new File(directory, "test.txt"); file.createNewFile(); this.wagon.putDirectory(directory, "foo"); verify(this.transferListenerSupport).fireTransferInitiated(new Resource("foo/test.txt"), TransferEvent.REQUEST_PUT); verify(this.transferListenerSupport).fireTransferStarted(new Resource("foo/test.txt"), TransferEvent.REQUEST_PUT); verify(this.wagon).putResource(eq(new File("target/test/test.txt")), eq("foo/test.txt"), any(TransferProgress.class)); verify(this.transferListenerSupport).fireTransferCompleted(new Resource("foo/test.txt"), TransferEvent.REQUEST_PUT); }
Example #6
Source File: SimpleStorageServiceWagon.java From lambadaframework with MIT License | 6 votes |
private void mkdirs(String path, int index) throws TransferFailedException { int directoryIndex = path.indexOf('/', index) + 1; if (directoryIndex != 0) { String directory = path.substring(0, directoryIndex); PutObjectRequest putObjectRequest = createDirectoryPutObjectRequest(directory); try { this.amazonS3.putObject(putObjectRequest); } catch (AmazonServiceException e) { throw new TransferFailedException(String.format("Cannot write directory '%s'", directory), e); } mkdirs(path, directoryIndex); } }
Example #7
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 6 votes |
@Test public void getAuthorizationException() throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { AuthorizationException exception = new AuthorizationException(""); doThrow(exception).when(this.wagon).getResource(eq("foo"), eq(new File("bar")), any(TransferProgress.class)); try { this.wagon.get("foo", new File("bar")); fail(); } catch (AuthorizationException e) { verify(this.transferListenerSupport).fireTransferInitiated(new Resource("foo"), TransferEvent.REQUEST_GET); verify(this.transferListenerSupport).fireTransferStarted(new Resource("foo"), TransferEvent.REQUEST_GET); verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET, exception); } }
Example #8
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 6 votes |
@Test public void getResourceDoesNotExistException() throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { ResourceDoesNotExistException exception = new ResourceDoesNotExistException(""); doThrow(exception).when(this.wagon).getResource(eq("foo"), eq(new File("bar")), any(TransferProgress.class)); try { this.wagon.get("foo", new File("bar")); fail(); } catch (ResourceDoesNotExistException e) { verify(this.transferListenerSupport).fireTransferInitiated(new Resource("foo"), TransferEvent.REQUEST_GET); verify(this.transferListenerSupport).fireTransferStarted(new Resource("foo"), TransferEvent.REQUEST_GET); verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET, exception); } }
Example #9
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 6 votes |
@Test public void getTransferFailedException() throws ResourceDoesNotExistException, AuthorizationException, TransferFailedException { TransferFailedException exception = new TransferFailedException(""); doThrow(exception).when(this.wagon).getResource(eq("foo"), eq(new File("bar")), any(TransferProgress.class)); try { this.wagon.get("foo", new File("bar")); fail(); } catch (TransferFailedException e) { verify(this.transferListenerSupport).fireTransferInitiated(new Resource("foo"), TransferEvent.REQUEST_GET); verify(this.transferListenerSupport).fireTransferStarted(new Resource("foo"), TransferEvent.REQUEST_GET); verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET, exception); } }
Example #10
Source File: RepositoryModelResolver.java From archiva with Apache License 2.0 | 6 votes |
/** * * @param wagon The wagon instance that should be connected. * @param remoteRepository The repository from where the checksum file should be retrieved * @param remotePath The remote path of the artifact (without extension) * @param resource The local artifact (without extension) * @param workingDir The working directory where the downloaded file should be placed to * @param ext The extension of th checksum file * @return The file where the data has been downloaded to. * @throws AuthorizationException * @throws TransferFailedException * @throws ResourceDoesNotExistException */ private Path transferChecksum( final Wagon wagon, final RemoteRepository remoteRepository, final String remotePath, final Path resource, final Path workingDir, final String ext ) throws AuthorizationException, TransferFailedException, ResourceDoesNotExistException { Path destFile = workingDir.resolve( resource.getFileName() + ext ); String remoteChecksumPath = remotePath + ext; log.info( "Retrieving {} from {}", remoteChecksumPath, remoteRepository.getName() ); wagon.get( addParameters( remoteChecksumPath, remoteRepository ), destFile.toFile() ); log.debug( "Downloaded successfully." ); return destFile; }
Example #11
Source File: MockWagon.java From archiva with Apache License 2.0 | 6 votes |
@Override public void get( String s, File file ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { String sourceFile = getBasedir() + "/src/test/resources/" + s; try { FileUtils.copyFile( new File( sourceFile ), file ); assert( file.exists() ); } catch( IOException e ) { throw new ResourceDoesNotExistException( e.getMessage() ); } }
Example #12
Source File: GitWagon.java From opoopress with Apache License 2.0 | 6 votes |
@Override public void get(String resourceName, File destination) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Resource resource = new Resource(resourceName); fireGetInitiated(resource, destination); fireGetStarted(resource, destination); try { File remote = new File(checkoutDirectory, resourceName); if (remote.exists()){ transfer(resource, new FileInputStream(remote), new FileOutputStream(destination), TransferEvent.REQUEST_GET); } } catch (Exception e) { fireTransferError(resource, e, TransferEvent.REQUEST_GET); throw new TransferFailedException("Unable to get file", e); } fireGetCompleted(resource, destination); }
Example #13
Source File: AbstractWagon.java From lambadaframework with MIT License | 6 votes |
@Override public final void put(File source, String destination) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Resource resource = new Resource(destination); this.transferListenerSupport.fireTransferInitiated(resource, TransferEvent.REQUEST_PUT); this.transferListenerSupport.fireTransferStarted(resource, TransferEvent.REQUEST_PUT); try { putResource(source, destination, new StandardTransferProgress(resource, TransferEvent.REQUEST_PUT, this.transferListenerSupport)); this.transferListenerSupport.fireTransferCompleted(resource, TransferEvent.REQUEST_PUT); } catch (TransferFailedException | ResourceDoesNotExistException | AuthorizationException e) { this.transferListenerSupport.fireTransferError(resource, TransferEvent.REQUEST_PUT, e); throw e; } }
Example #14
Source File: AbstractWagon.java From lambadaframework with MIT License | 6 votes |
@Override public final boolean getIfNewer(String resourceName, File destination, long timestamp) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Resource resource = new Resource(resourceName); try { if (isRemoteResourceNewer(resourceName, timestamp)) { get(resourceName, destination); return true; } return false; } catch (TransferFailedException | ResourceDoesNotExistException | AuthorizationException e) { this.transferListenerSupport.fireTransferError(resource, TransferEvent.REQUEST_GET, e); throw e; } }
Example #15
Source File: AbstractWagon.java From lambadaframework with MIT License | 5 votes |
@Override public final void putDirectory(File sourceDirectory, String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { File[] files = sourceDirectory.listFiles(); if (files != null) { for (File f : files) { put(f, destinationDirectory + "/" + f.getName()); } } }
Example #16
Source File: WagonDelegate.java From archiva with Apache License 2.0 | 5 votes |
@Override public boolean getIfNewer( String resourceName, File destination, long timestamp ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { log.info( ".getIfNewer({}, {}, {})", resourceName, destination, timestamp ); boolean result = delegate.getIfNewer( resourceName, destination, timestamp ); createIfMissing( destination.toPath() ); return result; }
Example #17
Source File: AbstractWagon.java From lambadaframework with MIT License | 5 votes |
@Override public final boolean resourceExists(String resourceName) throws TransferFailedException, AuthorizationException { try { return doesRemoteResourceExist(resourceName); } catch (AuthorizationException | TransferFailedException e) { this.transferListenerSupport.fireTransferError(new Resource(resourceName), TransferEvent.REQUEST_GET, e); throw e; } }
Example #18
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 5 votes |
@Test public void getIfNewerTransferFailedException() throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { TransferFailedException exception = new TransferFailedException(""); when(this.wagon.isRemoteResourceNewer("foo", 0)).thenThrow(exception); try { this.wagon.getIfNewer("foo", new File("bar"), 0); fail(); } catch (TransferFailedException e) { verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET, exception); } }
Example #19
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 5 votes |
@Test public void get() throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { this.wagon.get("foo", new File("bar")); verify(this.transferListenerSupport).fireTransferInitiated(new Resource("foo"), TransferEvent.REQUEST_GET); verify(this.transferListenerSupport).fireTransferStarted(new Resource("foo"), TransferEvent.REQUEST_GET); verify(this.wagon).getResource(eq("foo"), eq(new File("bar")), any(TransferProgress.class)); verify(this.transferListenerSupport).fireTransferCompleted(new Resource("foo"), TransferEvent.REQUEST_GET); }
Example #20
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 5 votes |
@Test public void getFileListTransferFailedException() throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { TransferFailedException exception = new TransferFailedException(""); when(this.wagon.listDirectory("foo")).thenThrow(exception); try { this.wagon.getFileList("foo"); fail(); } catch (TransferFailedException e) { verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET, exception); } }
Example #21
Source File: AbstractWagon.java From lambadaframework with MIT License | 5 votes |
@Override public final List<String> getFileList(String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { try { return listDirectory(destinationDirectory); } catch (TransferFailedException | ResourceDoesNotExistException | AuthorizationException e) { this.transferListenerSupport.fireTransferError(new Resource(destinationDirectory), TransferEvent.REQUEST_GET, e); throw e; } }
Example #22
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 5 votes |
@Test public void getIfNewerAuthorizationException() throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { AuthorizationException exception = new AuthorizationException(""); when(this.wagon.isRemoteResourceNewer("foo", 0)).thenThrow(exception); try { this.wagon.getIfNewer("foo", new File("bar"), 0); fail(); } catch (AuthorizationException e) { verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET, exception); } }
Example #23
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 5 votes |
@Test public void put() throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { this.wagon.put(new File("foo"), "bar"); verify(this.transferListenerSupport).fireTransferInitiated(new Resource("bar"), TransferEvent.REQUEST_PUT); verify(this.transferListenerSupport).fireTransferStarted(new Resource("bar"), TransferEvent.REQUEST_PUT); verify(this.wagon).putResource(eq(new File("foo")), eq("bar"), any(TransferProgress.class)); verify(this.transferListenerSupport).fireTransferCompleted(new Resource("bar"), TransferEvent.REQUEST_PUT); }
Example #24
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 5 votes |
@Test public void resourceExistsAuthorizationException() throws TransferFailedException, AuthorizationException { AuthorizationException exception = new AuthorizationException(""); when(this.wagon.doesRemoteResourceExist("foo")).thenThrow(exception); try { this.wagon.resourceExists("foo"); fail(); } catch (AuthorizationException e) { verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET, exception); } }
Example #25
Source File: GitWagon.java From opoopress with Apache License 2.0 | 5 votes |
@Override public void put(File source, String destination) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { if ( source.isDirectory() ) { throw new IllegalArgumentException( "Source is a directory: " + source ); } String resourceName = FilenameUtils.separatorsToUnix(destination); Resource resource = new Resource(resourceName); firePutInitiated(resource, source); firePutStarted(resource, source); try { File file = new File(checkoutDirectory, destination); file.getParentFile().mkdirs(); transfer(resource, source, new FileOutputStream(file), true); } catch (Exception e) { fireTransferError(resource, e, TransferEvent.REQUEST_PUT); throw new TransferFailedException("Unable to put file", e); } firePutCompleted(resource, source); }
Example #26
Source File: AbstractWagonTest.java From lambadaframework with MIT License | 5 votes |
@Test public void resourceExistsTransferFailedException() throws TransferFailedException, AuthorizationException { TransferFailedException exception = new TransferFailedException(""); when(this.wagon.doesRemoteResourceExist("foo")).thenThrow(exception); try { this.wagon.resourceExists("foo"); fail(); } catch (TransferFailedException e) { verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET, exception); } }
Example #27
Source File: WagonDelegate.java From archiva with Apache License 2.0 | 5 votes |
@SuppressWarnings ("unchecked") @Override public List<String> getFileList( String destinationDirectory ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { return delegate.getFileList( destinationDirectory ); }
Example #28
Source File: DefaultVersionsHelper.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
@Deprecated private static RuleSet getRuleSet( Wagon wagon, String remoteURI ) throws IOException, AuthorizationException, TransferFailedException, ResourceDoesNotExistException { File tempFile = File.createTempFile( "ruleset", ".xml" ); try { wagon.get( remoteURI, tempFile ); InputStream is = new FileInputStream(tempFile ); try { return readRulesFromStream(is); } finally { try { is.close(); } catch ( IOException e ) { // ignore } } } finally { if ( !tempFile.delete() ) { // maybe we can delete this later tempFile.deleteOnExit(); } } }
Example #29
Source File: MetadataTransferTest.java From archiva with Apache License 2.0 | 5 votes |
@Test public void testFetchFromTwoProxiesWhenFirstConnectionFails() throws Exception { // Project metadata that does not exist locally, but has multiple versions in remote repos String requestedResource = "org/apache/maven/test/get-default-layout/maven-metadata.xml"; setupTestableManagedRepository( requestedResource ); saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "http://bad.machine.com/repo/", "default" ); // Configure Connector (usually done within archiva.xml configuration) saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false ); saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false ); assertResourceNotFound( requestedResource ); assertNoRepoMetadata( "badproxied1", requestedResource ); assertNoRepoMetadata( ID_PROXIED2, requestedResource ); // ensure that a hard failure in the first proxy connector is skipped and the second repository checked Path expectedFile = managedDefaultDir.resolve( metadataTools.getRepositorySpecificName( "badproxied1", requestedResource ) ); wagonMock.get( EasyMock.eq( requestedResource ), EasyMock.anyObject( File.class )); EasyMock.expectLastCall().andThrow( new TransferFailedException( "can't connect" ) ); wagonMockControl.replay(); assertFetchProjectOrGroup( requestedResource ); wagonMockControl.verify(); assertProjectMetadataContents( requestedResource, new String[]{ "1.0.1" }, "1.0.1", "1.0.1" ); assertNoRepoMetadata( "badproxied1", requestedResource ); assertRepoProjectMetadata( ID_PROXIED2, requestedResource, new String[]{ "1.0.1" } ); }
Example #30
Source File: WagonDelegate.java From archiva with Apache License 2.0 | 5 votes |
@Override public void get( String resourceName, File destination ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { log.debug( ".get({}, {})", resourceName, destination ); delegate.get( resourceName, destination ); create( destination.toPath() ); }