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

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


    }
     
    Logger.debug(this, "validating CategoryForm: " + request.getParameter("cmd"));

        if ((request.getParameter("cmd") != null) && request.getParameter("cmd").equals(Constants.ADD)) {
            ActionErrors ae = super.validate(mapping, request);

            Logger.debug(this, "action errors: " + ae);

            if (UtilMethods.isSet(getKey())) {
                Category cat = null;
        try {
          cat = categoryAPI.findByKey(getKey(), user, false);

                  if (cat != null && (InodeUtils.isSet(cat.getInode())) && (!cat.getInode().equalsIgnoreCase(this.inode))) {
                      ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.category.folder.taken"));
                      return ae;
                  }
        } catch (DotDataException e) {
                    ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.system.error"));
        } catch (DotSecurityException e) {
                    ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.system.error"));
        }
            }

            if ( !UtilMethods.isSet( getCategoryName() ) ) {
                ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.category.folder.mandatoryname"));
                return ae;
            }

        }
View Full Code Here


    this.dateOfBirthDate = dateOfBirthDate;
  }

  @Override
  public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) {
    ActionErrors errors = new ActionErrors();

    boolean challengeQuestionProperty = false;

    try {
      challengeQuestionProperty = com.dotmarketing.util.Config.getBooleanProperty("USE_CHALLENGE_QUESTION");
    } catch (Exception e) {
      Logger.error(this, "UserManagerForm - Need to set USE_CHALLENGE_QUESTION property.");
    }
    if (!UtilMethods.isSet(firstName))
      errors.add("firstName", new ActionMessage("error.usermanager.form.mandatory", "First Name"));
    if (!UtilMethods.isSet(lastName))
      errors.add("lastName", new ActionMessage("error.usermanager.form.mandatory", "Last Name"));
    if (!UtilMethods.isSet(emailAddress))
      errors.add("emailAddress", new ActionMessage("error.usermanager.form.mandatory", "Email Address"));
    if (!emailAddress.matches("[^@]+@[^@]+"))
      errors.add("emailAddress", new ActionMessage("error.usermanager.form.format", "Email Address"));

    boolean isNewUser = !UtilMethods.isSet(getUserID());
    boolean isPwdSet = UtilMethods.isSet(password), isVerifyPwdSet = UtilMethods.isSet(verifyPassword);
    boolean isPwdFullySet = isPwdSet && isVerifyPwdSet;
    boolean isPwdPartiallySet = isPwdSet ^ isVerifyPwdSet;
   
    if(isNewUser){
      if ( ( isPwdFullySet && !password.equals(verifyPassword) ) || isPwdPartiallySet ) {
        // Password has not been properly specified?
        errors.add("newPassword", new ActionMessage("error.usermanager.form.verifyPassword"));
      }
    }
    else if( isNewUser && !isPwdFullySet ) {
      // New user and password has not been set?
      errors.add("newPassword", new ActionMessage("error.usermanager.form.setPassword"));
    }

    if (challengeQuestionProperty && (!UtilMethods.isSet(challengeQuestionId) || challengeQuestionId.equals("0")))
      errors.add("challengeQuestionId", new ActionMessage("error.usermanager.form.mandatory", "Challenge Question"));

    if (challengeQuestionProperty && !UtilMethods.isSet(challengeQuestionAnswer))
      errors.add("challengeQuestion", new ActionMessage("error.usermanager.form.mandatory", "Challenge Question Answer"));

    if (!"none".equals(description)) {
      if (!UtilMethods.isSet(street1) && !UtilMethods.isSet(street2) && !UtilMethods.isSet(city) && !UtilMethods.isSet(state) && !UtilMethods.isSet(zip)
          && !UtilMethods.isSet(phone) && !UtilMethods.isSet(cell) ) {
        errors.add("phone", new ActionMessage("error.usermanager.form.mandatory", "phone"));
      }
    }
    return errors;
  }
