Examples of PreferencesService


Examples of com.nevernote.service.PreferencesService

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

Examples of com.nevernote.service.PreferencesService

    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());
      preferenceService.save(prefs);

      String relativeWebPath = "WEB-INF/notesRepo";
      String absoluteDiskPath = getServletContext().getRealPath(relativeWebPath);
      File directory = new File(absoluteDiskPath + "/" + newUser.getId());
      boolean success = directory.mkdirs();
View Full Code Here

Examples of com.nevernote.service.PreferencesService

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

Examples of com.nevernote.service.PreferencesService

    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    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");
    }

    String sort = preferencesService.findOne(u.getId()).getSort();
    String colors = preferencesService.findOne(u.getId()).getColors();
 
    session.setAttribute("sort", sort);
    session.setAttribute("colors", colors);

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

Examples of org.eclipse.core.internal.preferences.PreferencesService

   * @param file The absolute file system path of the preference file to validate.
   * @see #exportPreferences(IPath)
   * @see #importPreferences(IPath)
   */
  public static IStatus validatePreferenceVersions(IPath file) {
    PreferencesService service = PreferencesService.getDefault();
    return service.validateVersions(file);
  }
View Full Code Here

Examples of org.osgi.service.prefs.PreferencesService

        {
            printWriter.println("Status: Preferences Service not available");
        }
        else
        {
            PreferencesService ps = (PreferencesService) getBundleContext().getService(sr);
            try
            {
                printPreferences(printWriter, ps.getSystemPreferences());

                String[] users = ps.getUsers();
                for (int i = 0; users != null && i < users.length; i++)
                {
                    printWriter.println("*** User Preferences " + users[i] + ":");
                    printPreferences(printWriter, ps.getUserPreferences(users[i]));
                }
            }
            catch (BackingStoreException bse)
            {
                // todo or not :-)
View Full Code Here

Examples of org.osgi.service.prefs.PreferencesService

    /**
     * @see org.osgi.service.prefs.PreferencesService#getSystemPreferences()
     */
    public Preferences getSystemPreferences() {
        PreferencesService prefs = (PreferencesService) localPrefs.getService();

        return prefs.getSystemPreferences();
    }
View Full Code Here

Examples of org.osgi.service.prefs.PreferencesService

    /**
     * @see org.osgi.service.prefs.PreferencesService#getUserPreferences(java.lang.String)
     */
    public Preferences getUserPreferences(String name) {
        PreferencesService prefs = (PreferencesService) localPrefs.getService();

        return prefs.getUserPreferences(name);
    }
View Full Code Here

Examples of org.osgi.service.prefs.PreferencesService

     * use a default.
     *
     * Take a look at
     * http://www.vogella.com/articles/EclipsePreferences/article.html#preferences_plugin.ini
     **/
    PreferencesService preferenceService = bundleContext
        .getService(bundleContext
            .getServiceReference(PreferencesService.class));
    if (preferenceService != null) {
      Preferences systemPreferences = preferenceService
          .getSystemPreferences();
      String logDirectory = systemPreferences
          .get("logDirectory", null);
      String minOSGILevel = systemPreferences
          .get("minOSGILevel", null);
View Full Code Here

Examples of org.osgi.service.prefs.PreferencesService

        pw.close();

        URI uri = tmp.toURI();

        Preferences prefs = EasyMock.createMock(Preferences.class);
        PreferencesService preferencesService = EasyMock.createMock(PreferencesService.class);
        Preferences repositoriesNode = EasyMock.createMock(Preferences.class);
        Preferences featuresNode = EasyMock.createMock(Preferences.class);
        BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
        Bundle installedBundle = EasyMock.createMock(Bundle.class);
        FeaturesRegistry featuresRegistry = EasyMock.createNiceMock(FeaturesRegistry.class);

        expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
        expect(prefs.node("repositories")).andReturn(repositoriesNode);
        repositoriesNode.clear();
        repositoriesNode.putInt("count", 1);
        repositoriesNode.put("item.0", uri.toString());
        expect(prefs.node("features")).andReturn(featuresNode);
        featuresNode.clear();
        prefs.putBoolean("bootFeaturesInstalled", false);
        prefs.flush();
        featuresRegistry.register(isA(Repository.class));

        replay(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle, featuresRegistry);

        FeaturesServiceImpl svc = new FeaturesServiceImpl();
        svc.setPreferences(preferencesService);
        svc.setBundleContext(bundleContext);
        svc.setFeaturesServiceRegistry(featuresRegistry);
        svc.addRepository(uri);
       
        Repository[] repositories = svc.listRepositories();
        assertNotNull(repositories);
        assertEquals(1, repositories.length);
        assertNotNull(repositories[0]);
        Feature[] features = repositories[0].getFeatures();
        assertNotNull(features);
        assertEquals(1, features.length);
        assertNotNull(features[0]);
        assertEquals("f1", features[0].getName());
        assertNotNull(features[0].getDependencies());
        assertEquals(0, features[0].getDependencies().size());
        assertNotNull(features[0].getBundles());
        assertEquals(1, features[0].getBundles().size());
        assertEquals(name, features[0].getBundles().get(0));

        verify(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle, featuresRegistry);

        reset(preferencesService, prefs, repositoriesNode, featuresNode, bundleContext, installedBundle, featuresRegistry);

        expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
        expect(bundleContext.installBundle(isA(String.class),
                                           isA(InputStream.class))).andReturn(installedBundle);
        expect(installedBundle.getBundleId()).andReturn(12345L);
        expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
        installedBundle.start();

        expect(preferencesService.getUserPreferences("FeaturesServiceState")).andStubReturn(prefs);
        expect(prefs.node("repositories")).andReturn(repositoriesNode);
        repositoriesNode.clear();
        repositoriesNode.putInt("count", 1);
        repositoriesNode.put("item.0", uri.toString());
        expect(prefs.node("features")).andReturn(featuresNode);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.