Search in sources :

Example 1 with ArtifactSinkException

use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.ArtifactSinkException in project tycho by eclipse.

the class LocalArtifactRepositoryP2APITest method testGetArtifactToBrokenSink.

@Test(expected = ArtifactSinkException.class)
public void testGetArtifactToBrokenSink() throws Exception {
    IArtifactSink brokenSink = new IArtifactSink() {

        @Override
        public IArtifactKey getArtifactToBeWritten() {
            return ARTIFACT_A_KEY;
        }

        @Override
        public boolean canBeginWrite() {
            return true;
        }

        @Override
        public OutputStream beginWrite() {
            return testOutputStream;
        }

        @Override
        public void commitWrite() throws ArtifactSinkException {
            throw new ArtifactSinkException("simulated error on commit");
        }

        @Override
        public void abortWrite() {
        }
    };
    subject.getArtifact(brokenSink, null);
}
Also used : ArtifactSinkException(org.eclipse.tycho.repository.p2base.artifact.provider.streaming.ArtifactSinkException) IArtifactSink(org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink) Test(org.junit.Test)

Example 2 with ArtifactSinkException

use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.ArtifactSinkException in project tycho by eclipse.

the class AbstractArtifactRepository2 method getRawArtifact.

/**
 * {@inheritDoc}
 *
 * @deprecated Obsolete. Use {@link #getRawArtifact(IRawArtifactSink, IProgressMonitor)}
 *             instead.
 */
// TODO make final?
@Override
@Deprecated
public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
    try {
        IStatus status = getRawArtifact(rawWriteToStream(descriptor, destination), monitor);
        setStatusOnStreamIfPossible(destination, status);
        return status;
    } catch (ArtifactSinkException e) {
        // the sink used shouldn't throw this exception
        return new Status(IStatus.ERROR, BUNDLE_ID, e.getMessage(), e);
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) ArtifactSinkException(org.eclipse.tycho.repository.p2base.artifact.provider.streaming.ArtifactSinkException)

Example 3 with ArtifactSinkException

use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.ArtifactSinkException in project tycho by eclipse.

the class AbstractArtifactRepository2 method getArtifact.

// implementations for old get(Raw)Artifact methods
/**
 * {@inheritDoc}
 *
 * @deprecated Obsolete. Use {@link #getArtifact(IArtifactSink, IProgressMonitor)} instead.
 */
// TODO make final?
@Override
@Deprecated
public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
    try {
        // use any format for getting the canonical artifact
        IArtifactKey requestedKey = descriptor.getArtifactKey();
        IStatus status = getArtifact(writeToStream(requestedKey, destination), monitor);
        setStatusOnStreamIfPossible(destination, status);
        return status;
    } catch (ArtifactSinkException e) {
        // the sink used shouldn't throw this exception
        return new Status(IStatus.ERROR, BUNDLE_ID, e.getMessage(), e);
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) IStatus(org.eclipse.core.runtime.IStatus) ArtifactSinkException(org.eclipse.tycho.repository.p2base.artifact.provider.streaming.ArtifactSinkException)

Aggregations

ArtifactSinkException (org.eclipse.tycho.repository.p2base.artifact.provider.streaming.ArtifactSinkException)3 IStatus (org.eclipse.core.runtime.IStatus)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 Status (org.eclipse.core.runtime.Status)2 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)1 IArtifactSink (org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink)1 Test (org.junit.Test)1