当前位置: 首页>>代码示例>>Java>>正文


Java BatchStatus类代码示例

本文整理汇总了Java中com.google.gdata.data.batch.BatchStatus的典型用法代码示例。如果您正苦于以下问题:Java BatchStatus类的具体用法?Java BatchStatus怎么用?Java BatchStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BatchStatus类属于com.google.gdata.data.batch包,在下文中一共展示了BatchStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
/**
 * Run the sample app with the provided arguments.
 * @param args
 * @throws OAuthException
 * @throws IOException
 * @throws ServiceException
 */
public static void main(String[] args) throws OAuthException, IOException, ServiceException {
  if (args.length != 3) {
    System.out.println("Usage: unshare_profile <consumerKey> <consumerSecret> <adminEmail>");
  } else {
    String consumerKey = args[0];
    String consumerSecret = args[1];
    String adminEmail = args[2];
    ProfilesManager manager = new ProfilesManager(consumerKey, consumerSecret, adminEmail);

    BatchResult result = manager.unshareProfiles();

    System.out.println("Success: " + result.getSuccess() + " - Error: " + result.getError());
    for (ContactEntry entry : result.getErrorEntries()) {
      BatchStatus status = BatchUtils.getBatchStatus(entry);

      System.out.println(" > Failed to update " + entry.getId() + ": (" + status.getCode() + ") "
          + status.getReason());
    }
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:28,代码来源:UnshareProfiles.java

示例2: CheckBatchDeleteResults

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
/**
 * Throw an exception if there were any errors in the batch delete.
 * @param batchResponse - The batch response.
 * @param googleCalEntries - The original list of items that we tried to delete.
 */
protected void CheckBatchDeleteResults(CalendarEventFeed batchResponse, ArrayList<CalendarEventEntry> googleCalEntries) throws Exception {
    // Ensure that all the operations were successful
    boolean isSuccess = true;

    StringBuffer batchFailureMsg = new StringBuffer("These entries in the batch delete failed:");
    for (CalendarEventEntry entry : batchResponse.getEntries()) {
        String batchId = BatchUtils.getBatchId(entry);
        if (!BatchUtils.isSuccess(entry)) {
            isSuccess = false;
            BatchStatus status = BatchUtils.getBatchStatus(entry);

            CalendarEventEntry entryOrig = googleCalEntries.get(new Integer(batchId));

            batchFailureMsg.append("\nID: " + batchId + "  Reason: " + status.getReason() +
                    "  Subject: " + entryOrig.getTitle().getPlainText() +
                    "  Start Date: " + entryOrig.getTimes().get(0).getStartTime().toString());
        }
    }

    if (!isSuccess) {
        throw new Exception(batchFailureMsg.toString());
    }
}
 
开发者ID:gavrie,项目名称:lngooglecalsync,代码行数:29,代码来源:GoogleManager.java

示例3: checkResults

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
protected boolean checkResults(CellFeed batchResponse)
{
    boolean isSuccess = true;
    for (CellEntry entry : batchResponse.getEntries()) {
        String batchId = BatchUtils.getBatchId(entry);
        if (!BatchUtils.isSuccess(entry)) {
            isSuccess = false;
            BatchStatus status = BatchUtils.getBatchStatus(entry);
            logger.error(String.format("%s failed (%s) %s", batchId, status.getReason(), status.getContent()));
        }
    }
    return isSuccess;
}
 
开发者ID:Netflix,项目名称:q,代码行数:14,代码来源:GoogleSheetsService.java

示例4: deleteEvents

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
/**
 * Makes a batch request to delete all the events in the given list. If any of
 * the operations fails, the errors returned from the server are displayed.
 * The CalendarEntry objects in the list given as a parameters must be entries
 * returned from the server that contain valid edit links (for optimistic
 * concurrency to work). Note: You can add entries to a batch request for the
 * other operation types (INSERT, QUERY, and UPDATE) in the same manner as
 * shown below for DELETE operations.
 * 
 * @param service An authenticated CalendarService object.
 * @param eventsToDelete A list of CalendarEventEntry objects to delete.
 * @throws ServiceException If the service is unable to handle the request.
 * @throws IOException Error communicating with the server.
 */
private static void deleteEvents(CalendarService service,
    List<CalendarEventEntry> eventsToDelete) throws ServiceException,
    IOException {

  // Add each item in eventsToDelete to the batch request.
  CalendarEventFeed batchRequest = new CalendarEventFeed();
  for (int i = 0; i < eventsToDelete.size(); i++) {
    CalendarEventEntry toDelete = eventsToDelete.get(i);
    // Modify the entry toDelete with batch ID and operation type.
    BatchUtils.setBatchId(toDelete, String.valueOf(i));
    BatchUtils.setBatchOperationType(toDelete, BatchOperationType.DELETE);
    batchRequest.getEntries().add(toDelete);
  }

  // Get the URL to make batch requests to
  CalendarEventFeed feed = service.getFeed(eventFeedUrl,
      CalendarEventFeed.class);
  Link batchLink = feed.getLink(Link.Rel.FEED_BATCH, Link.Type.ATOM);
  URL batchUrl = new URL(batchLink.getHref());

  // Submit the batch request
  CalendarEventFeed batchResponse = service.batch(batchUrl, batchRequest);

  // Ensure that all the operations were successful.
  boolean isSuccess = true;
  for (CalendarEventEntry entry : batchResponse.getEntries()) {
    String batchId = BatchUtils.getBatchId(entry);
    if (!BatchUtils.isSuccess(entry)) {
      isSuccess = false;
      BatchStatus status = BatchUtils.getBatchStatus(entry);
      System.out.println("\n" + batchId + " failed (" + status.getReason()
          + ") " + status.getContent());
    }
  }
  if (isSuccess) {
    System.out.println("Successfully deleted all events via batch request.");
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:53,代码来源:EventFeedDemo.java

示例5: declareExtensions

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
@Override
public void declareExtensions(ExtensionProfile extProfile) {
  if (extProfile.isDeclared(ContactGroupEntry.class)) {
    return;
  }
  super.declareExtensions(extProfile);
  extProfile.declare(ContactGroupEntry.class,
      new ExtensionDescription(BatchId.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "id", false, false, false));
  extProfile.declare(ContactGroupEntry.class,
      new ExtensionDescription(BatchInterrupted.class,
      new XmlNamespace("batch", "http://schemas.google.com/gdata/batch"),
      "interrupted", false, false, false));
  extProfile.declare(ContactGroupEntry.class,
      new ExtensionDescription(BatchOperation.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "operation", false, false,
      false));
  extProfile.declare(ContactGroupEntry.class,
      new ExtensionDescription(BatchStatus.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "status", false, false,
      false));
  extProfile.declare(ContactGroupEntry.class,
      new ExtensionDescription(Deleted.class, new XmlNamespace("gd",
      "http://schemas.google.com/g/2005"), "deleted", false, false, false));
  extProfile.declare(ContactGroupEntry.class,
      new ExtensionDescription(ExtendedProperty.class, new XmlNamespace("gd",
      "http://schemas.google.com/g/2005"), "extendedProperty", false, true,
      false));
  extProfile.declare(ContactGroupEntry.class, SystemGroup.class);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:31,代码来源:ContactGroupEntry.java

示例6: setBatchStatus

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
/**
 * Sets the batch response status information.
 *
 * @param batchStatus batch response status information or <code>null</code>
 *     to reset
 */
public void setBatchStatus(BatchStatus batchStatus) {
  if (batchStatus == null) {
    removeExtension(BatchStatus.class);
  } else {
    setExtension(batchStatus);
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:14,代码来源:ContactGroupEntry.java

示例7: declareExtensions

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
@Override
public void declareExtensions(ExtensionProfile extProfile) {
  if (extProfile.isDeclared(BaseContentEntry.class)) {
    return;
  }
  super.declareExtensions(extProfile);
  extProfile.declare(BaseContentEntry.class,
      new ExtensionDescription(BatchId.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "id", false, false, false));
  extProfile.declare(BaseContentEntry.class,
      new ExtensionDescription(BatchInterrupted.class,
      new XmlNamespace("batch", "http://schemas.google.com/gdata/batch"),
      "interrupted", false, false, false));
  extProfile.declare(BaseContentEntry.class,
      new ExtensionDescription(BatchOperation.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "operation", false, false,
      false));
  extProfile.declare(BaseContentEntry.class,
      new ExtensionDescription(BatchStatus.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "status", false, false,
      false));
  extProfile.declare(BaseContentEntry.class,
      new ExtensionDescription(Deleted.class, new XmlNamespace("gd",
      "http://schemas.google.com/g/2005"), "deleted", false, false, false));
  extProfile.declare(BaseContentEntry.class,
      SitesLink.getDefaultDescription(true, true));
  extProfile.declare(BaseContentEntry.class, Publisher.class);
  extProfile.declare(BaseContentEntry.class, Revision.class);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:30,代码来源:BaseContentEntry.java

示例8: processEndElement

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
@Override
public void processEndElement() throws ParseException {

  // Skip extension point validation for batch response entries
  if (getExtension(BatchStatus.class) == null &&
      getExtension(BatchInterrupted.class) == null) {
    super.processEndElement();
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:10,代码来源:BaseEntry.java

示例9: declareExtensions

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
@Override
public void declareExtensions(ExtensionProfile extProfile) {
  if (extProfile.isDeclared(FeatureEntry.class)) {
    return;
  }
  super.declareExtensions(extProfile);
  extProfile.declare(FeatureEntry.class,
      new ExtensionDescription(BatchId.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "id", false, false, false));
  extProfile.declare(FeatureEntry.class,
      new ExtensionDescription(BatchInterrupted.class,
      new XmlNamespace("batch", "http://schemas.google.com/gdata/batch"),
      "interrupted", false, false, false));
  extProfile.declare(FeatureEntry.class,
      new ExtensionDescription(BatchOperation.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "operation", false, false,
      false));
  extProfile.declare(FeatureEntry.class,
      new ExtensionDescription(BatchStatus.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "status", false, false,
      false));
  extProfile.declare(FeatureEntry.class,
      CustomProperty.getDefaultDescription(false, true));
  extProfile.declare(FeatureEntry.class,
      new ExtensionDescription(Deleted.class, new XmlNamespace("gd",
      "http://schemas.google.com/g/2005"), "deleted", false, false, false));
  extProfile.declare(FeatureEntry.class,
      new ExtensionDescription(PostalAddress.class, new XmlNamespace("gd",
      "http://schemas.google.com/g/2005"), "postalAddress", false, false,
      false));
  extProfile.declare(FeatureEntry.class, ResourceId.class);
  extProfile.declare(FeatureEntry.class, StructuredPostalAddress.class);
  new StructuredPostalAddress().declareExtensions(extProfile);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:35,代码来源:FeatureEntry.java

示例10: declareExtensions

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
@Override
public void declareExtensions(ExtensionProfile extProfile) {
  if (extProfile.isDeclared(MapEntry.class)) {
    return;
  }
  super.declareExtensions(extProfile);
  extProfile.declare(MapEntry.class, new ExtensionDescription(BatchId.class,
      new XmlNamespace("batch", "http://schemas.google.com/gdata/batch"),
      "id", false, false, false));
  extProfile.declare(MapEntry.class,
      new ExtensionDescription(BatchInterrupted.class,
      new XmlNamespace("batch", "http://schemas.google.com/gdata/batch"),
      "interrupted", false, false, false));
  extProfile.declare(MapEntry.class,
      new ExtensionDescription(BatchOperation.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "operation", false, false,
      false));
  extProfile.declare(MapEntry.class,
      new ExtensionDescription(BatchStatus.class, new XmlNamespace("batch",
      "http://schemas.google.com/gdata/batch"), "status", false, false,
      false));
  extProfile.declare(MapEntry.class,
      CustomProperty.getDefaultDescription(false, true));
  extProfile.declare(MapEntry.class, new ExtensionDescription(Deleted.class,
      new XmlNamespace("gd", "http://schemas.google.com/g/2005"), "deleted",
      false, false, false));
  extProfile.declare(MapEntry.class, new ExtensionDescription(FeedLink.class,
      new XmlNamespace("gd", "http://schemas.google.com/g/2005"), "feedLink",
      false, false, false));
  new FeedLink().declareExtensions(extProfile);
  extProfile.declare(MapEntry.class, ResourceId.class);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:33,代码来源:MapEntry.java

示例11: processBatchRequest

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
/**
 * Prompts the user for a set of operations and submits them in a batch
 * request.
 * 
 * @param reader to read input from the keyboard.
 * 
 * @throws ServiceException when the request causes an error in the Google
 *         Spreadsheets service.
 * @throws IOException when an error occurs in communication with the Google
 *         Spreadsheets service.
 */
public void processBatchRequest(BufferedReader reader) 
    throws IOException, ServiceException {

  final String BATCH_PROMPT = "Enter set operations one by one, "
      + "then enter submit to send the batch request:\n"
      + " set row# col# value  [[add a set operation]]\n"
      + " submit               [[submit the request]]";

  CellFeed batchRequest = new CellFeed();

  // Prompt user for operation
  System.out.println(BATCH_PROMPT);
  String operation = reader.readLine();
  while (!operation.startsWith("submit")) {
    String[] s = operation.split(" ", 4);
    if (s.length != 4 || !s[0].equals("set")) {
      System.out.println("Invalid command: " + operation);
      operation = reader.readLine();
      continue;
    }

    // Create a new cell entry and add it to the batch request.
    int row = Integer.parseInt(s[1]);
    int col = Integer.parseInt(s[2]);
    String value = s[3];
    CellEntry batchOperation = createUpdateOperation(row, col, value);
    batchRequest.getEntries().add(batchOperation);

    // Display the current entries in the batch request.
    printBatchRequest(batchRequest);

    // Prompt for another operation.
    System.out.println(BATCH_PROMPT);
    operation = reader.readLine();
  }

  // Get the batch feed URL and submit the batch request
  CellFeed feed = service.getFeed(cellFeedUrl, CellFeed.class);
  Link batchLink = feed.getLink(Link.Rel.FEED_BATCH, Link.Type.ATOM);
  URL batchUrl = new URL(batchLink.getHref());
  CellFeed batchResponse = service.batch(batchUrl, batchRequest);

  // Print any errors that may have happened.
  boolean isSuccess = true;
  for (CellEntry entry : batchResponse.getEntries()) {
    String batchId = BatchUtils.getBatchId(entry);
    if (!BatchUtils.isSuccess(entry)) {
      isSuccess = false;
      BatchStatus status = BatchUtils.getBatchStatus(entry);
      System.out.println("\n" + batchId + " failed (" + status.getReason()
          + ") " + status.getContent());
    }
  }
  if (isSuccess) {
    System.out.println("Batch operations successful.");
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:69,代码来源:CellDemo.java

示例12: ServiceErrors

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
/**
 * Creates a ServiceErrors object corresponding
 * to the errors contained in {@link BatchStatus}.
 * 
 * @param status
 */
public ServiceErrors(BatchStatus status) {
  addErrors(status);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:10,代码来源:ServiceErrors.java

示例13: addErrors

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
/**
 * Extracts errors from a {@link BatchStatus}.
 * 
 * @param status the BatchStatus to be parsed
 */
public void addErrors(BatchStatus status) {
  addErrors(status.getReason(), status.getContentType(), status.getContent());
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:9,代码来源:ServiceErrors.java

示例14: getBatchStatus

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
/**
 * Returns the batch response status information.
 *
 * @return batch response status information
 */
public BatchStatus getBatchStatus() {
  return getExtension(BatchStatus.class);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:9,代码来源:ContactGroupEntry.java

示例15: hasBatchStatus

import com.google.gdata.data.batch.BatchStatus; //导入依赖的package包/类
/**
 * Returns whether it has the batch response status information.
 *
 * @return whether it has the batch response status information
 */
public boolean hasBatchStatus() {
  return hasExtension(BatchStatus.class);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:9,代码来源:ContactGroupEntry.java


注:本文中的com.google.gdata.data.batch.BatchStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。