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


Java UserService类代码示例

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


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

示例1: process

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
public void process() {
    UserService userService = UserServiceFactory.getUserService();
    // Step 1: Add Text into DB.
    Entity textEntity = getNewEntity();
    textEntity.setProperty("rawText", new Text(text));
    textEntity.setProperty("user",
            userService.getCurrentUser().getNickname());
    textEntity.setProperty("date", new Date());
    putIntoDatabase(textEntity);
    Key parentKey = textEntity.getKey();
    factory.setParentKey(parentKey);
    // Step 2: Call other processors.
    factory.createTypePredictor().process();
    factory.createKnowledgeGraphBuilder().process();
    factory.createSummaryGenerator().process();
}
 
开发者ID:SamChou19815,项目名称:chunk-reader,代码行数:18,代码来源:MainProcessor.java

示例2: newSharedProduct

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@POST
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public void newSharedProduct(@FormParam("productID") String productID,
		@FormParam("productName") String productName,
		@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();
	Entity entity = new Entity("SharedList", productID);
	entity.setProperty("email", user.getEmail());
	entity.setProperty("productName", productName);
	entity.setProperty("sharedDate", new Date());
	datastore.put(entity);
	servletResponse.getWriter().println(productName + " has been added.");
	servletResponse.flushBuffer();
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:24,代码来源:Sharedlist.java

示例3: doGet

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
	UserService userService = UserServiceFactory.getUserService();
	String url = "";
	String urlLinktext = "Login";
	String user = "";
	EntityManager em = EMFService.get().createEntityManager();
	
	String email = (String) req.getSession().getAttribute("login");
	UsuariosModel usuario;

	if (email != null) {
		UsuariosDAOImpl udao = UsuariosDAOImpl.getInstance();
		usuario = udao.readUserByEmail(em, email);
			
		em.close();
		user = usuario.getName();
		url = "/logout";
		urlLinktext = "Logout";
	}

	req.getSession().setAttribute("user", user);
	req.getSession().setAttribute("url", url);
	req.getSession().setAttribute("urlLinktext", urlLinktext);
	RequestDispatcher view = req.getRequestDispatcher("contact.jsp");
	view.forward(req, resp);
}
 
开发者ID:enriquecs,项目名称:Currexify-Server,代码行数:27,代码来源:ContactServlet.java

