本文整理汇总了Java中com.google.api.services.mirror.Mirror类的典型用法代码示例。如果您正苦于以下问题:Java Mirror类的具体用法?Java Mirror怎么用?Java Mirror使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mirror类属于com.google.api.services.mirror包,在下文中一共展示了Mirror类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertMultiHtmlTimelineItem
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static void insertMultiHtmlTimelineItem( ServletContext ctx,
HttpServletRequest req )
throws IOException, ServletException
{
Mirror mirror = MirrorUtils.getMirror( req );
Timeline timeline = mirror.timeline();
// START:insertMultiHtmlTimelineItem
// Generate a unique Lunch Roulette bundle id
String bundleId = "lunchRoulette" + UUID.randomUUID();
// First Cuisine Option
TimelineItem timelineItem1 = new TimelineItem()
.setHtml( renderRandomCuisine( ctx ) )
.setBundleId( bundleId )
.setIsBundleCover( true );
timeline.insert( timelineItem1 ).execute();
// Alternate Cuisine Option
TimelineItem timelineItem2 = new TimelineItem()
.setHtml( renderRandomCuisine( ctx ) )
.setBundleId( bundleId );
timeline.insert( timelineItem2 ).execute();
// END:insertMultiHtmlTimelineItem
}
示例2: insertAndSaveSimpleHtmlTimelineItem
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static void insertAndSaveSimpleHtmlTimelineItem( ServletContext ctx,
String userId )
throws IOException, ServletException
{
Mirror mirror = MirrorUtils.getMirror( userId );
Timeline timeline = mirror.timeline();
// START:insertSimpleHtmlTimelineItem
// get a cuisine, populate an object, and render the template
String cuisine = getRandomCuisine();
Map<String, String> data = Collections.singletonMap( "food", cuisine );
String html = render( ctx, "glass/cuisine.ftl", data );
TimelineItem timelineItem = new TimelineItem()
.setTitle( "Lunch Roulette" )
.setHtml( html )
.setSpeakableText( "You should eat "+cuisine+" for lunch" );
TimelineItem tiResp = timeline.insert( timelineItem ).execute();
// END:insertSimpleHtmlTimelineItem
setLunchRouletteId( userId, tiResp.getId() );
}
示例3: insertAndSaveSimpleTextTimelineItem
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static void insertAndSaveSimpleTextTimelineItem( HttpServletRequest req )
throws IOException
{
String userId = SessionUtils.getUserId( req );
Credential credential = AuthUtils.getCredential( userId );
Mirror mirror = MirrorUtils.getMirror( credential );
Timeline timeline = mirror.timeline();
// START:insertAndSaveSimpleTimelineItem
TimelineItem timelineItem = new TimelineItem()
.setTitle( "Lunch Roulette" )
.setText( getRandomCuisine() );
TimelineItem tiResp = timeline.insert( timelineItem ).execute();
setLunchRouletteId( userId, tiResp.getId() );
// END:insertAndSaveSimpleTimelineItem
}
示例4: addAppAsContact
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static void addAppAsContact( HttpServletRequest req, String userId )
throws IOException
{
Mirror mirror = MirrorUtils.getMirror(req);
Contacts contacts = mirror.contacts();
Contact contact = new Contact()
.setId( "lunch-roulette" )
.setDisplayName( "Lunch Roulette" )
.setImageUrls( Collections.singletonList(
PROD_BASE_URL + "/static/images/roulette.png" ) )
.setPriority( 0L )
.setAcceptTypes( Collections.singletonList( "image/*" ) );
contacts.insert( contact ).executeAndDownloadTo( System.out );
}
示例5: previewOnGlass
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
private void previewOnGlass() {
try {
Credential cred = GoogleLogin.getInstance().getCredential();
cred.getAccessToken();
Mirror m = new Mirror.Builder(GoogleNetHttpTransport.newTrustedTransport(), new JacksonFactory(), cred)
.setApplicationName("Glassmaker Plugin")
.build();
String editorText = getDocumentProvider().getDocument(textEditor.getEditorInput()).get();
deletePreviewFiles();
TimelineItem timelineItem = CardUtil.createTimeline(editorText);
Mirror.Timeline timeline = m.timeline();
timeline.insert(timelineItem).execute();
} catch (Exception e) {
GlassmakerUIPlugin.logError(e.getMessage(), e);
}
}
示例6: getMirror
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
private Mirror getMirror(HttpServletRequest req) throws IOException{
Credential credential = AuthUtil.getCredential(req);
// build access to Mirror API
return new Mirror.Builder(
new UrlFetchTransport(), new JacksonFactory(), credential)
.setApplicationName("Hello World").build();
}
示例7: getMirror
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static Mirror getMirror( HttpServletRequest req )
throws IOException
{
String userId = SessionUtils.getUserId( req );
Credential credential = AuthUtils.getCredential(userId);
return getMirror(credential);
}
示例8: insertSimpleTextTimelineItem
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static void insertSimpleTextTimelineItem( HttpServletRequest req )
throws IOException
{
Mirror mirror = MirrorUtils.getMirror( req );
Timeline timeline = mirror.timeline();
TimelineItem timelineItem = new TimelineItem()
.setText( getRandomCuisine() );
timeline.insert( timelineItem ).executeAndDownloadTo( System.out );
}
示例9: getLastSavedTimelineItem
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static TimelineItem getLastSavedTimelineItem( String userId )
throws IOException
{
Credential credential = AuthUtils.getCredential( userId );
Mirror mirror = MirrorUtils.getMirror( credential );
Timeline timeline = mirror.timeline();
// START:getLastSavedTimelineItem
String id = getLunchRouletteId( userId );
TimelineItem timelineItem = timeline.get( id ).execute();
// END:getLastSavedTimelineItem
return timelineItem;
}
示例10: buildRandomRestaurantTimelineItem
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static TimelineItem buildRandomRestaurantTimelineItem(
ServletContext ctx, String userId )
throws IOException, ServletException
{
Mirror mirror = MirrorUtils.getMirror( userId );
Location location = mirror.locations().get("latest").execute();
double latitude = location.getLatitude();
double longitude = location.getLongitude();
// START:insertRandomRestaurantTimelineItem
// get a nearby restaurant from Google Places
Place restaurant = getRandomRestaurant(latitude, longitude);
// create a timeline item with restaurant information
TimelineItem timelineItem = new TimelineItem()
.setHtml( render( ctx, "glass/restaurant.ftl", restaurant ) )
.setTitle( "Lunch Roulette" )
.setMenuItems( new LinkedList<MenuItem>() )
.setLocation(
new Location()
.setLatitude( restaurant.getLatitude() )
.setLongitude( restaurant.getLongitude() )
.setAddress( restaurant.getAddress() )
.setDisplayName( restaurant.getName() )
.setKind( restaurant.getKind() ) );
// Add the NAVIGATE menu item
timelineItem.getMenuItems().add(
new MenuItem().setAction( "NAVIGATE" )
);
// END:insertRandomRestaurantTimelineItem
timelineItem.getMenuItems().add(
new MenuItem().setAction( "DELETE" )
);
return timelineItem;
}
示例11: pushPost
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
/**
* Create a timeline item for every follower of this blog
*/
// START:pushPost
private static void pushPost( Blog blog, Post post )
throws IOException
{
// find every user that follows that nickname
List<User> users = blog.getFollowers();
for (User user : users) {
String userId = user.getId();
Mirror mirror = MirrorUtils.getMirror( userId );
TimelineItem timelineItem = new TimelineItem()
.setText( post.getBody() );
mirror.timeline().insert( timelineItem ).execute();
}
}
示例12: getContact
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static Contact getContact(Credential credential, String id) throws IOException {
try {
Mirror.Contacts contacts = getMirror(credential).contacts();
return contacts.get(id).execute();
} catch (GoogleJsonResponseException e) {
LOG.warning("Could not find contact with ID " + id);
return null;
}
}
示例13: getAttachmentInputStream
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static InputStream getAttachmentInputStream(Credential credential, String timelineItemId, String attachmentId)
throws IOException {
Mirror mirrorService = getMirror(credential);
Mirror.Timeline.Attachments attachments = mirrorService.timeline().attachments();
Attachment attachmentMetadata = attachments.get(timelineItemId, attachmentId).execute();
HttpResponse resp = mirrorService.getRequestFactory().buildGetRequest(new GenericUrl(attachmentMetadata.getContentUrl())).execute();
return resp.getContent();
}
示例14: getContact
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static Contact getContact(Credential credential, String id) throws IOException {
try {
Mirror.Contacts contacts = getMirror(credential).contacts();
return contacts.get(id).execute();
} catch (GoogleJsonResponseException e) {
LOG.warning("Could not find contact with ID " + id);
return null;
}
}
示例15: listItems
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static TimelineListResponse listItems(Credential credential, long count)
throws IOException {
Mirror.Timeline timelineItems = getMirror(credential).timeline();
Mirror.Timeline.List list = timelineItems.list();
list.setMaxResults(count);
return list.execute();
}