View Full Code Here

  /*
   * Validator for the Report Form
   * @see com.dotcms.repackage.org.apache.struts.validator.ValidatorForm#validate(com.dotcms.repackage.org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
   */
  public ActionErrors validate(com.dotcms.repackage.org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request,User user)throws Exception {
    ActionErrors errors = new ActionErrors();
   
    if (!UtilMethods.isSet(reportName)) {
      errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.contentlet.required",LanguageUtil.get(user, "Name")));       
    }
   
    if (!UtilMethods.isSet(reportDescription)) {
      errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.contentlet.required",LanguageUtil.get(user, "Description")));       
    }
   
    if (!isWebFormReport()) {
      if (!UtilMethods.isSet(selectedDataSource)) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.contentlet.required",LanguageUtil.get(user, "Datasource")));       
      }
     
      if (!UtilMethods.isSet(request.getParameter("jrxmlFile"))) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.contentlet.required",LanguageUtil.get(user, "JRXML-File")));       
      }
    }
   
    return errors;
  }
View Full Code Here

  public void setSortOrder(int sortOrder) {
    this.sortOrder = sortOrder;
  }

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors ae = new ActionErrors();
    try {
      HostAPI hostAPI = APILocator.getHostAPI();
      User systemUser = APILocator.getUserAPI().getSystemUser();
      if (request.getParameter("cmd") != null && request.getParameter("cmd").equals(Constants.ADD)) {
        String inode = request.getParameter("parent");
        Folder parentFolder = APILocator.getFolderAPI().find(inode, systemUser, false);
        if (!InodeUtils.isSet(parentFolder.getInode())) {
          Host host;
          host = (Host) hostAPI.find(inode, systemUser, false);
          if (host != null) {
            ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.folder.ishostfolder"));
          }
        }
      }
    } catch (DotDataException e) {
      Logger.error(FileForm.class, e.getMessage(), e);
View Full Code Here

  public ActionForward saveComments(ActionMapping mapping, ActionForm lf, HttpServletRequest request, HttpServletResponse response) {

    CommentsForm commentsForm = (CommentsForm) lf;

    request.getSession().setAttribute("commentsForm", commentsForm);
    ActionErrors ae = commentsForm.validate(mapping, request);

    HashMap<String,String> commentsOptions = (HashMap<String,String>) request.getSession().getAttribute("commentsOptions");


    try {
      HibernateUtil.startTransaction();
      if ((ae != null) && (ae.size() > 0)) {
        String referrer = UtilMethods.isSet(commentsOptions.get("referrer"))?commentsOptions.get("referrer"):"";
        if(referrer != null){
          referrer=referrer.replaceAll("#comments", "#comments");
          if(referrer.indexOf("?") > -1){
            referrer = referrer + "&dotcache=no";
          }else{
            referrer = referrer + "?dotcache=no";
          }

        }
        referrer = (referrer.indexOf("#comments") == -1 ? referrer + "#comments" : referrer);




        saveMessages(request, ae);
        saveMessages(request.getSession(), ae);
        ActionForward forward = new ActionForward(SecurityUtils.stripReferer(request, referrer));
        forward.setRedirect(true);
        return forward;
      }

      User user = APILocator.getUserAPI().getSystemUser();
      if (request.getSession().getAttribute(WebKeys.CMS_USER) != null) {
        user = (User) request.getSession().getAttribute(WebKeys.CMS_USER);
      }
      String userId = user.getUserId();
      // Contentlet Data
      Contentlet contentlet = new Contentlet();
      try{
        contentlet = conAPI.find(commentsOptions.get("contentInode"), user, true);
      }catch(DotDataException e){
        Logger.error(this, "Unable to look up comment with inode " + commentsOptions.get("contentInode"), e);
      }

      Structure contentletStructure = StructureCache.getStructureByInode(contentlet.getStructureInode());
      Identifier contentletIdentifier = APILocator.getIdentifierAPI().find(contentlet);

      /*make sure we have a structure in place before saving */
      CommentsWebAPI cAPI = new CommentsWebAPI();
      cAPI.validateComments(contentlet.getInode());

      Structure commentsStructure = StructureCache.getStructureByVelocityVarName(CommentsWebAPI.commentsVelocityStructureName);

      Contentlet contentletComment = new Contentlet();

      // set the default language
      com.dotmarketing.portlets.contentlet.business.Contentlet beanContentlet = (com.dotmarketing.portlets.contentlet.business.Contentlet) InodeFactory.getInode(contentlet.getInode(), com.dotmarketing.portlets.contentlet.business.Contentlet.class);

      contentletComment.setLanguageId(beanContentlet.getLanguageId());

      // Add the default fields
      contentletComment.setStructureInode(commentsStructure.getInode());

      Field field;

      /* Set the title if we have one*/
      if(UtilMethods.isSet(commentsOptions.get("commentTitle"))){

        field = commentsStructure.getFieldVar("title");

        conAPI.setContentletProperty(contentletComment, field, commentsOptions.get("commentTitle"));
      }

      /* Validate if a CommentsCount field exists in the contentlet structure
         if not, then create it and populate it.*/

      field = contentletStructure.getFieldVar("commentscount");
      if (field==null || !InodeUtils.isSet(field.getInode())) {
        List<Field> fields = new ArrayList<Field>();
          field = new Field("CommentsCount", Field.FieldType.TEXT, Field.DataType.INTEGER, contentletStructure,
                      false, false, true, Integer.MAX_VALUE, "0", "0", "",true, true, true);
        FieldFactory.saveField(field);
        for(Field structureField: contentletStructure.getFields()){
          fields.add(structureField);
        }
        fields.add(field);
        FieldsCache.removeFields(contentletStructure);
        FieldsCache.addFields(contentletStructure,fields);
      }

      /* Get the  value from the CommentsCount field for this contentlet, if the value
       * is null, then the contentlet has no comments, otherwise increment its value by one
       * and set it to the contentlet.
       */
     
      String velVar = field.getVelocityVarName();

      int comentsCount = -1;
      try {
        Long countValue = contentlet.getLongProperty(velVar);
        comentsCount  = countValue.intValue();
      } catch (Exception e) {
        Logger.debug(this, e.toString());
      }

      if (comentsCount == -1) {
        try {
          String countValue = (contentlet.getStringProperty(velVar) ==  null) ? field.getDefaultValue() : contentlet.getStringProperty(velVar);
          comentsCount  = countValue.equals("") ? 0 : new Integer(countValue).intValue();
        } catch (Exception e) {
          Logger.debug(this, e.toString());
        }
      }

      ++comentsCount;
      conAPI.setContentletProperty(contentlet, field, comentsCount);
      //Update the contentlet with the new comment count
      /*List<Category> cats = catAPI.getParents(contentlet, user, true);
      Map<Relationship, List<Contentlet>> contentRelationships = new HashMap<Relationship, List<Contentlet>>();

      List<Relationship> rels = RelationshipFactory.getAllRelationshipsByStructure(contentlet.getStructure());
      for (Relationship r : rels) {
        if(!contentRelationships.containsKey(r)){
          contentRelationships.put(r, new ArrayList<Contentlet>());
        }
        List<Contentlet> cons = conAPI.getRelatedContent(contentlet, r, user, true);
        for (Contentlet co : cons) {
          List<Contentlet> l2 = contentRelationships.get(r);
          l2.add(co);
        }
      }
      conAPI.checkinWithoutVersioning(contentlet, contentRelationships, cats, APILocator.getPermissionAPI().getPermissions(contentlet), user, true);
            */
      // Date
      field = commentsStructure.getFieldVar("datePublished");
      conAPI.setContentletProperty(contentletComment, field, new Date());

      // User Id
      field = commentsStructure.getFieldVar("userid");
      conAPI.setContentletProperty(contentletComment, field, userId);

      // Author
      field = commentsStructure.getFieldVar("author");
      conAPI.setContentletProperty(contentletComment, field, VelocityUtil.cleanVelocity(commentsForm.getName()));

      // Email
      field = commentsStructure.getFieldVar("email");
      conAPI.setContentletProperty(contentletComment, field, VelocityUtil.cleanVelocity(commentsForm.getEmail()));

      // WebSite
      field = commentsStructure.getFieldVar("website");
      conAPI.setContentletProperty(contentletComment, field, VelocityUtil.cleanVelocity(commentsForm.getWebsite()));

      // EmailResponse
      field = commentsStructure.getFieldVar("emailResponse");
      conAPI.setContentletProperty(contentletComment, field, (commentsForm.isNotify()?"yes":"no"));

      // IP Address
      field = commentsStructure.getFieldVar("ipAddress");
      conAPI.setContentletProperty(contentletComment, field, request.getRemoteAddr());

      // Comment
      field = commentsStructure.getFieldVar("comment");
      String comment = commentsForm.getComment();
      comment=VelocityUtil.cleanVelocity(comment);


      if (UtilMethods.isSet(commentsOptions.get("commentStripHtml")) && commentsOptions.get("commentStripHtml").equalsIgnoreCase("true")) {
        comment = Html.stripHtml(comment);
      }

      conAPI.setContentletProperty(contentletComment, field, comment);

      // Add the permission
      PermissionAPI perAPI = APILocator.getPermissionAPI();
      List<Permission> pers = perAPI.getPermissions(commentsStructure);




      // new workflows
      if(UtilMethods.isSet(commentsOptions.get("commentsModeration"))){
        if(!UtilMethods.isSet(contentletComment.getStringProperty(Contentlet.WORKFLOW_ACTION_KEY)))
            contentletComment.setStringProperty(Contentlet.WORKFLOW_ACTION_KEY, APILocator.getWorkflowAPI().findEntryAction(contentletComment, user).getId());
        contentletComment.setStringProperty(Contentlet.WORKFLOW_COMMENTS_KEY, commentsForm.getComment());
      }






      // Save the comment
      contentletComment = conAPI.checkin(contentletComment, new HashMap<Relationship, List<Contentlet>>(), new ArrayList<Category>(), pers, user, true);

            // If live I have to publish the asset
            if (UtilMethods.isSet(commentsOptions.get("commentAutoPublish")) && commentsOptions.get("commentAutoPublish").equalsIgnoreCase("true")) {
                APILocator.getVersionableAPI().setLive(contentletComment);
            }

      // Set the relation between the content and the comments
      Identifier contentletCommentIdentifier = APILocator.getIdentifierAPI().find(contentletComment);
      String commentRelationStructureName = commentsStructure.getName().replaceAll("\\s", "_").replaceAll("[^a-zA-Z0-9\\_]", "");
      String contentletRelationStructureName = contentletStructure.getName().replaceAll("\\s", "_").replaceAll("[^a-zA-Z0-9\\_]", "");
      String relationName = contentletRelationStructureName + "-" + commentRelationStructureName;


      /* get the next in the order */
      int order  = RelationshipFactory.getMaxInSortOrder(contentletIdentifier.getInode(), relationName);


      contentletIdentifier.addChild(contentletCommentIdentifier, relationName, ++order);

      ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.comment.success"));

      /* If the comment has been sennt successfully, activeDiv is set to its initial value*/
      commentsForm.setActiveDiv("");









      beanContentlet = (com.dotmarketing.portlets.contentlet.business.Contentlet) InodeFactory.getInode(contentletComment.getInode(), com.dotmarketing.portlets.contentlet.business.Contentlet.class);
      beanContentlet = conAPI.convertContentletToFatContentlet(contentletComment, beanContentlet);
      HibernateUtil.saveOrUpdate(beanContentlet);

      if (UtilMethods.isSet(commentsOptions.get("commentAutoPublish")) && commentsOptions.get("commentAutoPublish").equalsIgnoreCase("true"))
      {
        conAPI.publish(contentletComment, user, true);
      }


      saveMessages(request, ae);
      saveMessages(request.getSession(), ae);
      String referrer = UtilMethods.isSet(commentsOptions.get("referrer"))?commentsOptions.get("referrer"):"";
      referrer = (referrer.indexOf("#comments") == -1 ? referrer + "#comments" : referrer);

      String commentQuestion = commentsOptions.get("commentTitle");

      //The send comment emails should be send when there is a new comment (ALWAYS)
      String userName = commentsForm.getName();
      String userEmail = commentsForm.getEmail();
      String userComment = commentsForm.getComment();
      HibernateUtil.commitTransaction();
      if(!conAPI.isInodeIndexed(contentletComment.getInode())){
        Logger.error(this, "Problem indexing comment content");
      }
      sendCommentEmails(contentletIdentifier, relationName, request, referrer,userName,userEmail,userComment,commentQuestion, commentsOptions);

      ActionForward forward = new ActionForward(referrer);
      forward.setRedirect(true);

      /* reset the form and reset the captcha */
      commentsForm.reset();

      request.setAttribute("commentsForm", commentsForm);
      return forward;
    } catch (Exception ex) {
      try {
        HibernateUtil.rollbackTransaction();
      } catch (DotHibernateException e) {
        Logger.error(CommentsAction.class,e.getMessage(),e);
      }
      Logger.error(this, ex.toString(), ex);

      ae.add(Globals.ERROR_KEY, new ActionMessage("message.comment.failure"));
      saveMessages(request, ae);
      saveMessages(request.getSession(), ae);
      String referrer = UtilMethods.isSet(commentsOptions.get("referrer"))?commentsOptions.get("referrer"):"";

      referrer = (referrer.indexOf("#comments") == -1 ? referrer + "#comments" : referrer);
View Full Code Here

 
  @SuppressWarnings("unchecked")
  public ActionForward unspecified(ActionMapping rMapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
  throws Exception {
    ActionErrors errors = new ActionErrors();
    //Email parameters
    HttpSession session = request.getSession();
    Host currentHost = hostWebAPI.getCurrentHost(request);
    User currentUser = (User) session.getAttribute(WebKeys.CMS_USER);
   
    String method = request.getMethod();
    String errorURL = request.getParameter("errorURL");   
    errorURL = (!UtilMethods.isSet(errorURL) ? request.getHeader("referer") : errorURL);
    if(errorURL.indexOf("?") > -1)
    {
      errorURL = errorURL.substring(0,errorURL.lastIndexOf("?"));
    }
    String x = request.getRequestURI();
    if(request.getParameterMap().size() <2){
     
      return null;
     
    }

    //Checking for captcha
    boolean useCaptcha = Config.getBooleanProperty("FORCE_CAPTCHA",true);
    if(!useCaptcha){
      useCaptcha = new Boolean(request.getParameter("useCaptcha")).booleanValue();
    }
   
    String captcha = request.getParameter("captcha");
    if (useCaptcha) {
        Captcha captchaObj = (Captcha) session.getAttribute(Captcha.NAME);
            String captchaSession=captchaObj!=null ? captchaObj.getAnswer() : null;
           
      if(captcha ==null && Config.getBooleanProperty("FORCE_CAPTCHA",true)){
        response.getWriter().write("Captcha is required to submit this form ( FORCE_CAPTCHA=true ).<br>To change this, edit the dotmarketing-config.properties and set FORCE_CAPTCHA=false");
        return null;
      }
     
     
      if(!UtilMethods.isSet(captcha) || !UtilMethods.isSet(captchaSession) || !captcha.equals(captchaSession)) {
        errors.add(Globals.ERROR_KEY, new ActionMessage("message.contentlet.required", "Validation Image"));
        request.setAttribute(Globals.ERROR_KEY, errors);
        session.setAttribute(Globals.ERROR_KEY, errors);
        String queryString = request.getQueryString();
        String invalidCaptchaURL = request.getParameter("invalidCaptchaReturnUrl");
        if(!UtilMethods.isSet(invalidCaptchaURL)) {
          invalidCaptchaURL = errorURL;
        }
        ActionForward af = new ActionForward();
          af.setRedirect(true);
          if (UtilMethods.isSet(queryString)) {
           
            af.setPath(invalidCaptchaURL + "?" + queryString + "&error=Validation-Image");
          } else {
            af.setPath(invalidCaptchaURL + "?error=Validation-Image");
          }
     

       
        return af;
      }
     
    }



    Map<String, Object> parameters = null;
    if (request instanceof UploadServletRequest)
    {
      UploadServletRequest uploadReq = (UploadServletRequest) request;
      parameters = new HashMap<String, Object> (uploadReq.getParameterMap());
      for (Entry<String, Object> entry : parameters.entrySet())
      {
        if(entry.getKey().toLowerCase().indexOf("file") > -1 && !entry.getKey().equals("attachFiles"))
        {
          parameters.put(entry.getKey(), uploadReq.getFile(entry.getKey()));
        }
      }
    }
    else
    {
      parameters = new HashMap<String, Object> (request.getParameterMap());
    }

    Set<String> toValidate = new java.util.HashSet<String>(parameters.keySet());

    //Enhancing the ignored parameters not to be send in the email
    String ignoredParameters = (String) EmailFactory.getMapValue("ignore", parameters);
    if(ignoredParameters == null)
    {
      ignoredParameters = "";
    }
    ignoredParameters += ":useCaptcha:captcha:invalidCaptchaReturnUrl:return:returnUrl:errorURL:ignore:to:from:cc:bcc:dispatch:order:prettyOrder:autoReplyTo:autoReplyFrom:autoReplyText:autoReplySubject:";
    parameters.put("ignore", ignoredParameters);

    // getting categories from inodes
    // getting parent category name and child categories name
    // and replacing the "categories" parameter
    String categories = "";
    String[] categoriesArray = request.getParameterValues("categories");
    if (categoriesArray != null) {
      HashMap hashCategories = new HashMap<String, String>();
      for (int i = 0; i < categoriesArray.length; i++) {
        Category node = (Category) InodeFactory.getInode(categoriesArray[i], Category.class);
        Category parent = (Category) InodeFactory.getParentOfClass(node, Category.class);
        String parentCategoryName = parent.getCategoryName();

        if (hashCategories.containsKey(parentCategoryName)) {
          String childCategoryName = (String) hashCategories.get(parentCategoryName);
          if (UtilMethods.isSet(childCategoryName)) {
            childCategoryName += ", ";
          }
          childCategoryName += node.getCategoryName();
          hashCategories.put(parentCategoryName, childCategoryName);
        }
        else {
          hashCategories.put(parentCategoryName, node.getCategoryName());
        }
      }

      Set<String> keySet = hashCategories.keySet();
      for (String stringKey: keySet) {

        if (UtilMethods.isSet(categories)) {
          categories += "; ";
        }
        categories += stringKey + " : " + (String) hashCategories.get(stringKey);
        parameters.put(stringKey, (String) hashCategories.get(stringKey));
      }
      parameters.remove("categories");
    }

    WebForm webForm = new WebForm();
    try
    {
      /*validation parameter should ignore the returnUrl and erroURL field in the spam check*/
      String[] removeParams = ignoredParameters.split(":");
      for(String param : removeParams){
        toValidate.remove(param);
      }
     
     
     
      parameters.put("request", request);
      parameters.put("response", response);
     
      //Sending the email     
      webForm = EmailFactory.sendParameterizedEmail(parameters, toValidate, currentHost, currentUser);
     
     
     
      webForm.setCategories(categories);

      if(UtilMethods.isSet(request.getParameter("createAccount")) && request.getParameter("createAccount").equals("true"))
      {
        //if we create account set to true we create a user account and add user comments.
        createAccount(webForm, request);
        try{
            String userInode = webForm.getUserInode();
            String customFields = webForm.getCustomFields();
            customFields += " User Inode = " + String.valueOf(userInode) + " | ";
            webForm.setCustomFields(customFields);
        }
        catch(Exception e){
           
        }

      }

     
            if(UtilMethods.isSet(webForm.getFormType())){
                HibernateUtil.saveOrUpdate(webForm);
            }
     
     
      if (request.getParameter("return") != null)
      {
        ActionForward af = new ActionForward(SecurityUtils.stripReferer(request, request.getParameter("return")));
        af.setRedirect(true);
        return af;
      }
      else if (request.getParameter("returnUrl") != null)
      {
        ActionForward af = new ActionForward(SecurityUtils.stripReferer(request, request.getParameter("returnUrl")));
        af.setRedirect(true);
        return af;
      }
      else
      {
        return rMapping.findForward("thankYouPage");
      }

        }
        catch (DotRuntimeException e)
        {
            errors.add(Globals.ERROR_KEY, new ActionMessage("error.processing.your.email"));
            request.getSession().setAttribute(Globals.ERROR_KEY, errors);

            String queryString = request.getQueryString();

            if (queryString == null) {
View Full Code Here

    }
   
    try {
      //Validating the input
      if(!APILocator.getUserAPI().userExistsWithEmail(form.getEmail())) {
        ActionMessages aes = new ActionErrors();
        aes.add(Globals.ERROR_KEY, new ActionMessage("error.user.email.doesnt.exists"));
        saveErrors(request, aes);
        return af;
      }
    } catch (DotDataException e) {
      ActionMessages aes = new ActionErrors();
      aes.add(Globals.ERROR_KEY, new ActionMessage("error.user.email.doesnt.exists"));
      saveErrors(request, aes);
      return af;
    } catch (NoSuchUserException e) {
      ActionMessages aes = new ActionErrors();
      aes.add(Globals.ERROR_KEY, new ActionMessage("error.user.email.doesnt.exists"));
      saveErrors(request, aes);
      return af;
    }
   
    //If the user doesn't exists
    User user = APILocator.getUserAPI().loadByUserByEmail(form.getEmail(), APILocator.getUserAPI().getSystemUser(), false);
    if(user.isNew()){
      ActionErrors aes = new ActionErrors();
      aes.add(Globals.ERROR_KEY, new ActionMessage("error.user.email.doesnt.exists"));
      saveMessages(request.getSession(), aes);
     
      if(UtilMethods.isSet(referrer)) {
            af = new ActionForward(SecurityUtils.stripReferer(request, referrer));
            af.setRedirect(true);
            return af;
      } else
        return af;
     
    }

    //If the account is not active
    if(!user.isActive()){
     
      ActionMessages aes = new ActionErrors();
      aes.add(Globals.ERROR_KEY, new ActionMessage("error.user.is.not.active"));
      saveErrors(request, aes);
     
          af = mapping.findForward("resendActivationPage");
          return af;
     
View Full Code Here

             
              return mapping.findForward("challengeQuestionPage");
          }
    } catch (Exception e) {
      Logger.debug(this, "Failed - Redirecting to: loginPage");
          ActionErrors errors = new ActionErrors();
          errors.add(Globals.ERROR_KEY, new ActionMessage("error.send_email"));
          request.setAttribute(Globals.ERROR_KEY, errors);
         
          return mapping.findForward("loginPage");
    }
    }
View Full Code Here

  //delete category
   
   
  private void _deleteCategory(ActionForm form, ActionRequest req, ActionResponse res, User user, HttpSession session) throws Exception {
        Category cat = ( Category ) req.getAttribute(WebKeys.CATEGORY_EDIT);
        ActionErrors errors = new ActionErrors();
        if(!categoryAPI.hasDependencies(cat)){
      req.removeAttribute(WebKeys.CATEGORY_EDIT);
      categoryAPI.delete(cat, user, false);
      SessionMessages.add(req, "message", "message.category.delete");
    }
View Full Code Here

        return ToStringBuilder.reflectionToString(this);
    }

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    try {
      ActionErrors ae = new ActionErrors();
      if (request.getParameter("cmd") != null && request.getParameter("cmd").equals(Constants.ADD)) {
        String inode = request.getParameter("parent");
        User user=com.liferay.portal.util.PortalUtil.getUser(request);
        Folder parentFolder = APILocator.getFolderAPI().find(inode, user, false);
        if (!InodeUtils.isSet(parentFolder.getInode())) {
          User systemUser;
          systemUser = APILocator.getUserAPI().getSystemUser();
          Host host = APILocator.getHostAPI().find(inode, systemUser, false);
          if (host != null && InodeUtils.isSet(host.getInode())) {
            ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.folder.ishostfolder"));
          }
        }
      }
      return ae;
    } catch (Exception e) {
View Full Code Here

TOP

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

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.