diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java index 7c53b92e59f..22cac567bf0 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java @@ -818,18 +818,18 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I } /** - * Defers to the file service. + * Defers to the file service. The method is basically another way to do download. * @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem#getInputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) */ public InputStream getInputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException { - return getFileService().getInputStream(remoteParent, remoteFile, isBinary, monitor); + return new FileSubSystemInputStream(getFileService().getInputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this); } /** - * Defers to the file service. + * Defers to the file service. The method is basically another way to do upload. * @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem#getOutputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) */ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException { - return getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor); + return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this); } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileSubSystemInputStream.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileSubSystemInputStream.java new file mode 100644 index 00000000000..4121769dca5 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileSubSystemInputStream.java @@ -0,0 +1,85 @@ +/******************************************************************************** + * Copyright (c) 2007 IBM Corporation. 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight. + * + * Contributors: + * David McKnight (IBM) - [207100] decorated input stream + ********************************************************************************/ +package org.eclipse.rse.subsystems.files.core.servicesubsystem; + +import java.io.IOException; +import java.io.InputStream; + +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.events.ISystemRemoteChangeEvents; +import org.eclipse.rse.core.events.SystemRemoteChangeEvent; +import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; + +/** + * Decorates an input stream that was created in the service layer. + * The purpose of this class is to notify download after the stream is closed. + */ +public class FileSubSystemInputStream extends InputStream { + + private InputStream _inStream; + private String _remoteParent; + private String _remoteFile; + private IRemoteFileSubSystem _fs; + + public FileSubSystemInputStream(InputStream inStream, String remoteParent, String remoteFile, IRemoteFileSubSystem fs) + { + _inStream = inStream; + _remoteParent = remoteParent; + _remoteFile = remoteFile; + _fs = fs; + } + + public int available() throws IOException { + return _inStream.available(); + } + + public void close() throws IOException { + _inStream.close(); + + // notify that the file was uploaded + ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); + + sr.fireEvent(new SystemRemoteChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_UPLOADED, _remoteParent, _remoteFile, _fs)); + } + + public synchronized void mark(int readlimit) { + _inStream.mark(readlimit); + } + + public boolean markSupported() { + return _inStream.markSupported(); + } + + public int read(byte[] b, int off, int len) throws IOException { + return _inStream.read(b, off, len); + } + + public int read(byte[] b) throws IOException { + return _inStream.read(b); + } + + public synchronized void reset() throws IOException { + _inStream.reset(); + } + + public long skip(long n) throws IOException { + return _inStream.skip(n); + } + + public int read() throws IOException { + return _inStream.read(); + } + +} diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileSubSystemOutputStream.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileSubSystemOutputStream.java new file mode 100644 index 00000000000..92b32537ce5 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileSubSystemOutputStream.java @@ -0,0 +1,71 @@ +/******************************************************************************** + * Copyright (c) 2007 IBM Corporation. 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight. + * + * Contributors: + * David McKnight (IBM) - [207100] decorated output stream + ********************************************************************************/ +package org.eclipse.rse.subsystems.files.core.servicesubsystem; + +import java.io.IOException; +import java.io.OutputStream; + +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.events.ISystemRemoteChangeEvents; +import org.eclipse.rse.core.events.SystemRemoteChangeEvent; +import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; + +/** + * Decorates an output stream that was created in the service layer. + * The purpose of this class is to notify upload after the stream is closed. + * + */ +public class FileSubSystemOutputStream extends OutputStream { + + private OutputStream _outStream; + private String _remoteParent; + private String _remoteFile; + private IRemoteFileSubSystem _fs; + + + public FileSubSystemOutputStream(OutputStream outStream, String remoteParent, String remoteFile, IRemoteFileSubSystem fs) + { + _outStream = outStream; + _remoteParent = remoteParent; + _remoteFile = remoteFile; + _fs = fs; + } + + public void close() throws IOException { + _outStream.close(); + + // notify that the file was uploaded + ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); + + sr.fireEvent(new SystemRemoteChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_UPLOADED, _remoteParent, _remoteFile, _fs)); + } + + public void flush() throws IOException { + _outStream.flush(); + } + + public void write(byte[] b, int off, int len) throws IOException { + _outStream.write(b, off, len); + } + + public void write(byte[] b) throws IOException { + _outStream.write(b); + } + + public void write(int b) throws IOException { + _outStream.write(b); + } + +}