diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/FileDownloadRequest.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/FileDownloadRequest.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/FileDownloadRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/FileDownloadRequest.java new file mode 100644 index 000000000..104d95879 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/FileDownloadRequest.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.prov.artifact.repository; + +import java.io.*; +import org.eclipse.core.runtime.*; +import org.eclipse.equinox.prov.metadata.IArtifactKey; + +public class FileDownloadRequest extends ArtifactRequest { + public static FileDownloadRequest[] NO_REQUEST = new FileDownloadRequest[0]; + + private File destination; //The fully qualified path where the file should be written + + public FileDownloadRequest(IArtifactKey downloadKey, IPath downloadPath) { + super(downloadKey); + destination = destination; + } + + public void perform(IProgressMonitor monitor) { + try { + OutputStream destinationStream = null; + try { + destinationStream = new BufferedOutputStream(new FileOutputStream(destination)); + setResult(source.getArtifact(descriptor, destinationStream, null)); + } finally { + if (destinationStream != null) + destinationStream.close(); + } + } catch (IOException e) { + setResult(new Status(IStatus.ERROR, Activator.ID, "Error downloading " + descriptor + " to " + destination, e)); + }; + } +} |