Commits

Juan Carlos Picado Herrera  committed 6c928b9 Merge

Merge branch 'juanpicado', remote-tracking branch 'origin' into development

  • Participants
  • Parent commits c6c2e38, ac9d7c6 1
    1. 772f76d

Comments (0)

Files changed (62)

 
 If you want to build and deploy from source follow these instructions:
 
-   http://wiki.encuestame.org/en/Build_Project
+   http://wiki.encuestame.org/display/DOC/How+to+build+Encuestame
 
 
 Fast Deploy

File encuestame-business/src/main/java/org/encuestame/business/service/FrontEndService.java

 package org.encuestame.business.service;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 import org.encuestame.core.util.ConvertDomainBean;
 import org.encuestame.persistence.dao.SearchPeriods;
 import org.encuestame.persistence.domain.HashTag;
+import org.encuestame.persistence.domain.HashTagHits;
 import org.encuestame.persistence.domain.survey.Poll;
 import org.encuestame.persistence.domain.tweetpoll.TweetPoll;
 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
         //TODO:Pending count relevance hashtags for polls and surveys.
         return relevance;
     }
+
+    /**
+     * Check previous hash tag hit.
+     * @param ipAddress
+     * @return
+     */
+    public Boolean checkPreviousHashTagHit(final String ipAddress){
+        boolean tagHit = false;
+        final List<HashTagHits> hashTag = getFrontEndDao().getHashTagsHitByIp(ipAddress);
+        try {
+            if(hashTag.size() == 1){
+                if(hashTag.get(0).getIpAddress().equals(ipAddress)){
+                    tagHit = true;
+                }
+             }
+        } catch (Exception e) {
+            // TODO: handle exception
+            e.printStackTrace();
+        }
+
+        return tagHit;
+    }
+
+
+    public void registerHashTagHit(final String tagName, final String ip, final String username){
+        final Date hitd = new Date();
+        final HashTagHits hashHit ;
+        final HashTag tag;
+        Long hitCount = 1L;
+        try {
+            if((ip!=null) || (tagName!=null) ){
+                hashHit = this.newHashTagHit(tagName, hitd, ip);
+                if (hashHit!=null){
+                    tag = getHashTagDao().getHashTagByName(tagName);
+                    hitCount = tag.getHits()+hitCount;
+                    tag.setHits(hitCount);
+                }
+            }
+        } catch (Exception e) {
+            log.debug(e);
+            e.printStackTrace();
+            // TODO: handle exception
+        }
+
+    }
+
+    /**
+     * New hash tag hit.
+     * @param tagName
+     * @param hitDate
+     * @param ipAddress
+     * @return
+     */
+    private HashTagHits newHashTagHit(final String tagName, final Date hitDate, final String ipAddress){
+        final HashTagHits tagHitsDomain = new HashTagHits();
+        tagHitsDomain.setHitDate(hitDate);
+        tagHitsDomain.setHashTagId(getHashTagDao().getHashTagByName(tagName));
+        tagHitsDomain.setIpAddress(ipAddress);
+      //  tagHitsDomain.setUserAccount(getUserAccountLogged());
+        this.getFrontEndDao().saveOrUpdate(tagHitsDomain);
+        return tagHitsDomain;
+    }
 }

File encuestame-business/src/main/java/org/encuestame/business/service/TweetPollService.java

                  //change status to failed
                  publishedStatus.setStatus(Status.FAILED);
                  //store error descrition
-                 publishedStatus.setDescriptionStatus(e.getMessage() == null ? "" : e.getMessage().substring(254)); //limited to 254 characters.
+                 if (e.getMessage() != null && e.getMessage().isEmpty()) {
+                     publishedStatus.setDescriptionStatus(e.getMessage().substring(254)); //limited to 254 characters.
+                 } else {
+                     publishedStatus.setDescriptionStatus("");
+                 }
                  //save original tweet content.
                  publishedStatus.setTweetContent(tweetText);
              }
     public List<LinksSocialBean> getTweetPollLinks(final TweetPoll tweetPoll) {
       final List<LinksSocialBean> linksBean = new ArrayList<LinksSocialBean>();
       final List<TweetPollSavedPublishedStatus> links = getTweetPollDao().getLinksByTweetPoll(tweetPoll);
+      log.debug("getTweetPollLinks "+links.size());
       for (TweetPollSavedPublishedStatus tweetPollSavedPublishedStatus : links) {
+          log.debug("getTweetPollLinks "+tweetPollSavedPublishedStatus.toString());
           final LinksSocialBean linksSocialBean = new LinksSocialBean();
             linksSocialBean.setProvider(tweetPollSavedPublishedStatus
                     .getTwitterAccount().getAccounType().name());
                     tweetPollSavedPublishedStatus.getTwitterAccount()
                             .getAccounType()));
           linksBean.add(linksSocialBean);
+          log.debug("getTweetPollLinks "+linksSocialBean.toString());
        }
+
       return linksBean;
     }
 }

File encuestame-business/src/main/java/org/encuestame/business/service/imp/IFrontEndService.java

  */
 package org.encuestame.business.service.imp;
 
+import java.util.Date;
 import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 
 import org.encuestame.core.service.ServiceOperations;
