Package org.eclipse.ecf.filetransfer

Examples of org.eclipse.ecf.filetransfer.IncomingFileTransferException


    //assertTrue(e.getClass().getName(), cls.isInstance(e));
    return e;
  }
 
  protected IncomingFileTransferException checkGetDoneIncomimgFileTransferException() {
    IncomingFileTransferException e = (IncomingFileTransferException) checkGetDoneException(IncomingFileTransferException.class);
    assertNotNull(e);
    return e;
  }
View Full Code Here


    assertNotNull(e);
    return e;
  }
 
  protected void assertIncomingFileExceptionWithCause(int expectedCode) {
    IncomingFileTransferException e = checkGetDoneIncomimgFileTransferException();
    int code = e.getErrorCode();
    assertTrue(code != -1);
    assertTrue(code == expectedCode);
  }
View Full Code Here

      protocol = remoteFileID.getURI().getScheme();
    } catch (URISyntaxException e) {
      try {
        protocol = remoteFileID.getURL().getProtocol();
      } catch (final MalformedURLException e1) {
        throw new IncomingFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
      }
    }

    IRetrieveFileTransferContainerAdapter fileTransfer = Activator.getDefault().getFileTransfer(protocol);
View Full Code Here

      protocol = remoteFileID.getURI().getScheme();
    } catch (URISyntaxException e) {
      try {
        protocol = remoteFileID.getURL().getProtocol();
      } catch (final MalformedURLException e1) {
        throw new IncomingFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
      }
    }

    IRetrieveFileTransferContainerAdapter fileTransfer = Activator.getDefault().getFileTransfer(protocol);
View Full Code Here

      responseHeaders = getResponseHeaders();
      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, responseHeaders); //$NON-NLS-1$
        } else if (code == HttpURLConnection.HTTP_UNAUTHORIZED) {
          throw new IncomingFileTransferException("Unauthorized", code, responseHeaders); //$NON-NLS-1$
        } else if (code == HttpURLConnection.HTTP_FORBIDDEN) {
          throw new IncomingFileTransferException("Forbidden", code, responseHeaders); //$NON-NLS-1$
        } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
          throw new IncomingFileTransferException("Proxy authentication required", code, responseHeaders); //$NON-NLS-1$
        } else {
          throw new IncomingFileTransferException(NLS.bind("General connection error with response code={0}", new Integer(code)), code, responseHeaders); //$NON-NLS-1$
        }
      } else {
        fireReceiveStartEvent();
      }
    } catch (final FileNotFoundException e) {
      throw new IncomingFileTransferException(NLS.bind("File not found: {0}", getRemoteFileURL().toString()), 404); //$NON-NLS-1$
    } 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, responseHeaders);
      hardClose();
      throw except;
    }
  }
View Full Code Here

        getResumeResponseHeaderValues();
        this.paused = false;
        fireReceiveResumedEvent();
        return true;
      } else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
        throw new IncomingFileTransferException(NLS.bind("File not found: {0}", getRemoteFileURL().toString()), code, responseHeaders); //$NON-NLS-1$
      } else if (code == HttpURLConnection.HTTP_UNAUTHORIZED) {
        throw new IncomingFileTransferException("Unauthorized", code, responseHeaders); //$NON-NLS-1$
      } else if (code == HttpURLConnection.HTTP_FORBIDDEN) {
        throw new IncomingFileTransferException("Forbidden", code, responseHeaders); //$NON-NLS-1$
      } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
        throw new IncomingFileTransferException("Proxy authentication required", code, responseHeaders); //$NON-NLS-1$
      } else {
        throw new IncomingFileTransferException(NLS.bind("General connection error with response code={0}", new Integer(code)), code, responseHeaders); //$NON-NLS-1$
      }
    } catch (final Exception e) {
      this.exception = (e instanceof IncomingFileTransferException) ? e : new IncomingFileTransferException(NLS.bind(Messages.UrlConnectionRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, getRemoteFileURL().toString()), e, code, responseHeaders);
      this.done = true;
      hardClose();
      fireTransferReceiveDoneEvent();
      return false;
    }
