Package com.google.gdata.data.docs

Examples of com.google.gdata.data.docs.DocumentListEntry


  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String task = req.getParameter("task");
    String title = req.getParameter("title");
    String client = req.getParameter("client");
    resp.setHeader("Content-Type", "text/html");
    DocumentListEntry entry = null;
    if (task.equals(GoogleDocumentsTaskTypes.STATS)) {

    }
  }
View Full Code Here


    String entityIds = req.getParameter("entityIds");
    Long companyId = Long.parseLong(req.getParameter("companyId"));
    int billNumber = Integer.parseInt(req.getParameter("billNumber"));
    resp.setHeader("Content-Type", "text/html");
    try {
      DocumentListEntry entry = null;
      if (task.equals(GoogleDocumentsTaskTypes.CREATE)) {
        log.info("Entering GDataTaskTypes.CREATE task!");
        if (companyId != null) {
          Company company = DatastoreProxy.getCompanyById(companyId);
          if (company != null) {
View Full Code Here

    String task = req.getParameter("task");
    String title = req.getParameter("title");
    String folder = req.getParameter("folder");
    resp.setHeader("Content-Type", "text/html");
    try {
      DocumentListEntry entry = null;
      if (task.equals(GoogleDocumentsTaskTypes.CREATE)) {
        log.info("Entering GDataTaskTypes.CREATE task!");
        log.info("Searching for document entry '" + title + "' in Google Docs account: " + gdataWebLogin);
        entry = proxy.findDocumentEntry(title);
        if (entry == null) {
          log.warning("Did not find document. Will create it.");
          entry = proxy.createDocumentFile("spreadsheet", title, folder);
          log.info("Created entry in: " + entry.getDocumentLink().getHref());
          log.info("Sleeping: " + gdataThreadSleep + " milliseconds");
          Thread.sleep(gdataThreadSleep);
          log.info("Wake up!");
        }
        log.info("Creating report worksheets");
        proxy.createReprtWorksheets(entry.getTitle().getPlainText());
        log.info("Queueing GDataTaskTypes.INIT task!");
        QueueFactory.getQueue("gdata").add(TaskOptions.Builder.withUrl("/tasks/gdata/reports").param("task", GoogleDocumentsTaskTypes.INIT).param("title", entry.getTitle().getPlainText()));
        log.info("GDataTaskTypes.INIT queued successfully!");
      } else if (task.equals(GoogleDocumentsTaskTypes.DELETE)) {
        log.info("Entering GDataTaskTypes.DELETE task!");
        entry = proxy.findDocumentEntry(title);
        if (entry != null) {
View Full Code Here

  public void deleteDocumentFile(DocumentListEntry entry) throws IOException, ServiceException {
    entry.delete();
  }

  public DocumentListEntry createDocumentFile(String type, String title, String folder) throws IOException, ServiceException {
    DocumentListEntry newEntry = null;
    if (type.equals("document")) {
      newEntry = new DocumentEntry();
    } else if (type.equals("presentation")) {
      newEntry = new PresentationEntry();
    } else if (type.equals("spreadsheet")) {
      newEntry = new com.google.gdata.data.docs.SpreadsheetEntry();
    }
    newEntry.setTitle(new PlainTextConstruct(title));
    DocumentListEntry folderEntry = findDocumentFolderEntry(folder);
    if (folderEntry != null) {
      return documentsService.insert(new URL(((MediaContent) folderEntry.getContent()).getUri()), newEntry);
    }
    return documentsService.insert(documentsFeedUri, newEntry);
  }
View Full Code Here

    entry.setMediaSource(new MediaByteArraySource(content.getBytes(), mediaType));
    return entry.updateMedia(true);
  }

  public DocumentListEntry findDocumentEntry(String title) throws IOException, ServiceException {
    DocumentListEntry entry = null;
    DocumentQuery query = new DocumentQuery(documentsFeedUri);
    query.setTitleQuery(title);
    query.setTitleExact(true);
    query.setMaxResults(1);
    DocumentListFeed feed = documentsService.getFeed(query, DocumentListFeed.class);
View Full Code Here

    }
    return null;
  }

  public DocumentListEntry uploadFile(byte[] mediaBytes, String mediaType, String title, String folder) throws IOException, ServiceException, URISyntaxException {
    DocumentListEntry newEntry = new DocumentListEntry();
    newEntry.setTitle(new PlainTextConstruct(title));
    newEntry.setMediaSource(new MediaByteArraySource(mediaBytes, mediaType));
    DocumentListEntry folderEntry = findDocumentFolderEntry(folder);
    if (folderEntry != null) {
      return documentsService.insert(new URL(((MediaContent) folderEntry.getContent()).getUri()), newEntry);
    }
    return documentsService.insert(documentsFeedUri, newEntry);
  }
View Full Code Here

    return null;
  }

  public String getSpreadsheetURL(String title) {
    try {
      DocumentListEntry entry = findDocumentEntry(title);
      return entry == null ? null : entry.getDocumentLink().getHref();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ServiceException e) {
      // TODO Auto-generated catch block
View Full Code Here

        }
        if (entityIds.endsWith(",")) {
          entityIds = entityIds.substring(0, entityIds.length() - 1);
        }
        log.info("Searching for document entry '" + title + "' in Google Docs account.");
        DocumentListEntry entry = proxy.findDocumentEntry(title);
        if(entry == null){
          log.warning("Did not find document. Will create it.");
          entry = proxy.createDocumentFile("document", title, "billing");
          log.info("Created entry in: " + entry.getDocumentLink().getHref());
        }
        link = proxy.getExportLink(entry, "pdf");
        log.info("Queueing billing resources tasks...");
        QueueFactory.getQueue("gdata").add(TaskOptions.Builder.withUrl("/tasks/gdata/billing")
            .param("task", GoogleDocumentsTaskTypes.CREATE)
View Full Code Here

    }
  }

  private String uploadToGoogleDocs() {
    if (stringXML != null && !"".equals(stringXML)) {
      DocumentListEntry entry = null;
      try {
        log.info("Looking for 'ads' file on Google Docs account: " + gdataWebLogin);
        entry = proxy.findDocumentEntry("ads");
        if (entry == null) {
          log.warning("Cound not find 'ads' file on Google Docs account!");
          entry = proxy.createDocumentFile("document", "ads", "schedule");
          log.info("Created new entry on " + entry.getDocumentLink().getHref());
          log.info("Sleeping " + gdataThreadSleep + " milliseconds");
          Thread.sleep(gdataThreadSleep);
          log.info("Wake up!");
        } else {
          log.info("Found 'ads' file on Google Docs account!");
        }
        log.info("Updating document content with XML data...");
        entry = proxy.updateDocumentFile(entry, stringXML, "text/plain");
        log.info("Success! Updated entry: " + entry.getDocumentLink().getHref());
      } catch (AuthenticationException e) {
        return e.getMessage();
      } catch (MalformedURLException e) {
        return e.getMessage();
      } catch (IOException e) {
        return e.getMessage();
      } catch (ServiceException e) {
        return e.getMessage();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      return entry.getDocumentLink().getHref();
    } else {
      return "No slots were found! See server logs for more details.";
    }
  }
View Full Code Here

    logger.info("Creating new file.");
    // Create "docs".SpreadsheetEntry
    final String appId = ApiProxy.getCurrentEnvironment().getAppId();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
    final String fileName = appId + "_" + sdf.format(new Date());
    DocumentListEntry entry = new com.google.gdata.data.docs.SpreadsheetEntry();
    entry.setTitle(new PlainTextConstruct(fileName));
    DocumentListEntry newSpreadSheet =
      cs.insert(new URL("https://docs.google.com/feeds/default/private/full/"), entry);

    try {
      // Re-get in "spreadsheet".SpreadsheetEntry
      FeedURLFactory urlFactory = FeedURLFactory.getDefault();
      SpreadsheetQuery spreadsheetQuery =
        new SpreadsheetQuery(urlFactory.getSpreadsheetsFeedUrl());
      spreadsheetQuery.setTitleQuery(fileName);
      SpreadsheetFeed spreadsheetFeed = ss.query(spreadsheetQuery, SpreadsheetFeed.class);
      SpreadsheetEntry spreadsheetEntry = spreadsheetFeed.getEntries().get(0);

      // Modify a default worksheet
      URL worksheetFeedUrl = spreadsheetEntry.getWorksheetFeedUrl();
      WorksheetFeed worksheetFeed = ss.getFeed(worksheetFeedUrl, WorksheetFeed.class);
      WorksheetEntry defaultWorksheet = worksheetFeed.getEntries().get(0);
      defaultWorksheet.setTitle(new PlainTextConstruct(targetKinds.get(0)));
      defaultWorksheet.setRowCount(2);
      defaultWorksheet.setColCount(1);
      defaultWorksheet.update();
      logger.info("Worksheet:" + targetKinds.get(0) + "is created.");

      // Add other Worksheets
      for (int i = 1; i < targetKinds.size(); i++) {
        WorksheetEntry newWorksheet = new WorksheetEntry();
        newWorksheet.setTitle(new PlainTextConstruct(targetKinds.get(i)));
        newWorksheet.setRowCount(2);
        newWorksheet.setColCount(1);
        ss.insert(worksheetFeedUrl, newWorksheet);
        logger.info("Worksheet:" + targetKinds.get(i) + "is created.");
      }
      logger.info("Created new file:" + fileName);
      return spreadsheetEntry;

    } catch (Exception e) {
      if (newSpreadSheet != null) {
        try {
          newSpreadSheet.delete();
        } catch (Exception e2) {
          logger.warning(e2.getMessage());
        }
      }
      throw e;
View Full Code Here

TOP

Related Classes of com.google.gdata.data.docs.DocumentListEntry

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.