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);
}
}
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);
}
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);
}
}
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));
}
Aggregations