View Full Code Here

        }
      }
      remoteFiles = new IRemoteFile[1];
      remoteFiles[0] = new URLRemoteFile(urlConnection.getLastModified(), urlConnection.getContentLength(), fileID);
    } catch (final FileNotFoundException e) {
      throw new IncomingFileTransferException(NLS.bind("File not found: {0}", directoryOrFile.toString()), 404); //$NON-NLS-1$
    } 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;
    }
  }
View Full Code Here

      // Check for NTLM proxy in response headers
      // This check is to deal with bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=252002
      boolean ntlmProxyFound = NTLMProxyDetector.detectNTLMProxy(httpContext);
      if (ntlmProxyFound && !hasForceNTLMProxyOption())
        throw new IncomingFileTransferException("HttpClient Provider is not configured to support NTLM proxy authentication.", HttpClientOptions.NTLM_PROXY_RESPONSE_CODE); //$NON-NLS-1$

      if (NTLMProxyDetector.detectSPNEGOProxy(httpContext))
        throw new BrowseFileTransferException("HttpClient Provider does not support the use of SPNEGO proxy authentication."); //$NON-NLS-1$

      if (code == HttpURLConnection.HTTP_PARTIAL || code == HttpURLConnection.HTTP_OK) {
        getResponseHeaderValues();
        setInputStream(httpResponse.getEntity().getContent());
        fireReceiveStartEvent();
      } else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
        EntityUtils.consume(httpResponse.getEntity());
        throw new IncomingFileTransferException(NLS.bind("File not found: {0}", urlString), code); //$NON-NLS-1$
      } else if (code == HttpURLConnection.HTTP_UNAUTHORIZED) {
        EntityUtils.consume(httpResponse.getEntity());
        throw new IncomingFileTransferException(Messages.HttpClientRetrieveFileTransfer_Unauthorized, code);
      } else if (code == HttpURLConnection.HTTP_FORBIDDEN) {
        EntityUtils.consume(httpResponse.getEntity());
        throw new IncomingFileTransferException("Forbidden", code); //$NON-NLS-1$
      } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
        EntityUtils.consume(httpResponse.getEntity());
        throw new IncomingFileTransferException(Messages.HttpClientRetrieveFileTransfer_Proxy_Auth_Required, code);
      } else {
        Trace.trace(Activator.PLUGIN_ID, EntityUtils.toString(httpResponse.getEntity()));
        //        EntityUtils.consume(httpResponse.getEntity());
        throw new IncomingFileTransferException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_ERROR_GENERAL_RESPONSE_CODE, new Integer(code)), code);
      }
    } catch (final Exception e) {
      Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, this.getClass(), "openStreams", e); //$NON-NLS-1$
      if (code == -1) {
        if (!isDone()) {
          setDoneException(e);
        }
        fireTransferReceiveDoneEvent();
      } else {
        IncomingFileTransferException ex = (IncomingFileTransferException) ((e instanceof IncomingFileTransferException) ? e : new IncomingFileTransferException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, urlString), e, code));
        throw ex;
      }
    }
    Trace.exiting(Activator.PLUGIN_ID, DebugOptions.METHODS_EXITING, this.getClass(), "openStreams"); //$NON-NLS-1$
  }
