Package com.nevernote.domain

Examples of com.nevernote.domain.Users


    ctx.refresh();

    PreferencesService prefService = ctx.getBean("preferencesService", PreferencesService.class);
    ClientService cs = ctx.getBean("clientService", ClientService.class);
   
    Users user = (Users) session.getAttribute("userSession");
    if (user == null){
      response.sendRedirect("Login.jsp");
    }
    if (!user.getEnabled()) {
      response.sendRedirect("Login.jsp");
    }
   
    //Test that we got the user
    System.out.println("********Users object passed from Login**************");
    System.out.println( user.getId() );
    System.out.println("********************");
   
    // Obtain Collection of all Nodes (Folders + Notes )
    List<Notes> userNotes = new ArrayList<Notes>();
   
    userNotes = cs.findAllForUser(user.getId());
   
    if (userNotes == null || !userNotes.isEmpty()) {
      //Test Notes results on console
      for (Notes note : userNotes) {
        System.out.println("Here is a file name: " + note.getFileName());
      }
     
      String sortMethod = prefService.findOne(user.getId()).getSort();
      if (sortMethod.equals("ALPHA_ASCENDING")) {
        Collections.sort(userNotes);
      } else if (sortMethod.equals("ALPHA_DESCENDING")) {
        Collections.sort(userNotes, Collections.reverseOrder());
      }

      session.setAttribute("userNotes", userNotes);
     
    } else {
      session.setAttribute("userNotes", new ArrayList<Notes>());
    }
    System.out.println("No More notes for this user");
   
    Preferences userPref = prefService.findOne(user.getId());

    session.setAttribute("fontColor", ColorScheme.valueOf(userPref.getColors()).getFontColor());
    session.setAttribute("backColor", ColorScheme.valueOf(userPref.getColors()).getBackColor());

    response.sendRedirect("ClientDash.jsp");
View Full Code Here


    List<Notes> all = ns.findAll();
    List<Notes> userNotes = new ArrayList<Notes>();
    System.out.println("***************I did get the right ID, right?**************");
    System.out.println(id);
   
    Users target = us.findById(id);
   
    System.out.println("***************this should be the right user**************");
    if(target==null){
      System.out.println("ARGH!!! NO USER FOUND!!! F-ING NULL?");
    }else{
      System.out.println("Here is the User ID I found: " + target.getId());
    }
   
   
    for(Notes note: all){
      Set<Users> owners = new HashSet<Users>(note.getUsers());
      //TODO: Comment this out later
      System.out.println("***************This should be all notes in DB **************");
      System.out.println("File Name: " + note.getFileName());
      for(Users use: owners){
        if( target.getId().equals(use.getId()) ){
          System.out.println("**ADDING NOTE: " + note.getFileName() + " for user: " + target.getId());
          userNotes.add(note);
        }
      }
    }
   
View Full Code Here

  }

  @Override
  public Users loginCheck(String id, String pass) {
       
    Users validate = usersRepository.findOne(id);
   
    BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor();
    if ((validate != null && validate.getEnabled()) && passwordEncryptor.checkPassword(pass, validate.getPassword())){
      return validate;
    } else{
      return null;
    }
  }
View Full Code Here

    }
  }

  @Override
  public boolean changePassword(String id, String password) {
    Users userUpdate;
    BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor();
    userUpdate = usersRepository.findOne(id);
    if (userUpdate == null || !userUpdate.getEnabled()){
      return false;
    } else {
      userUpdate.setPassword(passwordEncryptor.encryptPassword(password));
      save(userUpdate.getId(), userUpdate);
    }

    return true;
  }
View Full Code Here

    ctx.load("classpath:app-context.xml");
    ctx.refresh();

    UsersService usersService = ctx.getBean("usersService", UsersService.class);
    //validate user and return user object
    Users userSession = usersService.loginCheck(request.getParameter("un"), request.getParameter("pw"));
 
    if(userSession != null && !userSession.getId().equals("root")){
      session.setAttribute("userSession", userSession);
      response.sendRedirect("ClientDashServlet");
    } else if (userSession != null && userSession.getId().equals("root")) {
      session.setAttribute("userSession", userSession);
      response.sendRedirect("AdminDashServlet");
    } else {
      response.sendRedirect("invalidLogin.jsp");
    }
