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


Java ServiceException类代码示例

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


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

示例1: updateWorksheetWithAllItems

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
private void updateWorksheetWithAllItems(WorksheetEntry worksheet, String[] header, List<ReportItem> reportItems, int numberOfRows, int numberOfColumns, String reportSpreadsheetName)
        throws BatchInterruptedException, MalformedURLException, IOException, ServiceException
{
    URL cellFeedUrl = worksheet.getCellFeedUrl();
    CellFeed cellFeed = spreadsheetService.getFeed(cellFeedUrl, CellFeed.class);

    Map<String, CellEntry> cellEntries = prepareBatchByQueringWorksheet(cellFeedUrl, numberOfRows, numberOfColumns);

    int startingRow = 1;
    int rowsInBatch = ((Double) Math.ceil((double)numberOfRows / Properties.googleSheetsBatchUploadSizeSplitFactor.get())).intValue();
    int endingRow = rowsInBatch;
    for (int i = 0; i < Properties.googleSheetsBatchUploadSizeSplitFactor.get(); i++) {
        CellFeed batchRequest = createBatchRequest(header, reportItems, startingRow, endingRow, numberOfColumns, cellEntries);
        Link batchLink = cellFeed.getLink(Link.Rel.FEED_BATCH, Link.Type.ATOM);
        CellFeed batchResponse = spreadsheetService.batch(new URL(batchLink.getHref()), batchRequest);
        boolean isSuccess = checkResults(batchResponse);
        logger.info((isSuccess ? "Batch operations successful: " : "Batch operations failed: ") + reportSpreadsheetName + " " + worksheet.getTitle().getPlainText() + " starting row: " + startingRow +", through row: " + endingRow);
        startingRow = startingRow + rowsInBatch;
        endingRow = Math.min(numberOfRows, endingRow + rowsInBatch);
    }
}
 
开发者ID:Netflix,项目名称:q,代码行数:22,代码来源:GoogleSheetsService.java

示例2: prepareBatchByQueringWorksheet

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
private Map<String, CellEntry> prepareBatchByQueringWorksheet(URL cellFeedUrl, int numberOfRows, int numberOfColumns) throws IOException, ServiceException
{
    CellFeed batchRequest = new CellFeed();
    for (int rowIndex = 1; rowIndex <= numberOfRows; rowIndex++) {
        for (int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++) {
            String id = getR1C1Id(rowIndex, columnIndex);
            CellEntry batchEntry = new CellEntry(rowIndex, columnIndex, id);
            batchEntry.setId(String.format("%s/%s", cellFeedUrl.toString(), id));
            BatchUtils.setBatchId(batchEntry, id);
            BatchUtils.setBatchOperationType(batchEntry, BatchOperationType.QUERY);
            batchRequest.getEntries().add(batchEntry);
        }
    }

    CellFeed cellFeed = spreadsheetService.getFeed(cellFeedUrl, CellFeed.class);
    CellFeed queryBatchResponse = spreadsheetService.batch(new URL(cellFeed.getLink(Link.Rel.FEED_BATCH, Link.Type.ATOM).getHref()), batchRequest);

    Map<String, CellEntry> cellEntryMap = new HashMap<String, CellEntry>(numberOfColumns);
    for (CellEntry entry : queryBatchResponse.getEntries()) {
        cellEntryMap.put(BatchUtils.getBatchId(entry), entry);
    }
    return cellEntryMap;
}
 
开发者ID:Netflix,项目名称:q,代码行数:24,代码来源:GoogleSheetsService.java

