Package org.rssowl.core.connection

Examples of org.rssowl.core.connection.IProtocolHandler


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

    /* Handler present */
    if (handler != null)
      return handler.getLabel(link, monitor);

    /* No Handler present */
    throw new UnknownProtocolException(Activator.getDefault().createErrorStatus(NLS.bind(Messages.ConnectionServiceImpl_ERROR_NO_PROTOCOL_HANDLER, protocol), null), protocol);
  }
View Full Code Here


   * @see org.rssowl.core.connection.IConnectionService#reload(java.net.URI,
   * org.eclipse.core.runtime.IProgressMonitor, java.util.Map)
   */
  public Triple<IFeed, IConditionalGet, URI> reload(URI link, IProgressMonitor monitor, Map<Object, Object> properties) throws CoreException {
    String protocol = link.getScheme();
    IProtocolHandler handler = fProtocolHandler.get(protocol);

    /* Make sure to provide a Monitor */
    if (monitor == null)
      monitor = new NullProgressMonitor();

    /* Handler present */
    if (handler != null)
      return handler.reload(link, monitor, properties);

    /* No Handler present */
    throw new UnknownProtocolException(Activator.getDefault().createErrorStatus(NLS.bind(Messages.ConnectionServiceImpl_ERROR_NO_PROTOCOL_HANDLER, protocol), null), protocol);
  }
View Full Code Here

   * org.rssowl.core.connection.IConnectionService#getFeedIcon(java.net.URI,
   * org.eclipse.core.runtime.IProgressMonitor)
   */
  public byte[] getFeedIcon(URI link, IProgressMonitor monitor) throws ConnectionException {
    String protocol = link.getScheme();
    IProtocolHandler handler = fProtocolHandler.get(protocol);

    /* Handler present */
    if (handler != null)
      return handler.getFeedIcon(link, monitor);

    /* No Handler present */
    throw new UnknownProtocolException(Activator.getDefault().createErrorStatus(NLS.bind(Messages.ConnectionServiceImpl_ERROR_NO_PROTOCOL_HANDLER, protocol), null), protocol);
  }
View Full Code Here

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

    /* Handler present */
    if (handler != null)
      return handler.getFeed(link, monitor);

    /* No Handler present */
    throw new UnknownProtocolException(Activator.getDefault().createErrorStatus(NLS.bind(Messages.ConnectionServiceImpl_ERROR_NO_PROTOCOL_HANDLER, protocol), null), protocol);
  }
