Package it.twiskex.services

Source Code of it.twiskex.services.TwiSKExServlet

package it.twiskex.services;

import it.twiskex.dal.DALService;
import it.twiskex.dal.entities.SearchNTT;

import java.io.IOException;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import com.googlecode.objectify.Key;

@SuppressWarnings("serial")
public class TwiSKExServlet extends TwiSKExHttpServlet {
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    //
    // TaskOptions taskoptions = TaskOptions.Builder
    // .withUrl("/search_n_store_by_tag")
    // .param(HASHTAG, "#urbino2020")
    // .method(TaskOptions.Method.GET);
    // Queue queue = QueueFactory.getQueue(SEARCH_QUEUE);
    //
    // TaskHandle handle = queue.add(taskoptions);

    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();

    if (user != null) {
      resp.setContentType("text/plain");
      resp.getWriter().println("Hello, " + user.getNickname());

      if (req.getParameterMap().containsKey("hashtagTxtBox")) {
        SearchNTT currentSearch = null;

        currentSearch = new SearchNTT("#"
            + req.getParameter("hashtagTxtBox"));
        currentSearch.setLastUpdate(new Date());
        Key<SearchNTT> k = DALService.ofy().put(currentSearch);

        resp.setContentType("text/plain");
        resp.getWriter().println(k.getName());
      }
    } else {
      resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
    }
  }

}
TOP

Related Classes of it.twiskex.services.TwiSKExServlet

TOP
Copyright © 2018 www.massapi.com. 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.