View Full Code Here

      String url = "/Register.jsp";
      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
      dispatcher.forward(request, response);
      return;
    } else {
      Users newUser = new Users();
      newUser.setId(request.getParameter("un"));
      newUser.setPassword(encryptedPassword);
      newUser.setPriviledge("standard");
      newUser.setEnabled(true);
      System.out.println(newUser.toString())
      Users savedUser = usersService.save(request.getParameter("un"),newUser);

      Preferences prefs = new Preferences();
      prefs.setUserID(savedUser.getId());
      prefs.setColors(ColorScheme.valueOf("BLACK_ON_WHITE").toString());
      prefs.setSort(SortingMethod.valueOf("ALPHA_ASCENDING").toString());
      preferenceService.save(prefs);

      String relativeWebPath = "WEB-INF/notesRepo";
View Full Code Here

   
    //Keeping track of user session and notes
    PreferencesService preferencesService = ctx.getBean("preferencesService", PreferencesService.class);
   
    //Pulls user session and confirms they are logged in
    Users u = (Users) session.getAttribute("userSession");
    if(u == null){
      response.sendRedirect("Login.jsp");
    }
    if (!u.getEnabled()) {
      response.sendRedirect("Login.jsp");
    }

    String sort = request.getParameter("sort");
    String colors = request.getParameter("color");

    if (sort != null && colors != null) {
      Preferences pref = preferencesService.findOne(u.getId());
      pref.setColors(colors);
      pref.setSort(sort);
      preferencesService.save(pref);
    }
    response.sendRedirect("ClientDashServlet");
View Full Code Here

    //Keeping track of user session and notes
    PreferencesService preferencesService = ctx.getBean("preferencesService", PreferencesService.class);
    UsersService usersService = ctx.getBean("usersService", UsersService.class);
   
    //Pulls user session and confirms they are logged in
    Users u = (Users) session.getAttribute("userSession");
    Users userFromDB = usersService.findById(u.getId());
    if(userFromDB == null){
      response.sendRedirect("Login.jsp");
    }
    if (!userFromDB.getEnabled()) {
      response.sendRedirect("Login.jsp");
    }

    String sort = preferencesService.findOne(u.getId()).getSort();
    String colors = preferencesService.findOne(u.getId()).getColors();
View Full Code Here

    //Keeping track of user session and notes
    NotesService notesService = ctx.getBean("notesService", NotesService.class);
    UsersService usersService = ctx.getBean("usersService", UsersService.class);
   
    //Pulls user session and confirms they are logged in
    Users u = (Users) session.getAttribute("userSession");
    Users userFromDB = usersService.findById(u.getId());
    if (userFromDB == null) {
      response.sendRedirect("Login.jsp");
    }
    if (!userFromDB.getEnabled()) {
      response.sendRedirect("Login.jsp");
    }

    //Retrieve the not name and also what the user entered into the note
    String wholeNote = request.getParameter("wholeNote");
    String noteName = request.getParameter("noteName");   

    //Find the relative path of the notesRepo folder to append to note name for saving
    //Under windows running in Eclipse that location is:
    //C:\eclipse workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\NeverNote\WEB-INF\notesRepo\
    String relativeWebPath = "WEB-INF/notesRepo/" + userFromDB.getId();
    String absoluteDiskPath = getServletContext().getRealPath(relativeWebPath);
    File file = new File(absoluteDiskPath + "/" + noteName);

    //Save the note
    FileWriter writer = new FileWriter(file);
    writer.write(wholeNote);
    writer.flush();
    writer.close();

    //Update database to add a new note
    Notes theNote = new Notes(noteName);
    if (notesService.findOne(theNote.getFileName()) == null) {
             Set<Users> noteUsers = new HashSet<Users>();
             noteUsers.add(u);
             theNote.setUsers(noteUsers);
             notesService.save(theNote);

             userFromDB.addNote(theNote);
             Users savedUser = usersService.save(userFromDB.getId(), userFromDB);
             session.setAttribute("userSession", savedUser);
    }

    String url = "/ClientDashServlet";
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
View Full Code Here

   
    // This is where the file name is found from ClientDashServlet
    String noteName = request.getParameter("file");
    System.out.println("Note requested to be loaded: " + noteName);

    Users u = (Users) session.getAttribute("userSession");
    if (u == null) {
      response.sendRedirect("Login.jsp");
    }
    if (!u.getEnabled()) {
      response.sendRedirect("Login.jsp");
    }

    // This is where the file will be accessed and text loaded
    // New files will be created and then loaded
    System.out.println("Loading file " + noteName + " now.");
   
    //Find the relative path of the notesRepo folder to append to note name for saving
    String relativeWebPath = "WEB-INF/notesRepo";
    String absoluteDiskPath = getServletContext().getRealPath(relativeWebPath);
    File file = new File(absoluteDiskPath + "/" + u.getId() + "/" + noteName);

    BufferedReader br = null;
    try
    {
      br = new BufferedReader(new FileReader(file));
View Full Code Here

TOP

Related Classes of com.nevernote.domain.Users

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.