Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-05-05 17:27:53 -0400
committerslewis2009-05-05 17:27:53 -0400
commit2dc3f7c9a9667efd9a2d72e91ed28755f432fa8b (patch)
treebe5705e2c7cc5047c87d3ef7b2877aef2f6aef76 /providers/bundles/org.eclipse.ecf.provider.filetransfer
parent64ab8c1f9eff4dbb3145c2de0775b2664497f89c (diff)
downloadorg.eclipse.ecf-2dc3f7c9a9667efd9a2d72e91ed28755f432fa8b.tar.gz
org.eclipse.ecf-2dc3f7c9a9667efd9a2d72e91ed28755f432fa8b.tar.xz
org.eclipse.ecf-2dc3f7c9a9667efd9a2d72e91ed28755f432fa8b.zip
Fix for jar bug introduced in earlier checkinv20090505-1437
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.java34
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java27
2 files changed, 36 insertions, 25 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 96d8d4cf7..416e14b6c 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
@@ -104,26 +104,34 @@ public class URLFileSystemBrowser extends AbstractFileSystemBrowser {
InputStream ins = urlConnection.getInputStream();
code = getResponseCode(urlConnection);
ins.close();
- 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$
+ if (isHTTP()) {
+ 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$
+ }
}
+ remoteFiles = new IRemoteFile[1];
+ remoteFiles[0] = new URLRemoteFile(urlConnection.getLastModified(), urlConnection.getContentLength(), fileID);
} catch (Exception e) {
Exception except = (e instanceof BrowseFileTransferException) ? e : new BrowseFileTransferException(NLS.bind("Could not connect to {0}", directoryOrFile), e, code); //$NON-NLS-1$
throw except;
}
}
+ private boolean isHTTP() {
+ final String protocol = directoryOrFile.getProtocol();
+ if (protocol.equalsIgnoreCase("http") || protocol.equalsIgnoreCase("https")) //$NON-NLS-1$ //$NON-NLS-2$
+ return true;
+ return false;
+ }
+
private int getResponseCode(URLConnection urlConnection) {
int responseCode = -1;
String response = urlConnection.getHeaderField(0);
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 7f2f28b15..bb1560f1a 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
@@ -286,19 +286,22 @@ public class UrlConnectionRetrieveFileTransfer extends AbstractRetrieveFileTrans
setCompressionRequestHeader();
setInputStream(getDecompressedStream());
code = getResponseCode();
- if (code == HttpURLConnection.HTTP_PARTIAL || code == HttpURLConnection.HTTP_OK) {
- getResponseHeaderValues();
- fireReceiveStartEvent();
- } else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
- 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) {
- throw new IncomingFileTransferException("Forbidden", code); //$NON-NLS-1$
- } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
- throw new IncomingFileTransferException("Proxy authentication required", code); //$NON-NLS-1$
+ if (isHTTP()) {
+ if (code == HttpURLConnection.HTTP_PARTIAL || code == HttpURLConnection.HTTP_OK) {
+ fireReceiveStartEvent();
+ } else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
+ 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) {
+ throw new IncomingFileTransferException("Forbidden", code); //$NON-NLS-1$
+ } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
+ throw new IncomingFileTransferException("Proxy authentication required", code); //$NON-NLS-1$
+ } else {
+ throw new IncomingFileTransferException(NLS.bind("General connection error with response code={0}", new Integer(code)), code); //$NON-NLS-1$
+ }
} else {
- throw new IncomingFileTransferException(NLS.bind("General connection error with response code={0}", new Integer(code)), code); //$NON-NLS-1$
+ fireReceiveStartEvent();
}
} catch (final Exception e) {
IncomingFileTransferException except = (e instanceof IncomingFileTransferException) ? (IncomingFileTransferException) e : new IncomingFileTransferException(NLS.bind(Messages.UrlConnectionRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, getRemoteFileURL().toString()), e, code);

Back to the top