Package org.myphotodiary.model

Examples of org.myphotodiary.model.UserConfiguration


    EntityManager em = ModelFactory.getEntityManager();
    EntityTransaction tx = em.getTransaction();
    // reload user from database
    try {
      user = em.find(User.class, user.getUserName());
      UserConfiguration sessionConfig = user.getConfiguration();

      if (sessionConfig == null) {
        tx.begin();
        sessionConfig = new UserConfiguration(user);
        em.persist(sessionConfig);
        getServletContext().log("No configuration data for: " + user + ". Set default configuration");
        tx.commit();
      }
View Full Code Here


      response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      return;
    }
   
    // Extract request json message
    UserConfiguration newConfig = null;
    try {
      newConfig = UserConfiguration.decode(request.getInputStream());
    }
    catch (Exception ex) {
      getServletContext().log("Cannot decode POSTed configuration parameters", ex);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return;
    }

    // Persist the session configuration into database
    EntityManager em = ModelFactory.getEntityManager();
    EntityTransaction tx = null;
    try {
      tx = em.getTransaction();
      tx.begin();
     
      user = em.find(User.class, user.getUserName());
      UserConfiguration oldConfig = user.getConfiguration();
      if (oldConfig != null) {
        oldConfig.update(newConfig);
        em.merge(oldConfig);
      }
      else {
        em.persist(newConfig);
      }
View Full Code Here

    EntityManager em = ModelFactory.getEntityManager();
    EntityTransaction tx = em.getTransaction();
    // reload user from database
    try {
      user = em.find(User.class, user.getUserName());
      UserConfiguration sessionConfig = user.getConfiguration();

      if (sessionConfig == null) {
        tx.begin();
        sessionConfig = new UserConfiguration(user);
        em.persist(sessionConfig);
        getServletContext().log("No configuration data for: " + user + ". Set default configuration");
        tx.commit();
      }
View Full Code Here

      response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      return;
    }
   
    // Extract request json message
    UserConfiguration newConfig = null;
    try {
      newConfig = UserConfiguration.decode(request.getInputStream());
    }
    catch (Exception ex) {
      getServletContext().log("Cannot decode POSTed configuration parameters", ex);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return;
    }

    // Persist the session configuration into database
    EntityManager em = ModelFactory.getEntityManager();
    EntityTransaction tx = null;
    try {
      tx = em.getTransaction();
      tx.begin();
     
      user = em.find(User.class, user.getUserName());
      UserConfiguration oldConfig = user.getConfiguration();
      if (oldConfig != null) {
        oldConfig.update(newConfig);
        em.merge(oldConfig);
      }
      else {
        em.persist(newConfig);
      }
View Full Code Here

TOP

Related Classes of org.myphotodiary.model.UserConfiguration

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.