+import org.encuestame.persistence.domain.HashTagHits;
 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 import org.encuestame.persistence.exception.EnMeSearchException;
 import org.encuestame.utils.web.HashTagBean;
     List<TweetPollBean> getTweetPollsbyHashTagId(final Long hashTagId, final Integer limit, final String filter, final HttpServletRequest request);
 
     /**
-     * Get TweetPolls by top rated.
-     * @param hashTagId
-     * @param limit
-     * @param request
+     *
+     * @param ipAddress
      * @return
      */
-    //List<TweetPollBean> getTweetPollsbyTopRated(final Long hashTagId, final Integer limit, final HttpServletRequest request);
+    Boolean checkPreviousHashTagHit(final String ipAddress);
+
+    /**
+     * Register hashTag hits.
+     * @param tagName
+     * @param ipAddress
+     */
+    void registerHashTagHit(final String tagName, final String ip, final String username);
 }

File encuestame-business/src/main/resources/org/encuestame/business/mail/templates/confirm-your-account.vm

     <div id= containerBody style="margin-bottom:25px">
         <div style= "margin:10px;font-size:12px; ">
              Hi,
-             <span style="color:#0101DF;font-size:medium;"> ${user.username} </span>.
-             Your new user account has been successfully set up.
+             <br/>
+             Thank you <span style="color:#0101DF;font-size:12px;"> ${user.username} </span>. Your registration has been successful.
         </div>
 
         <div id= "containerLink" style="margin:10px; padding: 10px; background-color:#F8ECE0; border: 1px solid #FE9A2E;">

File encuestame-business/src/test/java/org/encuestame/test/business/service/TestFrontEndService.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2010 encuestame: system online surveys Copyright (C) 2009
+ * encuestame Development Team.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+ */
+package org.encuestame.test.business.service;
+
+import org.encuestame.business.service.FrontEndService;
+import org.encuestame.test.business.service.config.AbstractServiceBase;
+import org.junit.Test;
+
+/**
+ * Test for {@link FrontEndService}.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 12, 2011
+ * @version $Id:$
+ */
+public class TestFrontEndService extends AbstractServiceBase{
+
+    @Test
+    public void testGetHashTagHitbyIp(){
+            System.out.println("testing");
+    }
+
+}

File encuestame-business/src/test/java/org/encuestame/test/business/service/TestTweetPollService.java

 import org.encuestame.utils.web.UnitPatternBean;
 import org.encuestame.utils.web.UnitTweetPollResult;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
     }
 
     @Test
