Ejemplo n.º 1
0
 // make sure new list name doesn't equal the default example list name
 private String getNewNameTextBox(HttpServletRequest request, String newBagName) {
   Properties properties =
       SessionMethods.getWebProperties(request.getSession().getServletContext());
   String exampleName = properties.getProperty("lists.input.example");
   if (StringUtils.isEmpty(newBagName) || newBagName.equalsIgnoreCase(exampleName)) {
     return null;
   }
   return newBagName;
 }
Ejemplo n.º 2
0
  /**
   * Method called when user has finished updating a constraint.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @return an ActionForward object defining where control goes next
   * @exception Exception if the application business logic throws an exception
   */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    ProfileManager pm = im.getProfileManager();
    String username = ((CreateAccountForm) form).getUsername();
    String password = ((CreateAccountForm) form).getPassword();
    pm.createNewProfile(username, password);
    Properties webProperties = SessionMethods.getWebProperties(session.getServletContext());
    try {
      MailUtils.email(username, webProperties);
      if (((CreateAccountForm) form).getMailinglist()
          && webProperties.getProperty("mail.mailing-list") != null
          && webProperties.getProperty("mail.mailing-list").length() > 0) {
        MailUtils.subscribe(username, webProperties);
      }
      SessionMethods.recordMessage(
          "You have successfully created an account, and logged in.", session);
    } catch (Exception e) {
      SessionMethods.recordError("Failed to send confirmation email", session);
    }

    /*
     * This code generates an MD5 key for the given username which is then
     * encoded in Hexadecimal. This could later be used for account
     * activation.
     *
     * try { MessageDigest md5 = MessageDigest.getInstance("MD5"); byte[]
     * buffer = username.getBytes(); md5.update(buffer); byte[] array =
     * md5.digest(); String encoded = HexBin.encode(array); } catch
     * (NoSuchAlgorithmException e) { }
     */
    doLogin(request, username, password);
    return new ActionForward("/begin.do");
  }
Ejemplo n.º 3
0
 /**
  * Get the web proprties.
  *
  * @param request current request (from which we fetch the servlet context).
  * @return Properties
  */
 public static Properties getWebProperties(HttpServletRequest request) {
   return SessionMethods.getWebProperties(request.getSession().getServletContext());
 }