Package com.nevernote.service

Examples of com.nevernote.service.UsersService


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

    UsersService usersService = ctx.getBean("usersService", UsersService.class);

    boolean success = usersService.changePassword(request.getParameter("un"), request.getParameter("pw"));

    if (success) {
      request.setAttribute("success", "Successfully changed password.");
      String url = "/Login.jsp";
      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
View Full Code Here


    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.load("classpath:app-context.xml");
    ctx.refresh();
   
   
    UsersService us = ctx.getBean("usersService", UsersService.class);
    NotesService ns = ctx.getBean("notesService", NotesService.class);
   
   
    //TODO - There is probably a better way to do this, but its late, and I want to work on the Client Dash
   
    System.out.println("***************Inside findAllForUser**************");
    System.out.println("***************Get All Notes**************");
    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{
View Full Code Here

    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    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")) {
View Full Code Here

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

    UsersService usersService = ctx.getBean("usersService", UsersService.class);
    PreferencesService preferenceService = ctx.getBean("preferencesService", PreferencesService.class);

    BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor();
    String encryptedPassword = passwordEncryptor.encryptPassword(request.getParameter("pw"));

    if(usersService.findById(request.getParameter("un")) != null) {
      request.setAttribute("registrationMessage", "Username is already taken please regiser with another user name.");
      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());
View Full Code Here

    ctx.load("classpath:app-context.xml");
    ctx.refresh();
   
    //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");
View Full Code Here

    ctx.load("classpath:app-context.xml");
    ctx.refresh();
   
    //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

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

    UsersService us = ctx.getBean("usersService", UsersService.class);
   
    Users user = (Users) session.getAttribute("userSession");
    if (user == null){
      response.sendRedirect("Login.jsp");
    }
    if (!user.getEnabled()) {
      response.sendRedirect("Login.jsp");
    }
    if (!"root".equals(user.getId())) {
      response.sendRedirect("Login.jsp");
    }

    String userId = request.getParameter("disable");
    Users userToDisable = us.findById(userId);
    userToDisable.setEnabled(false);
    us.save(userToDisable.getId(), userToDisable);

    response.sendRedirect("AdminDashServlet");
  }
View Full Code Here

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

    UsersService us = ctx.getBean("usersService", UsersService.class);
   
    Users user = (Users) session.getAttribute("userSession");
    if (user == null){
      response.sendRedirect("Login.jsp");
    }
    if (!user.getEnabled()) {
      response.sendRedirect("Login.jsp");
    }
    if (!"root".equals(user.getId())) {
      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 Users
    List<Users> users = new ArrayList<Users>();
   
    users = us.findAll();

    List<Users> usersToBeSent = new ArrayList<Users>();
    for (Users u : users) {
      if (!"root".equals(u.getId())) {
        usersToBeSent.add(u);
View Full Code Here

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

    UsersService us = ctx.getBean("usersService", UsersService.class);
   
    Users user = (Users) session.getAttribute("userSession");
    if (user == null){
      response.sendRedirect("Login.jsp");
    }
    if (!user.getEnabled()) {
      response.sendRedirect("Login.jsp");
    }
    if (!"root".equals(user.getId())) {
      response.sendRedirect("Login.jsp");
    }

    String userId = request.getParameter("enable");
    Users userToEnable = us.findById(userId);
    userToEnable.setEnabled(true);
    us.save(userToEnable.getId(), userToEnable);

    response.sendRedirect("AdminDashServlet");
  }
View Full Code Here

TOP

Related Classes of com.nevernote.service.UsersService

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.