本文整理汇总了Java中com.google.gdata.data.Link.getHref方法的典型用法代码示例。如果您正苦于以下问题:Java Link.getHref方法的具体用法?Java Link.getHref怎么用?Java Link.getHref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gdata.data.Link
的用法示例。
在下文中一共展示了Link.getHref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveAllUsers
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Retrieves all users in domain. This method may be very slow for domains
* with a large number of users. Any changes to users, including creations
* and deletions, which are made after this method is called may or may not be
* included in the Feed which is returned.
*
* @return A UserFeed object of the retrieved users.
* @throws AppsForYourDomainException If a Provisioning API specific occurs.
* @throws ServiceException If a generic GData framework error occurs.
* @throws IOException If an error occurs communicating with the GData
* service.
*/
public UserFeed retrieveAllUsers()
throws AppsForYourDomainException, ServiceException, IOException {
LOGGER.log(Level.INFO,
"Retrieving all users.");
URL retrieveUrl = new URL(domainUrlBase + "user/" + SERVICE_VERSION + "/");
UserFeed allUsers = new UserFeed();
UserFeed currentPage;
Link nextLink;
do {
currentPage = userService.getFeed(retrieveUrl, UserFeed.class);
allUsers.getEntries().addAll(currentPage.getEntries());
nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);
if (nextLink != null) {
retrieveUrl = new URL(nextLink.getHref());
}
} while (nextLink != null);
return allUsers;
}
示例2: retrieveAllNicknames
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Retrieves all nicknames in domain. This method may be very slow for
* domains with a large number of nicknames. Any changes to nicknames,
* including creations and deletions, which are made after this method is
* called may or may not be included in the Feed which is returned.
*
* @return A NicknameFeed object of the retrieved nicknames.
* @throws AppsForYourDomainException If a Provisioning API specific occurs.
* @throws ServiceException If a generic GData framework error occurs.
* @throws IOException If an error occurs communicating with the GData
* service.
*/
public NicknameFeed retrieveAllNicknames()
throws AppsForYourDomainException, ServiceException, IOException {
LOGGER.log(Level.INFO,
"Retrieving all nicknames.");
URL retrieveUrl = new URL(domainUrlBase + "nickname/"
+ SERVICE_VERSION + "/");
NicknameFeed allNicknames = new NicknameFeed();
NicknameFeed currentPage;
Link nextLink;
do {
currentPage = nicknameService.getFeed(retrieveUrl, NicknameFeed.class);
allNicknames.getEntries().addAll(currentPage.getEntries());
nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);
if (nextLink != null) {
retrieveUrl = new URL(nextLink.getHref());
}
} while (nextLink != null);
return allNicknames;
}
示例3: retrieveAllEmailLists
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Retrieves all email lists in domain. This method may be very slow for
* domains with a large number of email lists. Any changes to email lists,
* including creations and deletions, which are made after this method is
* called may or may not be included in the Feed which is returned.
*
* @return A EmailListFeed object of the retrieved email lists.
* @throws AppsForYourDomainException If a Provisioning API specific occurs.
* @throws ServiceException If a generic GData framework error occurs.
* @throws IOException If an error occurs communicating with the GData
* service.
* @deprecated Email lists have been replaced by Groups. Use
* {@link AppsGroupsService#retrieveAllGroups()}
* with Groups instead.
*/
@Deprecated
public EmailListFeed retrieveAllEmailLists()
throws AppsForYourDomainException, ServiceException, IOException {
LOGGER.log(Level.INFO,
"Retrieving all email lists.");
URL retrieveUrl = new URL(domainUrlBase + "emailList/"
+ SERVICE_VERSION + "/");
EmailListFeed allEmailLists = new EmailListFeed();
EmailListFeed currentPage;
Link nextLink;
do {
currentPage = emailListService.getFeed(retrieveUrl, EmailListFeed.class);
allEmailLists.getEntries().addAll(currentPage.getEntries());
nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);
if (nextLink != null) {
retrieveUrl = new URL(nextLink.getHref());
}
} while (nextLink != null);
return allEmailLists;
}
示例4: retrieveAllRecipients
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Retrieves all recipients in an email list. This method may be very slow for
* email lists with a large number of recipients. Any changes to the email
* list contents, including adding or deleting recipients which are made after
* this method is called may or may not be included in the Feed which is
* returned.
*
* @return An EmailListRecipientFeed object of the retrieved recipients.
* @throws AppsForYourDomainException If a Provisioning API specific occurs.
* @throws ServiceException If a generic GData framework error occurs.
* @throws IOException If an error occurs communicating with the GData
* service.
* @deprecated Email lists have been replaced by Groups. Use
* {@link AppsGroupsService#retrieveAllMembers(String)}
* with Groups instead.
*/
@Deprecated
public EmailListRecipientFeed retrieveAllRecipients(String emailList)
throws AppsForYourDomainException, ServiceException, IOException {
LOGGER.log(Level.INFO,
"Retrieving all recipients in emailList '" + emailList + "'.");
URL retrieveUrl = new URL(domainUrlBase + "emailList/"
+ SERVICE_VERSION + "/" + emailList + "/recipient/");
EmailListRecipientFeed allRecipients = new EmailListRecipientFeed();
EmailListRecipientFeed currentPage;
Link nextLink;
do {
currentPage = emailListRecipientService.getFeed(retrieveUrl, EmailListRecipientFeed.class);
allRecipients.getEntries().addAll(currentPage.getEntries());
nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);
if (nextLink != null) {
retrieveUrl = new URL(nextLink.getHref());
}
} while (nextLink != null);
return allRecipients;
}
示例5: getUsers
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Retrieves the first 100 users from the domain.
*
* @param domain The domain in which settings will be modified.
* @param username The user name (not email) of a domain administrator.
* @param password The user's password on the domain.
* @return UserFeed containing all the user accounts in the domain.
* @throws MalformedURLException if the batch feed URL cannot be constructed.
* @throws IOException if an error occurs while communicating with the GData
* service.
* @throws ServiceException if the insert request failed due to system error.
*/
protected UserFeed getUsers(String domain, String username, String password)
throws MalformedURLException, IOException, ServiceException {
String domainUrlBase = null;
UserFeed allUsers = null;
UserService userService = new UserService(GmailSettingsClient.APP_TITLE);
userService.setUserCredentials(username + "@" + domain, password);
domainUrlBase = "https://www.google.com/a/feeds/" + domain + "/";
URL retrieveUrl = new URL(domainUrlBase + "user/2.0/");
AppsForYourDomainQuery query = new AppsForYourDomainQuery(retrieveUrl);
query.setStartUsername(null);
allUsers = new UserFeed();
UserFeed currentPage;
Link nextLink;
do {
currentPage = userService.query(query, UserFeed.class);
allUsers.getEntries().addAll(currentPage.getEntries());
nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);
if (nextLink != null) {
retrieveUrl = new URL(nextLink.getHref());
}
} while (nextLink != null);
return allUsers;
}
示例6: deleteEvents
import com.google.gdata.data.Link; //导入方法依赖的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.");
}
}
示例7: getLinkByRel
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Helper function to get a link by a rel value.
*/
public String getLinkByRel(List<Link> links, String relValue) {
for (Link link : links) {
if (relValue.equals(link.getRel())) {
return link.getHref();
}
}
throw new IllegalArgumentException("Missing " + relValue + " link.");
}
示例8: getLinkByRel
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Helper function to get a link by a rel value.
*/
public String getLinkByRel(List<Link> links, String relValue) {
for (Link link : links) {
if (relValue.equals(link.getRel())) {
return link.getHref();
}
}
throw new IllegalArgumentException("Missing " + relValue + " link.");
}
示例9: getDefaultWorksheet
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Gets the first worksheet in the spreadsheet.
*
* This is very useful if your spreadsheet only has one worksheet.
*
* @return the first worksheet
*/
public WorksheetEntry getDefaultWorksheet()
throws IOException, ServiceException {
Link feedLink = this.getLink(
com.google.gdata.data.spreadsheet.Namespaces.WORKSHEETS_LINK_REL,
Link.Type.ATOM);
String url = feedLink.getHref() + "/default";
return state.service.getEntry(new URL(url), WorksheetEntry.class);
}
示例10: getFeed
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Get the feed of entries related to this entry. The kinds parameter is
* a vararg array of associated kinds to return as entries. If the
* kinds parameter is empty, the default kind associated with this feed class
* will be used.
*/
public <F extends GphotoFeed<F>> F getFeed(Class<F> feedClass,
String... kinds) throws IOException, ServiceException {
if (state.service == null) {
throw new ServiceException(
"Entry is not associated with a GData service.");
}
Link feedLink = getFeedLink();
if (feedLink == null) {
throw new UnsupportedOperationException("Missing feed link.");
}
String feedHref = feedLink.getHref();
if (kinds != null && kinds.length > 0) {
StringBuilder kindBuilder = new StringBuilder();
for (int i = 0; i < kinds.length; i++) {
if (i > 0) kindBuilder.append(',');
kindBuilder.append(kinds[i]);
}
if (feedHref.indexOf('?') == -1) {
feedHref += "?kind=" + kindBuilder;
} else {
feedHref += "&kind=" + kindBuilder;
}
}
URL feedUrl = new URL(feedHref);
return state.service.getFeed(feedUrl, feedClass);
}
示例11: getWorksheetFeedUrlString
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Gets the URL for this spreadseet's worksheets feed as a string.
*
* <p>This checks for version compatibility also.
*
* and call that from here, just like in WorksheetEntry.
*
* @return a string representing the URL for the worksheets feed
*/
private String getWorksheetFeedUrlString() {
Version spreadsheetVersion = state.service.getProtocolVersion();
if (spreadsheetVersion.isCompatible(SpreadsheetService.Versions.V1)) {
Link feedLink = this.getLink(Namespaces.WORKSHEETS_LINK_REL,
Link.Type.ATOM);
return feedLink.getHref();
} else { // must be SpreadsheetService.Versions.V2; only 2 versions for now
return ((OutOfLineContent)(this.getContent())).getUri();
}
}
示例12: getPhotos
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Retrieves the photos for the given album.
*/
public List<PhotoEntry> getPhotos(AlbumEntry album) throws IOException,
ServiceException {
List<PhotoEntry> photos = new ArrayList<PhotoEntry>();
// If it doesn't have an ID, it's an album we haven't created yet!
if( album.getLinks().size() != 0 ) {
String feedHref = getLinkByRel(album.getLinks(), Link.Rel.FEED);
feedHref = addParameter(feedHref, "imgmax", "d");
feedHref = addParameter(feedHref, "max-results", "1000");
while (feedHref != null) {
AlbumFeed albumFeed = getFeed(feedHref, AlbumFeed.class);
List<GphotoEntry> entries = albumFeed.getEntries();
for (GphotoEntry entry : entries) {
GphotoEntry adapted = entry.getAdaptedEntry();
if (adapted instanceof PhotoEntry) {
photos.add((PhotoEntry) adapted);
}
}
Link nextLink = albumFeed.getNextLink();
if (nextLink != null) {
feedHref = nextLink.getHref();
} else {
feedHref = null;
}
}
}
TimeUtils.sortPhotoEntriesNewestFirst(photos);
return photos;
}
示例13: getParentId
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Returns the id given by the given entry's parent link, or null if it has
* no parent link.
*/
public static String getParentId(BaseContentEntry<?> entry) {
Link link = entry.getLink(SitesLink.Rel.PARENT, ILink.Type.ATOM);
if (link == null) {
return null;
}
return link.getHref();
}
示例14: getAlbums
import com.google.gdata.data.Link; //导入方法依赖的package包/类
/**
* Retrieves the albums for the given user.
* albumUrl = addParameter(albumUrl, "hidestreamid", "photos_from_posts" );
*/
public List<AlbumEntry> getAlbums(String username, boolean showall ) throws IOException,
ServiceException {
String albumUrl = API_PREFIX + username;
if( showall )
albumUrl = addParameter( albumUrl, "showall", null );
List<AlbumEntry> albums = new ArrayList<AlbumEntry>();
while( true ) {
UserFeed userFeed = getFeed(albumUrl, UserFeed.class);
feeds.add( userFeed );
List<GphotoEntry> entries = userFeed.getEntries();
for (GphotoEntry entry : entries) {
GphotoEntry adapted = entry.getAdaptedEntry();
if (adapted instanceof AlbumEntry) {
AlbumEntry album = (AlbumEntry)adapted;
albums.add(album);
}
}
Link nextLink = userFeed.getNextLink();
if( nextLink == null )
break;
albumUrl = nextLink.getHref();
}
TimeUtils.sortAlbumEntriesNewestFirst( albums );
return albums;
}
示例15: processBatchRequest
import com.google.gdata.data.Link; //导入方法依赖的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.");
}
}