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

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


      LoginForm loginForm = new LoginForm();
      loginForm.setUserName(form.getEmailAddress().toLowerCase());
      loginForm.setPassword(form.getPassword1());

      LoginAction la = new LoginAction();
      ActionForward af = la.login(mapping,loginForm,request,response);
     
      loadUser(form, request);
      request.getSession().setAttribute("createAccountForm",form);
      //Verify the session.redirect
      if (request.getSession().getAttribute(WebKeys.REDIRECT_AFTER_LOGIN) == null)
      {       
        af = new ActionForward("/");
        af.setRedirect(true);       
        request.getSession().setAttribute(WebKeys.REDIRECT_AFTER_LOGIN,af.getPath());                               
      }

      ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.createaccount.success"));       
      saveMessages(request, ae);
      return af;
View Full Code Here


    parametersToValidate.add("Message");
    EmailFactory.sendParameterizedEmail(parameters, parametersToValidate, currentHost, user);
   
    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");
    }
View Full Code Here

  private ContentletAPI conAPI = APILocator.getContentletAPI();
  private CategoryAPI catAPI = APILocator.getCategoryAPI();
  private HostWebAPI hostWebAPI = WebAPILocator.getHostWebAPI();

  public ActionForward unspecified(ActionMapping mapping, ActionForm lf, HttpServletRequest request, HttpServletResponse response) {
    ActionForward forward = new ActionForward("/");
    forward.setRedirect(false);
    return forward;
  }
View Full Code Here



        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);
      ActionForward forward = new ActionForward(referrer);
      forward.setRedirect(true);
      return forward;
    }
  }
View Full Code Here

    rt.setSessionId(session.getId());
    rt.setUserIP(request.getRemoteAddr());

    RatingAPI.saveRating (rt);

    return new ActionForward(referer,true);

  }
View Full Code Here

    if (!UtilMethods.isSet(url_params)) {
      url_params = "";
    }
    if (request.getSession().getAttribute(WebKeys.CMS_USER) == null) {
      String path = URLEncoder.encode("/dotCMS/addFavorites?url_page="+url_page+"&url_params="+url_params);
      return new ActionForward(SecurityUtils.stripReferer(request, "/dotCMS/login?referrer="+path));
    }

    //Getting the user from the session
    User user = (User) request.getSession().getAttribute(WebKeys.CMS_USER);
    String user_id = user.getUserId();

    if (UtilMethods.isSet(url_page)) {
      if (FavoritesWebAPI.setUrlFavorite(url_page, url_params, user_id)) {
        List<Map> favorites = (List<Map>) request.getSession().getAttribute(WebKeys.USER_FAVORITES);
        if (!UtilMethods.isSet(favorites)) {
          favorites = new ArrayList<Map>();
        }
        Host host = hostAPI.findDefaultHost(user, false);
        Map<String, String> hm = new HashMap<String, String>();

        if (UtilMethods.isSet(url_params) && (url_params.indexOf("pageTitle=") > -1)) {
          String url_params_decoded = URLDecoder.decode(url_params);
          String pageTitle = url_params_decoded.substring((url_params_decoded.indexOf("pageTitle=") + 10), url_params_decoded.length());
          if (pageTitle.indexOf("&") > -1) {
            pageTitle = url_params.substring(0, pageTitle.indexOf("&"));
          }
          hm.put("page_title", pageTitle);

        }
        else {
          // Map with all identifier inodes for a given uri.
          Identifier idInode = APILocator.getIdentifierAPI().find( host,url_page);
          HTMLPage livePage = (HTMLPage) APILocator.getVersionableAPI().findLiveVersion(idInode, APILocator.getUserAPI().getSystemUser(), false);
          hm.put("page_title", livePage.getTitle());
        }

        hm.put("page_url", UtilMethods.isSet(url_params)?url_page + "?" + url_params:url_page);

        if (FavoritesWebAPI.isUrlFavorite(url_page, url_params, user_id)) {
          favorites.add(hm);
          SessionMessages.add(request.getSession(), "message", "message.favorites.added");
        }
        else {
          favorites.remove(hm);
          SessionMessages.add(request.getSession(), "message", "message.favorites.removed");
        }
        request.getSession().setAttribute(WebKeys.USER_FAVORITES, favorites);
      }
      else {
        SessionMessages.add(request.getSession(), "error", "message.favorites.error");
      }
    }

    ActionForward af = new ActionForward(UtilMethods.isSet(url_params)?url_page + "?" + url_params:url_page);
        af.setRedirect(true);
        return af;
  }
