throws TransferFailedException, ResourceDoesNotExistException String remotePath = repository.pathOf( artifact ); ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases(); String error = ( e.getMessage() != null ) ? e.getMessage() : e.getClass().getSimpleName(); updateCheckManager.touch( artifact, repository, error ); throw e; if ( error != null ) throw new TransferFailedException( "Failure to resolve " + remotePath + " from " + repository.getUrl() + " was cached in the local repository. " throw new ResourceDoesNotExistException( "Failure to resolve " + remotePath + " from " + repository.getUrl() + " was cached in the local repository. "
/** * {@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); } }
String url = getRepository().getUrl() + "/" + destinationDirectory; throw new AuthorizationException( "Access denied to: " + url ); throw new AuthorizationException( "Not authorized." ); throw new AuthorizationException( "Not authorized by proxy." ); throw new ResourceDoesNotExistException( "File: " + url + " does not exist" ); throw new TransferFailedException( "Failed to transfer file: " + url + ". Return code is: " + statusCode ); throw new TransferFailedException( "Could not read response body.", e ); throw new TransferFailedException( "Could not read response body.", e ); throw new TransferFailedException( "Unable to wait for resource.", e );
if ( metadata instanceof RepositoryMetadata ) getLogger().info( "Retrieving previous metadata from " + deploymentRepository.getId() ); try metadata + " could not be retrieved from repository: " + deploymentRepository.getId() + " due to an error: " + e.getMessage(), e ); file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) ); throw new RepositoryMetadataDeploymentException( "Error while deploying metadata: " + e.getMessage(), e );
public void putDirectory( File sourceDirectory, String destinationDirectory ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { final RepositoryPermissions permissions = repository.getPermissions(); try { channel.cd( "/" ); String basedir = getRepository().getBasedir(); int directoryMode = getDirectoryMode( permissions ); mkdirs( basedir + "/", directoryMode ); fireTransferDebug( "Recursively uploading directory " + sourceDirectory.getAbsolutePath() + " as " + destinationDirectory ); mkdirs( destinationDirectory, directoryMode ); ftpRecursivePut( sourceDirectory, null, ScpHelper.getResourceFilename( destinationDirectory ), directoryMode ); } catch ( SftpException e ) { String msg = "Error occurred while deploying '" + sourceDirectory.getAbsolutePath() + "' " + "to remote repository: " + getRepository().getUrl() + ": " + e.getMessage(); throw new TransferFailedException( msg, e ); } }
String repositoryUrl = getRepository().getUrl(); String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + resource.getName(); HttpGet getMethod = new HttpGet( url ); long timestamp = resource.getLastModified(); if ( timestamp > 0 ) case HttpStatus.SC_FORBIDDEN: fireSessionConnectionRefused(); throw new AuthorizationException( "Access denied to: " + url ); throw new AuthorizationException( "Not authorized" ); throw new AuthorizationException( "Not authorized by proxy" ); throw new ResourceDoesNotExistException( "File " + url + " does not exist" ); TransferFailedException e = new TransferFailedException( "Failed to transfer file " + url + " with status code " + statusCode ); fireTransferError( resource, e, TransferEvent.REQUEST_GET ); resource.setContentLength( contentLength ); throw new TransferFailedException( e.getMessage(), e ); throw new TransferFailedException( e.getMessage(), e ); throw new TransferFailedException( e.getMessage(), e );
mkdirs( PathUtils.dirname( resource.getName() ) ); HttpHost targetHost = new HttpHost( repo.getHost(), repo.getPort(), repo.getProtocol() ); AuthScope targetScope = getBasicAuthScope().getScope( targetHost ); case HttpStatus.SC_FORBIDDEN: fireSessionConnectionRefused(); throw new AuthorizationException( "Access denied to: " + url ); throw new ResourceDoesNotExistException( "File " + url + " does not exist" ); TransferFailedException e = new TransferFailedException( "Failed to transfer file " + url + " with status code " + statusCode ); fireTransferError( resource, e, TransferEvent.REQUEST_PUT ); throw new TransferFailedException( e.getMessage(), e ); throw new TransferFailedException( e.getMessage(), e ); throw new TransferFailedException( e.getMessage(), e );
String protocol = repository.getProtocol(); Wagon wagon; try wagon = getWagon( protocol, repository.getId() ); throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); getLogger().debug( "Connecting to repository: \'" + repository.getId() + "\' with url: \'" + repository.getUrl() + "\'." ); wagon.connect( new Repository( repository.getId(), repository.getUrl() ), getAuthenticationInfo( repository.getId() ), new ProxyInfoProvider() throw new TransferFailedException( "Unable to add checksum methods: " + 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 ResourceDoesNotExistException( "Downloaded file does not exist: " + temp ); throw new TransferFailedException( "Error copying temporary file to the final destination: " + e.getMessage(), e );
String protocol = repository.getProtocol(); wagon = getWagon( protocol, repository.getId() ); throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); throw new TransferFailedException( "Unable to add checksum methods: " + e.getMessage(), e ); Repository artifactRepository = new Repository( repository.getId(), repository.getUrl() ); if ( serverPermissionsMap.containsKey( repository.getId() ) ) "adding permissions to wagon connection: " + perms.getFileMode() + " " + perms.getDirectoryMode() ); artifactRepository.setPermissions( perms ); artifactRepository.setPermissions( defaultRepositoryPermissions ); 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 );
String basedir = repository.getBasedir(); dir = StringUtils.replace( dir, "\\", "/" ); dest = dest + resource.getName(); dest = dest + "/" + resource.getName(); throw new TransferFailedException( "Destination path exists and is not a WebDAV collection (directory): " + cdpath ); throw new TransferFailedException( "Failed to create destination WebDAV collection (directory): " + relpath, ioe ); throw new TransferFailedException( "Failed to create destination WebDAV collection (directory): " + relpath, e ); throw new AuthorizationException( "Access denied to: " + dest ); throw new ResourceDoesNotExistException( "File: " + dest + " does not exist" ); throw new TransferFailedException( "Failed to transfer file: " + dest + ". Return code is: " + statusCode + " " + HttpStatus.getStatusText( statusCode ) ); throw new TransferFailedException( "Specified source file does not exist: " + source, e ); throw new TransferFailedException( msg, e );
logger.debug( "Unable to find artifact " + artifact.getId() + " in repository " + repository.getId() + " (" + repository.getUrl() + ")", e ); "Unable to get artifact " + artifact.getId() + " from repository " + repository.getId() + " (" + repository.getUrl() + "): " + e.getMessage(); throw new ResourceDoesNotExistException( "Unable to download the artifact from any repository" );
public void put(File file, String s) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { outputDebug(String.format("put: %s", s)); Resource resource = new Resource(s); resource.setContentLength(file.length()); resource.setLastModified(file.lastModified()); throw new ResourceDoesNotExistException(String.format("Not found %s", s)); throw new AuthorizationException(String.format("Could not authenticate with %s", getAuthenticationInfo().getPassword())); throw new TransferFailedException(String.format("Upload failed: %s", responseText)); throw new TransferFailedException("There was an unexpected server error! (500)"); throw new TransferFailedException(String.format("Could not transfer %s to %s", s, getTargetHost().getHostName())); } catch (URISyntaxException e) { throw new TransferFailedException(String.format("Could not construct url %s to %s", s, getTargetHost().getHostName())); } finally { try {
public List<String> getFileList( String destinationDirectory ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { if ( getRepository().getBasedir() == null ) { throw new TransferFailedException( "Unable to getFileList() with a null basedir." ); } File path = resolveDestinationPath( destinationDirectory ); if ( !path.exists() ) { throw new ResourceDoesNotExistException( "Directory does not exist: " + destinationDirectory ); } if ( !path.isDirectory() ) { throw new ResourceDoesNotExistException( "Path is not a directory: " + destinationDirectory ); } File[] files = path.listFiles(); List<String> list = new ArrayList<String>( files.length ); for ( File file : files ) { String name = file.getName(); if ( file.isDirectory() && !name.endsWith( "/" ) ) { name += "/"; } list.add( name ); } return list; }
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"); } }
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException Resource resource = new Resource( destinationDirectory ); String filename = PathUtils.filename( resource.getName() ); FTPFile[] ftpFiles = ftp.listFiles( filename ); throw new ResourceDoesNotExistException( "Could not find file: '" + resource + "'" ); throw new TransferFailedException( "Error transferring file via FTP", 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; } }
public void getMd5Hash(Repository repository, NugetArtifact artifact, File destination) throws TransferFailedException, ResourceDoesNotExistException { if (!artifact.isNugetFile()) { throw new ResourceDoesNotExistException("hash for files extracted from nuget archive not supported."); } try (CloseableHttpClient client = HttpClients.createDefault()) { HttpHead headRequest = new HttpHead(repository.getUrl() + "/" + artifact.resourceString()); try (CloseableHttpResponse response = client.execute(headRequest)) { Header checkSum = response.getFirstHeader("Content-MD5"); if (checkSum == null) { throw new ResourceDoesNotExistException("Content-MD5 header not set"); } FileUtils.write(destination, checkSum.getValue(), StandardCharsets.ISO_8859_1); } } catch (IOException e) { throw new TransferFailedException(e.getMessage(), e); } } }
private void handleIOException( Resource resource, IOException e ) throws TransferFailedException { if ( e.getMessage().contains( "set mode: Operation not permitted" ) ) { fireTransferDebug( e.getMessage() ); } else { fireTransferError( resource, e, TransferEvent.REQUEST_PUT ); String msg = "Error occurred while deploying '" + resource.getName() + "' to remote repository: " + getRepository().getUrl() + ": " + e.getMessage(); throw new TransferFailedException( msg, e ); } }
Repository repo = new Repository( sourceUrl.getHost(), baseUrl ); messageHolder.addMessage( "Connecting to: " + repo.getHost() + "(baseUrl: " + repo.getUrl() + ")" ); throw new DownloadFailedException( url, "Download failed. Reason: " + e.getMessage(), e ); throw new DownloadFailedException( url, "Download failed. Reason: " + e.getMessage(), e ); throw new DownloadFailedException( url, "Download failed. Reason: " + e.getMessage(), e );
resource.getContentLength() == WagonConstants.UNKNOWN_LENGTH ? Long.MAX_VALUE : resource.getContentLength() ); String msg = "PUT request to: " + resource.getName() + " in " + repository.getName() + " failed"; throw new TransferFailedException( msg, e );