Java Code Examples for org.apache.maven.wagon.ResourceDoesNotExistException

The following examples show how to use org.apache.maven.wagon.ResourceDoesNotExistException. These examples are extracted from open source projects. 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 Project: lambadaframework   Source File: AbstractWagon.java    License: MIT License 6 votes vote down vote up
@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 Project: lambadaframework   Source File: AbstractWagon.java    License: MIT License 6 votes vote down vote up
@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 3
Source Project: lambadaframework   Source File: AbstractWagon.java    License: MIT License 6 votes vote down vote up
@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 4
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 6 votes vote down vote up
@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 5
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 6 votes vote down vote up
@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 6
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 6 votes vote down vote up
@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 7
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 6 votes vote down vote up
@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 8
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 6 votes vote down vote up
@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 9
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 6 votes vote down vote up
@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 10
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 6 votes vote down vote up
@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 11
Source Project: archiva   Source File: RepositoryModelResolver.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *
 * @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 12
Source Project: archiva   Source File: MockWagon.java    License: Apache License 2.0 6 votes vote down vote up
@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 13
Source Project: opoopress   Source File: GitWagon.java    License: Apache License 2.0 6 votes vote down vote up
@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 14
Source Project: lambadaframework   Source File: SimpleStorageServiceWagon.java    License: MIT License 5 votes vote down vote up
@Override
protected boolean isRemoteResourceNewer(String resourceName, long timestamp) throws ResourceDoesNotExistException {
    try {
        Date lastModified = getObjectMetadata(resourceName).getLastModified();
        return lastModified == null || lastModified.getTime() > timestamp;
    } catch (AmazonServiceException e) {
        throw new ResourceDoesNotExistException(String.format("'%s' does not exist", resourceName), e);
    }
}
 
Example 15
Source Project: lambadaframework   Source File: SimpleStorageServiceWagon.java    License: MIT License 5 votes vote down vote up
@Override
protected List<String> listDirectory(String directory) throws ResourceDoesNotExistException {
    List<String> directoryContents = new ArrayList<>();

    try {
        String prefix = getKey(directory);
        Pattern pattern = Pattern.compile(String.format(RESOURCE_FORMAT, prefix));

        ListObjectsRequest listObjectsRequest = new ListObjectsRequest() //
                .withBucketName(this.bucketName) //
                .withPrefix(prefix) //
                .withDelimiter("/");

        ObjectListing objectListing;

        objectListing = this.amazonS3.listObjects(listObjectsRequest);
        directoryContents.addAll(getResourceNames(objectListing, pattern));

        while (objectListing.isTruncated()) {
            objectListing = this.amazonS3.listObjects(listObjectsRequest);
            directoryContents.addAll(getResourceNames(objectListing, pattern));
        }

        return directoryContents;
    } catch (AmazonServiceException e) {
        throw new ResourceDoesNotExistException(String.format("'%s' does not exist", directory), e);
    }
}
 
Example 16
Source Project: lambadaframework   Source File: AbstractWagon.java    License: MIT License 5 votes vote down vote up
@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 17
Source Project: lambadaframework   Source File: AbstractWagon.java    License: MIT License 5 votes vote down vote up
@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 18
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 5 votes vote down vote up
@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 19
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 5 votes vote down vote up
@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 20
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 5 votes vote down vote up
@Test
public void getFileResourceDoesNotExistException() throws TransferFailedException, ResourceDoesNotExistException,
        AuthorizationException {
    ResourceDoesNotExistException exception = new ResourceDoesNotExistException("");
    when(this.wagon.listDirectory("foo")).thenThrow(exception);

    try {
        this.wagon.getFileList("foo");
        fail();
    } catch (ResourceDoesNotExistException e) {
        verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET,
                exception);
    }
}
 
Example 21
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 5 votes vote down vote up
@Test
public void getFileListAuthorizationException() throws TransferFailedException, ResourceDoesNotExistException,
        AuthorizationException {
    AuthorizationException exception = new AuthorizationException("");
    when(this.wagon.listDirectory("foo")).thenThrow(exception);

    try {
        this.wagon.getFileList("foo");
        fail();
    } catch (AuthorizationException e) {
        verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET,
                exception);
    }
}
 
Example 22
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 5 votes vote down vote up
@Test
public void getIfNewerNewer() throws TransferFailedException, ResourceDoesNotExistException,
        AuthorizationException {
    when(this.wagon.isRemoteResourceNewer("foo", 0)).thenReturn(true);

    assertTrue(this.wagon.getIfNewer("foo", new File("bar"), 0));
    verify(this.wagon).getResource(eq("foo"), eq(new File("bar")), any(TransferProgress.class));
}
 
Example 23
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 5 votes vote down vote up
@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 24
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 5 votes vote down vote up
@Test
public void getIfNewerResourceDoesNotExistException() throws TransferFailedException, ResourceDoesNotExistException,
        AuthorizationException {
    ResourceDoesNotExistException exception = new ResourceDoesNotExistException("");
    when(this.wagon.isRemoteResourceNewer("foo", 0)).thenThrow(exception);

    try {
        this.wagon.getIfNewer("foo", new File("bar"), 0);
        fail();
    } catch (ResourceDoesNotExistException e) {
        verify(this.transferListenerSupport).fireTransferError(new Resource("foo"), TransferEvent.REQUEST_GET,
                exception);
    }
}
 
Example 25
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 5 votes vote down vote up
@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 26
Source Project: lambadaframework   Source File: AbstractWagonTest.java    License: MIT License 5 votes vote down vote up
@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 27
@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 28
Source Project: archiva   Source File: WagonDelegate.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void get( String resourceName, File destination )
    throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
{
    log.debug( ".get({}, {})", resourceName, destination );
    delegate.get( resourceName, destination );
    create( destination.toPath() );
}
 
Example 29
Source Project: archiva   Source File: WagonDelegate.java    License: Apache License 2.0 5 votes vote down vote up
@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 30
Source Project: archiva   Source File: WagonDelegate.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings ("unchecked")
@Override
public List<String> getFileList( String destinationDirectory )
    throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
{
    return delegate.getFileList( destinationDirectory );
}