Package hirondelle.web4j.model

Examples of hirondelle.web4j.model.ModelCtorException


  private final SafeText fBaseText;
  private final Boolean fIsCoderKey;
  private int fHashCode;
 
  private void validateState() throws ModelCtorException {
    ModelCtorException ex = new ModelCtorException();
    if ( FAILS == Check.optional(fId, Check.range(1,50)) ) {
      ex.add("Id is optional, 1..50 chars.");
    }
    if ( FAILS == Check.required(fBaseText, Check.range(1, 255))) {
      ex.add("Base Text is required, 1..255 chars, and must be unique.");
    }
    if ( FAILS == Check.required(fIsCoderKey)) {
      ex.add("Is Coder Key is required.");
    }
    if ( ! ex.isEmpty() ) throw ex;
  }
View Full Code Here


  
   See {@link hirondelle.web4j.model.AppResponseMessage} for further information on compound messages.
  */
  public ModelCtorException get(Class<?> aTargetClass, String aUserInputValue, RequestParameter aRequestParameter){
    String errorMessagePattern = getPatternAsFixedString(aTargetClass);
    ModelCtorException result = new ModelCtorException();
    if( SafeText.class == aTargetClass) {
      //User input might be long, so it's not included here as a second param.
      //Ideally, the second param should contain the offending character(s).
      //That is not possible here, unfortunately.
      //Mitigated by treating all chars known to EscapeChars.forHTML() as permitted chars.
      Object[] params = { aRequestParameter };
      result.add(errorMessagePattern, params);   
    }
    else {
      Object[] params = { aRequestParameter, aUserInputValue };
      result.add(errorMessagePattern, params);   
    }
    return result;
  }
View Full Code Here

  private static final String MAGIC_INITIAL_PASSWORD = "changemetosomethingalotmoreconvenienttotype";
  private static final Pattern ACCEPTED_PATTERN = Pattern.compile("(?:\\S){6,50}");
  private static final Logger fLogger = Util.getLogger(User.class);

  private void validateState() throws ModelCtorException {
    ModelCtorException ex = new ModelCtorException();
    Validator validPattern = Check.pattern(ACCEPTED_PATTERN);
    if ( FAILS == Check.required(fName, validPattern) ) {
      ex.add("Name is required, 6..50 chars, no spaces.");
    }
    if ( FAILS == Check.required(fHashedPassword, validPattern)) {
      ex.add("Password is required, 6..50 chars, no spaces.");
    }
    if( fName != null && fHashedPassword != null ) {
      if( fName.getRawString().equalsIgnoreCase(fHashedPassword.getRawString()) ){
        ex.add("Password cannot be the same as the user name.");
      }
    }
    if ( ! ex.isEmpty() ) throw ex;
  }
View Full Code Here

  private final List<Id> fRoles;
  private int fHashCode;
  private static final Pattern ACCEPTED_PATTERN = Pattern.compile("(?:\\S){6,50}");

  private void validateState() throws ModelCtorException {
    ModelCtorException ex = new ModelCtorException();
    Validator validPattern = Check.pattern(ACCEPTED_PATTERN);
    if ( FAILS == Check.required(fUserName, validPattern) ) {
      ex.add("User Name is required, 6..50 chars, no spaces.");
    }
    if ( FAILS == Check.required(fRoles) )  {
      ex.add("Roles is required.");
    }
    if ( ! ex.isEmpty() ) throw ex;
  }
View Full Code Here

  
   See {@link hirondelle.web4j.model.AppResponseMessage} for further information on compound messages.
  */
  public ModelCtorException get(Class<?> aTargetClass, String aUserInputValue, RequestParameter aRequestParameter){
    String errorMessagePattern = getPatternAsFixedString(aTargetClass);
    ModelCtorException result = new ModelCtorException();
    if( SafeText.class == aTargetClass) {
      //User input might be long, so it's not included here as a second param.
      //Ideally, the second param should contain the offending character(s).
      //That is not possible here, unfortunately.
      //Mitigated by treating all chars known to EscapeChars.forHTML() as permitted chars.
      Object[] params = { aRequestParameter };
      result.add(errorMessagePattern, params);   
    }
    else {
      Object[] params = { aRequestParameter, aUserInputValue };
      result.add(errorMessagePattern, params);   
    }
    return result;
  }
View Full Code Here

   private final SafeText fCaptchaChallenge;
   private final SafeText fCaptchaResponse;
   private final Id fIpAddress;

   private void validateState() throws ModelCtorException {
     ModelCtorException ex = new ModelCtorException();
    
     if ( FAILS == Check.required(fEmail, Check.email()) ) {
       ex.add("Valid email address is required.");
     }
     if( FAILS == isCaptchaPresent() ){
       ex.add("Please type in the fuzzy characters (CAPTCHA)");
     }
     else  ifFAILS == isCaptchaValid() ){
       ex.add("CAPTCHA invalid. Please type in the fuzzy characters (CAPTCHA) again.");
     }

     if ( ! ex.isEmpty() ) throw ex;
   }