+    @Ignore
     public void testPublicMultiplesTweetAccounts(){
             createDefaultSettedSocialAccount(this.userAccount);
             final List<SocialAccount> list = getAccountDao().getSocialAccountByAccount(this.userAccount.getAccount(), SocialProvider.TWITTER);

File encuestame-mvc/src/main/java/org/encuestame/mvc/controller/AbstractBaseOperations.java

      * @param args
      * @return
      */
-   @Deprecated
+
     public String getMessage(final String message,
             final HttpServletRequest request, Object[] args) {
         String stringValue = "";
      * @param args
      * @return
      */
-    @Deprecated
+    //@Deprecated
     public String getMessage(final String message, Object[] args){
         return getMessage(message, null, args);
     }
      * @param message
      * @return
      */
-    @Deprecated
+    //@Deprecated
     public String getMessage(final String message){
         return getMessage(message, null, null);
     }
      * @param request
      * @return
      */
-    @Deprecated
-    private Locale getLocale(final HttpServletRequest request){
-        return RequestContextUtils.getLocale(request);
+    private Locale getLocale(final HttpServletRequest request) {
+        if(request == null){
+            return Locale.ENGLISH;
+        } else {
+            return RequestContextUtils.getLocale(request);
+        }
     }
 
     /**

File encuestame-mvc/src/main/java/org/encuestame/mvc/controller/json/FrontEndJsonController.java

 package org.encuestame.mvc.controller.json;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.collections.ListUtils;
 import org.apache.log4j.Logger;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.map.JsonMappingException;
-import org.encuestame.core.util.ConvertDomainBean;
 import org.encuestame.mvc.controller.AbstractJsonController;
-import org.encuestame.persistence.dao.SearchPeriods;
-import org.encuestame.persistence.domain.tweetpoll.TweetPoll;
 import org.encuestame.persistence.exception.EnMeSearchException;
-import org.encuestame.utils.web.HashTagBean;
 import org.encuestame.utils.web.TweetPollBean;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.RequestMapping;

File encuestame-mvc/src/main/java/org/encuestame/mvc/controller/security/SignUpAccountFormController.java

 import org.apache.log4j.Logger;
 import org.encuestame.core.config.EnMePlaceHolderConfigurer;
 import org.encuestame.core.security.util.PasswordGenerator;
+import org.encuestame.mvc.util.WidgetUtil;
 import org.encuestame.mvc.validator.ValidateOperations;
 import org.encuestame.persistence.domain.security.UserAccount;
 import org.encuestame.utils.captcha.ReCaptchaResponse;
 import org.springframework.web.bind.support.SessionStatus;
 
 /**
- * Register Form.
- *
+ * Sign Up Form.
  * @author Picado, Juan juan@encuestame.org
  * @since 26/04/2009
- * @version $Id: ServiceManager.java 469 2010-04-01 00:09:12Z juanpicado $
  */
 @Controller
 @SessionAttributes(types = SignUpBean.class)
      * @param model
      * @return
      */
-    @RequestMapping(method = RequestMethod.GET)
+    @RequestMapping(value = "/signup", method = RequestMethod.GET)
     public String addHandler(Model model) {
-        log.info("/register");
         final Boolean privateHome = EnMePlaceHolderConfigurer
         .getBooleanProperty("application.signup.enabled");
-        if (privateHome) {
+        if (!privateHome) {
             log.debug("signup is disabled");
             return "redirect:/signin";
         } else {
             final SignUpBean user = new SignUpBean();
             final String captcha = getReCaptcha().createRecaptchaHtml(null, null);
+            log.debug(captcha);
             user.setCaptcha(captcha);
-            log.info("username "+user.getCaptcha());
-            model.addAttribute(user);
-            return "user/signup";
+            log.info("username "+user);
+            model.addAttribute("user",user);
+            return "signup";
         }
     }
 

File encuestame-mvc/src/main/java/org/encuestame/mvc/controller/security/json/ValidatorServiceJsonController.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 encuestame: system online surveys Copyright (C) 2011
+ * encuestame Development Team.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+ */
+package org.encuestame.mvc.controller.security.json;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.RandomStringUtils;
+import org.apache.log4j.Logger;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.encuestame.mvc.controller.AbstractJsonController;
+import org.encuestame.mvc.validator.ValidateOperations;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * Validator json controller.
+ * @author Picado, Juan juanATencuestame.org
+ * @since Jul 14, 2011
+ */
+@Controller
+public class ValidatorServiceJsonController extends AbstractJsonController {
+
+    /** Log. **/
+    private Logger log = Logger.getLogger(this.getClass());
+
+    @RequestMapping(value = "/api/public/validator/email.json", method = RequestMethod.GET)
+    public ModelMap validateEmail(
+            @RequestParam(value = "context", required = false) String context,
+            @RequestParam(value = "email", required = false) String email,
+            HttpServletRequest request, HttpServletResponse response)
+            throws JsonGenerationException, JsonMappingException, IOException {
+        try {
+            setItemResponse(this.validate(context, "email", email, request));
+        } catch (Exception e) {
+            log.error(e);
+            e.printStackTrace();
+        }
+        return returnData();
+    }
+
+    @RequestMapping(value = "/api/public/validator/realName.json", method = RequestMethod.GET)
+    public ModelMap validateRealName(
+            @RequestParam(value = "context", required = false) String context,
+            @RequestParam(value = "real_name", required = false) String name,
+            HttpServletRequest request, HttpServletResponse response)
+            throws JsonGenerationException, JsonMappingException, IOException {
+        try {
+            setItemResponse(this.validate(context, "realName", name, request));
+        } catch (Exception e) {
+            log.error(e);
+            e.printStackTrace();
+        }
+        return returnData();
+    }
+
+    @RequestMapping(value = "/api/public/validator/username.json", method = RequestMethod.GET)
+    public ModelMap validateUsername(
+            @RequestParam(value = "context", required = false) String context,
+            @RequestParam(value = "username", required = false) String username,
+            HttpServletRequest request, HttpServletResponse response)
+            throws JsonGenerationException, JsonMappingException, IOException {
+        try {
+            setItemResponse(this.validate(context, "username", username, request));
+        } catch (Exception e) {
+            log.error(e);
+            e.printStackTrace();
+        }
+        return returnData();
+    }
+
+
+    /**
+     * Validate items based on context.
+     * @param context could be signup, update profile or another one.
+     * @param type
+     * @param value
+     * @return
+     */
+    private  Map<String, Object> validate(final String context, final String type, final String value, final  HttpServletRequest request){
+        final Map<String, Object> jsonResponse = new HashMap<String, Object>();
+        final ValidateOperations validateOperations = new ValidateOperations(getSecurityService());
+        boolean valid = false;
+        if ("email".equals(type)) {
+            if (value.isEmpty() || value.length() < ValidateOperations.MIN_EMAIL_LENGTH) {
+                jsonResponse.put("msg", getMessage("secure.email.emtpy", request, null));
+            } else {
+                valid = validateOperations.validateEmail(value);
+                log.debug("validate EMAIL"+valid);
+                if (valid) {
+                    jsonResponse.put("msg", getMessage("secure.email.valid", request, null));
+                } else {
+                    jsonResponse.put("msg", getMessage("secure.email.notvalid", request, null));
+                }
+            }
+        } else if("username".equals(type)) {
+            valid = validateOperations.validateUsername(value, null);
+            if (value.isEmpty() || value.length() < ValidateOperations.MIN_USERNAME_LENGTH) {
+                jsonResponse.put("msg", getMessage("secure.username.empty", request, null));
+            } else {
+                if (!valid) {
+                    jsonResponse.put("msg", getMessage("secure.user.notvalid", request, null));
+                    final List<String> suggestions = new ArrayList<String>();
+                    for (int i = 0; i < 5; i++) {
+                        suggestions.add(value+RandomStringUtils.randomAlphabetic(6));
+                    }
+                    jsonResponse.put("suggestions", suggestions);
+                } else {
+                    jsonResponse.put("msg", getMessage("secure.username.valid", request, null));
+                }
+                jsonResponse.put("valid", valid);
+            }
+        } else if("realName".equals(type)) {
+            valid = true;
+            jsonResponse.put("msg", getMessage("secure.realName.valid", request, null));
+        }
+        jsonResponse.put("valid", valid);
+        jsonResponse.put("color", "#RRR");
+        return jsonResponse;
+    }
+}

File encuestame-mvc/src/main/java/org/encuestame/mvc/util/WidgetUtil.java

         }
         return analyticBlock;
     }
+
+
+    /**
+     *
+     * @param path
+     * @return
+     */
+    public static final String getPasswordBlackList(final String path){
+        final String scriptFilePath = path;
+        final StringBuffer stb = new StringBuffer("[");
+        BufferedReader reader;
+        String passwordArray;
+        try {
+            reader = new BufferedReader(
+                     new InputStreamReader(new ClassPathResource(scriptFilePath).getInputStream()));
+            String aux;
+            while(true) {
+                aux = reader.readLine();
+                if (aux == null) {
+                    stb.append("\"\"]");
+                    break;
+                }
+                stb.append("\"");
+                stb.append(aux);
+                stb.append("\",");
+            }
+            reader.close();
+            passwordArray = stb.toString();
+        } catch (IOException e) {
+            passwordArray = "";
+        }
+        return passwordArray;
+    }
 }

File encuestame-mvc/src/main/java/org/encuestame/mvc/validator/SignUpBeanValidator.java

-/*
- ************************************************************************************
- * Copyright (C) 2001-2011 encuestame: system online surveys Copyright (C) 2009
- * encuestame Development Team.
- * Licensed under the Apache Software License version 2.0
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to  in writing,  software  distributed
- * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
- * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
- * specific language governing permissions and limitations under the License.
- ************************************************************************************
- */
-package org.encuestame.mvc.validator;
-
-import org.apache.log4j.Logger;
-import org.encuestame.business.service.SecurityService;
-import org.encuestame.business.service.imp.SecurityOperations;
-import org.encuestame.utils.security.SignUpBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.binding.message.MessageBuilder;
-import org.springframework.binding.message.MessageContext;
-import org.springframework.binding.validation.ValidationContext;
-import org.springframework.stereotype.Component;
-
-/**
- * Validator for SignUp.
- * @author Picado, Juan juanATencuestame.org
- * @since Jan 22, 2011 9:09:11 AM
- * @version $Id:$
- */
-@Component
-public class SignUpBeanValidator{
-
-    /**
-     * Log.
-     */
-    protected Logger log = Logger.getLogger(this.getClass());
-
-    /**
-     * Reference to {@link SecurityService}.
-     */
-    @Autowired
-    private SecurityOperations securityService;
-
-    /**
-     * Validate SignUn Bean.
-     * @param booking
-     * @param context
-     */
-    public void validateSignup(SignUpBean booking, ValidationContext context) {
-        log.debug("Validate Sign Up");
-        final ValidateOperations validation = new ValidateOperations(securityService);
-        MessageContext messages = context.getMessageContext();
-        if(validation.validateUserEmail(booking.getEmail(), null) != null){
-            log.warn("Email NOT VALID");
-            //result.rejectValue("email", "secure.email.notvalid"); //secure.email.notvalid
-            messages.addMessage(new MessageBuilder().error().source("email").
-                    defaultText("Email NOT VALID").build());
-        }
-        if(!validation.validateUsername(booking.getUsername(), null)){
-            log.warn("Username NOT VALID");
-             //result.rejectValue("username", "secure.user.notvalid"); //secure.user.notvalid
-            messages.addMessage(new MessageBuilder().error().source("username").
-                    defaultText("Username NOT VALID").build());
-        }
-    }
-
-    /**
-     * @return the securityService
-     */
-    public SecurityOperations getSecurityService() {
-        return securityService;
-    }
-
-    /**
-     * @param securityService the securityService to set
-     */
-    public void setSecurityService(final SecurityOperations securityService) {
-        this.securityService = securityService;
-    }
-}

File encuestame-mvc/src/main/java/org/encuestame/mvc/validator/ValidateOperations.java

 import org.apache.log4j.Logger;
 import org.encuestame.business.service.imp.SecurityOperations;
 import org.encuestame.core.util.ValidationUtils;
-import org.encuestame.persistence.domain.security.Account;
 import org.encuestame.persistence.domain.security.UserAccount;
 import org.encuestame.utils.captcha.ReCaptchaResponse;
 import org.encuestame.utils.web.UserAccountBean;
  * Controller Validation.
  * @author Picado, Juan juanATencuestame.org
  * @since Jun 13, 2010 7:48:27 PM
- * @version $Id:$
  */
 public class ValidateOperations {
 
      */
     private static final Pattern emailPattern = Pattern.compile(ValidationUtils.EMAIL_REGEXP, Pattern.CASE_INSENSITIVE);
 
+    /**
+     * Minimum username length.
+     */
+    public static final Integer MIN_USERNAME_LENGTH = 3;
 
-    private static final Integer MIN_USERNAME_LENGTH = 3;
+    /**
+     * Minimum email length.
+     */
+    public static final Integer MIN_EMAIL_LENGTH = 5;
 
     /**
      *
         log.debug("validating email... ->"+email);
         Boolean valid = false;
         if (this.validateEmail(email)) {
-            if(user == null){
-                log.debug("email is valid..");
+            if (user == null) {
+                log.debug("email is valid.. 1 ");
                 getMessages().put("email", "email is available");
                 valid = true;
             } else if(userLogged != null && userLogged.getUserEmail().equals(email)){
-                log.debug("email is valid..");
+                log.debug("email is valid.. 2 ");
                 getMessages().put("email", "it's your email");
                 valid = true;
             } else if(email.equals(user.getUserEmail())){
+                log.debug("email not valid.. 3 ");
                 getMessages().put("email", "email already exist");
             } else {
+                log.debug("email not valid.. 4 ");
                 getMessages().put("email", "email not valid");
             }
         } else {
             getMessages().put("email", "email wrong format");
         }
+        log.debug("validateUserEmail valid ->>>>"+valid);
         return valid;
     }
 

File encuestame-mvc/src/main/java/org/encuestame/mvc/view/HashTagController.java

         final IFrontEndService service = getFrontService();
         log.debug("hashTag Name ---> "+name);
         name = filterValue(name);
+        final String IP = getIpClient();
+        log.info("IP" + IP);
+
+        // Search HashTag hits.
+        boolean hashTagVisite = service.checkPreviousHashTagHit(IP);
+        // TODO: Check that previous hash Tag hit has been visited the same day.
+        if (!hashTagVisite) {
+            service.registerHashTagHit(name, IP, "pao");
+        }
         try {
             final HashTagBean tag = service.getHashTagItem(name);
             log.debug("hashTag Id ---> "+ tag.getId());

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/IFrontEndDao.java

 
 import java.util.List;
 
+import org.encuestame.persistence.domain.HashTagHits;
 import org.encuestame.persistence.domain.survey.Poll;
 import org.encuestame.persistence.domain.tweetpoll.TweetPoll;
 
      */
     List<TweetPoll> getTweetPollFrontEndAllTime(final Integer start, final Integer maxResults);
 
+    /**
+     * Get hashTag by ip address.
+     * @param ipAddress
+     * @return
+     */
+    List<HashTagHits> getHashTagsHitByIp(final String ipAddress);
+
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/FrontEndDao.java

  */
 package org.encuestame.persistence.dao.imp;
 
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
-
+import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.encuestame.persistence.dao.IFrontEndDao;
 import org.encuestame.persistence.dao.IHashTagDao;
 import org.encuestame.persistence.dao.SearchSurveyPollTweetItem;
+import org.encuestame.persistence.domain.HashTagHits;
 import org.encuestame.persistence.domain.survey.Poll;
 import org.encuestame.persistence.domain.tweetpoll.TweetPoll;
+import org.hibernate.Criteria;
 import org.hibernate.SessionFactory;
 import org.hibernate.criterion.DetachedCriteria;
 import org.hibernate.criterion.Restrictions;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.orm.hibernate3.HibernateCallback;
 import org.springframework.stereotype.Repository;
 
 /**
     public void setHashTagDao(final IHashTagDao hashTagDao) {
         this.hashTagDao = hashTagDao;
     }
+
+    /**
+     * Get hash tags hits by Ip.
+     * @param ipAddress
+     * @return
+     */
+     public List<HashTagHits> getHashTagsHitByIp(final String ipAddress){
+        log.debug("search by ipAddress ---> "+ipAddress);
+        @SuppressWarnings({ "unchecked", "rawtypes" })
+        List<HashTagHits> searchResult = (List) getHibernateTemplate().execute(new HibernateCallback() {
+                    public Object doInHibernate(org.hibernate.Session session) {
+                        List<HashTagHits> searchResult = new ArrayList<HashTagHits>();
+                        final Criteria criteria = session.createCriteria(HashTagHits.class);
+                        searchResult = (List<HashTagHits>) fetchPhraseFullText(ipAddress, "ipAddress", HashTagHits.class,
+                        criteria, new SimpleAnalyzer());
+                        log.debug("total results ---> "+searchResult.size());
+                        return searchResult;
+                        }
+        });
+        return searchResult;
+    }
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/domain/HashTag.java

     /** Total of hits. **/
     private Long hits;
 
+    /** {@link TweetPoll} **/
     private Set<TweetPoll> tweetPoll = new HashSet<TweetPoll>();
 
+    /** Size Tag**/
+    private Long size;
+
     /**
      * @return the hashTagId
      */
         this.tweetPoll = tweetPoll;
     }
 
+    /**
+    * @return the size
+    */
+    public Long getSize() {
+        return size;
+    }
 
+    /**
+    * @param size the size to set
+    */
+    public void setSize(final Long size) {
+        this.size = size;
+    }
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/domain/HashTagHits.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2010 encuestame: system online surveys Copyright (C) 2009
+ * encuestame Development Team.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+ */
+package org.encuestame.persistence.domain;
+
+import java.util.Date;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import org.encuestame.persistence.domain.security.UserAccount;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+
+/**
+ * Hash Tags Hits.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since Jul 23, 2010 11:49:56 PM
+ * @version Id:
+ */
+
+@Entity
+@Indexed(index="HashTagHits")
+@Table(name = "hash_tags_hits")
+public class HashTagHits {
+
+    /** Hash Tag Id. **/
+    private Long hitId;
+
+    /** Tag String.**/
+    private Date hitDate;
+
+    /** Hash**/
+    private HashTag hashTagId;
+
+    /** Ip address**/
+    private String ipAddress;
+
+    /** {@link UserAccount} **/
+    private UserAccount userAccount;
+
+    /**
+    * @return the hitId
+    */
+    @Id
+    @DocumentId
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "hash_tag_id", unique = true, nullable = false)
+    public Long getHitId() {
+        return hitId;
+    }
+
+    /**
+    * @param hitId the hitId to set
+    */
+    public void setHitId(final Long hitId) {
+        this.hitId = hitId;
+    }
+
+    /**
+    * @return the hitDate
+    */
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "hitDate", nullable = false)
+    public Date getHitDate() {
+        return hitDate;
+    }
+
+    /**
+    * @param hitDate the hitDate to set
+    */
+    public void setHitDate(final Date hitDate) {
+        this.hitDate = hitDate;
+    }
+
+    /**
+    * @return the hashTagId
+    */
+    @ManyToOne()
+    public HashTag getHashTagId() {
+        return hashTagId;
+    }
+
+    /**
+    * @param hashTagId the hashTagId to set
+    */
+    public void setHashTagId(final HashTag hashTagId) {
+        this.hashTagId = hashTagId;
+    }
+
+    /**
+    * @return the ipAddress
+    */
+    @Field(index=Index.TOKENIZED, store=Store.YES)
+    @Column(name = "ip_address", nullable = false, length = 100)
+    public String getIpAddress() {
+        return ipAddress;
+    }
+
+    /**
+    * @param ipAddress the ipAddress to set
+    */
+    public void setIpAddress(final String ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    /**
+    * @return the userAccount
+    */
+    @ManyToOne(cascade = CascadeType.MERGE)
+    @JoinColumn(name = "user")
+    public UserAccount getUserAccount() {
+        return userAccount;
+    }
+
+    /**
+    * @param userAccount the userAccount to set
+    */
+    public void setUserAccount(final UserAccount userAccount) {
+        this.userAccount = userAccount;
+    }
+
+}

