Package com.nevernote.service

Examples of com.nevernote.service.NotesService


    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);
View Full Code Here


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

    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.load("classpath:app-context.xml");
    ctx.refresh();
   
    //Keeping track of user session and notes
    NotesService notesService = ctx.getBean("notesService", NotesService.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 noteName = request.getParameter("delete");

    //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);
    boolean success = file.delete();

    if (success) {
      //Update database with the note deletion
      Notes theNote = notesService.findOne(noteName);
      if (theNote != null) {
        theNote.removeUsers(u);
        notesService.delete(theNote);
      }
    }
    String url = "/ClientDashServlet";
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
    dispatcher.forward(request, response);
View Full Code Here

TOP

Related Classes of com.nevernote.service.NotesService

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.