public static IStatus getStatus(OutputStream stream) { if (stream instanceof IStateful) return ((IStateful) stream).getStatus(); return Status.OK_STATUS; }
private IStatus transferSingle(IArtifactDescriptor destinationDescriptor, IArtifactDescriptor sourceDescriptor, IProgressMonitor monitor) { OutputStream destination; try { destination = target.getOutputStream(destinationDescriptor); } catch (ProvisionException e) { return e.getStatus(); } IStatus status = null; // Do the actual transfer try { status = getArtifact(sourceDescriptor, destination, monitor); if (destination instanceof IStateful && status != null && !status.isOK()) { IStatus destStatus = ((IStateful) destination).getStatus(); IStatus root = extractRootCause(status); Throwable e = root != null ? root.getException() : null; ((IStateful) destination).setStatus(new MultiStatus(Activator.ID, status.getCode(), new IStatus[] {status, destStatus}, status.getMessage(), e)); } } finally { try { destination.close(); } catch (IOException e) { if (status != null && status.getSeverity() == IStatus.ERROR && status.getCode() == IArtifactRepository.CODE_RETRY) return new MultiStatus(Activator.ID, status.getCode(), new IStatus[] {status}, NLS.bind(Messages.error_closing_stream, getArtifactKey(), target.getLocation()), e); return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.error_closing_stream, getArtifactKey(), target.getLocation()), e); } } return status; }
/** * Set the status on the output stream if it implements IStateful. * Update the DownloadStatus with information from FileReader. * @param target an OutputStream possibly implementing IStateful * @param status a DownloadStatus configured with status message, code, etc * @param reader a FileReade that was used to download (or null if not known). * @throws OperationCanceledException if the operation was canceled by the user. * @return the configured DownloadStatus status. */ private static DownloadStatus statusOn(OutputStream target, DownloadStatus status, FileReader reader) { if (reader != null) { FileInfo fi = reader.getLastFileInfo(); if (fi != null) { status.setFileSize(fi.getSize()); status.setLastModified(fi.getLastModified()); status.setTransferRate(fi.getAverageSpeed()); } } if (target instanceof IStateful) ((IStateful) target).setStatus(status); return status; }
status = getArtifact(sourceDescriptor, destination, monitor); if (destination instanceof IStateful && status != null && !status.isOK()) { IStatus destStatus = ((IStateful) destination).getStatus(); IStatus root = extractRootCause(status); Throwable e = root != null ? root.getException() : null; ((IStateful) destination).setStatus(new MultiStatus(Activator.ID, status.getCode(), new IStatus[] {status, destStatus}, status.getMessage(), e));
/** * Set the status on the output stream if it implements IStateful. * Update the DownloadStatus with information from FileReader. * @param target an OutputStream possibly implementing IStateful * @param status a DownloadStatus configured with status message, code, etc * @param reader a FileReade that was used to download (or null if not known). * @throws OperationCanceledException if the operation was canceled by the user. * @return the configured DownloadStatus status. */ private static DownloadStatus statusOn(OutputStream target, DownloadStatus status, FileReader reader) { if (reader != null) { FileInfo fi = reader.getLastFileInfo(); if (fi != null) { status.setFileSize(fi.getSize()); status.setLastModified(fi.getLastModified()); status.setTransferRate(fi.getAverageSpeed()); } } if (target instanceof IStateful) ((IStateful) target).setStatus(status); return status; }
status = getArtifact(sourceDescriptor, destination, monitor); if (destination instanceof IStateful && status != null && !status.isOK()) { IStatus destStatus = ((IStateful) destination).getStatus(); IStatus root = extractRootCause(status); Throwable e = root != null ? root.getException() : null; ((IStateful) destination).setStatus(new MultiStatus(Activator.ID, status.getCode(), new IStatus[] {status, destStatus}, status.getMessage(), e));
/** * Set the status on the output stream if it implements IStateful. * Update the DownloadStatus with information from FileReader. * @param target an OutputStream possibly implementing IStateful * @param status a DownloadStatus configured with status message, code, etc * @param reader a FileReade that was used to download (or null if not known). * @throws OperationCanceledException if the operation was canceled by the user. * @return the configured DownloadStatus status. */ private static DownloadStatus statusOn(OutputStream target, DownloadStatus status, FileReader reader) { if (reader != null) { FileInfo fi = reader.getLastFileInfo(); if (fi != null) { status.setFileSize(fi.getSize()); status.setLastModified(fi.getLastModified()); status.setTransferRate(fi.getAverageSpeed()); } } if (target instanceof IStateful) ((IStateful) target).setStatus(status); return status; }
public static IStatus getStatus(OutputStream stream) { if (stream instanceof IStateful) return ((IStateful) stream).getStatus(); return Status.OK_STATUS; }
status = getArtifact(sourceDescriptor, destination, monitor); if (destination instanceof IStateful && status != null && !status.isOK()) { IStatus destStatus = ((IStateful) destination).getStatus(); IStatus root = extractRootCause(status); Throwable e = root != null ? root.getException() : null; ((IStateful) destination).setStatus(new MultiStatus(Activator.ID, status.getCode(), new IStatus[] {status, destStatus}, status.getMessage(), e));
public static IStatus getStatus(OutputStream stream) { if (stream instanceof IStateful) return ((IStateful) stream).getStatus(); return Status.OK_STATUS; }
public static IStatus getStatus(OutputStream stream) { if (stream instanceof IStateful) return ((IStateful) stream).getStatus(); return Status.OK_STATUS; }