File encuestame-persistence/src/main/resources/spring-test/encuestame-test-hibernate-context.xml

                 <value>org.encuestame.persistence.domain.survey.PollFolder</value>
                 <value>org.encuestame.persistence.domain.notifications.Notification</value>
                 <value>org.encuestame.persistence.domain.Attachment</value>
+                <value>org.encuestame.persistence.domain.HashTagHits</value>
             </list>
         </property>
         <property name="hibernateProperties">

File encuestame-persistence/src/test/java/org/encuestame/test/config/AbstractBase.java

 import org.encuestame.persistence.dao.IAccountDao;
 import org.encuestame.persistence.dao.IClientDao;
 import org.encuestame.persistence.dao.IEmail;
+import org.encuestame.persistence.dao.IFrontEndDao;
 import org.encuestame.persistence.dao.IGeoPoint;
 import org.encuestame.persistence.dao.IGeoPointTypeDao;
 import org.encuestame.persistence.dao.IGroupDao;
 import org.encuestame.persistence.dao.ITweetPoll;
 import org.encuestame.persistence.dao.imp.ClientDao;
 import org.encuestame.persistence.dao.imp.EmailDao;
+import org.encuestame.persistence.dao.imp.FrontEndDao;
 import org.encuestame.persistence.dao.imp.HashTagDao;
 import org.encuestame.persistence.dao.imp.PollDao;
 import org.encuestame.persistence.dao.imp.TweetPollDao;
 import org.encuestame.persistence.domain.GeoPointFolderType;
 import org.encuestame.persistence.domain.GeoPointType;
 import org.encuestame.persistence.domain.HashTag;
