Package com.dyuproject.demos.deprecated.todolist.model

Examples of com.dyuproject.demos.deprecated.todolist.model.User


        {
            response.sendError(404);
            return;
        }
        CookieSession session = getWebContext().getSession(request);
        User user = _userDao.get((Long)session.getAttribute(Constants.ID));
        request.setAttribute(Constants.USER, user);
        response.setContentType(Constants.TEXT_HTML);
        getWebContext().getJSPDispatcher().dispatch("overview/index.jsp", request,
                response);
    }
View Full Code Here


            response.setContentType(Constants.TEXT_HTML);
            getWebContext().getJSPDispatcher().dispatch("login/index.jsp", request,
                    response);
            return;
        }
        User user = _userDao.get(username, password);
        if(user==null)
        {
            request.setAttribute(Constants.MSG, Feedback.USER_NOT_FOUND.getMsg());
            response.setContentType(Constants.TEXT_HTML);
            getWebContext().getJSPDispatcher().dispatch("login/index.jsp", request,
                    response);
            return;
        }
        CookieSession session = getWebContext().getSession(request, true);
        session.setAttribute(Constants.ID, user.getId());
        getWebContext().persistSession(session, request, response);
        response.setContentType(Constants.TEXT_HTML);
        response.sendRedirect(request.getContextPath() + "/overview");
    }
View Full Code Here

                dispatchToFormView(null, request, response);
            }
            return;
        }
       
        User user = new User();
        user.setFirstName(firstName);
        user.setLastName(lastName);
        user.setEmail(email);
        user.setUsername(username);
        user.setPassword(password);
       
        boolean created = _userDao.create(user);
       
        if(Constants.XML.equals(mime))
        {
            writeXML(created ? user : UserDao.getCurrentFeedback()!=null ?
                    UserDao.getCurrentFeedback() : Feedback.COULD_NOT_CREATE_USER, request,
                    response);
        }
        else if(Constants.JSON.equals(mime))
        {
            writeJSON(created ? user : UserDao.getCurrentFeedback()!=null ?
                    UserDao.getCurrentFeedback() : Feedback.COULD_NOT_CREATE_USER, request,
                    response);
        }
        else
        {
            if(created)
            {      
                //request.setAttribute(Constants.MSG, Feedback.USER_CREATED.getMsg());               
                //dispatchToView(user, request, response);
                response.sendRedirect(request.getContextPath() + "/users/" +user.getId());
            }
            else
            {               
                request.setAttribute(Constants.MSG, UserDao.getCurrentFeedback()!=null ?
                        UserDao.getCurrentFeedback().getMsg() : Feedback.COULD_NOT_CREATE_USER);
View Full Code Here

    @Override
    protected void delete(HttpServletRequest request,
            HttpServletResponse response, String mime, String id)
            throws IOException, ServletException
    {
        User user = _userDao.get(Long.valueOf(id));
        if(user==null)
        {
            response.sendError(404);
            return;
        }
View Full Code Here

   
    protected void read(HttpServletRequest request,
            HttpServletResponse response, String mime, String id)
            throws IOException, ServletException
    {       
        User user = _userDao.get(Long.valueOf(id));
        if(user==null)
        {
            response.sendError(404);
            return;
        }
View Full Code Here

    @Override
    protected void update(HttpServletRequest request,
            HttpServletResponse response, String mime, String id)
            throws IOException, ServletException
    {
        User user = _userDao.get(Long.valueOf(id));
        if(user==null)
        {
            response.sendError(404);
            return;
        }
       
        String firstName = request.getParameter(Constants.FIRST_NAME);
        String lastName = request.getParameter(Constants.LAST_NAME);
        String email = request.getParameter(Constants.EMAIL);
        //String username = request.getParameter(Constants.USERNAME);
        //String password = request.getParameter(Constants.PASSWORD);
       
        boolean updated = false;
        if(firstName!=null)
        {
            user.setFirstName(firstName);
            updated = true;
        }
        if(lastName!=null)
        {
            user.setLastName(lastName);
            updated = true;
        }
        if(email!=null)
        {
            user.setEmail(email);
            updated = true;
        }
        /*if(username!=null)
        {
            user.setUsername(username);
View Full Code Here

        }
        else if(oldPassword.equals(newPassword))
        {
            feedback = Feedback.PASSWORD_DID_NOT_MATCH;
        }
        User user = id!=null ? _userDao.get(Long.valueOf(id)) : null;
        if(user==null)
        {
            feedback = Feedback.USER_NOT_FOUND;
        }
       
View Full Code Here

            HttpServletResponse response) throws ServletException, IOException
    {
        String method = request.getMethod();
        if(method.equals(GET))           
        {
            User user = null;
            request.setAttribute(Constants.ACTION, Constants.ACTION_CREATE);
            dispatchToFormView(user, request, response);
        }
        else if(method.equals(POST))
            create(request, response, mime);
View Full Code Here

        }
       
        String method = request.getMethod();
        if(method.equals(GET))
        {
            User user = _userDao.get(Long.valueOf(id));
            if(user==null)
                request.setAttribute(Constants.MSG, Feedback.USER_NOT_FOUND.getMsg());
            else
                request.setAttribute(Constants.USER, user);
            request.setAttribute(Constants.ACTION, Constants.ACTION_EDIT);
View Full Code Here

    protected void create(HttpServletRequest request,
            HttpServletResponse response, String mime) throws IOException,
            ServletException
    {
        String userId = (String)request.getAttribute(UsersController.IDENTIFIER_ATTR);
        User user = userId!=null ? _userDao.get(Long.valueOf(userId)) : null;
        if(user==null)
        {
            response.sendError(404);
            return;
        }
       
        String title = request.getParameter(Constants.TITLE);       
        String content = request.getParameter(Constants.CONTENT);
       
        boolean created = false;       
        Todo todo = null;
       
        if(title!=null && title.length()>0)
        {
            todo = new Todo();
            todo.setTitle(title);
            todo.setContent(content);
            todo.setUser(user);           
            created = _todoDao.create(todo);
        }
       
        if(Constants.XML.equals(mime))
        {                    
            writeXML(created ? todo : Feedback.COULD_NOT_CREATE_TODO, request, response);
        }
        else if(Constants.JSON.equals(mime))
        {           
            writeJSON(created ? todo : Feedback.COULD_NOT_CREATE_TODO, request, response);
        }
        else
        {
            if(created)
            {
                /*request.setAttribute(Constants.MSG, Feedback.TODO_CREATED.getMsg());
                request.setAttribute(Constants.USER, user);
                response.setContentType(Constants.TEXT_HTML);
                getWebContext().getJSPDispatcher().dispatch("users/id.jsp",
                        request, response);*/
                response.sendRedirect(request.getContextPath() + "/users/" + user.getId() + "/todos");
            }
            else
            {
                request.setAttribute(Constants.MSG, Feedback.COULD_NOT_CREATE_TODO.getMsg());
                request.setAttribute(Constants.ACTION, Constants.ACTION_CREATE);
View Full Code Here

TOP

Related Classes of com.dyuproject.demos.deprecated.todolist.model.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.