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


Java User.getEmail方法代码示例

本文整理汇总了Java中com.google.appengine.api.users.User.getEmail方法的典型用法代码示例。如果您正苦于以下问题:Java User.getEmail方法的具体用法?Java User.getEmail怎么用?Java User.getEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.users.User的用法示例。


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

示例1: CryptonomicaUser

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
public CryptonomicaUser(User googleUser,
                        PGPPublicKeyData pgpPublicKeyData,
                        NewUserRegistrationForm newUserRegistrationForm) {
    this.userId = googleUser.getUserId();
    this.webSafeStringKey = Key.create(
            CryptonomicaUser.class, googleUser.getUserId()
    ).toWebSafeString();
    this.firstName = pgpPublicKeyData.getFirstName().toLowerCase();
    this.lastName = pgpPublicKeyData.getLastName().toLowerCase();
    this.birthday = newUserRegistrationForm.getBirthday();
    this.googleUser = googleUser;
    if (googleUser.getEmail() != null) {
        this.email = new Email(googleUser.getEmail().toLowerCase()); // or email = pgpPublicKeyData.getUserEmail()
    }
    if (newUserRegistrationForm.getUserInfo() != null) {
        this.userInfo = new Text(newUserRegistrationForm.getUserInfo());
    }
    this.publicKeys = new ArrayList<>();
    Key<CryptonomicaUser> cryptonomicaUserKey = Key.create(CryptonomicaUser.class, googleUser.getUserId());
    this.publicKeys.add(
            Key.create(
                    cryptonomicaUserKey, PGPPublicKeyData.class, pgpPublicKeyData.getFingerprint()
            )
    );
}
 
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:26,代码来源:CryptonomicaUser.java