+import org.encuestame.persistence.domain.HashTagHits;
 import org.encuestame.persistence.domain.Project;
 import org.encuestame.persistence.domain.Project.Priority;
 import org.encuestame.persistence.domain.Status;
     @Autowired
     private IHashTagDao hashTagDao;
 
+    /** {@link FrontEndDao} **/
+    @Autowired
+    private IFrontEndDao frontEndDao;
+
     /**
      * Get Property.
      * @param property
     }
 
     /**
+    * @return the frontEndDao
+    */
+    public IFrontEndDao getFrontEndDao() {
+        return frontEndDao;
+    }
+
+    /**
+    * @param frontEndDao the frontEndDao to set
+    */
+    public void setFrontEndDao(IFrontEndDao frontEndDao) {
+        this.frontEndDao = frontEndDao;
+    }
+
+
+    /**
      * Create fake questions.
      * @param user {@link Account};
      */
          return tweetPoll;
      }
 
-     /**
-      *
+      /**
       * @param tweetPoll
       * @param tweetId
       * @param socialAccount
         getTweetPoll().saveOrUpdate(publishedStatus);
         return publishedStatus;
     }
+
+
+    /**
+     * Create hash tag hit by ip.
+     * @param hashTagName
+     * @param ipAddress
+     * @return
+     */
+    public HashTagHits createHashTagHit(final HashTag hashTag, final String ipAddress){
+       final Date hitDate = new Date();
+       final HashTagHits tagHits = new HashTagHits();
+       tagHits.setHitDate(hitDate);
+       tagHits.setIpAddress(ipAddress);
+       tagHits.setHashTagId(hashTag);
+       getHashTagDao().saveOrUpdate(tagHits);
+       return tagHits;
+    }
 }