示例4: provideBrainframe

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
/** URL of Braintree iframe sandbox iframe static HTML file. */
@Provides
@Config("brainframe")
static String provideBrainframe(
    ConsoleDebug debug,
    UserService userService,
    @Config("projectId") String projectId) {
  switch (debug) {
    case PRODUCTION:
      return String.format("https://%s.storage.googleapis.com/%s",
          projectId,
          userService.isUserLoggedIn() && userService.isUserAdmin()
              ? "brainframe-map.html"
              : "brainframe.html");
    case DEBUG:
    case RAW:
    case TEST:
      return "/assets/html/insecure-brainframe.html";
    default:
      throw new AssertionError(debug.toString());
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:23,代码来源:ConsoleConfigModule.java

示例5: doFilter

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest servletReq, ServletResponse servletResp, FilterChain chain)
    throws IOException, ServletException {
  HttpServletRequest req = (HttpServletRequest) servletReq;
  HttpServletResponse resp = (HttpServletResponse) servletResp;
  String path = req.getRequestURI();

  chain.doFilter(servletReq, servletResp);

  UserService userService = UserServiceFactory.getUserService();
  if (userService.isUserLoggedIn()) {
    resp.sendRedirect(userService.createLogoutURL("/logout"));
  } else if (path.startsWith("/logout")) {
    resp.sendRedirect("/books");
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:getting-started-java,代码行数:17,代码来源:LogoutFilter.java

示例6: doGet

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException, ServletException {

  UserService userService = UserServiceFactory.getUserService();
  if (userService.isUserLoggedIn()) {
    // Save the relevant profile info and store it in the session.
    User user = userService.getCurrentUser();
    req.getSession().setAttribute("userEmail", user.getEmail());
    req.getSession().setAttribute("userId", user.getUserId());

    String destination = (String) req.getSession().getAttribute("loginDestination");
    if (destination == null) {
      destination = "/books";
    }

    logger.log(Level.INFO, "logging destination " + destination);
    resp.sendRedirect(destination);
  } else {
    resp.sendRedirect(userService.createLoginURL("/login"));
    logger.log(Level.INFO, "logging destination /login");
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:getting-started-java,代码行数:24,代码来源:LoginServlet.java

示例7: doFilter

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest servletReq, ServletResponse servletResp, FilterChain chain)
    throws IOException, ServletException {
  HttpServletRequest req = (HttpServletRequest) servletReq;
  HttpServletResponse resp = (HttpServletResponse) servletResp;

  // [START logStuff]
  String instanceId = System.getenv().containsKey("GAE_MODULE_INSTANCE")
      ? System.getenv("GAE_MODULE_INSTANCE") : "-1";
  logger.log(
      Level.INFO,
      "ListByUserFilter processing new request for path: " + req.getRequestURI()
      + " and instance: " + instanceId);
  // [END logStuff]

  UserService userService = UserServiceFactory.getUserService();
  if (userService.isUserLoggedIn()) {
    chain.doFilter(servletReq, servletResp);
  } else {
    logger.log(Level.INFO, "Not logged in, setting loginDestination to /books/mine");
    req.getSession().setAttribute("loginDestination", "/books/mine");
    resp.sendRedirect(userService.createLoginURL("/login"));
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:getting-started-java,代码行数:25,代码来源:ListByUserFilter.java

示例8: doGet

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException, ServletException {

  UserService userService = UserServiceFactory.getUserService();
  if (userService.isUserLoggedIn()) {
    // Save the relevant profile info and store it in the session.
    User user = userService.getCurrentUser();
    req.getSession().setAttribute("userEmail", user.getEmail());
    req.getSession().setAttribute("userId", user.getUserId());

    String destination = (String) req.getSession().getAttribute("loginDestination");
    if (destination == null) {
      destination = "/books";
    }

    resp.sendRedirect(destination);
  } else {
    resp.sendRedirect(userService.createLoginURL("/login"));
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:getting-started-java,代码行数:22,代码来源:LoginServlet.java

示例9: doPost

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {
  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser();

  String guestbookName = req.getParameter("guestbookName");
  Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName);
  String content = req.getParameter("content");
  Date date = new Date();
  Entity greeting = new Entity("Greeting", guestbookKey);
  if (user != null) {
    greeting.setProperty("author_id", user.getUserId());
    greeting.setProperty("author_email", user.getEmail());
  }
  greeting.setProperty("date", date);
  greeting.setProperty("content", content);

  DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
  datastore.put(greeting);

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:luisibanez,项目名称:running-with-zebras-101,代码行数:24,代码来源:SignGuestbookServlet.java

示例10: doGet

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
   throws IOException {
  if (req.getParameter("testing") == null) {
    resp.setContentType("text/plain");
    resp.getWriter().println("Hello, this is a testing servlet. \n\n");
    Properties p = System.getProperties();
    p.list(resp.getWriter());

  } else {
    UserService userService = UserServiceFactory.getUserService();
    User currentUser = userService.getCurrentUser();

    if (currentUser != null) {
      resp.setContentType("text/plain");
      resp.getWriter().println("Hello, " + currentUser.getNickname());
    } else {
      resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
    }
  }
}
 
开发者ID:luisibanez,项目名称:running-with-zebras-101,代码行数:22,代码来源:GuestbookServlet.java

示例11: doPost

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {
  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser(); 

  String guestbookName = req.getParameter("guestbookName");
  Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName);
  String content = req.getParameter("content");
  Date date = new Date();
  Entity greeting = new Entity("Greeting", guestbookKey);
  greeting.setProperty("user", user);
  greeting.setProperty("date", date);
  greeting.setProperty("content", content);

  DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
  datastore.put(greeting);

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:raghu-sannlingappa,项目名称:push-to-delploy,代码行数:21,代码来源:SignGuestbookServlet.java

示例12: doGet

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {
  if (req.getParameter("testing") == null) {
    resp.setContentType("text/plain");
    resp.getWriter().println("Hello, this is a testing servlet. \n\n");
    Properties p = System.getProperties();
    p.list(resp.getWriter());

  } else {
    UserService userService = UserServiceFactory.getUserService();
    User currentUser = userService.getCurrentUser();

    if (currentUser != null) {
      resp.setContentType("text/plain");
      resp.getWriter().println("Hello, " + currentUser.getNickname());
    } else {
      resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
    }
  }
}
 
开发者ID:raghu-sannlingappa,项目名称:push-to-delploy,代码行数:22,代码来源:GuestbookServlet.java

示例13: getUserInfo

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
public RpcResult< UserInfo > getUserInfo() {
	LOGGER.fine( "" );
	
	final UserInfo userInfo = new UserInfo();
	
	final UserService userService = UserServiceFactory.getUserService();
	final User        user        = userService.getCurrentUser();
	
	if ( user == null )
		userInfo.setLoginUrl( userService.createLoginURL( "/Admin.html" ) );
	else {
		userInfo.setAdmin( userService.isUserAdmin() );
		userInfo.setUserName( user.getNickname() );
		userInfo.setLogoutUrl( userService.createLogoutURL( "/Admin.html" ) );
	}
	
	return new RpcResult< UserInfo >( userInfo );
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:20,代码来源:AdminServiceImpl.java

示例14: getMiscFunctionInfoList

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
public RpcResult< List< MiscFunctionInfo > > getMiscFunctionInfoList() {
	LOGGER.fine( "" );
	
	final UserService userService = UserServiceFactory.getUserService();
	final User user = userService.getCurrentUser();
	if ( user == null )
		return RpcResult.createNotLoggedInErrorResult();
	if ( !userService.isUserAdmin() )
		return RpcResult.createNoPermissionErrorResult();
	
	final List< MiscFunctionInfo > miscFunctionInfoList = new ArrayList< MiscFunctionInfo >( miscFunctionMap.size() );
	
	for ( final Entry< String, DatastoreTask > entry : miscFunctionMap.entrySet() )
		miscFunctionInfoList.add( new MiscFunctionInfo( entry.getKey(), entry.getValue().getParamNames() ) );
	
	Collections.sort( miscFunctionInfoList, new Comparator< MiscFunctionInfo >() {
		@Override
           public int compare( final MiscFunctionInfo i1, final MiscFunctionInfo i2 ) {
            return i1.getName().compareTo( i2.getName() );
           }
	} );
	
	return new RpcResult< List< MiscFunctionInfo > >( miscFunctionInfoList );
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:26,代码来源:AdminServiceImpl.java

示例15: getApiKey

import com.google.appengine.api.users.UserService; //导入依赖的package包/类
@Override
public RpcResult< String > getApiKey( final String sharedApiAccount ) {
	LOGGER.fine( "sharedApiAccount: " + sharedApiAccount );
	
	final UserService userService = UserServiceFactory.getUserService();
	final User user = userService.getCurrentUser();
	if ( user == null )
		return RpcResult.createNotLoggedInErrorResult();
	
	PersistenceManager pm = null;
	try {
		
		pm = PMF.get().getPersistenceManager();
		
		final ApiAccount apiAccount = getApiAccount( pm, sharedApiAccount, user );
		if ( apiAccount == null )
			return RpcResult.createNoPermissionErrorResult();
		else
			return new RpcResult< String >( apiAccount.getApiKey() );
		
	} finally {
		if ( pm != null )
			pm.close();
	}
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:26,代码来源:ApiUserServiceImpl.java


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