org.apache.maven.wagon.events.TransferEvent Java Examples
The following examples show how to use
org.apache.maven.wagon.events.TransferEvent.
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: 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 #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 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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
Source File: ArchivaIndexManagerMock.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferStarted( TransferEvent transferEvent ) { this.totalLength = 0; resourceName = transferEvent.getResource( ).getName( ); log.info( "start transfer of {}", transferEvent.getResource( ).getName( ) ); }
Example #13
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 #14
Source File: ArchivaIndexManagerMock.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferInitiated( TransferEvent transferEvent ) { startTime = System.currentTimeMillis( ); resourceName = transferEvent.getResource( ).getName( ); log.debug( "initiate transfer of {}", resourceName ); }
Example #15
Source File: DownloadRemoteIndexTask.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferCompleted( TransferEvent transferEvent ) { resourceName = transferEvent.getResource().getName(); long endTime = System.currentTimeMillis(); log.info( "end of transfer file {}: {}b, {}ms", transferEvent.getResource().getName(), this.totalLength, ( endTime - startTime ) ); }
Example #16
Source File: DownloadRemoteIndexTask.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferStarted( TransferEvent transferEvent ) { this.totalLength = 0; resourceName = transferEvent.getResource().getName(); log.info("Transferring: {}, {}", transferEvent.getResource().getContentLength(), transferEvent.getLocalFile().toString()); log.info( "start transfer of {}", transferEvent.getResource().getName() ); }
Example #17
Source File: MavenIndexManager.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferInitiated( TransferEvent transferEvent ) { startTime = System.currentTimeMillis( ); resourceName = transferEvent.getResource( ).getName( ); log.debug( "initiate transfer of {}", resourceName ); }
Example #18
Source File: ArchivaIndexManagerMock.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferInitiated( TransferEvent transferEvent ) { startTime = System.currentTimeMillis( ); resourceName = transferEvent.getResource( ).getName( ); log.debug( "initiate transfer of {}", resourceName ); }
Example #19
Source File: RemoteIndexTransferListener.java From netbeans with Apache License 2.0 | 5 votes |
public @Override void transferStarted(TransferEvent e) { checkCancel(); long contentLength = e.getResource().getContentLength(); LOG.log(Level.FINE, "contentLength: {0}", contentLength); // #189806: could be resumed due to FNFE in DefaultIndexUpdater (*.gz -> *.zip) this.units = contentLength / 1024; handle.switchToDeterminate(100); }
Example #20
Source File: ArchivaIndexManagerMock.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferCompleted( TransferEvent transferEvent ) { resourceName = transferEvent.getResource( ).getName( ); long endTime = System.currentTimeMillis( ); log.info( "end of transfer file {} {} kb: {}s", transferEvent.getResource( ).getName( ), this.totalLength / 1024, ( endTime - startTime ) / 1000 ); }
Example #21
Source File: ArchivaIndexManagerMock.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferCompleted( TransferEvent transferEvent ) { resourceName = transferEvent.getResource( ).getName( ); long endTime = System.currentTimeMillis( ); log.info( "end of transfer file {} {} kb: {}s", transferEvent.getResource( ).getName( ), this.totalLength / 1024, ( endTime - startTime ) / 1000 ); }
Example #22
Source File: ArchivaIndexManagerMock.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferCompleted( TransferEvent transferEvent ) { resourceName = transferEvent.getResource( ).getName( ); long endTime = System.currentTimeMillis( ); log.info( "end of transfer file {} {} kb: {}s", transferEvent.getResource( ).getName( ), this.totalLength / 1024, ( endTime - startTime ) / 1000 ); }
Example #23
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 #24
Source File: DownloadRemoteIndexTask.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferInitiated( TransferEvent transferEvent ) { startTime = System.currentTimeMillis(); resourceName = transferEvent.getResource().getName(); log.debug( "initiate transfer of {}", resourceName ); }
Example #25
Source File: ArchivaIndexManagerMock.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferStarted( TransferEvent transferEvent ) { this.totalLength = 0; resourceName = transferEvent.getResource( ).getName( ); log.info( "start transfer of {}", transferEvent.getResource( ).getName( ) ); }
Example #26
Source File: ArchivaIndexManagerMock.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferInitiated( TransferEvent transferEvent ) { startTime = System.currentTimeMillis( ); resourceName = transferEvent.getResource( ).getName( ); log.debug( "initiate transfer of {}", resourceName ); }
Example #27
Source File: ArchivaIndexManagerMock.java From archiva with Apache License 2.0 | 5 votes |
@Override public void transferStarted( TransferEvent transferEvent ) { this.totalLength = 0; resourceName = transferEvent.getResource( ).getName( ); log.info( "start transfer of {}", transferEvent.getResource( ).getName( ) ); }
Example #28
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 #29
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 #30
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); } }