File encuestame-persistence/src/test/java/org/encuestame/test/persistence/dao/TestFrontEndDao.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2010 encuestame: system online surveys Copyright (C) 2009
+ * encuestame Development Team.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+ */
+package org.encuestame.test.persistence.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.encuestame.persistence.dao.imp.FrontEndDao;
+import org.encuestame.persistence.domain.HashTag;
+import org.encuestame.persistence.domain.HashTagHits;
+import org.encuestame.test.config.AbstractBase;
+import org.junit.Before;
+import org.junit.Test;
+/**
+ * Test {@link FrontEndDao}..
+ * @author Morales Urbina, Diana paola AT encuestame.org
+ * @since January 06, 2011
+ * @version $Id: $
+ */
+public class TestFrontEndDao extends AbstractBase {
+
+    /** {@link HashTag} **/
+    private HashTag hashTag;
+
+    /** {@link HashTagHits} **/
+    private HashTagHits hashTagHit;
+
+    final String ipAddress = "192.168.1.1";
+
+    @Before
+    public void initData(){
+        this.hashTag = createHashTag("software");
+        this.hashTagHit = createHashTagHit(hashTag, ipAddress);
+      /*  System.out.println("hashTag ID --->"+ hashTag.getHashTagId());
+        System.out.println("hashTagHit IP --->"+ hashTagHit.getIpAddress());
+        System.out.println("hashTagHit ID --->"+ hashTagHit.getHitId());
+        System.out.println("hashTagHit tag ID--->"+ hashTagHit.getHashTagId().getHashTagId());*/
+    }
+
+    /** Test Get hash tags by ip.**/
+    @Test
+    public void testGetHashTagsHitByIp(){
+        assertNotNull(this.hashTagHit);
+        flushIndexes();
+        final List<HashTagHits> hitsbyIp = getFrontEndDao().getHashTagsHitByIp(this.ipAddress);
+        System.out.print("SIZE HASHTAG hit---> "+ hitsbyIp.size());
+        assertNotNull(hitsbyIp);
+        //System.out.println("HashTagHits data ---> "+ hitsbyIp.get(0).getIpAddress());
+       // assertEquals("Should be equals", hitsbyIp.get(0).getIpAddress(), this.ipAddress);
+    }
+}

