Package org.rssowl.core.connection

Examples of org.rssowl.core.connection.IProtocolHandler


  private void registerURLStreamHandlers() {

    /* Foreach Contributed Protocol */
    for (String protocol : fProtocolHandler.keySet()) {
      IProtocolHandler protocolHandler = fProtocolHandler.get(protocol);

      /* A URLStreamHandler is provided */
      try {
        if (protocolHandler.getURLStreamHandler() != null) {
          Hashtable<String, String[]> properties = new Hashtable<String, String[]>(1);
          properties.put(URLConstants.URL_HANDLER_PROTOCOL, new String[] { protocol });
          Activator.getDefault().getContext().registerService(URLStreamHandlerService.class.getName(), protocolHandler.getURLStreamHandler(), properties);
        }
      } catch (ConnectionException e) {
        Activator.getDefault().getLog().log(e.getStatus());
      }
    }
View Full Code Here


  @SuppressWarnings("restriction")
  private void saveAsXml(final String fileName) {
    final IBookMark bm = (IBookMark) fInput.getMark();
    final URI feedLink = bm.getFeedLinkReference().getLink();
    try {
      final IProtocolHandler handler = Owl.getConnectionService().getHandler(feedLink);
      if (handler instanceof org.rssowl.core.internal.connection.DefaultProtocolHandler) {
        Job downloadJob = new Job(Messages.FeedView_DOWNLOADING_FEED) {
          @Override
          protected IStatus run(IProgressMonitor monitor) {
            monitor.beginTask(bm.getName(), IProgressMonitor.UNKNOWN);

            InputStream in = null;
            FileOutputStream out = null;
            boolean canceled = false;
            Exception error = null;
            try {
              byte[] buffer = new byte[8192];

              in = handler.openStream(feedLink, monitor, null);
              out = new FileOutputStream(fileName);
              while (true) {

                /* Check for Cancellation and Shutdown */
                if (monitor.isCanceled() || Controller.getDefault().isShuttingDown()) {
View Full Code Here

            /* Return if dialog closed */
            if (monitor.isCanceled() || getShell().isDisposed() || fBrowser.getControl().isDisposed())
              return;

            /* Retrieve Stream */
            IProtocolHandler handler = Owl.getConnectionService().getHandler(feed.getLink());
            InputStream inS = handler.openStream(feed.getLink(), monitor, null);

            /* Return if dialog closed */
            if (monitor.isCanceled() || getShell().isDisposed() || fBrowser.getControl().isDisposed())
              return;

View Full Code Here

  @SuppressWarnings("restriction")
  private void saveAsXml(final String fileName) {
    final IBookMark bm = (IBookMark) fInput.getMark();
    final URI feedLink = bm.getFeedLinkReference().getLink();
    try {
      final IProtocolHandler handler = Owl.getConnectionService().getHandler(feedLink);
      if (handler instanceof org.rssowl.core.internal.connection.DefaultProtocolHandler) {
        Job downloadJob = new Job(Messages.FeedView_DOWNLOADING_FEED) {
          @Override
          protected IStatus run(IProgressMonitor monitor) {
            monitor.beginTask(bm.getName(), IProgressMonitor.UNKNOWN);

            InputStream in = null;
            FileOutputStream out = null;
            boolean canceled = false;
            Exception error = null;
            try {
              byte[] buffer = new byte[8192];

              in = handler.openStream(feedLink, monitor, null);
              out = new FileOutputStream(fileName);
              while (true) {

                /* Check for Cancellation and Shutdown */
                if (monitor.isCanceled() || Controller.getDefault().isShuttingDown()) {
View Full Code Here

        in.close();
    }
  }

  private InputStream openStream(URI link, IProgressMonitor monitor, int timeout, boolean setAcceptLanguage, boolean isLocalized, String authToken) throws ConnectionException {
    IProtocolHandler handler = Owl.getConnectionService().getHandler(link);

    Map<Object, Object> properties = new HashMap<Object, Object>();
    properties.put(IConnectionPropertyConstants.CON_TIMEOUT, timeout);

    /* Set Authorization Header if required */
    if (StringUtils.isSet(authToken)) {
      Map<String, String> headers = new HashMap<String, String>();
      headers.put("Authorization", SyncUtils.getGoogleAuthorizationHeader(authToken)); //$NON-NLS-1$
      properties.put(IConnectionPropertyConstants.HEADERS, headers);
    }

    /* Set the Accept-Language Header */
    if (setAcceptLanguage) {
      StringBuilder languageHeader = new StringBuilder();
      String clientLanguage = Locale.getDefault().getLanguage();

      /* Set Both English and Client Locale */
      if (!isLocalized) {
        languageHeader.append(DEFAULT_LANGUAGE);
        if (StringUtils.isSet(clientLanguage) && !DEFAULT_LANGUAGE.equals(clientLanguage))
          languageHeader.append(",").append(clientLanguage); //$NON-NLS-1$
      }

      /* Only set Client Locale */
      else {
        if (StringUtils.isSet(clientLanguage))
          languageHeader.append(clientLanguage);
        else
          languageHeader.append(DEFAULT_LANGUAGE);
      }

      properties.put(IConnectionPropertyConstants.ACCEPT_LANGUAGE, languageHeader.toString());
    }

    return handler.openStream(link, monitor, properties);
  }
View Full Code Here

      @Override
      protected void runInBackground(IProgressMonitor monitor) {
        try {
          URI uri = new URI(transformedUrl);
          IProtocolHandler handler = Owl.getConnectionService().getHandler(uri);
          if (handler != null) {
            BufferedReader reader = null;
            try {
              InputStream inS = handler.openStream(uri, monitor, null);
              reader = new BufferedReader(new InputStreamReader(inS, "UTF-8")); //$NON-NLS-1$
              String line;
              while (!monitor.isCanceled() && (line = reader.readLine()) != null) {
                result.append(line);
              }
View Full Code Here

      if (monitor.isCanceled() || !StringUtils.isSet(authToken))
        return null;

      /* Import from Google */
      URI opmlImportUri = URI.create(SyncUtils.GOOGLE_READER_OPML_URI);
      IProtocolHandler handler = Owl.getConnectionService().getHandler(opmlImportUri);

      Map<Object, Object> properties = new HashMap<Object, Object>();
      Map<String, String> headers = new HashMap<String, String>();
      headers.put("Authorization", SyncUtils.getGoogleAuthorizationHeader(authToken)); //$NON-NLS-1$
      properties.put(IConnectionPropertyConstants.HEADERS, headers);

      inS = handler.openStream(opmlImportUri, monitor, properties);

      /* Return on Cancellation */
      if (monitor.isCanceled()) {
        isCanceled = true;
        return null;
View Full Code Here

    if (isCanceled(monitor))
      return itemCount;

    /* Perform POST */
    URI uri = URI.create(SyncUtils.GOOGLE_EDIT_TAG_URL);
    IProtocolHandler handler = Owl.getConnectionService().getHandler(uri);
    InputStream inS = null;
    try {
      inS = handler.openStream(uri, new NullProgressMonitor(), properties); //Do not allow to cancel this outgoing request for transactional reasons
      fSyncItemsManager.removeUncommitted(equivalentItems);
      itemCount += equivalentItems.size();
    } finally {
      if (inS != null) {
        try {
View Full Code Here

    job.setProperty(IProgressConstants.ICON_PROPERTY, OwlUI.getAttachmentImage(downloadFileName, request.getType()));

    int bytesConsumed = 0;
    try {
      IProtocolHandler handler = Owl.getConnectionService().getHandler(request.getLink());
      if (handler != null) {
        Map<Object, Object> properties = new HashMap<Object, Object>();
        properties.put(IConnectionPropertyConstants.CON_TIMEOUT, DEFAULT_CON_TIMEOUT);

        /* Check for Cancellation and Shutdown */
        if (monitor.isCanceled() || Controller.getDefault().isShuttingDown())
          return Status.CANCEL_STATUS;

        /* Initialize Fields */
        long bytesPerSecond = 0;
        long lastTaskNameUpdate = 0;
        long lastBytesCheck = 0;
        int length = request.getLength();
        byte[] buffer = new byte[8192];

        /* First Download to a temporary File */
        int contentLength = length;
        InputStream in = null;
        FileOutputStream out = null;
        File partFile = null;
        boolean canceled = false;
        Exception error = null;
        try {

          /* Open Stream */
          in = handler.openStream(request.getLink(), monitor, properties);

          /* Obtain real Content Length from Stream if available */
          if (in instanceof HttpConnectionInputStream) {
            int len = ((HttpConnectionInputStream) in).getContentLength();
            if (len > 0)
View Full Code Here

  /*
   * @see org.rssowl.core.connection.IConnectionService#getHandler(java.net.URI)
   */
  public IProtocolHandler getHandler(URI link) throws ConnectionException {
    String protocol = link.getScheme();
    IProtocolHandler handler = fProtocolHandler.get(protocol);

    /* Handler present */
    if (handler != null)
      return handler;

View Full Code Here

TOP

Related Classes of org.rssowl.core.connection.IProtocolHandler

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.