Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-05-05 13:21:24 -0400
committerslewis2009-05-05 13:21:24 -0400
commit64ab8c1f9eff4dbb3145c2de0775b2664497f89c (patch)
treef2f63cec632da940919d52ebae109876d3d8bed3 /providers/bundles/org.eclipse.ecf.provider.filetransfer
parent060b754127c92958664870912dea3b8ed3c85382 (diff)
downloadorg.eclipse.ecf-64ab8c1f9eff4dbb3145c2de0775b2664497f89c.tar.gz
org.eclipse.ecf-64ab8c1f9eff4dbb3145c2de0775b2664497f89c.tar.xz
org.eclipse.ecf-64ab8c1f9eff4dbb3145c2de0775b2664497f89c.zip
Added BrowseFileTransferException and OutgoingFileTransferException as per bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=274632v20090505-1104
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.filetransfer')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/URLFileSystemBrowser.java20
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java13
2 files changed, 23 insertions, 10 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/URLFileSystemBrowser.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/URLFileSystemBrowser.java
index 52ae5acd5..96d8d4cf7 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/URLFileSystemBrowser.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/URLFileSystemBrowser.java
@@ -14,6 +14,7 @@ package org.eclipse.ecf.provider.filetransfer.browse;
import java.io.IOException;
import java.io.InputStream;
import java.net.Authenticator;
+import java.net.HttpURLConnection;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.net.URLConnection;
@@ -103,10 +104,23 @@ public class URLFileSystemBrowser extends AbstractFileSystemBrowser {
InputStream ins = urlConnection.getInputStream();
code = getResponseCode(urlConnection);
ins.close();
- remoteFiles = new IRemoteFile[1];
- remoteFiles[0] = new URLRemoteFile(urlConnection.getLastModified(), urlConnection.getContentLength(), fileID);
+ if (code == HttpURLConnection.HTTP_OK) {
+ remoteFiles = new IRemoteFile[1];
+ remoteFiles[0] = new URLRemoteFile(urlConnection.getLastModified(), urlConnection.getContentLength(), fileID);
+ } else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
+ throw new BrowseFileTransferException(NLS.bind("File not found: {0}", directoryOrFile.toString()), code); //$NON-NLS-1$
+ } else if (code == HttpURLConnection.HTTP_UNAUTHORIZED) {
+ throw new BrowseFileTransferException("Unauthorized", code); //$NON-NLS-1$
+ } else if (code == HttpURLConnection.HTTP_FORBIDDEN) {
+ throw new BrowseFileTransferException("Forbidden", code); //$NON-NLS-1$
+ } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
+ throw new BrowseFileTransferException("Proxy auth required", code); //$NON-NLS-1$
+ } else {
+ throw new BrowseFileTransferException(NLS.bind("General connection error with response code={0}", new Integer(code)), code); //$NON-NLS-1$
+ }
} catch (Exception e) {
- throw new BrowseFileTransferException(NLS.bind("Could not connect to {0}", directoryOrFile), e, code); //$NON-NLS-1$
+ Exception except = (e instanceof BrowseFileTransferException) ? e : new BrowseFileTransferException(NLS.bind("Could not connect to {0}", directoryOrFile), e, code); //$NON-NLS-1$
+ throw except;
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java
index 9e26bcb24..7f2f28b15 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java
@@ -9,7 +9,6 @@
******************************************************************************/
package org.eclipse.ecf.provider.filetransfer.retrieve;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.Authenticator;
@@ -291,7 +290,7 @@ public class UrlConnectionRetrieveFileTransfer extends AbstractRetrieveFileTrans
getResponseHeaderValues();
fireReceiveStartEvent();
} else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
- throw new FileNotFoundException(getRemoteFileName());
+ throw new IncomingFileTransferException(NLS.bind("File not found: {0}", getRemoteFileURL().toString()), code); //$NON-NLS-1$
} else if (code == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new IncomingFileTransferException("Unauthorized", code); //$NON-NLS-1$
} else if (code == HttpURLConnection.HTTP_FORBIDDEN) {
@@ -299,10 +298,10 @@ public class UrlConnectionRetrieveFileTransfer extends AbstractRetrieveFileTrans
} else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
throw new IncomingFileTransferException("Proxy authentication required", code); //$NON-NLS-1$
} else {
- throw new IOException(NLS.bind("General connection error with response code={0}", new Integer(code))); //$NON-NLS-1$
+ throw new IncomingFileTransferException(NLS.bind("General connection error with response code={0}", new Integer(code)), code); //$NON-NLS-1$
}
} catch (final Exception e) {
- IncomingFileTransferException except = new IncomingFileTransferException(NLS.bind(Messages.UrlConnectionRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, getRemoteFileURL().toString()), e, code);
+ IncomingFileTransferException except = (e instanceof IncomingFileTransferException) ? (IncomingFileTransferException) e : new IncomingFileTransferException(NLS.bind(Messages.UrlConnectionRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, getRemoteFileURL().toString()), e, code);
hardClose();
throw except;
}
@@ -399,7 +398,7 @@ public class UrlConnectionRetrieveFileTransfer extends AbstractRetrieveFileTrans
fireReceiveResumedEvent();
return true;
} else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
- throw new FileNotFoundException(getRemoteFileName());
+ throw new IncomingFileTransferException(NLS.bind("File not found: {0}", getRemoteFileURL().toString()), code); //$NON-NLS-1$
} else if (code == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new IncomingFileTransferException("Unauthorized", code); //$NON-NLS-1$
} else if (code == HttpURLConnection.HTTP_FORBIDDEN) {
@@ -407,10 +406,10 @@ public class UrlConnectionRetrieveFileTransfer extends AbstractRetrieveFileTrans
} else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
throw new IncomingFileTransferException("Proxy authentication required", code); //$NON-NLS-1$
} else {
- throw new IOException(NLS.bind("General connection error with response code={0}", new Integer(code))); //$NON-NLS-1$
+ throw new IncomingFileTransferException(NLS.bind("General connection error with response code={0}", new Integer(code)), code); //$NON-NLS-1$
}
} catch (final Exception e) {
- this.exception = new IncomingFileTransferException(NLS.bind(Messages.UrlConnectionRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, getRemoteFileURL().toString()), e, code);
+ this.exception = (e instanceof IncomingFileTransferException) ? e : new IncomingFileTransferException(NLS.bind(Messages.UrlConnectionRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, getRemoteFileURL().toString()), e, code);
this.done = true;
hardClose();
fireTransferReceiveDoneEvent();

Back to the top