File encuestame-persistence/src/test/java/org/encuestame/test/persistence/dao/TestHashTagDao.java

 
 import org.encuestame.persistence.dao.imp.HashTagDao;
 import org.encuestame.persistence.domain.HashTag;
+import org.encuestame.persistence.domain.HashTagHits;
 import org.encuestame.test.config.AbstractBase;
 import org.junit.Before;
 import org.junit.Test;
         assertEquals("Should be equals", hashTag4.getHashTag(), expHas3.getHashTag());
         assertEquals("Should be equals", hashTag3.getHashTag(), expHas4.getHashTag());
     }
+
+
 }

File encuestame-persistence/src/test/java/org/encuestame/test/persistence/domain/TestHibernateDomains.java

 import org.encuestame.persistence.domain.GeoPointFolder;
 import org.encuestame.persistence.domain.GeoPoint;
 import org.encuestame.persistence.domain.GeoPointFolderType;
+import org.encuestame.persistence.domain.HashTag;
+import org.encuestame.persistence.domain.HashTagHits;
 import org.encuestame.persistence.domain.Project;
 import org.encuestame.persistence.domain.Status;
 import org.encuestame.persistence.domain.question.CatQuestionCategory;
          client.setClientUrl("http://www.encuestame.org");
          client.setProject(createProject("encuestame","open source", "info", createAccount()));
      }
+
+     /** HashTag domain. **/
+     @Test
+     public void testHashTag(){
+        final String hashTag = "";
+        final Long hits = 1L;
+        final Long size = 10L;
+        final HashTag tag = new HashTag();
+        tag.setHashTag(hashTag);
+        tag.setHits(hits);
+        tag.setSize(size);
+        tag.getTweetPoll().add(createTweetPollPublicated(
+                Boolean.TRUE,
+                Boolean.TRUE,
+                new Date(),
+                createUserAccount("juan carlos", createAccount()),
+                createQuestion("Did you do the homework?", "YesNo")));
+        getHashTagDao().saveOrUpdate(tag);
+        assertNotNull(tag.getHashTagId());
+     }
+
+     /** HashTag domain. **/
+     @Test
+     public void testHashTagHits(){
+        final Date hitDate = new Date();
+        final String ipAddress = "";
+        final String tagName = "programmer";
+        final HashTagHits tagHits = new HashTagHits();
+        tagHits.setHitDate(hitDate);
+        tagHits.setIpAddress(ipAddress);
+        tagHits.setUserAccount(createUserAccount("juan carlos", createAccount()));
+        tagHits.setHashTagId(createHashTag(tagName));
+        getHashTagDao().saveOrUpdate(tagHits);
+        assertNotNull(tagHits.getHashTagId());
+     }
 }

File encuestame-utils/src/main/java/org/encuestame/utils/json/LinksSocialBean.java

     }
 
 
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return "LinksSocialBean [link=" + link + ", provider=" + provider + "]";
+    }
 }

File encuestame-war/src/main/resources/messages.properties

 # Sign In
 ################
 
-secure.email.notvalid = Email Not Valid
-secure.user.notvalid = Username is not available
+secure.email.notvalid = This email is already registered"
+secure.user.notvalid = This username is already taken!
+secure.username.empty = A username is required!
 secure.captcha.invalid = Catpcha is not valid
-
-
+secure.email.emtpy = Whats your email address?
+secure.email.valid = An email is perfect!
+secure.username.valid = Username is perfect!
+secure.realName.valid = Name looks great
 
 #######################
 # Notification Messages