View Full Code Here

   * Send you to the forgot password page unless you are coming form and reset password
   * link gotten in your email that case it sends you to the reset password page
   */
  public ActionForward unspecified(ActionMapping mapping, ActionForm lf, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    ActionForward af = (mapping.findForward("forgotPasswordPage"));
    ForgotPasswordForm form = (ForgotPasswordForm) lf;
   
    if (UtilMethods.isSet(form.getAccKey()) && Config.getBooleanProperty("USE_RESET_PASSWORD_EMAIL")) {     
      request.setAttribute("email", form.getEmail());
      af = (mapping.findForward("resetPasswordPage"));
    }
   
    if (Config.getBooleanProperty("USE_CHALLENGE_QUESTION"))
    {
         af = new ActionForward(SecurityUtils.stripReferer(
                     request, mapping.findForward("challengeQuestionPage").getPath() + "?emailAddress=" + form.getEmail()));
      }
   
    return af;
  }
View Full Code Here

   */
  public ActionForward forgotPassword(ActionMapping mapping, ActionForm lf, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
   
    //setting some variables
    ActionForward af = (mapping.findForward("forgotPasswordPage"));
    ForgotPasswordForm form = (ForgotPasswordForm) lf;
    request.setAttribute("email", form.getEmail());

    String referrer = null;
    if (request.getAttribute("referrer") != null && !request.getAttribute("referrer").toString().equalsIgnoreCase(""))
    {
      referrer = (String)request.getAttribute("referrer");
    }
    else if (request.getParameter("referrer") != null && !request.getParameter("referrer").toString().equalsIgnoreCase(""))
    {
      referrer = SecurityUtils.stripReferer(request, (String)request.getParameter("referrer"));
    }
   
    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;
     
    }
   
   
    if (Config.getBooleanProperty("USE_CHALLENGE_QUESTION")) {
   
      request.setAttribute("email", form.getEmail());
      form.setAccKey(PublicEncryptionFactory.encryptString(user.getUserId()));
      return mapping.findForward("challengeQuestionPage");
   
    } else if (Config.getBooleanProperty("USE_RESET_PASSWORD_EMAIL")) {     
   
      request.setAttribute("email", form.getEmail());
      return sendResetPassword(mapping, lf, request, response);

    } else {
     
      //if we have some errors

      String pass = PublicEncryptionFactory.getRandomPassword();
      user.setPassword(PublicEncryptionFactory.digestString(pass));
      APILocator.getUserAPI().save(user,APILocator.getUserAPI().getSystemUser(),false);
      Host host = hostWebAPI.getCurrentHost(request);
          Company company = PublicCompanyFactory.getDefaultCompany();
     
      HashMap<String, Object> parameters = new HashMap<String, Object> ();
      parameters.put("subject", "Your " + host.getHostname() + " Password");
      parameters.put("password", pass);
      parameters.put("emailTemplate", Config.getStringProperty("FORGOT_PASSWORD_EMAIL_TEMPLATE"));
      parameters.put("to", user.getEmailAddress());
      parameters.put("from", company.getEmailAddress());
     
      EmailFactory.sendParameterizedEmail(parameters, null, host, user);

      ActionMessages msg = new ActionMessages();
      msg.add(Globals.MESSAGE_KEY, new ActionMessage("message.forgot.password.email.sent"));
      request.setAttribute(Globals.MESSAGE_KEY, msg);
     
      af = (mapping.findForward("passwordChangeConfirmationPage"));
 
      if(UtilMethods.isSet(referrer)) {
            af = new ActionForward(SecurityUtils.stripReferer(request, referrer));
            af.setRedirect(true);
      }
          return af;
    }
  }
View Full Code Here

         
          ActionMessages msg = new ActionMessages();
                msg.add(Globals.MESSAGE_KEY, new ActionMessage("message.challenge_question.answer_successful", email));
                saveMessages(request.getSession(), msg);
                if(UtilMethods.isSet(referrer)) {
                return (new ActionForward(SecurityUtils.stripReferer(request, referrer + "?" + request.getQueryString())));
                } else {
                  return mapping.findForward("passwordChangeConfirmationPage");
                }
        } catch (Exception e) {
              ActionMessages msg = new ActionMessages();
View Full Code Here

                LoginFactory.doLogin(user.getUserId(), user.getPassword(), false, request, response);
              }
         
          am.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.account.user.activated"));
          saveMessages(request.getSession(), am);
          ActionForward forward = mapping.findForward("confirmation");
          return forward;
        }
        else {
          // resending activation account link
          request.setAttribute("userId", user.getUserId());
          return mapping.findForward("resendPage");
        }
      }
      else {
        am.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.account.user.already.active"));
        saveMessages(request.getSession(), am);
        ActionForward forward = mapping.findForward("confirmation");
        return forward;
      }
    }

    // the user does not exists
View Full Code Here

TOP

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

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.