View Full Code Here

  private final SafeText fCaptchaResponse;
  private final Id fIpAddress;
  private int fHashCode;

  private void validateState() throws ModelCtorException {
    ModelCtorException ex = new ModelCtorException();
   
    if ( FAILS == Check.required(fLoginName, Check.range(6, 50)) ) {
      ex.add("Login Name is required, must be at least 6 characters.");
    }
    if ( FAILS == Check.required(fScreenName, Check.range(6, 50)) ) {
      ex.add("Screen Name is required, minimum 6 characters.");
    }
    if ( FAILS == Check.required(fPassword, Check.range(6, 50)) ) {
      ex.add("Password is required, minimum 6 characters.");
    }
    if ( FAILS == Check.required(fPasswordConfirm, Check.range(6, 50)) ) {
      ex.add("Password confirmation is required, must match the password supplied above.");
    }
    if( bothPasswordsPresent() && passwordsDontMatch() ){
      ex.add("Password confirmation doesn't match the original password.");     
    }
    if ( FAILS == Check.required(fEmail, Check.email()) ) {
      ex.add("Valid email address is required (in case you forget your password).");
    }
    if( FAILS == isCaptchaPresent() ){
      ex.add("Please type in the fuzzy characters (CAPTCHA)");
    }
    else  ifFAILS == isCaptchaValid() ){
      ex.add("CAPTCHA invalid. Please type in the fuzzy characters (CAPTCHA) again.");
    }

    if ( ! ex.isEmpty() ) throw ex;
  }
View Full Code Here

  private Object[] getSignificantFields(){
    return new Object[] {fSearchText, fFromDate, fToDate, fSearchStyle};
  }
 
  private void validateState() throws ModelCtorException {
    ModelCtorException ex = new ModelCtorException();

    if ( FAILS == Check.required(fSearchText, Check.range(2, 255)) ) {
      ex.add("Please input between 2 and 255 characters.");
    }
    if(FAILS == Check.required(fSearchStyle)){
      ex.add("Please check off the style of search.");
    }
    if( fFromDate != null && fToDate != null ){
      if(fFromDate.gt(fToDate)){
        ex.add("The From Date cannot come after the To Date");
      }
    }

    if ( ! ex.isEmpty() ) throw ex;
  }
View Full Code Here

   private final SafeText fCaptchaResponse;
   private final Id fIpAddress;
   private int fHashCode;

   private void validateState() throws ModelCtorException {
     ModelCtorException ex = new ModelCtorException();
    
     if ( FAILS == Check.required(fNonce)  ) {
       ex.add("Nonce is not present.");
     }
     if ( FAILS == Check.required(fEmail, Check.email()) ) {
       ex.add("Valid email address is required.");
     }
     if ( FAILS == Check.required(fPassword, Check.range(6, 50)) ) {
       ex.add("Password is required, minimum 6 characters.");
     }
     if ( FAILS == Check.required(fPasswordConfirm, Check.range(6, 50)) ) {
       ex.add("Password confirmation is required, must match the password supplied above.");
     }
     if( bothPasswordsPresent() && passwordsDontMatch() ){
       ex.add("Password confirmation doesn't match the original password.");     
     }
     if( FAILS == isCaptchaPresent() ){
       ex.add("Please type in the fuzzy characters (CAPTCHA)");
     }
     else  ifFAILS == isCaptchaValid() ){
       ex.add("CAPTCHA invalid. Please type in the fuzzy characters (CAPTCHA) again.");
     }

     if ( ! ex.isEmpty() ) throw ex;
   }
View Full Code Here

  private int fHashCode;
 
  private enum CheckDates{YES, NO};
 
  private void validateState(CheckDates aCheckDates) throws ModelCtorException {
    ModelCtorException ex = new ModelCtorException();
   
    if ( FAILS == Check.required(fParentId) ) {
      ex.add("Parent Id is required. Programmer error.");
    }
    if ( FAILS == Check.required(fText, Check.range(1, 255)) ) {
      ex.add("You must input text for your prediction (maximum 255 characters)");
    }
    if ( FAILS == Check.optional(fRemark, Check.range(1, 2000)) ) {
      ex.add("Remark must have visible text, maximum 2,000 chars.");
    }
   
    if(CheckDates.YES == aCheckDates){
      if ( FAILS == Check.required(fCreationDate) ) {
        ex.add("Creation Date is missing (programmer error)");
      }
      if( fOutcome != null && fOutcomeDate == null) {
        ex.add("Outcome and Outcome Date must appear together.");
      }
      if( fOutcome == null && fOutcomeDate != null) {
        ex.add("Outcome and Outcome Date must appear together.");
      }
    }

    if ( ! ex.isEmpty() ) throw ex;
  }
View Full Code Here

TOP

Related Classes of hirondelle.web4j.model.ModelCtorException

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.