File encuestame-war/src/main/resources/messages_en.properties

 # Sign In
 ################
 
-secure.email.notvalid = Email Not Valid
-secure.user.notvalid = Username is not available
+secure.email.notvalid = This email is already registered"
+secure.user.notvalid = This username is already taken!
+secure.username.empty = A username is required!
 secure.captcha.invalid = Catpcha is not valid
-
-
+secure.email.emtpy = Whats your email address?
+secure.email.valid = An email is perfect!
+secure.username.valid = Username is perfect!
+secure.realName.valid = Name looks great
 
 #######################
 # Notification Messages

File encuestame-war/src/main/resources/messages_es.properties

 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 #
 
+
+################
+# Sign In
+################
+
+secure.email.notvalid = This email is already registered"
+secure.user.notvalid = This username is already taken!
+secure.username.empty = A username is required!
+secure.captcha.invalid = Catpcha is not valid
+secure.email.emtpy = Whats your email address?
+secure.email.valid = An email is perfect!
+secure.username.valid = Username is perfect!
+secure.realName.valid = Name looks great
+
 #######################
 # Notification Messages
 #######################

File encuestame-war/src/main/resources/passwords.inc

+111111
+11111111
+112233
+121212
+123123
+123456
+1234567
+12345678
+131313
+232323
+654321
+666666
+696969
+777777
+7777777
+8675309
+987654
+aaaaaa
+abc123
+abc123
+abcdef
+abgrtyu
+access
+access14
+action
+albert
+alexis
+amanda
+amateur
+andrea
+andrew
+angela
+angels
+animal
+anthony
+apollo
+apples
+arsenal
+arthur
+asdfgh
+ashley
+august
+austin
+badboy
+bailey
+banana
+barney
+baseball
+batman
+beaver
+beavis
+bigdaddy
+bigdog
+birdie
+bitches
+biteme
+blazer
+blonde
+blondes
+bond007
+bonnie
+booboo
+booger
+boomer
+boston
+brandon
+brandy
+braves
+brazil
+bronco
+broncos
+bulldog
+buster
+butter
+butthead
+calvin
+camaro
+cameron
+canada
+captain
+carlos
+carter
+casper
+charles
+charlie
+cheese
+chelsea
+chester
+chicago
+chicken
+cocacola
+coffee
+college
+compaq
+computer
+cookie
+cooper
+corvette
+cowboy
+cowboys
+crystal
+dakota
+dallas
+daniel
+danielle
+debbie
+dennis
+diablo
+diamond
+doctor
+doggie
+dolphin
+dolphins
+donald
+dragon
+dreams
+driver
+eagle1
+eagles
+edward
+einstein
+erotic
+extreme
+falcon
+fender
+ferrari
+firebird
+fishing
+florida
+flower
+flyers
+football
+forever
+freddy
+freedom
+gandalf
+gateway
+gators
+gemini
+george
+giants
+ginger
+golden
+golfer
+gordon
+gregory
+guitar
+gunner
+hammer
+hannah
+hardcore
+harley
+heather
+helpme
+hockey
+hooters
+horney
+hotdog
+hunter
+hunting
+iceman
+iloveyou
+internet
+iwantu
+jackie
+jackson
+jaguar
+jasmine
+jasper
+jennifer
+jeremy
+jessica
+johnny
+johnson
+jordan
+joseph
+joshua
+junior
+justin
+killer
+knight
+ladies
+lakers
+lauren
+leather
+legend
+letmein
+little
+london
+lovers
+maddog
+madison
+maggie
+magnum
+marine
+marlboro
+martin
+marvin
+master
+matrix
+matthew
+maverick
+maxwell
+melissa
+member
+mercedes
+merlin
+michael
+michelle
+mickey
+midnight
+miller
+mistress
+monica
+monkey
+monster
+morgan
+mother
+mountain
+muffin
+murphy
+mustang
+naked
+nascar
+nathan
+naughty
+ncc1701
+newyork
+nicholas
+nicole
+nipple
+nipples
+oliver
+orange
+packers
+panther
+panties
+parker
+password
+password1
+password12
+password123
+patrick
+peaches
+peanut
+pepper
+phantom
+phoenix
+player
+please
+pookie
+porsche
+prince
+princess
+private
+purple
+pussies
+qazwsx
+qwerty
+qwertyui
+rabbit
+rachel
+racing
+raiders
+rainbow
+ranger
+rangers
+rebecca
+redskins
+redsox
+redwings
+richard
+robert
+rocket
+rosebud
+runner
+rush2112
+russia
+samantha
+sammy
+samson
+sandra
+saturn
+scooby
+scooter
+scorpio
+scorpion
+secret
+sexsex
+shadow
+shannon
+shaved
+sierra
+silver
+skippy
+slayer
+smokey
+snoopy
+soccer
+sophie
+spanky
+sparky
+spider
+squirt
+srinivas
+startrek
+starwars
+steelers
+steven
+sticky
+stupid
+success
+summer
+sunshine
+superman
+surfer
+swimming
+sydney
+taylor
+tennis
+teresa
+tester
+testing
+theman
+thomas
+thunder
+thx1138
+tiffany
+tigers
+tigger
+tomcat
+topgun
+toyota
+travis
+trouble
+trustno1
+tucker
+turtle