View Full Code Here

  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

    return fgSharedAuthToken;
  }

  private static String internalGetGoogleAuthToken(String email, String pw, IProgressMonitor monitor) throws ConnectionException, URISyntaxException, IOException {
    URI uri = new URI(GOOGLE_LOGIN_URL);
    IProtocolHandler handler = Owl.getConnectionService().getHandler(uri);
    if (handler != null) {

      /* Google Specific Parameters */
      Map<String, String> parameters = new HashMap<String, String>();
      parameters.put("accountType", "GOOGLE"); //$NON-NLS-1$ //$NON-NLS-2$
      parameters.put("Email", email); //$NON-NLS-1$
      parameters.put("Passwd", pw); //$NON-NLS-1$
      parameters.put("service", "reader"); //$NON-NLS-1$ //$NON-NLS-2$
      parameters.put("source", "RSSOwl.org-RSSOwl-" + Activator.getDefault().getVersion()); //$NON-NLS-1$ //$NON-NLS-2$

      Map<Object, Object> properties = new HashMap<Object, Object>();
      properties.put(IConnectionPropertyConstants.PARAMETERS, parameters);
      properties.put(IConnectionPropertyConstants.POST, Boolean.TRUE);
      properties.put(IConnectionPropertyConstants.CON_TIMEOUT, getConnectionTimeout());

      BufferedReader reader = null;
      try {
        InputStream inS = handler.openStream(uri, monitor, properties);
        reader = new BufferedReader(new InputStreamReader(inS));
        String line;
        while (!monitor.isCanceled() && (line = reader.readLine()) != null) {
          if (line.startsWith(AUTH_IDENTIFIER))
            return line.substring(AUTH_IDENTIFIER.length());
View Full Code Here

    }
  }

  private static String internalGetGoogleApiToken(String email, String pw, boolean refresh, IProgressMonitor monitor) throws ConnectionException, IOException, URISyntaxException {
    URI uri = new URI(GOOGLE_API_TOKEN_URL);
    IProtocolHandler handler = Owl.getConnectionService().getHandler(uri);
    if (handler != null) {

      String token = SyncUtils.getGoogleAuthToken(email, pw, refresh, monitor);

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

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

      BufferedReader reader = null;
      try {
        InputStream inS = handler.openStream(uri, monitor, properties);
        reader = new BufferedReader(new InputStreamReader(inS));
        String line;
        while (!monitor.isCanceled() && (line = reader.readLine()) != null) {
          return line;
        }
View Full Code Here

   */
  @Test
  public void testGzipConnectionInputStream() throws Exception {
    IConnectionService conManager = Owl.getConnectionService();
    URI url = new URI("http://www.google.com/reader/api/0/stream/contents/feed/http%3A%2F%2Frss.golem.de%2Frss.php%3Ffeed%3DRSS1.0?r=n&n=20&ck=" + System.currentTimeMillis() + "&client=scroll");
    IProtocolHandler handler = conManager.getHandler(url);

    Map<String, String> headers = new HashMap<String, String>();
    String token = SyncUtils.getGoogleAuthToken("rssowl@mailinator.com", "rssowl.org", true, new NullProgressMonitor());
    headers.put("Authorization", SyncUtils.getGoogleAuthorizationHeader(token));
    headers.put("Accept-Charset", "utf-8");
    headers.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1");

    Map<Object, Object> properties = new HashMap<Object, Object>();
    properties.put(IConnectionPropertyConstants.HEADERS, headers);

    InputStream stream = handler.openStream(url, null, properties);

    assertEquals("gzip", ((HttpConnectionInputStream) stream).getContentEncoding());
  }
View Full Code Here

   */
  @Test
  public void testIncomingMergeConflict() throws Exception {
    URI slashdot = new URI("reader://rss.slashdot.org/Slashdot/slashdot");
    IConnectionService conManager = Owl.getConnectionService();
    IProtocolHandler handler = conManager.getHandler(slashdot);

    Map<Object, Object> properties = new HashMap<Object, Object>();
    Map<String, SyncItem> syncitems = new HashMap<String, SyncItem>();
    properties.put(IConnectionPropertyConstants.UNCOMMITTED_ITEMS, syncitems);

    Triple<IFeed, IConditionalGet, URI> result = handler.reload(slashdot, new NullProgressMonitor(), null);

    List<INews> news = result.getFirst().getNews();
    for (int i = 0; i < 10; i++) {
      INews item = news.get(i);
      SyncItem sync = SyncItem.toSyncItem(item);
      syncitems.put(sync.getId(), sync);
      sync.setMarkedRead();
      sync.setStarred();
      sync.addLabel("Foo");
    }

    result = handler.reload(slashdot, new NullProgressMonitor(), properties);
    news = result.getFirst().getNews();
    for (INews item : news) {
      if (syncitems.containsKey(item.getGuid().getValue())) {
        assertTrue(item.getProperty(SyncUtils.GOOGLE_MARKED_READ) != null);
        assertTrue(item.isFlagged());
View Full Code Here

   */
  @Test
  public void testHttpConnectionInputStream() throws Exception {
    IConnectionService conManager = Owl.getConnectionService();
    URI url = new URI("http://www.rssowl.org/favicon.ico");
    IProtocolHandler handler = conManager.getHandler(url);
    InputStream stream = handler.openStream(url, null, null);
    if (stream instanceof HttpConnectionInputStream) {
      HttpConnectionInputStream inS = (HttpConnectionInputStream) stream;
      assertTrue(inS.getContentLength() > 0);
      assertNotNull(inS.getIfModifiedSince());
      assertNotNull(inS.getIfNoneMatch());
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.