Package eu.scape_project.planning.model

Examples of eu.scape_project.planning.model.User


    /**
     * Discards changes.
     */
    public void discard() {
        User origUser = em.find(User.class, user.getId());
        user.setUserGroup(origUser.getUserGroup());

        init();

        log.debug("Group changes discarted for user " + user.getUsername());
    }
View Full Code Here


        LOGGER.info("recieved a notification: {}", notification.getMessage());

        List<User> recipients = new ArrayList<User>();
       
        if (notification.getPlannerEmail() != null) {
            User recipient = em.createQuery("select u from User u where u.email = :email", User.class)
                .setParameter("email", notification.getPlannerEmail()).getSingleResult();
            if (recipient != null) {
                recipients.add(recipient);
            }
        }
View Full Code Here

                projectExportAction
                    .exportComplete(planPropertiesId, new FileOutputStream(tempFile), binarydataTempPath);
                List<Plan> plans = projectImporter.importPlans(new FileInputStream(tempFile));
                Notification notification = null;
                if (newOwner != null) {
                    User user = em.createQuery("Select u from User u where u.username = :username", User.class)
                        .setParameter("username", newOwner).getSingleResult();

                    for (Plan p : plans) {
                        PlanProperties prop = p.getPlanProperties();
                        prop.setDescription(newOwner + "'s copy of: " + prop.getDescription()
View Full Code Here

 
  @Produces
  @Named // we will need it in the view
  public User getUser() {
    if (user == null) {
      user = new User();
      user.setUsername("admin");
    }
    return user;
  }
View Full Code Here

    if (existingUser == null) {
      UserGroup userGroup = new UserGroup();
      userGroup.setName("UT Vienna");
      em.persist(userGroup);
     
      User user = new User();
      user.setUsername("admin");
      user.setFirstName("admin");
      user.setLastName("admin");
     
      // set admin rights
      Role adminRole = new Role();
      adminRole.setName("admin");
      user.getRoles().add(adminRole);
      user.setUserGroup(userGroup);
     
      em.persist(user);
    }
  }
View Full Code Here

        if (principal == null) {
            return null;
        }

        // Read user from DB
        User user = getUserFromDB(principal.getName());
        // Create new user object
        if (user == null) {
            user = createUser(principal.getName());
        }

        // Get attributes
        HttpSession session = request.getSession();
        @SuppressWarnings("unchecked")
        Map<String, List<Object>> attributes = (Map<String, List<Object>>) session
            .getAttribute("SESSION_ATTRIBUTE_MAP");

        String email = null;
        String firstName = null;
        String lastName = null;

        if (attributes != null) {
            // Set transient data from attributes
            List<Object> firstNameList = attributes.get("firstName");
            if (firstNameList != null) {
                if (firstNameList.size() > 0) {
                    firstName = (String) firstNameList.get(0);
                }
            }

            List<Object> lastNameList = attributes.get("lastName");
            if (lastNameList != null) {
                if (lastNameList.size() > 0) {
                    lastName = (String) lastNameList.get(0);
                }
            }

            List<Object> emailList = attributes.get("email");
            if (emailList != null) {
                if (emailList.size() > 0) {
                    email = (String) emailList.get(0);
                }
            }
        }

        ArrayList<Role> roles = new ArrayList<Role>();
        if (request.isUserInRole("authenticated")) {
            Role role = new Role();
            role.setName("authenticated");
            roles.add(role);

        }
        if (request.isUserInRole("admin")) {
            Role role = new Role();
            role.setName("admin");
            roles.add(role);

        }
        user.setRoles(roles);

        boolean update = false;
        if (email != null && !email.equals("") && !email.equals(user.getEmail())) {
            user.setEmail(email);
            update = true;
        }
        if (firstName != null && !firstName.equals("") && !firstName.equals(user.getFirstName())) {
            user.setFirstName(firstName);
            update = true;
        }
        if (lastName != null && !lastName.equals("") && !lastName.equals(user.getLastName())) {
            user.setLastName(lastName);
            update = true;
        }

        if (update) {
            em.merge(user);
            log.debug("Updating email address of user " + user.getUsername());
        }

        // try {
        // Subject caller = (Subject) PolicyContext
        // .getContext("javax.security.auth.Subject.container");
View Full Code Here

//    }

    private User getUserFromDB(String username) {
        // Get user from DB
        try {
            User user = em.createQuery("SELECT u From User u WHERE u.username = :username", User.class)
                .setParameter("username", username).getSingleResult();

            return user;
        } catch (NoResultException e) {
            return null;
View Full Code Here

            return null;
        }
    }

    private User createUser(String username) {
        User user = new User();
        user.setUsername(username);
        UserGroup userGroup = new UserGroup();
        userGroup.setName(username);
        user.setUserGroup(userGroup);
        em.persist(userGroup);
        em.persist(user);
        return user;
    }
View Full Code Here

    @Produces
    @Named("user")
    public User getUser() {
        if (user == null) {
            user = new User();
            user.setFirstName("Testing");
            user.setLastName("Plato");
        }
        return user;
    }
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.User

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.