use of org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository in project tycho by eclipse.
the class SimpleArtifactRepositoryIO method write.
/**
* Writes the given artifact repository to the stream. This method performs buffering, and
* closes the stream when finished.
*/
public void write(SimpleArtifactRepository repository, OutputStream output) {
OutputStream bufferedOutput = null;
try {
try {
bufferedOutput = new BufferedOutputStream(output);
Writer repositoryWriter = new Writer(bufferedOutput);
repositoryWriter.write(repository);
} finally {
if (bufferedOutput != null) {
bufferedOutput.close();
}
}
} catch (IOException ioe) {
// TODO shouldn't this throw a core exception?
ioe.printStackTrace();
}
}
use of org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository in project tycho by eclipse.
the class SimpleArtifactRepositoryIO method read.
/**
* Reads the artifact repository from the given stream, and returns the contained array of
* abstract artifact repositories.
*
* This method performs buffering, and closes the stream when finished.
*/
public IArtifactRepository read(URL location, InputStream input, IProgressMonitor monitor) throws ProvisionException {
BufferedInputStream bufferedInput = null;
try {
try {
bufferedInput = new BufferedInputStream(input);
Parser repositoryParser = new Parser(Activator.getContext(), Activator.ID);
repositoryParser.parse(input);
IStatus result = repositoryParser.getStatus();
switch(result.getSeverity()) {
case IStatus.CANCEL:
throw new OperationCanceledException();
case IStatus.ERROR:
throw new ProvisionException(result);
case IStatus.WARNING:
case IStatus.INFO:
LogHelper.log(result);
break;
case IStatus.OK:
break;
default:
// $NON-NLS-1$
throw new IllegalStateException("Unknown serverity value: " + result.getSeverity());
}
SimpleArtifactRepository repository = repositoryParser.getRepository();
if (repository == null)
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, Messages.io_parseError, null));
return repository;
} finally {
if (bufferedInput != null)
bufferedInput.close();
}
} catch (IOException ioe) {
String msg = NLS.bind(Messages.io_failedRead, location);
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, msg, ioe));
}
}
Aggregations