Package com.dyuproject.demos.todolist.model

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


       
        Credential cred = new Credential();
        cred.setUsername(username);
        cred.setPassword(password);
        cred.setRole(Integer.valueOf(0));
        User user = null;
        try
        {
            user = (User)rc.getConsumer().consume(rc);
        }
        catch(ValidationException ve)
View Full Code Here


    public void form_change_password(RequestContext rc) throws IOException, ServletException
    {
        HttpServletRequest request = rc.getRequest();
        HttpServletResponse response = rc.getResponse();
       
        User user = MainService.getUser(rc, getWebContext());
        Credential cred = _credentialDao.get(user.getId());
        if(cred==null)
        {           
            response.sendError(404);
            return;
        }
View Full Code Here

        {
            request.setAttribute(Constants.MSG, Feedback.USER_NOT_FOUND.getMsg());
            dispatchToLogin(rc, getWebContext());
            return;
        }
        User user = credential.getUser();
        saveUser(user, rc, getWebContext());
        redirectToOverview(rc, getWebContext());
    }
View Full Code Here

    @Get
    public void overview(RequestContext rc) throws IOException, ServletException
    {
        HttpServletRequest request = rc.getRequest();

        User user = getUser(rc, getWebContext());
        request.setAttribute(Constants.USER, user);
        request.setAttribute(Constants.TODOS, _todoDao.getByUser(user.getId()));
        dispatchToOverview(rc, getWebContext());
    }
View Full Code Here

   
    @HttpResource(location="/users/$")
    @Get
    public void getById(RequestContext rc) throws IOException, ServletException
    {
        User user = _userDao.get(Long.valueOf(rc.getPathElement(1)));
        if(user==null)
        {
            rc.getResponse().sendError(404);
            return;
        }
View Full Code Here

    public void deleteById(RequestContext rc) throws IOException, ServletException
    {
        HttpServletRequest request = rc.getRequest();
        HttpServletResponse response = rc.getResponse();
       
        User user = _userDao.get(Long.valueOf(rc.getPathElement(1)));
        if(user==null)
        {
            response.sendError(404);
            return;
        }
View Full Code Here

    public void updateById(RequestContext rc) throws IOException, ServletException
    {
        HttpServletRequest request = rc.getRequest();
        HttpServletResponse response = rc.getResponse();
       
        User user = _userDao.get(Long.valueOf(rc.getPathElement(1)));
        if(user==null)
        {
            response.sendError(404);
            return;
        }
View Full Code Here

    @Get
    public void verb_edit(RequestContext rc) throws IOException, ServletException
    {
        HttpServletRequest request = rc.getRequest();

        User user = _userDao.get(Long.valueOf(rc.getPathElement(1)));
        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

    public void createByUserId(RequestContext rc) throws IOException, ServletException
    {
        HttpServletRequest request = rc.getRequest();
        HttpServletResponse response = rc.getResponse();
       
        User user = _userDao.get(Long.valueOf(rc.getPathElement(1)));       
        if(user==null)
        {
            response.sendError(404);
            return;
        }
         
        Todo todo = null;
        try
        {
            todo = (Todo)rc.getConsumer().consume(rc);
        }
        catch(ValidationException ve)
        {
            request.setAttribute(Constants.MSG, ve.getMessage());
            request.setAttribute(Constants.ACTION, Constants.ACTION_CREATE);
            dispatchToFormView((Todo)ve.getPojo(), rc, getWebContext());
            return;
        }
       
        todo.setUser(user);
        boolean created = _todoDao.create(todo);
       
        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.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.