private File getFile( RepositorySystemSession session, Artifact artifact, File file ) throws ArtifactTransferException { if ( artifact.isSnapshot() && !artifact.getVersion().equals( artifact.getBaseVersion() ) && ConfigUtils.getBoolean( session, true, CONFIG_PROP_SNAPSHOT_NORMALIZATION ) ) { String name = file.getName().replace( artifact.getVersion(), artifact.getBaseVersion() ); File dst = new File( file.getParent(), name ); boolean copy = dst.length() != file.length() || dst.lastModified() != file.lastModified(); if ( copy ) { try { fileProcessor.copy( file, dst ); dst.setLastModified( file.lastModified() ); } catch ( IOException e ) { throw new ArtifactTransferException( artifact, null, e ); } } file = dst; } return file; }
/** * Creates a new exception with the specified artifact, repository and cause. * * @param artifact The untransferable artifact, may be {@code null}. * @param repository The involved remote repository, may be {@code null}. * @param cause The exception that caused this one, may be {@code null}. */ public ArtifactTransferException( Artifact artifact, RemoteRepository repository, Throwable cause ) { this( artifact, repository, "Could not transfer artifact " + artifact + getString( " from/to ", repository ) + getMessage( ": ", cause ), cause ); }
public void testArtifactUpload() throws Exception { addExpectation("gid/aid/version/aid-version-classifier.extension", "artifact"); addExpectation("gid/aid/version/aid-version-classifier.extension.sha1", sha1("artifact")); addExpectation("gid/aid/version/aid-version-classifier.extension.md5", md5("artifact")); Artifact artifact = artifact("artifact"); ArtifactUpload up = new ArtifactUpload(artifact, artifact.getFile()); List<ArtifactUpload> uploads = Arrays.asList(up); connector().put(uploads, null); ArtifactTransferException ex = up.getException(); assertNull(ex != null ? ex.getMessage() : "", ex); assertExpectations(); }
@Test public void testDownloadArtifact() throws Exception { addDelivery("gid/aid/version/aid-version-classifier.extension", "artifact"); addDelivery("gid/aid/version/aid-version-classifier.extension.sha1", sha1("artifact")); addDelivery("gid/aid/version/aid-version-classifier.extension.md5", md5("artifact")); File f = TestFileUtils.createTempFile(""); Artifact a = artifact("bla"); ArtifactDownload down = new ArtifactDownload(a, null, f, RepositoryPolicy.CHECKSUM_POLICY_FAIL); Collection<? extends ArtifactDownload> downs = Arrays.asList(down); RepositoryConnector c = connector(); c.get(downs, null); if(down.getException() != null) { down.getException().printStackTrace(); } assertNull(String.valueOf(down.getException()), down.getException()); TestFileUtils.assertContent("artifact", f); }
public void IGNOREtestArtifactWithZeroBytesFile() throws Exception { String content = ""; addExpectation("gid/aid/version/aid-version-classifier.extension", content); addExpectation("gid/aid/version/aid-version-classifier.extension.sha1", sha1(content)); addExpectation("gid/aid/version/aid-version-classifier.extension.md5", md5(content)); Artifact artifact = artifact(content); ArtifactUpload up = new ArtifactUpload(artifact, artifact.getFile()); List<ArtifactUpload> uploads = Arrays.asList(up); connector().put(uploads, null); ArtifactTransferException ex = up.getException(); assertNull(ex != null ? ex.getMessage() : "", ex); assertExpectations(); }
private File getFile( RepositorySystemSession session, Artifact artifact, File file ) throws ArtifactTransferException { if ( artifact.isSnapshot() && !artifact.getVersion().equals( artifact.getBaseVersion() ) && ConfigUtils.getBoolean( session, true, CONFIG_PROP_SNAPSHOT_NORMALIZATION ) ) { String name = file.getName().replace( artifact.getVersion(), artifact.getBaseVersion() ); File dst = new File( file.getParent(), name ); boolean copy = dst.length() != file.length() || dst.lastModified() != file.lastModified(); if ( copy ) { try { fileProcessor.copy( file, dst ); dst.setLastModified( file.lastModified() ); } catch ( IOException e ) { throw new ArtifactTransferException( artifact, null, e ); } } file = dst; } return file; }
throw new DeploymentException( "Failed to deploy artifacts: " + upload.getException().getMessage(), upload.getException() );
/** * Creates a new exception with the specified artifact, repository and cause. * * @param artifact The untransferable artifact, may be {@code null}. * @param repository The involved remote repository, may be {@code null}. * @param cause The exception that caused this one, may be {@code null}. */ public ArtifactTransferException( Artifact artifact, RemoteRepository repository, Throwable cause ) { this( artifact, repository, "Could not transfer artifact " + artifact + getString( " from/to ", repository ) + getMessage( ": ", cause ), cause ); }
private ArtifactTransferException newException(String error, Artifact artifact, RemoteRepository repository) { if (error == null || error.length() <= 0) { return new ArtifactNotFoundException(artifact, repository, "Failure to find " + artifact + " in " + repository.getUrl() + " was cached in the local repository, " + "resolution will not be reattempted until the update interval of " + repository.getId() + " has elapsed or updates are forced"); } else { return new ArtifactTransferException(artifact, repository, "Failure to transfer " + artifact + " from " + repository.getUrl() + " was cached in the local repository, " + "resolution will not be reattempted until the update interval of " + repository.getId() + " has elapsed or updates are forced. Original error: " + error); } }
throw new DeploymentException( "Failed to deploy artifacts: " + upload.getException().getMessage(), upload.getException() );
private ArtifactTransferException newException(String error, Artifact artifact, RemoteRepository repository) { if (error == null || error.length() <= 0) { return new ArtifactNotFoundException(artifact, repository, "Failure to find " + artifact + " in " + repository.getUrl() + " was cached in the local repository, " + "resolution will not be reattempted until the update interval of " + repository.getId() + " has elapsed or updates are forced"); } else { return new ArtifactTransferException(artifact, repository, "Failure to transfer " + artifact + " from " + repository.getUrl() + " was cached in the local repository, " + "resolution will not be reattempted until the update interval of " + repository.getId() + " has elapsed or updates are forced. Original error: " + error); } }
private ArtifactTransferException newException( String error, Artifact artifact, RemoteRepository repository ) { if ( error == null || error.length() <= 0 ) { return new ArtifactNotFoundException( artifact, repository, "Failure to find " + artifact + " in " + repository.getUrl() + " was cached in the local repository, " + "resolution will not be reattempted until the update interval of " + repository.getId() + " has elapsed or updates are forced", true ); } else { return new ArtifactTransferException( artifact, repository, "Failure to transfer " + artifact + " from " + repository.getUrl() + " was cached in the local repository, " + "resolution will not be reattempted until the update interval of " + repository.getId() + " has elapsed or updates are forced. Original error: " + error, true ); } }
private ArtifactTransferException newException( String error, Artifact artifact, RemoteRepository repository ) { if ( error == null || error.length() <= 0 ) { return new ArtifactNotFoundException( artifact, repository, "Failure to find " + artifact + " in " + repository.getUrl() + " was cached in the local repository, " + "resolution will not be reattempted until the update interval of " + repository.getId() + " has elapsed or updates are forced", true ); } else { return new ArtifactTransferException( artifact, repository, "Failure to transfer " + artifact + " from " + repository.getUrl() + " was cached in the local repository, " + "resolution will not be reattempted until the update interval of " + repository.getId() + " has elapsed or updates are forced. Original error: " + error, true ); } }
public Exception wrap( ArtifactTransfer transfer, Exception e, RemoteRepository repository ) { ArtifactTransferException ex = null; e = WagonCancelledException.unwrap( e ); if ( e instanceof ResourceDoesNotExistException ) { ex = new ArtifactNotFoundException( transfer.getArtifact(), repository ); } else if ( e != null ) { ex = new ArtifactTransferException( transfer.getArtifact(), repository, e ); } transfer.setException( ex ); return ex; }
@Override public void transferFailed( Exception exception, int classification ) { ArtifactTransferException e; if ( classification == Transporter.ERROR_NOT_FOUND ) { e = new ArtifactNotFoundException( getTransfer().getArtifact(), repository ); } else { e = new ArtifactTransferException( getTransfer().getArtifact(), repository, exception ); } getTransfer().setException( e ); super.transferFailed( e, classification ); }
@Override public void transferFailed( Exception exception, int classification ) { ArtifactTransferException e; if ( classification == Transporter.ERROR_NOT_FOUND ) { e = new ArtifactNotFoundException( getTransfer().getArtifact(), repository ); } else { e = new ArtifactTransferException( getTransfer().getArtifact(), repository, exception ); } getTransfer().setException( e ); super.transferFailed( e, classification ); }
download.setException( new ArtifactTransferException( download.getArtifact(), group.repository, e ) );
download.setException( new ArtifactTransferException( download.getArtifact(), group.repository, e ) );
artEx = new ArtifactTransferException( transfer.getArtifact(), repository, e ); transfer.setException( new ArtifactTransferException( transfer.getArtifact(), repository, t ) ); break; case METADATA: