Package com.google.feedserver.util

Examples of com.google.feedserver.util.FeedServerClientException


  public Map<String, Object> getEntry(URL feedUrl) throws FeedServerClientException {
    try {
      FeedServerEntry entry = service.getEntry(feedUrl, FeedServerEntry.class);
      return getMapFromEntry(entry);
    } catch (IOException e) {
      throw new FeedServerClientException("Error while fetching " + feedUrl, e);
    } catch (ResourceNotFoundException e) {
      return null;
    } catch (ServiceException e) {
      throw new FeedServerClientException(e);
    }
  }
View Full Code Here


    // Retrieve Feed from network
    FeedServerFeed feed;
    try {
      feed = service.getFeed(feedUrl, FeedServerFeed.class);
    } catch (IOException e) {
      throw new FeedServerClientException("Error while fetching " + feedUrl, e);
    } catch (ResourceNotFoundException e) {
      return null;
    } catch (ServiceException e) {
      throw new FeedServerClientException(e);
    }

    // Go through all entries and build the map.
    List<Map<String, Object>> feedMap = new ArrayList<Map<String, Object>>();
    for (FeedServerEntry entry : feed.getEntries()) {
View Full Code Here

   */
  public void deleteEntry(URL entryUrl) throws FeedServerClientException {
    try {
      service.delete(entryUrl);
    } catch (IOException e) {
      throw new FeedServerClientException("Error while deleting " + entryUrl, e);
    } catch (ServiceException e) {
      throw new FeedServerClientException(e);
    }
  }
View Full Code Here

  public void deleteEntry(URL feedUrl, Map<String, Object> entry) throws FeedServerClientException {
    try {
      String entryUrl = (String) entry.get(ContentUtil.ID);
      deleteEntry(new URL(entryUrl));
    } catch (MalformedURLException e) {
      throw new FeedServerClientException("invalid base URL", e);
    }
  }
View Full Code Here

    for (Map<String, Object> entry : entries) {
      URL entryUrl;
      try {
        entryUrl = new URL(getEntryId(entry));
      } catch (MalformedURLException e) {
        throw new FeedServerClientException(e);
      }
      deleteEntry(entryUrl);
    }
  }
View Full Code Here

      FeedServerEntry entry = service.update(entryUrl, getEntryFromMap(mapEntry));
      return getMapFromEntry(entry);
    } catch (MalformedURLException e) {
      throw new RuntimeException("Invalid URL", e);
    } catch (IOException e) {
      throw new FeedServerClientException("Error while deleting " + entryUrl, e);
    } catch (ResourceNotFoundException e) {
      return null;
    } catch (ServiceException e) {
      throw new FeedServerClientException(e);
    } catch (NullPointerException e) {
      throw new RuntimeException("Invalid Entry", e);
    } catch (ClassCastException e) {
      throw new RuntimeException("entry map does not have 'name' key as String", e);
    }
View Full Code Here

    for (Map<String, Object> entry : entries) {
      URL entryUrl;
      try {
        entryUrl = new URL(getEntryId(entry));
      } catch (MalformedURLException e) {
        throw new FeedServerClientException(e);
      }
      updateEntry(entryUrl, entry);
    }
  }
View Full Code Here

      FeedServerEntry insertedEntry = service.insert(feedUrl, getEntryFromMap(entry));
      return getMapFromEntry(insertedEntry);
    } catch (MalformedURLException e) {
      throw new RuntimeException("Invalid URL", e);
    } catch (IOException e) {
      throw new FeedServerClientException("Error while inserting " + feedUrl, e);
    } catch (ServiceException e) {
      throw new FeedServerClientException(e);
    } catch (NullPointerException e) {
      throw new RuntimeException("Invalid Entry", e);
    } catch (ClassCastException e) {
      throw new RuntimeException("entry map does not have 'name' key as String", e);
    }
View Full Code Here

  public Map<String, Object> getMapFromXml(String xmlText) throws FeedServerClientException {
    try {
      Map<String, Object> rawEntryMap = xmlUtil.convertXmlToProperties(xmlText);
      return rawEntryMap;
    } catch (SAXException e) {
      throw new FeedServerClientException(e);
    } catch (IOException e) {
      throw new FeedServerClientException(e);
    } catch (ParserConfigurationException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

        }
        // copy id which is the same as self and edit link
        entity.put(ContentUtil.ID, entry.getId());
        return entity;
      } catch (SAXException e) {
        throw new FeedServerClientException(e);
      } catch (IOException e) {
        throw new FeedServerClientException(e);
      } catch (ParserConfigurationException e) {
        throw new RuntimeException(e);
      }
    } else if (content instanceof TextContent) {
      TextContent textContent = (TextContent) content;
      TextConstruct textConstruct = textContent.getContent();

      int type = textContent.getContent().getType();
      String typeName;
      String text;
      switch (type) {
        case TextConstruct.Type.HTML:
          typeName = "html";
          text = ((HtmlTextConstruct) textConstruct).getHtml();
          break;

        case TextConstruct.Type.TEXT:
          typeName = "text";
          text = ((PlainTextConstruct) textConstruct).getPlainText();
          break;

        case TextConstruct.Type.XHTML:
          typeName = "xhtml";
          text = ((XhtmlTextConstruct) textConstruct).getXhtml().getBlob();
          break;

        default:
          typeName = "unknown";
          text = textConstruct.toString();
      }

      Map<String, Object> entity = new HashMap<String, Object>();
      entity.put("content", text);
      entity.put("type", typeName);

      String lang = textContent.getContent().getLang();
      if (lang != null) {
        entity.put("lang", lang);
      }

      return entity;
    } else {
      throw new FeedServerClientException("Unsupported content class " +
          content.getClass().getName());
    }
  }
View Full Code Here

TOP

Related Classes of com.google.feedserver.util.FeedServerClientException

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.