Package com.google.gdata.data

Examples of com.google.gdata.data.BaseEntry


        storage.storeEntry(e);
        ServerBaseEntry e1 = createServerBaseEntry();
        storage.storeEntry(e1);
       
        storage = this.controller.getStorage();
        BaseEntry result = storage.getEntry(e);
        assertNotNull(result);
        assertEquals(e.getId(), result.getId());
        try {
            e1.setId("hello");
            result = storage.getEntry(e1);
            fail("no such entry");
        } catch (StorageException ex) {
View Full Code Here


                    "Current version does not match given version  -- currentVersion: "+persistentEntry.getVersion()+"; given Version: "+entry.getVersion() );
       
        setUpdated(entry, persistentEntry);
        BaseFeed<BaseFeed, BaseEntry> feed = getFeedOnly(entry.getFeedId(),entry.getServiceType());
        refreshPersistentObject(feed);
        BaseEntry retVal = entry.getEntry();
        DB4oEntry newEntry = new DB4oEntry();
        newEntry.setEntry(retVal);
        newEntry.setUpdateTime(entry.getUpdated().getValue());
        newEntry.setFeedId(feed.getId());
        // increment Version
View Full Code Here

        writeEntryID(wrapper.getEntryId(),writer);
        writeTimeStamp(wrapper.getTimestamp().toString(),writer);
        if(!wrapper.getOperation().equals(StorageOperation.DELETE)){
        writeService(wrapper,writer);
            writer.write(META_DATA_ENTRY_SEPARATOR);
            BaseEntry entry = wrapper.getEntry();
            XmlWriter xmlWriter = new XmlWriter(writer);
            entry.generateAtom(xmlWriter,wrapper.getConfigurator().getExtensionProfile());
        }
        writer.write(META_DATA_ENTRY_SEPARATOR);
        writer.write(STORAGE_OPERATION_SEPARATOR);
        writer.write(META_DATA_ENTRY_SEPARATOR);
        writer.flush();
View Full Code Here

    System.out.println("| TITLE: " + resultFeed.getTitle().getPlainText());
    if (resultFeed.getEntries().size() == 0) {
      System.out.println("|\tNo entries found.");
    } else {
      for (int i = 0; i < resultFeed.getEntries().size(); i++) {
        BaseEntry entry = (BaseEntry) resultFeed.getEntries().get(i);
        System.out.println("|\t" + (i + 1) + ": "
            + entry.getTitle().getPlainText());
      }
    }
    System.out.println("=====================================================");
    System.out.println();
View Full Code Here

    System.out.println("| TITLE: " + resultFeed.getTitle().getPlainText());
    if (resultFeed.getEntries().size() == 0) {
      System.out.println("|\tNo entries found.");
    } else {
      for (int i = 0; i < resultFeed.getEntries().size(); i++) {
        BaseEntry entry = (BaseEntry) resultFeed.getEntries().get(i);
        System.out.println("|\t" + (i + 1) + ": "
            + entry.getTitle().getPlainText());
      }
    }
    System.out.println("=====================================================");
  }
View Full Code Here

   * @throws IOException if an I/O error occurs while getting input from user
   */
  private int getIndexFromUser(BufferedReader reader, List entries, String type)
      throws IOException {
    for (int i = 0; i < entries.size(); i++) {
      BaseEntry entry = (BaseEntry) entries.get(i);
      System.out.println("\t(" + (i + 1) + ") "
          + entry.getTitle().getPlainText());
    }
    int index = -1;
    while (true) {
      out.print("Enter the number of the spreadsheet to load: ");
      String userInput = reader.readLine();
View Full Code Here

                           (content.length() > 0 ? ": " : "") + content);
      }

      // Insert, update, and delete an entry if so requested.
      if (updateEntry) {
        BaseEntry newEntry = new Entry();
        newEntry.setTitle(new PlainTextConstruct("Sample entry title"));
        newEntry.setContent(new PlainTextConstruct("Sample entry content"));
        BaseEntry e = service.insert(feedUrl, newEntry);
        System.out.println("Inserted an entry, ID is " + e.getId());
        e.setContent(new PlainTextConstruct("New sample entry content"));
        service.update(new URL(e.getEditLink().getHref()), e);
        System.out.println("Updated the entry");
        service.delete(new URL(e.getEditLink().getHref()));
        System.out.println("Deleted the entry");
      }

    } catch (ServiceException e) {
      throw new RuntimeException(e.getMessage() + "\n" + e.getResponseBody());
    }

  }
