Package com.dotcms.repackage.org.apache.struts.action

Examples of com.dotcms.repackage.org.apache.struts.action.ActionError


    }catch (DotSecurityException dse) {
      Logger.error(this, "Unable to look up contentlet with inode " + contentInode + " because of security issue", dse);
    }
   
    if(parentContentlet==null || !InodeUtils.isSet(parentContentlet.getInode())){
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("message.contentlet.required","Contentlet Inode"));       
      return errors;
    }
    if (!UtilMethods.isSet(name))
    {
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("message.contentlet.required","Name"));       
    }
    if (!UtilMethods.isSet(email) || ! UtilMethods.isValidEmail(email))
    {       
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("message.contentlet.required","Email"));       
    }
    /*  Try to find a title if we don't have one.  */
    if (!UtilMethods.isSet(commentTitle))
      {
      Structure s = StructureCache.getStructureByInode(parentContentlet.getStructureInode());
      List<Field> lf = s.getFields();
      for(Field f : lf){
        if("text".equals(f.getFieldType()) && f.isIndexed() && f.isListed()){
          try{
            commentTitle = "re: " + conAPI.getFieldValue(parentContentlet, f);
          }catch (Exception e) {
            Logger.error(CommentsForm.class, "Unable to set comment title", e);
          }
          break;
        }
      }
      }
    if (!UtilMethods.isSet(comment))
    {
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("message.contentlet.required","Comment"));
    }
    if (UtilMethods.isSet(accept) && accept == false)
    {
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("message.contentlet.required","Accept"));
    }

        if ( commentUseCaptcha ) {
            if ( !UtilMethods.isSet( captcha ) || !UtilMethods.isSet( captchaSession ) || !captcha.equals( captchaSession.getAnswer() ) ) {
                errors.add( ActionErrors.GLOBAL_ERROR, new ActionError( "message.contentlet.required", "Validation Image" ) );
            }
        }

        if(commentUseAudioCaptcha && !UtilMethods.isSet(captchaSession)){
        
      Boolean isResponseCorrect =Boolean.FALSE;
      String captchaId = request.getSession().getId()
      if(UtilMethods.isSet(audioCaptcha) && UtilMethods.isSet(captchaId)){
        try {
//          isResponseCorrect = CaptchaServiceSingleton.getInstance().validateResponseForID(captchaId,
//              audioCaptcha);
         
          isResponseCorrect = CaptchaUtil.isValidAudioCaptcha(request);
        } catch (CaptchaServiceException e) {
          Logger.error(CommentsForm.class, "An error ocurred trying to validate audio captcha", e);
        }
       }
   
      if(!isResponseCorrect){
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("message.contentlet.required","Validation Sound"));
      }

    }
    return errors;
  }
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.apache.struts.action.ActionError

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.