Package org.cipres.treebase.domain.admin

Examples of org.cipres.treebase.domain.admin.User


    return fbo;
  }
 
  protected boolean isAdmin(HttpServletRequest request) {
        String username = request.getRemoteUser();
        User currentUser = getUserService().findUserByName(username);
        if (currentUser == null) return false;
        UserRole role = currentUser.getRole();
        if (role == null) return false;
        return role.isAdmin();
  }
View Full Code Here


    HttpServletRequest request,
    HttpServletResponse response,
    Object command,
    BindException bindExp) throws Exception {

    User user = (User) command;

    if (!checkPasswords(request, user)) {
      return setAttributeAndShowForm(
        request,
        response,
        bindExp,
        "errors",
        "The passwords you typed are not identical.");
    }

    // Only the admin user can update the user role:
    String username = request.getRemoteUser();
    User currentUser = getUserService().findUserByName(username);
    String updateRole = user.getTmpRoleDescription();
    String uid = request.getParameter("id");
    user.setId(Long.parseLong(uid)); // XXX

    // update role if it is changed:
    if (!TreebaseUtil.isEmpty(updateRole) && !updateRole.equals(user.getRoleDescription())) {
      if (currentUser.getRole().isAdmin()) {

        if (!TreebaseUtil.isEmpty(updateRole)) {
          UserRole newRole = getUserService().findUserRole(updateRole);

          if (newRole != null) {
View Full Code Here

   *
   */
  protected Object formBackingObject(HttpServletRequest request) throws ServletException {

    String username = request.getRemoteUser();
    User user;

    if (username != null) {
      user = getUserService().findUserByName(username);
    } else {
      user = new User();
    }
    return user;
  }
View Full Code Here

      return showForm(request, response, errors);
    }
   
    String publicationStatusUpdate = citation.getStatusDescriptionUpdate();
    if (request.getParameter(ACTION_SUBMIT) != null) {
      User user = ControllerUtil.getUser(request, mUserService);
      Study study = ControllerUtil.findStudy(request, mStudyService);
      if (citation.isCitationTypeChanged()) {
        // need to create a new citation object for the study:
        replaceCitation(study, citation);
      } else if (citation != study.getCitation()) {
View Full Code Here

    HttpServletResponse response,
    Object command,
    BindException errors) throws Exception {

    Study study = (Study) command;
    User user = ControllerUtil.getUser(request, mUserService);
   
    if (request.getParameter(ACTION_SUBMIT) != null) {
      // Study must be submitted with citation together
      // here we are just saving the data to the session
      // request.getSession().setAttribute(Constants.STUDY_KEY, study);
View Full Code Here

    HttpServletRequest request,
    HttpServletResponse response,
    Object command,
    BindException errors) throws Exception {

    User user = (User) command;

    String username = user.getUsername().trim();
    String userEmail = user.getTmpEmailAddress().trim();
    if ( TreebaseUtil.isEmpty(username) && TreebaseUtil.isEmpty(userEmail) ) {
      request.setAttribute("errors", "Please provide either user name or email.");
      return showForm(request, response, errors);
    }
       
    // look up user information
    User u = null;
    if (!TreebaseUtil.isEmpty(username)) {
      u = mUserService.findUserByName(username);
    }
    else {
      List<User> users = mUserService.findUserByEmail(userEmail);     
      if (users != null && !users.isEmpty()) {
        u = users.iterator().next();
      }
    }
   
    if ( u == null ) {
      request.setAttribute("errors", "User name: " + username
        + ", email: " + userEmail
        + ", you have provided does not exist.");
      return showForm(request, response, errors);
    }

    if ( LOGGER.isDebugEnabled() ) {
      LOGGER.debug("Server URL: " + generateServerURL(request));
    }

    //SimpleMailMessage msg = new SimpleMailMessage(this.message);
    // XXX start of new stuff
   
    // create mail session
    Properties props = new Properties();
    props.put("mail.smtp.host", TreebaseUtil.getSmtpHost());
    Session mailSession = Session.getDefaultInstance(props,null);
   
    // create email message header information
      MimeMessage message = new MimeMessage(mailSession);
      message.setRecipient(Message.RecipientType.TO, new InternetAddress(u.getEmailAddressString(),u.getLastName() + ", " + u.getFirstName()));
      message.setFrom(new InternetAddress("admin@treebase.org", "TreeBase administrator"));
      InternetAddress[] replyTo = { new InternetAddress("admin@treebase.org", "TreeBase administrator") };
      message.setReplyTo(replyTo);
      message.setRecipient(Message.RecipientType.BCC, new InternetAddress("passwords@treebase.org", "TreeBase passwords"));
      message.setSubject("TreeBASE Password", "UTF8");     
      message.setText(
        "To: " + u.getEmailAddressString() + "\n"
        + "Subject: TreeBASE Password\n\n"
        + "Thank you for requesting username/password from TreeBASE.\n\nHere is your username: "
        + u.getUsername() + "\nYour password: "
        + u.getPassword()
        + "\n\nTreebase site: "
      + TreebaseUtil.getSiteUrl());
//        + "\n\nTreebase login site: "
//      + generateServerURL(request)
//      + "/login.jsp");     
     
      // send the message
      Transport.send(message);
      request.setAttribute("messages", getMessageSourceAccessor().getMessage(
    "user.password.sent.successful")
    + " (" + u.getEmailAddressString() + ")");
      // XXX end of new stuff
   
      /*
      // XXX old spring-style mail sending
    SimpleMailMessage msg = new SimpleMailMessage();
View Full Code Here

  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
   
    String importKey = (String)request.getSession().getAttribute("importKey");
    User user = ControllerUtil.getUser(request, mUserService);
   
    if(importKey != null && importKey.length()>0){
                 
      String uploadpath = request.getSession().getServletContext()
          .getRealPath(TreebaseUtil.FILESEP + "DryadFileUpload")
View Full Code Here

   * @see org.cipres.treebase.web.controllers.UserFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
   */
  @Override
  protected Object formBackingObject(HttpServletRequest request) throws ServletException {

    User user = null;

    String username = null;
    String userId = ServletRequestUtils.getStringParameter(request, "id", null);

    if (!TreebaseUtil.isEmpty(userId)) {
      user = getUserHome().findPersistedObjectByID(User.class, Long.valueOf(userId));
    }

    if (user == null) {
      if (request.getSession().getAttribute("ADMIN_UPDATING_USERINFO_USERNAME") != null) {
        username = (String) request.getSession().getAttribute(
          "ADMIN_UPDATING_USERINFO_USERNAME");
      }

      if (username != null) {
        user = getUserService().findUserByName(username);
        if (user == null) {
          user = getUserService().findUserByName(request.getRemoteUser());
        }
      } else {
        user = getUserService().findUserByName(request.getRemoteUser());
      }
    }

    if (user == null) {
      user = new User();
    }
    return user;
  }
View Full Code Here

    if (dataMap == null) {
      dataMap = new HashMap<String, Object>();
    }

    String username = request.getRemoteUser();
    User currentUser = getUserService().findUserByName(username);
    if (currentUser.getRole().isAdmin()) {
      // drop down list for user role list
      List<String> allRoles = UserRole.allUserRoleList();
      dataMap.put("allRoles", allRoles);
    } else {
      dataMap.put("allRoles", "");
View Full Code Here

TOP

Related Classes of org.cipres.treebase.domain.admin.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.