Search in sources :

Example 1 with Resource

use of org.apache.maven.wagon.resource.Resource in project wagon-git by synergian.

the class GitWagon method fillInputData.

/**
	 * {@inheritDoc}
	 */
public void fillInputData(InputData inputData) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException {
    log.debug("Invoked fillInputData()");
    Resource resource = inputData.getResource();
    File file = new File(git.workDir, resource.getName());
    if (!file.exists()) {
        throw new ResourceDoesNotExistException("File: " + file + " does not exist");
    }
    try {
        InputStream in = new BufferedInputStream(new FileInputStream(file));
        inputData.setInputStream(in);
        resource.setContentLength(file.length());
        resource.setLastModified(file.lastModified());
    } catch (FileNotFoundException e) {
        throw new TransferFailedException("Could not read from file: " + file.getAbsolutePath(), e);
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Resource(org.apache.maven.wagon.resource.Resource) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) TransferFailedException(org.apache.maven.wagon.TransferFailedException) ResourceDoesNotExistException(org.apache.maven.wagon.ResourceDoesNotExistException) FileInputStream(java.io.FileInputStream)

Example 2 with Resource

use of org.apache.maven.wagon.resource.Resource in project wagon-git by synergian.

the class GitWagon method fillOutputData.

/**
	 * {@inheritDoc}
	 */
public void fillOutputData(OutputData outputData) throws TransferFailedException {
    log.debug("Invoked fillOutputData()");
    Resource resource = outputData.getResource();
    File file = new File(git.workDir, resource.getName());
    createParentDirectories(file);
    OutputStream outputStream = new BufferedOutputStream(new LazyFileOutputStream(file));
    outputData.setOutputStream(outputStream);
}
Also used : LazyFileOutputStream(org.apache.maven.wagon.LazyFileOutputStream) OutputStream(java.io.OutputStream) BufferedOutputStream(java.io.BufferedOutputStream) LazyFileOutputStream(org.apache.maven.wagon.LazyFileOutputStream) Resource(org.apache.maven.wagon.resource.Resource) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 3 with Resource

use of org.apache.maven.wagon.resource.Resource in project gradle by gradle.

the class RepositoryTransportDeployWagon method get.

@Override
public final void get(String resourceName, File destination) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException {
    Resource resource = new Resource(resourceName);
    this.transferEventSupport.fireTransferInitiated(transferEvent(resource, TRANSFER_INITIATED, REQUEST_GET));
    this.transferEventSupport.fireTransferStarted(transferEvent(resource, TRANSFER_STARTED, REQUEST_GET));
    try {
        if (!destination.exists()) {
            destination.getParentFile().mkdirs();
            destination.createNewFile();
        }
        if (!getDelegate().getRemoteFile(destination, resourceName)) {
            throw new ResourceDoesNotExistException(String.format("Resource '%s' does not exist", resourceName));
        }
        this.transferEventSupport.fireTransferCompleted(transferEvent(resource, TRANSFER_COMPLETED, REQUEST_GET));
    } catch (ResourceDoesNotExistException e) {
        this.transferEventSupport.fireTransferError(transferEvent(resource, e, REQUEST_GET));
        throw e;
    } catch (Exception e) {
        this.transferEventSupport.fireTransferError(transferEvent(resource, e, REQUEST_GET));
        throw new TransferFailedException(String.format("Could not get resource '%s'", resourceName), e);
    }
}
Also used : Resource(org.apache.maven.wagon.resource.Resource) LocalResource(org.gradle.internal.resource.local.LocalResource) FileLocalResource(org.gradle.internal.resource.local.FileLocalResource) TransferFailedException(org.apache.maven.wagon.TransferFailedException) ResourceDoesNotExistException(org.apache.maven.wagon.ResourceDoesNotExistException) AuthenticationException(org.apache.maven.wagon.authentication.AuthenticationException) ConnectionException(org.apache.maven.wagon.ConnectionException) AuthorizationException(org.apache.maven.wagon.authorization.AuthorizationException) IOException(java.io.IOException) ResourceDoesNotExistException(org.apache.maven.wagon.ResourceDoesNotExistException) GradleException(org.gradle.api.GradleException) TransferFailedException(org.apache.maven.wagon.TransferFailedException)

Example 4 with Resource

use of org.apache.maven.wagon.resource.Resource in project gradle by gradle.

the class RepositoryTransportDeployWagon method put.

@Override
public final void put(File file, String resourceName) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException {
    Resource resource = new Resource(resourceName);
    this.transferEventSupport.fireTransferInitiated(transferEvent(resource, TRANSFER_INITIATED, REQUEST_PUT));
    try {
        LocalResource localResource = new MavenTransferLoggingFileResource(file, resource);
        getDelegate().putRemoteFile(localResource, resourceName);
    } catch (Exception e) {
        this.transferEventSupport.fireTransferError(transferEvent(resource, e, REQUEST_PUT));
        throw new TransferFailedException(String.format("Could not write to resource '%s'", resourceName), e);
    }
    this.transferEventSupport.fireTransferCompleted(transferEvent(resource, TRANSFER_COMPLETED, REQUEST_PUT));
}
Also used : Resource(org.apache.maven.wagon.resource.Resource) LocalResource(org.gradle.internal.resource.local.LocalResource) FileLocalResource(org.gradle.internal.resource.local.FileLocalResource) TransferFailedException(org.apache.maven.wagon.TransferFailedException) AuthenticationException(org.apache.maven.wagon.authentication.AuthenticationException) ConnectionException(org.apache.maven.wagon.ConnectionException) AuthorizationException(org.apache.maven.wagon.authorization.AuthorizationException) IOException(java.io.IOException) ResourceDoesNotExistException(org.apache.maven.wagon.ResourceDoesNotExistException) GradleException(org.gradle.api.GradleException) TransferFailedException(org.apache.maven.wagon.TransferFailedException) LocalResource(org.gradle.internal.resource.local.LocalResource) FileLocalResource(org.gradle.internal.resource.local.FileLocalResource)

Aggregations

Resource (org.apache.maven.wagon.resource.Resource)4 ResourceDoesNotExistException (org.apache.maven.wagon.ResourceDoesNotExistException)3 TransferFailedException (org.apache.maven.wagon.TransferFailedException)3 File (java.io.File)2 IOException (java.io.IOException)2 ConnectionException (org.apache.maven.wagon.ConnectionException)2 AuthenticationException (org.apache.maven.wagon.authentication.AuthenticationException)2 AuthorizationException (org.apache.maven.wagon.authorization.AuthorizationException)2 GradleException (org.gradle.api.GradleException)2 FileLocalResource (org.gradle.internal.resource.local.FileLocalResource)2 LocalResource (org.gradle.internal.resource.local.LocalResource)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 LazyFileOutputStream (org.apache.maven.wagon.LazyFileOutputStream)1