Package com.google.appengine.api.users

Examples of com.google.appengine.api.users.User


    addNewTag(tag);
       
    ContentAPI api = new ContentAPI();
       
    String content = "dummy content";
    User user = helper.loginAsPortalAdmin();
    APIResponse resp = api.setContent(content, tag, false, user);
   
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    //ensure error when not logged in     
View Full Code Here


    addNewTag(tag);
       
    ContentAPI api = new ContentAPI();
       
    String content = "dummy content";
    User user = helper.loginAsPortalAdmin();
    APIResponse resp = api.setContent(content, tag, true, user);
   
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    //ensure content can be retrieved even without login
View Full Code Here

           
    ContentAPI api = new ContentAPI();
    String tag = "tag_" + UUID.randomUUID();
   
    helper.loginAsPortalAdmin();
    User user = UserServiceFactory.getUserService().getCurrentUser();       
    APIResponse response = api.addNewTag(tag, user);
    assertTrue(response.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);
       
    helper.loginAsPortalReadOnly();
    user = UserServiceFactory.getUserService().getCurrentUser();   
View Full Code Here

  }
 
  public static Boolean isAdministrator(HttpServletRequest req, HttpServletResponse resp) {
    UserService userService = UserServiceFactory.getUserService();
   
    User user = userService.getCurrentUser();

    try {
      if (null == user) {
        String loginUrl = userService.createLoginURL(req.getRequestURI() + "?" + req.getQueryString());
        _logger.info("Sending redirect to: " + loginUrl);
View Full Code Here

      entity.setProperty("Long", new Long(RandomUtils.nextLong()));
      entity.setProperty("Boolean", new Boolean(RandomUtils.nextBoolean()));
      entity.setProperty("Float", new Float(RandomUtils.nextFloat()));
      entity.setProperty("Double", new Double(RandomUtils.nextDouble()));
      entity.setProperty("Date", new Date(RandomUtils.nextLong()));
      entity.setProperty("User", new User("test@example", "google.com"));
      entity.setProperty("Key", KeyFactory.createKey("test", RandomStringUtils
        .randomAlphabetic(5)));
      entity.setProperty("Category", new Category(RandomStringUtils.randomAlphabetic(3)));
      entity.setProperty("Email", new Email("test@example"));
      entity.setProperty("GeoPt", new GeoPt(new Float(new Integer(RandomStringUtils
View Full Code Here

    entity.setProperty(GbProperty.SHORT, new Short(RandomStringUtils.randomNumeric(1)));
    entity.setProperty(GbProperty.INTEGER, new Integer(RandomUtils.nextInt()));
    entity.setProperty(GbProperty.LONG, new Long(RandomUtils.nextLong()));
    entity.setProperty(GbProperty.FLOAT, new Float(RandomUtils.nextFloat()));
    entity.setProperty(GbProperty.DOUBLE, new Double(RandomUtils.nextDouble()));
    entity.setProperty(GbProperty.USER, new User(
      RandomStringUtils.randomAlphanumeric(20),
      RandomStringUtils.randomAlphanumeric(20)));
    entity.setProperty(GbProperty.KEY + "Id", KeyFactory.createKey(RandomStringUtils
      .randomAlphabetic(5), RandomUtils.nextLong()));
    entity.setProperty(GbProperty.KEY + "Name", KeyFactory.createKey(RandomStringUtils
View Full Code Here

  }

  public static Boolean isAdministrator(HttpServletRequest req, HttpServletResponse resp) {
    UserService userService = UserServiceFactory.getUserService();

    User user = userService.getCurrentUser();

    try {
      if (null == user) {
        String loginUrl = userService.createLoginURL(req.getRequestURI() + "?" + req.getQueryString());
        _logger.info("Sending redirect to: " + loginUrl);
View Full Code Here

public class SignGuestbookServlet extends HttpServlet {
  private static final Logger log = Logger.getLogger(SignGuestbookServlet.class.getName());
 
  public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException{
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
   
    String content = req.getParameter("content");
   
    Date date = new Date();
   
    Greeting greeting = new Greeting(user, content, date);
   
    PersistenceManager pm  = PMF.get().getPersistenceManager();
   
    try {
      pm.makePersistent(greeting);

      if (content == null) {
        content = "(No greeting)";
      }
     
      if (user != null) {
        log.info("Greeting posted by user " + user.getNickname() + " : " + content);
      } else {
        log.info("Greeting posted anonymously: " + content);
      }
     
    } finally {
View Full Code Here

public class SignGuestbookServlet extends HttpServlet {
  private static final Logger log = Logger.getLogger(SignGuestbookServlet.class.getName());
 
  public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException{
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
   
    String content = req.getParameter("content");
   
    Date date = new Date();
   
    Greeting greeting = new Greeting(user, content, date);
   
    EntityManager em = EMF.get().createEntityManager();
   
    try {
     
      em.getTransaction().begin();
      em.persist(greeting);
      em.getTransaction().commit();

      if (content == null) {
        content = "(No greeting)";
      }
     
      if (user != null) {
        log.info("Greeting posted by user " + user.getNickname() + " : " + content);
      } else {
        log.info("Greeting posted anonymously: " + content);
      }
     
    } finally {
View Full Code Here

    public <T extends Response> T execute(Action<T> action) throws Exception {
        RunnedBy runnedBy = action.getClass().getAnnotation(RunnedBy.class);
        Class<? extends ActionRunner> clazz = runnedBy.value();
        ActionRunner actionRunner = injector.getInstance(clazz);

        User user = appEngineServices.getUserService().getCurrentUser();
        String userNickname = "anonymous";
        if (user != null) {
            userNickname = user.getNickname();
        }
        String ipAddress = getThreadLocalRequest().getRemoteAddr();
        String className = action.getClass().getSimpleName();
        logger.info("User {} (ip: {}) executing action: {}", new Object[]{userNickname, ipAddress, className});
View Full Code Here

TOP

Related Classes of com.google.appengine.api.users.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.