當前位置: 首頁>>代碼示例>>Java>>正文


Java UserServiceFactory類代碼示例

本文整理匯總了Java中com.google.appengine.api.users.UserServiceFactory的典型用法代碼示例。如果您正苦於以下問題:Java UserServiceFactory類的具體用法?Java UserServiceFactory怎麽用?Java UserServiceFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UserServiceFactory類屬於com.google.appengine.api.users包,在下文中一共展示了UserServiceFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: process

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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: doGet

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的package包/類
@Override
  public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
//    req.getSession().invalidate();
    Cookie cookie = new Cookie("AppInventor", null);
    cookie.setPath("/");
    cookie.setMaxAge(0);        // This should cause it to be tossed immediately
    res.addCookie(cookie);

    // The code below is how you logout of Google. We have commented it out
    // here because in LoginServlet.java we are now destroying the ACSID Cookie
    // which effectively logs you out from Google's point of view, without effecting
    // other Google Systems that the user might be using.

    // Note: The code below will logout you out of ALL Google services
    // (which can be pretty annoying
    if (useGoogle.get() == true) {
      res.sendRedirect(UserServiceFactory.getUserService().createLogoutURL("/"));
      res.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
    } else {
      res.sendRedirect("/");
    }
  }
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:23,代碼來源:LogoutServlet.java

示例3: newSharedProduct

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例4: doGet

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例5: setUp

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
  action.enabled = true;
  action.logoFilename = "logo.png";
  action.productName = "Nomulus";
  action.integrationEmail = "[email protected]";
  action.supportEmail = "[email protected]";
  action.announcementsEmail = "[email protected]";
  action.supportPhoneNumber = "1 (888) 555 0123";
  action.technicalDocsUrl = "http://example.com/technical-docs";
  action.req = request;
  action.response = response;
  action.sessionUtils = sessionUtils;
  action.userService = UserServiceFactory.getUserService();
  action.xsrfTokenManager = new XsrfTokenManager(new FakeClock(), action.userService);
  UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false);
  action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo);
  when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true);
  when(sessionUtils.getRegistrarClientId(request)).thenReturn("TheRegistrar");
}
 
開發者ID:google,項目名稱:nomulus,代碼行數:21,代碼來源:ConsoleUiActionTest.java

示例6: doFilter

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例7: doGet

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例8: doFilter

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例9: doGet

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例10: doPost

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例11: doGet

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例12: doPost

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例13: doGet

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例14: getUserInfo

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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

示例15: getMiscFunctionInfoList

import com.google.appengine.api.users.UserServiceFactory; //導入依賴的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


注:本文中的com.google.appengine.api.users.UserServiceFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。