private ChecksumObserver addChecksumObserver( Wagon wagon, String algorithm ) throws TransferFailedException { try { ChecksumObserver checksumObserver = new ChecksumObserver( algorithm ); wagon.addTransferListener( checksumObserver ); return checksumObserver; } catch ( NoSuchAlgorithmException e ) { throw new TransferFailedException( "Unable to add checksum for unsupported algorithm " + algorithm, e ); } }
throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); throw new TransferFailedException( "Connection failed: " + e.getMessage(), e ); throw new TransferFailedException( "Authentication failed: " + e.getMessage(), e ); throw new TransferFailedException( "Authorization failed: " + e.getMessage(), e ); throw new TransferFailedException( "Resource to deploy not found: " + e.getMessage(), e ); throw new TransferFailedException( "Error creating temporary file for deployment: " + e.getMessage(), e );
throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); throw new TransferFailedException( "Connection failed: " + e.getMessage(), e ); throw new TransferFailedException( "Authentication failed: " + e.getMessage(), e ); throw new TransferFailedException( "Authorization failed: " + e.getMessage(), e ); throw new TransferFailedException( "Error copying temporary file to the final destination: " + e.getMessage(), e );
if ( error != null ) throw new TransferFailedException( "Failure to resolve " + remotePath + " from " + repository.getUrl() + " was cached in the local repository. "
private void failIfNotOnline() throws TransferFailedException { if ( !isOnline() ) { throw new TransferFailedException( "System is offline." ); } }
protected int backoff( int wait, String url ) throws InterruptedException, TransferFailedException { TimeUnit.SECONDS.sleep( wait ); int nextWait = wait * 2; if ( nextWait >= getMaxBackoffWaitSeconds() ) { throw new TransferFailedException( "Waited too long to access: " + url + ". Return code is: " + SC_TOO_MANY_REQUESTS ); } return nextWait; }
protected int backoff( int wait, String url ) throws InterruptedException, TransferFailedException { TimeUnit.SECONDS.sleep( wait ); int nextWait = wait * 2; if ( nextWait >= getMaxBackoffWaitSeconds() ) { throw new TransferFailedException( "Waited too long to access: " + url + ". Return code is: " + SC_TOO_MANY_REQUESTS ); } return nextWait; }
private void provideUnpackedFile(File destination, File file) throws TransferFailedException, IOException, ResourceDoesNotExistException { if (file.exists()) { if (destination.exists() && !destination.delete()) { throw new TransferFailedException("cannot delete file " + destination.getAbsolutePath()); } Files.createLink(destination.toPath(), file.toPath()); } else { throw new ResourceDoesNotExistException("no compatible artifact found in nuget package"); } }
protected void handleGetException( Resource resource, Exception e ) throws TransferFailedException { fireTransferError( resource, e, TransferEvent.REQUEST_GET ); String msg = "Error occurred while downloading '" + resource + "' from the remote repository:" + getRepository() + ": " + e.getMessage(); throw new TransferFailedException( msg, e ); }
protected void handleGetException( Resource resource, Exception e ) throws TransferFailedException { fireTransferError( resource, e, TransferEvent.REQUEST_GET ); String msg = "Error occurred while downloading '" + resource + "' from the remote repository:" + getRepository() + ": " + e.getMessage(); throw new TransferFailedException( msg, e ); }
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); } }
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); } }
public final boolean resourceExists(final String resourceName) throws TransferFailedException, AuthorizationException { try { return doesRemoteResourceExist(resourceName); } catch (TransferFailedException e) { throw e; } catch (AuthorizationException e) { throw e; } catch (Exception e) { sessionListeners.fireSessionError(e); throw new TransferFailedException("Listing of resource " + resourceName + "failed", e); } }
private void extractTool(File downloadPackageFile, NugetArtifact nugetArtifact, File destination) throws TransferFailedException, ResourceDoesNotExistException { try { File file = Streams.unpackForFile(downloadPackageFile, new File(TOOLS_DIRECTORY, nugetArtifact.artifactName())); provideUnpackedFile(destination, file); } catch (IOException e) { throw new TransferFailedException(e.getMessage(), e); } }
@Override public void putDirectory(File sourceDirectory, String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { try { List<String> files = FileUtils.getFileNames( sourceDirectory, "**/**", "", false ); for (String file : files) put(new File(sourceDirectory,file),combine(destinationDirectory,file)); } catch (IOException e) { throw new TransferFailedException("Failed to list up files in "+sourceDirectory,e); } }
private void transFormToPom(File sourceFile, File destination) throws TransferFailedException { try (InputStream source = NuGetWagon.class.getResourceAsStream("/nuspec-to-pom.xsl")) { Xml.transformFile(sourceFile, new StreamSource(source), destination, false, new TargetFrameworkParameterSetter(getFrameworkProvider().getFrameworkVersion().versionedFullName())); } catch (IOException | ParserConfigurationException | TransformerException | SAXException e) { throw new TransferFailedException(e.getMessage(), e); } }
protected void checkOutputStream( Resource resource, OutputStream os ) throws TransferFailedException { if ( os == null ) { TransferFailedException e = new TransferFailedException( getRepository().getUrl() + " - Could not open output stream for resource: '" + resource + "'" ); fireTransferError( resource, e, TransferEvent.REQUEST_PUT ); throw e; } }
protected void checkInputStream( InputStream is, Resource resource ) throws TransferFailedException { if ( is == null ) { TransferFailedException e = new TransferFailedException( getRepository().getUrl() + " - Could not open input stream for resource: '" + resource + "'" ); fireTransferError( resource, e, TransferEvent.REQUEST_GET ); throw e; } }
protected void checkOutputStream( Resource resource, OutputStream os ) throws TransferFailedException { if ( os == null ) { TransferFailedException e = new TransferFailedException( getRepository().getUrl() + " - Could not open output stream for resource: '" + resource + "'" ); fireTransferError( resource, e, TransferEvent.REQUEST_PUT ); throw e; } }
protected void checkInputStream( InputStream is, Resource resource ) throws TransferFailedException { if ( is == null ) { TransferFailedException e = new TransferFailedException( getRepository().getUrl() + " - Could not open input stream for resource: '" + resource + "'" ); fireTransferError( resource, e, TransferEvent.REQUEST_GET ); throw e; } }