View Full Code Here

        setInputStream(httpResponse.getEntity().getContent());
        this.paused = false;
        fireReceiveResumedEvent();
      } else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
        EntityUtils.consume(httpResponse.getEntity());
        throw new IncomingFileTransferException(NLS.bind("File not found: {0}", urlString), code, responseHeaders); //$NON-NLS-1$
      } else if (code == HttpURLConnection.HTTP_UNAUTHORIZED) {
        EntityUtils.consume(httpResponse.getEntity());
        throw new IncomingFileTransferException(Messages.HttpClientRetrieveFileTransfer_Unauthorized, code, responseHeaders);
      } else if (code == HttpURLConnection.HTTP_FORBIDDEN) {
        EntityUtils.consume(httpResponse.getEntity());
        throw new IncomingFileTransferException("Forbidden", code, responseHeaders); //$NON-NLS-1$
      } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
        EntityUtils.consume(httpResponse.getEntity());
        throw new IncomingFileTransferException(Messages.HttpClientRetrieveFileTransfer_Proxy_Auth_Required, code, responseHeaders);
      } else {
        EntityUtils.consume(httpResponse.getEntity());
        throw new IncomingFileTransferException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_ERROR_GENERAL_RESPONSE_CODE, new Integer(code)), code, responseHeaders);
      }
      Trace.exiting(Activator.PLUGIN_ID, DebugOptions.METHODS_EXITING, this.getClass(), "openStreamsForResume", Boolean.TRUE); //$NON-NLS-1$
      return true;
    } catch (final Exception e) {
      Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "openStreamsForResume", e); //$NON-NLS-1$
      if (code == -1) {
        if (!isDone()) {
          setDoneException(e);
        }
      } else {
        setDoneException((e instanceof IncomingFileTransferException) ? e : new IncomingFileTransferException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, urlString), e, code, responseHeaders));
      }
      fireTransferReceiveDoneEvent();
      Trace.exiting(Activator.PLUGIN_ID, DebugOptions.METHODS_EXITING, this.getClass(), "openStreamsForResume", Boolean.FALSE); //$NON-NLS-1$
      return false;
    }
View Full Code Here

      // Check for NTLM proxy in response headers
      // This check is to deal with bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=252002
      boolean ntlmProxyFound = NTLMProxyDetector.detectNTLMProxy(getMethod);
      if (ntlmProxyFound && !hasForceNTLMProxyOption())
        throw new IncomingFileTransferException("HttpClient Provider is not configured to support NTLM proxy authentication.", HttpClientOptions.NTLM_PROXY_RESPONSE_CODE); //$NON-NLS-1$

      if (code == HttpURLConnection.HTTP_PARTIAL || code == HttpURLConnection.HTTP_OK) {
        getResponseHeaderValues();
        setInputStream(getMethod.getResponseBodyAsUnzippedStream());
        fireReceiveStartEvent();
      } else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
        getMethod.releaseConnection();
        throw new IncomingFileTransferException(NLS.bind("File not found: {0}", urlString), code); //$NON-NLS-1$
      } else if (code == HttpURLConnection.HTTP_UNAUTHORIZED) {
        getMethod.releaseConnection();
        throw new IncomingFileTransferException(Messages.HttpClientRetrieveFileTransfer_Unauthorized, code);
      } else if (code == HttpURLConnection.HTTP_FORBIDDEN) {
        getMethod.releaseConnection();
        throw new IncomingFileTransferException("Forbidden", code); //$NON-NLS-1$
      } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
        getMethod.releaseConnection();
        throw new IncomingFileTransferException(Messages.HttpClientRetrieveFileTransfer_Proxy_Auth_Required, code);
      } else {
        getMethod.releaseConnection();
        throw new IncomingFileTransferException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_ERROR_GENERAL_RESPONSE_CODE, new Integer(code)), code);
      }
    } catch (final Exception e) {
      Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, this.getClass(), "openStreams", e); //$NON-NLS-1$
      if (code == -1) {
        if (!isDone()) {
          setDoneException(e);
        }
        fireTransferReceiveDoneEvent();
      } else {
        IncomingFileTransferException ex = (IncomingFileTransferException) ((e instanceof IncomingFileTransferException) ? e : new IncomingFileTransferException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, urlString), e, code));
        throw ex;
      }
    }
    Trace.exiting(Activator.PLUGIN_ID, DebugOptions.METHODS_EXITING, this.getClass(), "openStreams"); //$NON-NLS-1$
  }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.filetransfer.IncomingFileTransferException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.