Package com.google.gdata.data

Examples of com.google.gdata.data.Entry


       cachedUser = user;
       cachedEntries = provider.getOrderedEntriesForUser(user, checkpoint);
     }
    
     // Try to consume the first element of the list.
     Entry entry = null;
     if (cachedEntries.size() > 0) {
       entry = (Entry) cachedEntries.get(0);
       cachedEntries.remove(0);
     }
    
View Full Code Here


      LOGGER.severe(ioe.toString());
      throw new RepositoryException(ioe);
    }
    List entries = feed.getEntries();
    Collections.sort(entries, comparator);
    Entry lastEntry = (Entry) entries.get(entries.size() - 1);
    lastEntryId = lastEntry.getId();
    lastEntryCheckpoint = fetchTime.toString() + "!" + lastEntryId;
   
   
    if (checkpoint != null && ifModifiedSince != null) {
      // All of these entries were modified during or after the checkpoint time
      // but we still need to skip over any that have been processed before
      // during the checkpoint time.
      String idString = checkpoint.substring(checkpoint.indexOf("!") + 1);
      while (entries.size() > 0) {
        Entry firstEntry = (Entry) entries.get(0);
        boolean isIdLessEq =
          firstEntry.getId().compareTo(idString) <= 0;
        boolean isUpdatedEqual =
          firstEntry.getUpdated().compareTo(ifModifiedSince) == 0;
        if (isIdLessEq && isUpdatedEqual) {
          entries.remove(0);
        } else {
          break;
        }
View Full Code Here

   * This class implements Comparator for the traversal order described above.
   */
  public static class TraversalOrderComparator implements Comparator {
   
    public int compare(Object o1, Object o2) {
      Entry e1 = (Entry) o1;
      Entry e2 = (Entry) o2;
     
      int updatedResult = e1.getUpdated().compareTo(e2.getUpdated());
      if (updatedResult == 0) {
        return e1.getId().compareTo(e2.getId());
      } else {
        return updatedResult;
      }
    }
View Full Code Here

        return updatedResult;
      }
    }
   
    public boolean equals(Object o1, Object o2) {
      Entry e1 = (Entry) o1;
      Entry e2 = (Entry) o2;
      return e1.getId().compareTo(e1.getId()) == 0;
    }
View Full Code Here

    List entries = new LinkedList();
   
    int id = 0;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        Entry entry = new Entry();
        String dateString = "200" + i + "-01-01T00:00:00.000Z";
        entry.setUpdated(DateTime.parseDateTime(dateString));
        entry.setId("j=" + j + ", i=" + i);
        entries.add(entry);
        id++;
      }
    }
   
    Collections.reverse(entries);
    Collections.rotate(entries, entries.size() / 2);
    Collections.swap(entries, 0, entries.size() - 1);
   
    Feed riggedFeed = new Feed();
    riggedFeed.getEntries().addAll(entries);
   
    RiggedCalendarService service = new RiggedCalendarService(riggedFeed);
   
    CalendarEntryProvider provider =
      new CalendarEntryProvider(service, "admin@example.com", "secret");
    List results = provider.getOrderedEntriesForUser("lolcat", aCheckpoint);
   
    for (int idx = 0; idx < entries.size() - 1; idx++) {
      Entry current = (Entry) results.get(idx);
      Entry next = (Entry) results.get(idx + 1);
      int updatedResult = current.getUpdated().compareTo(next.getUpdated());
      int idResult = current.getId().compareTo(next.getId());

      if (updatedResult == 0 && idResult > 0)
        fail("Id-order violation within single second.");
     
      if (updatedResult > 1)
View Full Code Here

    final int SKIP = 6;
   
    List entries = new LinkedList();
    DateTime sometime = DateTime.now();
    for (int idx = 0; idx < COUNT; idx++) {
      Entry entry = new Entry();
      entry.setUpdated(sometime);
      entry.setId("" + idx);
      entries.add(entry);
    }
   
    Feed riggedFeed = new Feed();
    riggedFeed.getEntries().addAll(entries);
View Full Code Here

 
  public void testParsesCheckpoints()
  throws RepositoryException, AuthenticationException {
   
    List entries = new LinkedList();
    Entry entry = new Entry();
    entry.setUpdated(DateTime.now());
    entry.setId("meow");
    entries.add(entry);
   
    Feed riggedFeed = new Feed();
    riggedFeed.getEntries().addAll(entries);
    RiggedCalendarService service = new RiggedCalendarService(riggedFeed);
    CalendarEntryProvider provider =
      new CalendarEntryProvider(service, "admin@example.com", "secret");
   

    // In this test we are not interested in the results, just what exceptions
    // are thrown.
    List results = null;
    String checkpoint = null;
   
    try {
      results = provider.getOrderedEntriesForUser("somebody", null);
      fail("Should have thrown DidNotPassIfModifiedSinceException.");
    } catch (DidNotPassIfModifiedSinceException dnpimse) {
      // this is the desired behavior
    }
   
    String realCheckpoint = provider.getCheckpointForEntry(entry);
       
    try {
      results = provider.getOrderedEntriesForUser("somebody", realCheckpoint);
    } catch (DidNotPassIfModifiedSinceException dnpimse) {
      // checkpoint was generated by this provider, it should be able to parse
      fail(dnpimse.toString());
    }
   
    try {
      String brokenCheckpoint = "123hax" + "!" + entry.getId();
      results = provider.getOrderedEntriesForUser("somebody", brokenCheckpoint);
      fail("Should have thrown DidNotPassIfModifiedSinceException.");
    } catch (DidNotPassIfModifiedSinceException dnpimse) {
      // this is the desired behavior again
    }
View Full Code Here

    assertTrue(hasId(doc, nonceId));
  }
 
  /** This factory method creates Entry objects with a specified id. */
  public static Entry getEntryWithId(String id) {
    Entry entry = new Entry();
    entry.setId(id);
    entry.setUpdated(DateTime.now());
    entry.addHtmlLink("http://0.0.0.0/" + id, "en", id);
    PlainTextConstruct construct = new PlainTextConstruct();
    construct.setText(id);
    TextContent content = new TextContent();
    content.setContent(construct);
    entry.setContent(content);
    return entry;
  }
View Full Code Here

    String id = "ID";
    String uri = "http://localhost";
    DateTime dt = DateTime.now();
    String contentNonce = "\u9762" + System.currentTimeMillis();
   
    Entry entry = new Entry();
    entry.setId(id);
    entry.setUpdated(dt);
    entry.addHtmlLink(uri, "en", "example");
    entry.setContent(
        TextConstruct.create(TextConstruct.Type.TEXT, contentNonce, null));
   
    Document doc = null;
    try {
      doc = EntryDocumentizer.makeDocument(entry);
View Full Code Here

  public Entry createPost(
      String blogID,
      String title,
      String content) {
    // Create the entry to insert
    Entry myEntry = new Entry();
    myEntry.setTitle(new PlainTextConstruct(title));
    myEntry.setContent(new PlainTextConstruct(content));
   
    // Ask the service to insert the new entry
    URL postUrl = null;
    try {
      postUrl = new URL("http://www.blogger.com/feeds/" + blogID + "/posts/default");
View Full Code Here

TOP

Related Classes of com.google.gdata.data.Entry

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.