Examples of BadInputException


Examples of net.naijatek.myalumni.framework.exceptions.BadInputException

    public static String getParameterDropDown(final HttpServletRequest request, final String param, final boolean checkEmpty, final String desc)
    throws BadInputException{
        String ret = getParameter(request, param, checkEmpty);
        if ( ret.indexOf('<') != -1 || ret.indexOf('>') != -1){
          throw new BadInputException("The parameter '" + param +
              "' is not allowed to contain '<' or '>' or '@@' ! Please try again.");
        }
        if (checkEmpty){
            if (ret.equals("--") || ret.equals(" ")){
              throw new BadInputException("The " + desc +
                  " field is not allowed to be empty, please try again.");
            }
        }
        return ret;
    }
View Full Code Here

Examples of net.naijatek.myalumni.framework.exceptions.BadInputException

                // numeric char
            } else if (( b=='_' || b=='.' ) && i != 0) {
                // _ char
            } else {
                // not good char, throw an BadInputException
                throw new BadInputException("The string '" + str + "' is not a good name. Reason: character '" + (char)b + "' is not allowed.");
            }
        }// for
    }
View Full Code Here

Examples of net.naijatek.myalumni.framework.exceptions.BadInputException

* @return java.lang.String
* @throws BadInputException
   */
  public static String getShorterString(final String str, final int maxLength) throws BadInputException {
        if (maxLength < 0) {
      throw new BadInputException("The maxLength < 0 is not allowed.");
    }
        if (str == null) {
      return "";
    }
        if (str.length() <= maxLength) {
View Full Code Here

Examples of net.naijatek.myalumni.framework.exceptions.BadInputException

  // --------------------------------------------------------------------------------------

  protected static void checkGoodEmail(final String input)
      throws BadInputException {
    if (input == null) {
      throw new BadInputException(
          "Sorry, null string is not a good email.");
    }
    int atIndex = input.indexOf('@');
    int dotIndex = input.lastIndexOf('.');
    if (atIndex == -1 || dotIndex == -1 || atIndex >= dotIndex) {
      throw new BadInputException("Error: '" + input
          + "' is not a valid email value. Please try again.");
    }
    // now check for content of the string
    byte[] s = input.getBytes();
    int length = s.length;
    byte b = 0;

    for (int i = 0; i < length; i++) {
      b = s[i];
      if (b >= 'a' && b <= 'z') {
        // lower char
      } else if (b >= 'A' && b <= 'Z') {
        // upper char
      } else if (b >= '0' && b <= '9' && i != 0) {
        // numeric char
      } else if ((b == '_' || b == '-' || b == '.' || b == '@') && i != 0) {
        // _ char
      } else {
        // not good char, throw an BadInputException
        throw new BadInputException(input
            + " is not a valid email. Reason: character '"
            + (char) b + "' is not accepted in an email.");
      }
    }// for

    // last check
    try {
      new javax.mail.internet.InternetAddress(input);
    } catch (Exception ex) {
      logger.error("Error when running checkGoodEmail", ex);
      throw new BadInputException(
          "Assertion: dont want to occur in Util.checkGoodEmail");
    }
  }
View Full Code Here

Examples of org.neo4j.server.rest.repr.BadInputException

    long extractId(Object uri) throws BadInputException {
        try {
            return Long.parseLong(uri.toString().substring(uri.toString().lastIndexOf("/") + 1));
        } catch (NumberFormatException ex) {
            throw new BadInputException(ex);
        } catch (NullPointerException ex) {
            throw new BadInputException(ex);
        }
    }
View Full Code Here

Examples of ru.org.linux.site.BadInputException

      }
    }

    if (showDeleted) {
      if (!tmpl.isSessionAuthorized()) {
        throw new BadInputException("Вы уже вышли из системы");
      }
    }

    params.put("showDeleted", showDeleted);
View Full Code Here

Examples of ru.org.linux.site.BadInputException

  @RequestMapping(method=RequestMethod.POST)
  public ModelAndView sendPassword(@RequestParam("email") String email, HttpServletRequest request) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (Strings.isNullOrEmpty(email)) {
      throw new BadInputException("email не задан");
    }

    User user = userDao.getByEmail(email, true);
    if (user==null) {
      throw new BadInputException("Этот email не зарегистрирован!");
    }

    user.checkBlocked();
    user.checkAnonymous();

    if (user.isModerator() && !tmpl.isModeratorSession()) {
      throw new AccessViolationException("этот пароль могут сбросить только модераторы");
    }

    if (!tmpl.isModeratorSession() && !userDao.canResetPassword(user)) {
      throw new BadInputException("Нельзя запрашивать пароль чаще одного раза в неделю!");
    }

    Timestamp now = new Timestamp(System.currentTimeMillis());

    try {
View Full Code Here

Examples of ru.org.linux.site.BadInputException

    User addUser = userDao.getUser(nick);

    // Add nick to ignore list
    if (nick.equals(user.getNick())) {
      throw new BadInputException("нельзя игнорировать самого себя");
    }

    Set<Integer> ignoreSet = ignoreListDao.get(user);

    if (!ignoreSet.contains(addUser.getId())) {
View Full Code Here

Examples of ru.org.linux.site.BadInputException

    params.put("groups", groupDao.getGroups(preparedTopic.getSection()));

    if (editable) {
      String title = request.getParameter("title");
      if (title == null || title.trim().isEmpty()) {
        throw new BadInputException("заголовок сообщения не может быть пустым");
      }
    }

    boolean preview = request.getParameter("preview") != null;
    if (preview) {
      params.put("info", "Предпросмотр");
    }

    boolean publish = request.getParameter("publish") != null;

    List<EditHistoryDto> editInfoList = editHistoryService.getEditInfo(message.getId(), EditHistoryObjectTypeEnum.TOPIC);

    if (!editInfoList.isEmpty()) {
      EditHistoryDto editHistoryDto = editInfoList.get(0);
      params.put("editInfo", editHistoryDto);

      if (lastEdit == null || editHistoryDto.getEditdate().getTime()!=lastEdit) {
        errors.reject(null, "Сообщение было отредактировано независимо");
      }
    }

    boolean commit = request.getParameter("commit") != null;

    if (commit) {
      user.checkCommit();
      if (message.isCommited()) {
        throw new BadInputException("сообщение уже подтверждено");
      }
    }

    params.put("commit", !message.isCommited() && preparedTopic.getSection().isPremoderated() && user.isModerator());
View Full Code Here

Examples of ru.org.linux.site.BadInputException

    return corrector;
  }

  public static void checkNick(String nick) throws BadInputException {
    if (nick==null || !StringUtil.checkLoginName(nick)) {
      throw new BadInputException("некорректное имя пользователя");
    }
  }
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.