示例3: getRowValuesWithoutNull

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
@Ignore
@Test
public void getRowValuesWithoutNull() throws IOException, ServiceException {
    GdataSpreadSheetReader reader = spy(new GdataSpreadSheetReader(mock(SpreadsheetService.class), "url"));
    //params
    int rowNum = 0;
    Set<String> tags = new HashSet<>(Arrays.asList("a","b","c","d"));
    Map<String, String> headerValues = new HashMap<>();
    headerValues.put("a", "null");
    headerValues.put("b", "value");
    headerValues.put("c", "");
    headerValues.put("d", null);
    //mocks
    List<ListEntry> entries = Collections.singletonList(prepareRowWithMockHeadersAndValues(headerValues, tags));
    doReturn(entries).when(reader).readRows();
    //expected result
    Set<String> expected = new HashSet<>(Collections.singletonList("value"));
    //assert
    Assert.assertEquals(expected, reader.getHeaders());
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:21,代码来源:GdataSpreadSheetReaderUnitTest.java

示例4: testInsert

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
@Test
public void testInsert() throws IOException, ServiceException {
  final BasePageEntry<?> parent = new WebPageEntry();
  parent.setPageName(new PageName("parent"));
  final BasePageEntry<?> newEntry = new WebPageEntry();
  newEntry.setPageName(new PageName("entry"));
  final List<BasePageEntry<?>> ancestors = Lists.newLinkedList();
  ancestors.add(parent);
  final BasePageEntry<?> oldEntry = new WebPageEntry();
  final String id = feedUrl.toExternalForm() + "/entry";
  oldEntry.setId(id);
  oldEntry.addLink(ILink.Rel.ENTRY_EDIT, ILink.Type.ATOM, id);
  final BaseContentEntry<?> returnedEntry = new WebPageEntry();
  
  context.checking(new Expectations() {{
    allowing (entryProvider).getEntries(with(any(ContentQuery.class)), 
        with(sitesService));
        will(returnValue(Lists.newArrayList()));
    oneOf (entryInserter).insertEntry(newEntry, feedUrl, sitesService);
        will(returnValue(returnedEntry));
  }});
  
  assertEquals(returnedEntry, entryUploader.uploadEntry(newEntry, ancestors,
      feedUrl, sitesService));
}
 
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:26,代码来源:EntryUploaderImplTest.java

示例5: printSidewikiEntries

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
/**
 * Prints Sidewiki entries in the feed specified by the given URL.
 *
 * @param service an authenticated SidewikiService object
 * @param feedUrl the URL of a Sidewiki entry feed to retrieve
 * @throws IOException if there is a problem communicating with the server
 * @throws ServiceException if the service is unable to handle the request
 * @return a set of author IDs who wrote entries found in given feed
 */
private static Set<String> printSidewikiEntries(SidewikiService service, URL feedUrl)
    throws IOException, ServiceException {
  Set<String> authors = new HashSet<String>();

  // Send the request and receive the response.
  SidewikiEntryFeed resultFeed = service.getFeed(feedUrl, SidewikiEntryFeed.class);

  // Print each Sidewiki entry.
  System.out.println(resultFeed.getTitle().getPlainText());

  for (int i = 0; i < resultFeed.getEntries().size(); i++) {
    SidewikiEntry entry = resultFeed.getEntries().get(i);
    printEntry(entry);
    SidewikiAuthor author = (SidewikiAuthor) entry.getAuthors().get(0);
    authors.add(author.getResourceId().getValue());
  }
  return authors;
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:28,代码来源:SidewikiEntryFeedDemo.java

示例6: insert

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
/**
 * Inserts a new {@link IEntry} into a feed associated
 * with the target service. It will return the inserted entry, including any
 * additional attributes or extensions set by the GData server.
 *
 * @param feedUrl the POST URI associated with the target feed.
 * @param entry the new entry to insert into the feed.
 * @return the newly inserted Entry returned by the service.
 * @throws IOException error communicating with the GData service.
 * @throws com.google.gdata.util.ParseException error parsing the return entry
 *         data.
 * @throws com.google.gdata.util.ServiceForbiddenException the inserted Entry
 *         has associated media content and can only be inserted using a media
 *         service.
 * @throws ServiceException insert request failed due to system error.
 *
 * @see IFeed#getEntryPostLink()
 */
@SuppressWarnings("unchecked")
public <E extends IEntry> E insert(URL feedUrl, E entry)
    throws IOException, ServiceException {

  if (entry == null) {
    throw new NullPointerException("Must supply entry");
  }

  GDataRequest request = createInsertRequest(feedUrl);
  try {
    startVersionScope();

    writeRequestData(request, entry);
    request.execute();
    return parseResponseData(request, classOf(entry));

  } finally {
    endVersionScope();
    request.end();
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:40,代码来源:Service.java

示例7: getAllPages

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
/**
 * Executes a GData query against the target service and returns a
 * List containing all the {@link IEntry} that match the query result. 
 * This method will page through the feed and return all matching records 
 * to the client. Should be only used by services that have paged resultsets.
 * <p>Please note that this method may take a very long time to execute for 
 * feeds with thousands of entries.</p>
 * 
 * @param feedUrl resource URL of the feed
 * @param feedClass class used to represent service entries 
 * @return List of {@link IEntry}
 * @throws IOException error communicating with the GData service
 * @throws com.google.gdata.util.ServiceForbiddenException feed does not 
 *         support the query.
 * @throws com.google.gdata.util.ParseException error parsing the returned 
 *         feed data.
 * @throws ServiceException query request failed.
 */
@SuppressWarnings("unchecked")
protected <E extends IEntry, F extends IFeed> List<E> getAllPages(
    URL feedUrl, Class<F> feedClass) 
    throws IOException, ServiceException {
  List<E> allEntries = new ArrayList<E>();
  try {
    do {
      IFeed feed = getFeed(feedUrl, feedClass);
      allEntries.addAll((Collection<E>) feed.getEntries());
      feedUrl = (feed.getNextLink() == null)
        ? null : new URL(feed.getNextLink().getHref());
    } while (feedUrl != null); 
  } catch (ServiceException se) {
    AppsForYourDomainException ae = AppsForYourDomainException.narrow(se);
    throw (ae != null) ? ae : se;
  }
  return allEntries;
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:37,代码来源:AppsForYourDomainService.java

示例8: processScript

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
/**
 * Processes script consisting of sequence of parameter lines in the same
 * form as command line parameters.
 *
 * @param example object controlling the execution
 * @param parameters parameters passed from command line
 */
private static void processScript(ContactsExample example,
    ContactsExampleParameters parameters) throws IOException,
    ServiceException {
  BufferedReader reader =
      new BufferedReader(new FileReader(parameters.getScript()));
  try {
    String line;
    while ((line = reader.readLine()) != null) {
      ContactsExampleParameters newParams =
          new ContactsExampleParameters(parameters, line);
      processAction(example, newParams);
      if (lastAddedId != null) {
        parameters.setId(lastAddedId);
        lastAddedId = null;
      }
    }
  } finally {
    if (reader != null) {
      reader.close();
    }
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:30,代码来源:ContactsExample.java

示例9: main

import com.google.gdata.util.ServiceException; //导入依赖的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

示例10: printAlbumLocation

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
/**
 * Demonstrates use of partial query to retrieve album title and location
 * information for user's albums.
 */
private void printAlbumLocation(String uname) throws IOException, ServiceException {
	String albumsUrl = API_PREFIX + uname;
	String fields = "entry(title,gphoto:id,gphoto:location)";

	Query albumQuery = new Query(new URL(albumsUrl));
	albumQuery.setFields(fields);

	AlbumFeed feed = service.query(albumQuery, AlbumFeed.class);
	for (GphotoEntry entry : feed.getEntries()) {
		if (entry instanceof AlbumEntry) {
			AlbumEntry albumEntry = (AlbumEntry) entry;
			log.info(albumEntry.getGphotoId() + ":" + albumEntry.getTitle().getPlainText() + " ("
					+ albumEntry.getLocation() + ")");
		}
	}
}
 
开发者ID:Dotosoft,项目名称:dotoquiz-tools,代码行数:21,代码来源:PicasawebClient.java

示例11: update

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
/**
 * Updates an existing entry.
 * 
 * See the comment in {@code delete} for why the entry is cached in a hash
 * map.
 * 
 * @param id the ID of the row to update
 * @param nameValuePairs the name value pairs, such as "title=UpdatedTitle"
 *        to change
 *        the table's title to UpdatedTitle
 * @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 update(String id, String nameValuePairs) throws IOException,
    ServiceException {

  // The next line of code finds the entry to update.
  // See the javadoc on entriesCached.
  TableEntry entry = entriesCached.get(id);

  setEntryContentsFromString(entry, nameValuePairs);

  if (entry != null) {
    entry.update(); // This updates the existing entry.
    out.println("Updated!");
  } else {
    out.println("I don't know that ID.");
    out.println("In GData, you must get an entry before deleting it.");
    out.println("You might have to 'list' first.");
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:34,代码来源:TableDemo.java

示例12: getWsListHelper

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
/**
 * Retrieves a <code>List</code> of <code>WorksheetEntry</code> instances
 * available from the list of Worksheets in the specified feed
 *
 * @param wsFeedUrl The feed of worksheets
 * @throws EPAuthenticationException 
 * @return List of worksheets in the specified feed
 */
private List<WorksheetEntry> getWsListHelper(String wsFeedUrl) 
throws EPAuthenticationException {
  List<WorksheetEntry> returnList = null;

  try {
    SpreadsheetService ssService = getSsService();
    WorksheetFeed wsFeed = ssService.getFeed(
        new URL(wsFeedUrl), 
        WorksheetFeed.class);
    returnList = wsFeed.getEntries();
  } catch (com.google.gdata.util.AuthenticationException authEx) {
    throw new EPAuthenticationException(
        "WS list read access not available");
  } catch (com.google.gdata.util.ServiceException svcex) {
    System.err.println("ServiceException while retrieving " +
        "available worksheets: " + svcex.getMessage());
    returnList = null;
  } catch (java.io.IOException ioex) {
    System.err.println("IOException while retrieving " +
        "available worksheets: " + ioex.getMessage());
    returnList = null;
  }
  return returnList;    
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:33,代码来源:EventPublisher.java

示例13: getEntries

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<BaseContentEntry<?>> getEntries(Query query, 
    SitesService sitesService) throws IOException, ServiceException {
  checkNotNull(query, "query");
  checkNotNull(sitesService, "sitesService");
  List<BaseContentEntry> baseEntries = 
      sitesService.getFeed(query, ContentFeed.class).getEntries();
  List<BaseContentEntry<?>> adaptedEntries = Lists.newLinkedList();
  for (BaseContentEntry entry : baseEntries) {
    BaseContentEntry<?> adaptedEntry = 
        (BaseContentEntry<?>) entry.getAdaptedEntry();
    if (adaptedEntry == null) {
      adaptedEntries.add(entry);
    } else {
      adaptedEntries.add(adaptedEntry);
    }
  }
  return adaptedEntries;
}
 
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:21,代码来源:EntryProviderImpl.java

示例14: getTags

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
/**
 * Retrieves the tags for the given user.  These are tags aggregated across
 * the entire account.
 */
public List<TagEntry> getTags(String uname) throws IOException,
        ServiceException {
    String tagUrl = API_PREFIX + uname + "?kind=tag";
    UserFeed userFeed = getFeed(tagUrl, UserFeed.class);

    List<GphotoEntry> entries = userFeed.getEntries();
    List<TagEntry> tags = new ArrayList<TagEntry>();
    for (GphotoEntry entry : entries) {
        GphotoEntry adapted = entry.getAdaptedEntry();
        if (adapted instanceof TagEntry) {
            tags.add((TagEntry) adapted);
        }
    }
    return tags;
}
 
开发者ID:Dotosoft,项目名称:dotoquiz-tools,代码行数:20,代码来源:PicasawebClient.java

示例15: main

import com.google.gdata.util.ServiceException; //导入依赖的package包/类
public static void main(String[] args) throws DocumentListException,
    IOException, ServiceException, InterruptedException {

  SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
  String user = parser.getValue("username", "user", "u");
  String password = parser.getValue("password", "pass", "p");
  boolean help = parser.containsKey("help", "h");

  if (help || (user == null || password == null)) {
    printMessage(USAGE_MESSAGE);
    System.exit(1);
  }

  // authenticate
  DocumentList docs = new DocumentList(APPLICATION_NAME);
  docs.login(user, password);

  DocumentResumableUploadDemo demo = new DocumentResumableUploadDemo(
      docs, System.out);
  demo.run();
  System.exit(1);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:23,代码来源:DocumentResumableUploadDemo.java


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