View Full Code Here

   * @return
   * @throws Exception
   */
  private static BaseEntry parseEntry(ApiClient actor, InputStream is,
      MapsService maps, boolean preview, PrintWriter pw) throws Exception {
    BaseEntry entry;
    entry = actor.parseAtom(is);
    if (draft) {
      entry.setDraft(true);
    }
    if (preview) {
      pp(maps, entry, pw);
    }
    return entry;
View Full Code Here

    } else if (version == 2){
      maps.setProtocolVersion(MapsService.Versions.V2);
    }

    // Perform action.
    BaseEntry entry;
    switch (action) {

      // For now, just get the whole feed.
      case query:
        pp(maps, client.readFeed(uid, mid, fid), pw);
        break;

      // Create an entry from scratch or read from input.
      case create:
        client.trimFormat("/%s");     // sleazy hack to remove trailing id
        entry = title == null
          ? parseEntry(client, is, maps, preview, pw)
          : client.buildEntry(title, content, summary);
        if (id.length() > 0) {
          entry.setExtension(new ResourceId(id));
        }
        setProperties(props, entry);
        if (preview) {
          pp(maps, entry, pw);
        }
        pp(maps, client.createEntry(entry, uid, mid), pw);
        break;

      // Read an individual entry.
      case read:
        pp(maps, client.readEntry(uid, mid, fid), pw);
        break;

      // Update an existing entry.
      case update:
        entry = title == null
          ? parseEntry(client, is, maps, preview, pw)
          : client.buildEntry(title, content, summary);
        setProperties(props, entry);
        if (preview) {
          pp(maps, entry, pw);
        }
        pp(maps, client.updateEntry(entry, uid, mid, fid), pw);
        break;

      // Delete an existing entry.
      case delete:
        String err = client.deleteEntry(uid, mid, fid);
        if (null != err) {
          System.err.println("delete error: " + err);
        }
        break;

      case batch:
        client.trimFormat("/%s");     // sleazy hack to remove trailing id
        client.addFormat("/batch");
        BaseFeed bf = parseFeed(client, is, maps, preview, pw);
        pp(maps, client.createFeed(bf, uid, mid), pw);
        break;

      // Clear out a feed.
      case clear:
        client.trimFormat("/%s");     // sleazy hack to remove trailing id
        bf = client.readFeed(uid, mid, fid);
        client.addFormat("/batch");
        BaseFeed batch = client.newFeed();
        count = 0;
        for (Object o : bf.getEntries()) {
          String entryId = ((BaseEntry) o).getSelfLink().getHref();
          if (count == 0 && fudge) {
            entryId += "-xx";
          }
          BaseEntry delete = client.newEntry();
          delete.setId(replaceUserId(uid, entryId));
          BatchUtils.setBatchOperationType(delete, BatchOperationType.DELETE);
          BatchUtils.setBatchId(delete, Integer.toString(++count));
          batch.getEntries().add(delete);
        }
        if (preview) {
          pp(maps, batch, pw);
        }
        BaseFeed response = maps.batch(client.makeUri(uid, mid, fid), batch);
        pp(maps, response, pw);
        break;

      // Test bulk insert latency.
      case bulk:
        client.trimFormat("/%s");     // sleazy hack to remove trailing id
        String baseXml = "";
        if (title == null) {
          char buf[] = new char[1024 * 64];
          int n = new InputStreamReader(is).read(buf);
          baseXml = new String(buf, 0, n);
        }
        client.addFormat("/batch");
        for (int i = 0; i < count; i++) {
          batch = client.newFeed();
          long t0 = System.currentTimeMillis();
          for (int j = 0; j < chunk; j++) {
            String entryId = "" + i + "-" + j;
            String xml = baseXml.replace("COUNT", entryId);
            System.err.println(xml);
            entry = title == null
                ? parseEntry(client, new ByteArrayInputStream(xml.getBytes()),
                    maps, preview, pw)
                : client.buildEntry(title, content, summary);
            setProperties(props, entry);
            entry.setId(entryId);
            BatchUtils.setBatchId(entry, entryId);
            BatchUtils.setBatchOperationType(entry, BatchOperationType.INSERT);
            batch.getEntries().add(entry);
          }
          if (preview) {
            pp(maps, batch, pw);
          }
          response = maps.batch(
              client.makeUri(uid, mid, fid), batch);
          pp(maps, response, pw);
          System.err.println("chunk insert time: " +
              (System.currentTimeMillis() - t0) + "ms");
        }
        break;

      // Post a file as is, no interpretation.
      case rawpost:
        break;

      // Update a bloc of entries.
      case revise:
        client.trimFormat("/%s");     // sleazy hack to remove trailing id
        baseXml = "";
        if (title == null) {
          char buf[] = new char[1024 * 64];
          int n = new InputStreamReader(is).read(buf);
          baseXml = new String(buf, 0, n);
        }
        bf = client.readFeed(uid, mid, fid);
        int n = bf.getEntries().size();
        client.addFormat("/batch");
        int dex = 0;
        count = Math.min(count, n / chunk);
        for (int i = 0; i < count; i++) {
          long t0 = System.currentTimeMillis();
          batch = client.newFeed();
          for (int j = 0; j < Math.min(n, chunk); j++) {
            Object o = bf.getEntries().get(j + i*chunk);
            String entryId = ((BaseEntry) o).getSelfLink().
                getHref().replaceAll("\\.", sep);
            if (dex == 0 && fudge) {
              entryId += "-xx";
            }
            String xml = baseXml.replace("COUNT", entryId.substring(entryId.lastIndexOf('/')));
            BaseEntry update = title == null
                ? parseEntry(client, new ByteArrayInputStream(xml.getBytes()),
                    maps, preview, pw)
                : client.buildEntry(title, content, summary);
            update.setId(replaceUserId(uid, entryId));
            setProperties(props, update);
            BatchUtils.setBatchOperationType(update, BatchOperationType.UPDATE);
            BatchUtils.setBatchId(update, Integer.toString(++dex));
            batch.getEntries().add(update);
          }
View Full Code Here

    /**
     * Test method for 'org.apache.lucene.gdata.data.GDataEntityBuilder.buildEntry(String, Reader)'
     */
    public void testBuildEntryStringReader() throws  ParseException, IOException {
        this.reader = new FileReader(incomingEntry);
        BaseEntry entry = GDataEntityBuilder.buildEntry(this.reader,this.config);
        assertNotNull(entry);
        assertEquals("entry summary",entry.getSummary().getPlainText(),entrySummaryFromXML);
       
       

        
    }
View Full Code Here

TOP

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

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.