示例2: getEmail

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public String getEmail() {
  
  try {
    OAuthService authService = OAuthServiceFactory.getOAuthService();
    
    User user = authService.getCurrentUser();
    
    if ( user != null ) {
      String email = user.getEmail();
      if ( email != null && email.length() != 0 ) {
        return "mailto:" + email;
      }
    }
  } catch ( OAuthRequestException e) {
    // ignore this -- just means it isn't an OAuth-mediated request.
  }
  return null;
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:20,代码来源:GaeOutOfBandUserFetcher.java

示例3: updateUserInformation

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
/**
 * Updates current Tech Gallery user information with user data found on
 * Google.
 *
 * @param user
 *          Google user
 * @param person
 *          Google Plus person information
 * @param tgUser
 *          Tech Gallery user
 */
private void updateUserInformation(final User user, Person person, TechGalleryUser tgUser) {
  String plusEmail = user.getEmail();
  String plusPhoto = person.getImage().getUrl();
  String plusName = person.getDisplayName();

  String currentEmail = tgUser.getEmail();
  String currentPhoto = tgUser.getPhoto();
  String currentName = tgUser.getName();

  if (currentEmail == null || !currentEmail.equals(plusEmail)) {
    tgUser.setEmail(plusEmail);
  }
  if (currentPhoto == null || !currentPhoto.equals(plusPhoto)) {
    tgUser.setPhoto(plusPhoto);
  }
  if (currentName == null || !currentName.equals(plusName)) {
    tgUser.setName(plusName);
  }
  if (tgUser.getGoogleId() == null) {
    tgUser.setGoogleId(user.getUserId());
  }
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:34,代码来源:UserServiceTGImpl.java

示例4: getAccountKeyByUser

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
/**
 * Returns the Account key associated with the specified user.
 * @param pm   reference to the persistence manager
 * @param user user to return the account key for
 * @return the Account key associated with the specified user; or <code>null</code> if no account is associated with the specified user
 */
public static Key getAccountKeyByUser( final PersistenceManager pm, final User user ) {
	final String memcacheKey = CACHE_KEY_USER_ACCOUNT_KEY_PREFIX + user.getEmail();
	final String accountKeyString = (String) memcacheService.get( memcacheKey );
	if ( accountKeyString != null )
		return KeyFactory.stringToKey( accountKeyString );
	
	final Query q = new Query( Account.class.getSimpleName() );
	q.setFilter( new FilterPredicate( "user", FilterOperator.EQUAL, user ) );
	q.setKeysOnly();
	final List< Entity > entityList = DatastoreServiceFactory.getDatastoreService().prepare( q ).asList( FetchOptions.Builder.withDefaults() );
	if ( entityList.isEmpty() )
		return null;
	
	final Key accountKey = entityList.get( 0 ).getKey();
	try {
		memcacheService.put( memcacheKey, KeyFactory.keyToString( accountKey ) );
	}
	catch ( final MemcacheServiceException mse ) {
		LOGGER.log( Level.WARNING, "Failed to put key to memcache: " + memcacheKey, mse );
		// Ignore memcache errors, do not prevent serving user request
	}
	
	return accountKey;
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:31,代码来源:CachingService.java

示例5: doPost

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  Greeting greeting;

  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser();  // Find out who the user is.

  String guestbookName = req.getParameter("guestbookName");
  String content = req.getParameter("content");
  if (user != null) {
    greeting = new Greeting(guestbookName, content, user.getUserId(), user.getEmail());
  } else {
    greeting = new Greeting(guestbookName, content);
  }

  // Use Objectify to save the greeting and now() is used to make the call synchronously as we
  // will immediately get a new page using redirect and we want the data to be present.
  ObjectifyService.ofy().save().entity(greeting).now();

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:22,代码来源:SignGuestbookServlet.java

示例6: createDocument

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
/**
 * Code snippet for creating a Document.
 * @return Document Created document.
 */
public Document createDocument() {
  // [START create_document]
  User currentUser = UserServiceFactory.getUserService().getCurrentUser();
  String userEmail = currentUser == null ? "" : currentUser.getEmail();
  String userDomain = currentUser == null ? "" : currentUser.getAuthDomain();
  String myDocId = "PA6-5000";
  Document doc = Document.newBuilder()
      // Setting the document identifer is optional.
      // If omitted, the search service will create an identifier.
      .setId(myDocId)
      .addField(Field.newBuilder().setName("content").setText("the rain in spain"))
      .addField(Field.newBuilder().setName("email").setText(userEmail))
      .addField(Field.newBuilder().setName("domain").setAtom(userDomain))
      .addField(Field.newBuilder().setName("published").setDate(new Date()))
      .build();
  // [END create_document]
  return doc;
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:23,代码来源:DocumentServlet.java

示例7: doPost

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {
  Greeting greeting;

  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser();  // Find out who the user is.

  String guestbookName = req.getParameter("guestbookName");
  String content = req.getParameter("content");
  if (user != null) {
    greeting = new Greeting(guestbookName, content, user.getUserId(), user.getEmail());
  } else {
    greeting = new Greeting(guestbookName, content);
  }

  // Use Objectify to save the greeting and now() is used to make the call synchronously as we
  // will immediately get a new page using redirect and we want the data to be present.
  ObjectifyService.ofy().save().entity(greeting).now();

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:23,代码来源:SignGuestbookServlet.java

示例8: doPost

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  Greeting greeting;

  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser(); // Find out who the user is.

  String guestbookName = req.getParameter("guestbookName");
  String content = req.getParameter("content");
  if (user != null) {
    greeting = new Greeting(guestbookName, content, user.getUserId(), user.getEmail());
  } else {
    greeting = new Greeting(guestbookName, content);
  }

  greeting.save();

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:20,代码来源:SignGuestbookServlet.java

示例9: doPost

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  Greeting greeting;

  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser(); // Find out who the user is.

  String guestbookName = req.getParameter("guestbookName");
  String content = req.getParameter("content");
  if (user != null) {
    greeting = new Greeting(guestbookName, content, user.getUserId(), user.getEmail());
  } else {
    greeting = new Greeting(guestbookName, content);
  }

  // Use Objectify to save the greeting and now() is used to make the call synchronously as we
  // will immediately get a new page using redirect and we want the data to be present.
  ObjectifyService.ofy().save().entity(greeting).now();

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:22,代码来源:SignGuestbookServlet.java

示例10: createDocument

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
/**
 * Code snippet for creating a Document.
 *
 * @return Document Created document.
 */
public Document createDocument() {
  // [START create_document]
  User currentUser = UserServiceFactory.getUserService().getCurrentUser();
  String userEmail = currentUser == null ? "" : currentUser.getEmail();
  String userDomain = currentUser == null ? "" : currentUser.getAuthDomain();
  String myDocId = "PA6-5000";
  Document doc =
      Document.newBuilder()
          // Setting the document identifer is optional.
          // If omitted, the search service will create an identifier.
          .setId(myDocId)
          .addField(Field.newBuilder().setName("content").setText("the rain in spain"))
          .addField(Field.newBuilder().setName("email").setText(userEmail))
          .addField(Field.newBuilder().setName("domain").setAtom(userDomain))
          .addField(Field.newBuilder().setName("published").setDate(new Date()))
          .build();
  // [END create_document]
  return doc;
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:25,代码来源:DocumentServlet.java

示例11: getEntitiesBrowser

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@GET
@Produces(MediaType.TEXT_XML)
public List<WishlistProduct> getEntitiesBrowser() {
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	if (user == null) {
		System.out.println("Login first");
		return null;
	}

	List<WishlistProduct> list = new ArrayList<WishlistProduct>();
	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	Query query = new Query(user.getEmail());
	query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
	List<Entity> results = datastore.prepare(query).asList(
			FetchOptions.Builder.withDefaults());
	for (Entity entity : results) {
		String productID = (String) entity.getKey().getName();
		String productName = (String) entity.getProperty("productName");
		double currentPrice = (double) entity.getProperty("currentPrice");
		double lowestPrice = (double) entity.getProperty("lowestPrice");
		Date lowestDate = (Date) entity.getProperty("lowestDate");
		list.add(new WishlistProduct(productID, productName, currentPrice,
				lowestPrice, lowestDate));
	}

	return list;
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:30,代码来源:Wishlist.java

示例12: getEntities

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public List<WishlistProduct> getEntities() {
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	if (user == null) {
		System.out.println("Login first");
		return null;
	}

	List<WishlistProduct> list = new ArrayList<WishlistProduct>();
	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	Query query = new Query(user.getEmail());
	query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
	List<Entity> results = datastore.prepare(query).asList(
			FetchOptions.Builder.withDefaults());
	for (Entity entity : results) {
		String productID = (String) entity.getKey().getName();
		String productName = (String) entity.getProperty("productName");
		double currentPrice = (double) entity.getProperty("currentPrice");
		double lowestPrice = (double) entity.getProperty("lowestPrice");
		Date lowestDate = (Date) entity.getProperty("lowestDate");
		list.add(new WishlistProduct(productID, productName, currentPrice,
				lowestPrice, lowestDate));
	}

	return list;
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:30,代码来源:Wishlist.java

示例13: newWishlistProductJson

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@POST
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_JSON)
public void newWishlistProductJson(WishlistProduct product,
		@Context HttpServletResponse servletResponse) throws Exception {
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	if (user == null) {
		System.out.println("Login first");
		return;
	}

	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
	Entity entity = new Entity(user.getEmail(), product.getProductID());
	entity.setProperty("productName", product.getProductName());
	entity.setProperty("currentPrice", product.getCurrentPrice());
	entity.setProperty("lowestPrice", product.getLowestPrice());
	entity.setProperty("lowestDate", new Date());
	datastore.put(entity);
	syncCache.put(product.getProductID(), product.getCurrentPrice());
	servletResponse.getWriter().println("<html><head>");
	servletResponse
			.getWriter()
			.println(
					"<meta http-equiv=\"refresh\" content=\"3;url=/wishlist.jsp\" />");
	servletResponse.getWriter().println("</head><body>");
	servletResponse.getWriter()
			.println(
					"<h1>" + product.getProductName()
							+ " has been added.</h1><br>");
	servletResponse
			.getWriter()
			.println(
					"<h2>Redirecting in 3 seconds...</h2> <a href=\"/wishlist.jsp\">Go back now</a>");
	servletResponse.getWriter().println("</body></html>");
	servletResponse.flushBuffer();
	return;
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:41,代码来源:Wishlist.java

示例14: getEntity

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
@Path("{productID}")
public WishlistProductResource getEntity(
		@PathParam("productID") String productID) {
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	if (user == null) {
		System.out.println("Login first");
		return null;
	}
	return new WishlistProductResource(uriInfo, request, productID, user.getEmail());
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:12,代码来源:Wishlist.java

示例15: pushPersonalizedOffers

import com.google.appengine.api.users.User; //导入方法依赖的package包/类
/**
 * Sends personalized offers to a user that checked in at a place.
 * @param placeId the place from which we want to retrieve offers.
 * @param user the user to whom we send the personalized offers.
 */
private void pushPersonalizedOffers(final String placeId, final User user) {
    // insert a task to a queue
    LOG.info("adding a task to recommendations-queue");
    Queue queue = QueueFactory.getQueue("recommendations-queue");

    try {
        String userEmail = user.getEmail();
        queue.add(withUrl("/tasks/recommendations")
                .param("userEmail", userEmail).param("placeId", placeId));
        LOG.info("task added");
    } catch (RuntimeException e) {
        LOG.severe(e.getMessage());
    }
}
 
开发者ID:googlearchive,项目名称:MobileShoppingAssistant-sample,代码行数:20,代码来源:CheckInEndpoint.java


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