Commits

Juan Carlos Picado Herrera committed a1d019a Merge

Merge branch 'development' into release

Comments (0)

Files changed (253)

 *DEADJOE*
 encuestame-war/src/main/webapp/resource/js/dijit/
 encuestame-war/src/main/webapp/resource/js/dojox/
-encuestame-war/src/main/webapp/resource/js/dojo/
+encuestame-war/src/main/webapp/resource/js/dojo/
+encuestame-war/src/main/webapp/resource/js/org/

buildDojo.sh

-#!/bin/bash
-DOJO_PATH=dojo
-SVN_DOJO=http://svn.dojotoolkit.org/src/tags/release-1.5.0/
-
-echo 'Building Dojo'
-
-function createSymbolic {
-        if [ -d ${DOJO_PATH} ]; then
-            if [ -d encuestame-war/src/main/webapp/resource/js/dojo ]; then
-                rm -Rf encuestame-war/src/main/webapp/resource/js/dojo
-            fi
-
-            if [ -d encuestame-war/src/main/webapp/resource/js/dojox ]; then
-                rm -Rf encuestame-war/src/main/webapp/resource/js/dojox
-            fi
-
-            if [ -d encuestame-war/src/main/webapp/resource/js/dijit ]; then
-                rm -Rf encuestame-war/src/main/webapp/resource/js/dijit
-            fi
-            cp -Rf ${DOJO_PATH}/dojo encuestame-war/src/main/webapp/resource/js/
-            cp -Rf ${DOJO_PATH}/dojox encuestame-war/src/main/webapp/resource/js/
-            cp -Rf ${DOJO_PATH}/dijit encuestame-war/src/main/webapp/resource/js/
-        fi
-}
-
-
-if [ -d ${DOJO_PATH} ]; then
-    echo "Create Links"
-    createSymbolic
-else
-    echo "Create Dir"
-    mkdir ${DOJO_PATH}
-    #cd ${DOJO_PATH}
-    echo "SVN Checkout"
-    svn co ${SVN_DOJO} ${DOJO_PATH}
-    echo "Create Links"
-    createSymbolic
-fi
-echo 'Done'
+#!/bin/bash
+DOJO_PATH=dojo
+SVN_DOJO=http://svn.dojotoolkit.org/src/tags/release-1.6.0/
+FILE_DOJO=http://download.dojotoolkit.org/release-1.6.0/dojo-release-1.6.0-src.zip
+FILE_NAME=dojo-release-1.6.0-src.zip
+
+function createFromDownload {
+        if [ -d ${DOJO_PATH} ]; then
+            removeCurrentResources
+	    copyResources  
+        else
+            warningNoResources      
+        fi
+}
+
+function removeCurrentResources {
+            if [ -d encuestame-war/src/main/webapp/resource/js/dojo ]; then
+                rm -Rf encuestame-war/src/main/webapp/resource/js/dojo
+            fi
+
+            if [ -d encuestame-war/src/main/webapp/resource/js/dojox ]; then
+                rm -Rf encuestame-war/src/main/webapp/resource/js/dojox
+            fi
+
+            if [ -d encuestame-war/src/main/webapp/resource/js/dijit ]; then
+                rm -Rf encuestame-war/src/main/webapp/resource/js/dijit
+            fi
+	    if [ -d encuestame-war/src/main/webapp/resource/js/org ]; then
+                rm -Rf encuestame-war/src/main/webapp/resource/js/org
+            fi
+}
+
+
+function replaceCometDResources {
+    if [ -d ${DOJO_PATH} ]; then
+	    cp -Rfv lib/dojo-replace/org ${DOJO_PATH}
+	    cp -v lib/dojo-replace/cometd.js ${DOJO_PATH}/dojox/ 
+	    rm -Rf ${DOJO_PATH}/dojox/cometd 
+	    cp -Rfv lib/dojo-replace/cometd ${DOJO_PATH}/dojox/
+    else
+	warningNoResources
+    fi
+}
+
+function copyResources {
+        removeCurrentResources
+	replaceCometDResources
+	if [ -d ${DOJO_PATH} ]; then
+		cp -Rfv ${DOJO_PATH}/dojo encuestame-war/src/main/webapp/resource/js/
+		cp -Rfv ${DOJO_PATH}/dojox encuestame-war/src/main/webapp/resource/js/
+		cp -Rfv ${DOJO_PATH}/dijit encuestame-war/src/main/webapp/resource/js/
+		cp -Rfv ${DOJO_PATH}/org encuestame-war/src/main/webapp/resource/js/
+	else
+		warningNoResources
+	fi                
+}
+
+function warningNoResources {
+    echo "****************************************************************"
+    echo "*  WARNING !!! -- DOJO FOLDER NOT EXIST                        *"
+    echo "*  http://wiki.encuestame.org/en/Build_Project for more info.  *"
+    echo "****************************************************************"
+    exit
+}
+
+function warningShow {
+    echo "****************************************************************"
+    echo "*  WARNING !!! -- DOJO 1.6 IS REQUIRED                         *"
+    echo "*  Download from http://dojotoolkit.org/download               *"
+    echo "*  Copy the content on root folder named DOJO                  *"   
+    echo "*  After that run again this script                            *"
+    echo "*  http://wiki.encuestame.org/en/Build_Project for more info.  *"
+    echo "****************************************************************"
+}
+
+function svnDownload {
+    if [ -d ${DOJO_PATH} ]; then
+	 rm -Rf ${DOJO_PATH}
+    fi	
+    echo "SVN - Remove old resources"
+    echo "SVN - Create work path"
+    mkdir ${DOJO_PATH}
+    echo "SVN - Downloading source code .."
+    svn export ${SVN_DOJO} ${DOJO_PATH} --force
+    echo "SVN - Copy Resources"
+    copyResources
+}
+
+function fileDownload {
+    if [ -d ${DOJO_PATH} ]; then
+	 rm -Rf ${DOJO_PATH}
+    fi	
+    echo "ZIP - Download"
+    wget ${FILE_DOJO}
+    echo "ZIP - Create work path"
+    unzip ${FILE_NAME}
+    mv dojo-release-1.6.0-src ${DOJO_PATH}
+    echo "ZIP - Copy Resources"
+    rm ${FILE_NAME}
+    copyResources
+}
+
+
+cmd=(dialog --separate-output --checklist "Select options:" 22 76 16)
+options=(1 "Download DOJO FRAMEWORK Source Code from SVN" off
+         2 "Download DOJO FRAMEWORK on Download ZIP " on
+         3 "Install from local path  DOJO FRAMEWORK" off)
+choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
+clear
+for choice in $choices
+do
+    case $choice in
+        1)
+            svnDownload
+	    exit
+            ;;
+        2)
+            fileDownload
+	    exit
+            ;;
+        3)
+            copyResources
+            exit
+            ;;
+    esac
+done

encuestame-business/pom.xml

                 </executions>
             </plugin>
         </plugins>
+        <resources>
+            <resource>
+              <directory>src/main/resources/</directory>
+              <includes>
+                <include>spring-test/*.*</include>
+                <include>org/**/*.*</include>
+                <include>properties-test/*.*</include>
+              </includes>
+              <filtering>true</filtering>
+            </resource>
+        </resources>
     </build>
     <dependencies>
      <dependency>
         </dependency>
         <dependency>
             <groupId>org.hibernate</groupId>
-            <artifactId>hibernate-annotations</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.hibernate</groupId>
             <artifactId>hibernate-core</artifactId>
         </dependency>
         <dependency>

encuestame-business/src/main/java/org/encuestame/business/config/EncuestamePlaceHolderConfigurer.java

+package org.encuestame.business.config;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+
+/**
+ * Extend {@link PropertyPlaceholderConfigurer}
+ * @author Picado, Juan juanATencuestame.org
+ * @since Mar 17, 2011
+ */
+public class EncuestamePlaceHolderConfigurer extends PropertyPlaceholderConfigurer {
+
+    /**
+     * JVM encuestame path param.
+     */
+    private static String overwriteJvmParam = "encuestame.custom.config";
+
+    /**
+     * List of Properties.
+     */
+    private static Map<String, String> propertiesMap;
+
+
+    private static Log log = LogFactory.getLog(EncuestamePlaceHolderConfigurer.class);
+
+    /**
+     * Process collection of properties.
+     */
+    @SuppressWarnings("deprecation")
+    @Override
+    protected void processProperties(
+            ConfigurableListableBeanFactory beanFactory, Properties props)
+            throws BeansException {
+
+        //get form system property enviroment out file path.
+        final String enviromentPropertyFile = System.getProperty(overwriteJvmParam);
+        File customEncuestameFile;
+        if(enviromentPropertyFile != null && enviromentPropertyFile.length() > 0) {
+            customEncuestameFile = new File(enviromentPropertyFile);
+            // make sure the file exists, then try and load it
+            if(customEncuestameFile != null && customEncuestameFile.exists()) {
+                InputStream is = null;
+                try {
+                    //trying to load custom file.
+                    is = new FileInputStream(customEncuestameFile);
+                } catch (FileNotFoundException e) {
+                    log.error("Encuestame JVM Config file: File not Found from "+
+                            customEncuestameFile.getAbsolutePath());
+                }
+                try {
+                    //cool, if we can load all properties on the parent list.
+                    props.load(is);
+                } catch (IOException e) {
+                    log.error("Encuestame JVM Config file: I/O Error, Permission Error? Check your path. "+
+                            customEncuestameFile.getAbsolutePath());
+                }
+                log.info("Encuestame JVM Config file: Successfully loaded custom properties from "+
+                        customEncuestameFile.getAbsolutePath());
+            } else {
+                log.info("Encuestame JVM Config file: Failed to load custom properties from "+
+                        customEncuestameFile.getAbsolutePath());
+            }
+        }
+        super.processProperties(beanFactory, props);
+        propertiesMap = new HashMap<String, String>();
+        for (Object key : props.keySet()) {
+            String keyStr = key.toString();
+            log.debug("Property--->"+keyStr+ " value="+props.getProperty(keyStr));
+            propertiesMap.put(
+                    keyStr,
+                    parseStringValue(props.getProperty(keyStr), props,
+                            new HashSet()));
+        }
+    }
+
+    /**
+     * Get property.
+     * @param name property key
+     * @return property value.
+     */
+    public static String getProperty(final String name) {
+        return propertiesMap.get(name);
+    }
+}

encuestame-business/src/main/java/org/encuestame/business/mail/MailServiceImpl.java

 import org.apache.commons.logging.LogFactory;
 import org.apache.velocity.app.VelocityEngine;
 import org.encuestame.core.mail.MailService;
-import org.encuestame.core.service.IService;
+import org.encuestame.core.service.ServiceOperations;
 import org.encuestame.business.service.AbstractBaseService;
 import org.encuestame.utils.mail.InvitationBean;
 import org.encuestame.utils.mail.NotificationBean;
  */
 
 @SuppressWarnings("unchecked")
-public class MailServiceImpl extends AbstractBaseService implements MailService, IService {
+public class MailServiceImpl extends AbstractBaseService implements MailService, ServiceOperations {
 
     private Log log = LogFactory.getLog(this.getClass());
 
               Map model = new HashMap();
               model.put("invitation", invitation);
               String text = VelocityEngineUtils.mergeTemplateIntoString(
-                 velocityEngine, "invitation.vm", model);
+                 velocityEngine, "/org/encuestame/business/mail/templates/invitation.vm", model);
               message.setText(text, true);
            }
         };
               Map model = new HashMap();
               model.put("notification", notification);
               String text = VelocityEngineUtils.mergeTemplateIntoString(
-                 velocityEngine, "notification.vm", model);
+                 velocityEngine, "/org/encuestame/business/mail/templates/notification.vm", model);
               message.setText(text, true);
            }
         };
               Map model = new HashMap();
               model.put("user", user);
               String text = VelocityEngineUtils.mergeTemplateIntoString(
-                 velocityEngine, "password-confirmation.vm", model);
+                 velocityEngine, "/org/encuestame/business/mail/templates/password-confirmation.vm", model);
               message.setText(text, true);
            }
         };
               model.put("user", user);
               model.put("inviteCode", inviteCode);
               String text = VelocityEngineUtils.mergeTemplateIntoString(
-                              velocityEngine, "confirm-your-account.vm", model);
+                              velocityEngine, "/org/encuestame/business/mail/templates/confirm-your-account.vm", model);
               message.setText(text, true);
            }
         };
         final Map<String, UserAccountBean> model = new HashMap<String, UserAccountBean>();
         model.put("user", unitUserBean);
         this.sendMimeEmail(model, unitUserBean.getEmail(), "Your New Password", this.noEmailResponse,
-                           "renew-password.vm");
+                           "/org/encuestame/business/mail/templates/renew-password.vm");
     }
 
     /**

encuestame-business/src/main/java/org/encuestame/business/service/AbstractBaseService.java

 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.encuestame.business.mail.MailServiceImpl;
+import org.encuestame.business.service.imp.ITwitterService;
 import org.encuestame.core.files.PathUtil;
 import org.encuestame.core.util.ConvertDomainBean;
 import org.encuestame.core.util.MD5Utils;
  * @author Picado, Juan juan@encuestame.org
  * @since 22/05/2009 1:02:45
  */
-public abstract class AbstractBaseService extends AbstractConfigurationService {
+public abstract class AbstractBaseService extends AbstractSocialService {
 
     private Log log = LogFactory.getLog(this.getClass());
 
     private MailServiceImpl serviceMail;
 
     /**
-     *
-     */
-    private static int TWITTER_AUTH_ERROR = 401;
-
-    /**
      * Constructor.
      */
     public AbstractBaseService() {}
      }
 
     /**
-     * Verify OAuth Credentials
-     * @param token token stored
-     * @param secretToken secret Token
-     * @param pin pin
-     * @return
-     * @throws TwitterException
-     */
-    public Boolean verifyCredentials(final String token,
-                                     final String tokenSecret,
-                                     final String consumerKey,
-                                     final String consumerSecret,
-                final String pin){
-        Boolean verified = false;
-        log.debug("verifyCredentials OAuth");
-        log.debug("Token {"+token);
-        log.debug("secretToken {"+tokenSecret);
-        log.debug("pin {"+pin);
-        log.debug("consumerKey {"+consumerKey);
-        log.debug("consumerSecret {"+consumerSecret);
-        Twitter twitter = null;
-        try {
-             twitter = new TwitterFactory().getInstance();
-            if(token == null || token.isEmpty()){
-                verified = false;
-            } else {
-                log.debug("Exist Previous Token.");
-                final AccessToken accessToken = new AccessToken(token, tokenSecret);
-                log.debug("Created Token "+accessToken);
-                twitter = new TwitterFactory().getOAuthAuthorizedInstance(consumerKey, consumerSecret, accessToken);
-                log.debug("Verifying Credentials");
-                final User user = twitter.verifyCredentials();
-                log.debug("Verifying Credentials User "+user);
-                if (user != null) {
-                    log.debug("Verify OAuth User " + user.getId());
-                    verified = true;
-                }
-            }
-        } catch (TwitterException te) {
-            log.error("Twitter Error "+te.getMessage());
-            if (AbstractBaseService.TWITTER_AUTH_ERROR == te.getStatusCode()) {
-                log.error("Twitter Error "+te.getStatusCode());
-                verified = false;
-            } else {
-                log.error(te);
-            }
-            log.error("Verify OAuth Error " + te.getLocalizedMessage());
-        }
-        log.debug("verified "+verified);
-        return verified;
-    }
-
-    /**
      * Get Access Token.
      * @param token
      * @param tokenSecret
             throw new EnMeExpcetion("error on create directory");
         }
     }
-
 }

encuestame-business/src/main/java/org/encuestame/business/service/AbstractChartService.java

  * @version $Id:$
  */
 @Service
-public abstract class AbstractChartService extends AbstractBaseService {
+public abstract class AbstractChartService extends AbstractIndexService {
 
 }

encuestame-business/src/main/java/org/encuestame/business/service/AbstractConfigurationService.java

 
     private String proxyPass;
 
-    private @Value("${application.picture.path}") String dataGlobalPath;
+    //private @Value("${dir.data.warehouse}") String dataGlobalPath;
 
+    private String dataGlobalPath;
     /**
      * App Consumer Key.
      */

encuestame-business/src/main/java/org/encuestame/business/service/AbstractIndexService.java

+
+package org.encuestame.business.service;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.encuestame.core.util.ConvertDomainBean;
+import org.encuestame.persistence.domain.HashTag;
+import org.encuestame.persistence.domain.Question;
+import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
+import org.encuestame.utils.web.HashTagBean;
+import org.encuestame.utils.web.QuestionBean;
+
+/**
+ * Provide of index/search layer.
+ * @author Picado, Juan juanATencuestame.org
+ * @since Mar 18, 2011
+ */
+public abstract class AbstractIndexService extends AbstractBaseService{
+
+    /**
+     * Log.
+     */
+    private Log log = LogFactory.getLog(this.getClass());
+
+    /**
+     * List Suggested Hash Tags.
+     * @param hashTagKeyWord keyword to search
+     * @param maxResults limit of results
+     * @return list of hash tags.
+     */
+    public List<HashTagBean> listSuggestHashTags(final String hashTagKeyWord, final Integer maxResults){
+        final List<HashTag> tags = getHashTagDao().getListHashTagsByKeyword(hashTagKeyWord, maxResults);
+        log.debug("Hash Tag Suggested size "+tags.size());
+        return ConvertDomainBean.convertListHashTagsToBean(tags);
+    }
+
+    /**
+     * Return suggested list of questions by keyword on indexed results.
+     * @param keyword keyword to search
+     * @param username username logged
+     * @return
+     * @throws EnMeNoResultsFoundException
+     */
+    public List<QuestionBean> searchIndexedQuestions(final String keyword, final String username)
+           throws EnMeNoResultsFoundException{
+        final List<Question> questions = getQuestionDao().retrieveIndexQuestionsByKeyword(keyword,
+                                         getUserAccount(username).getAccount().getUid());
+        return ConvertDomainBean.convertListToUnitQuestionBean(questions);
+    }
+}

encuestame-business/src/main/java/org/encuestame/business/service/AbstractSocialService.java

+
+package org.encuestame.business.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.encuestame.business.service.imp.ITwitterService;
+import org.encuestame.core.util.ConvertDomainBean;
+import org.encuestame.persistence.domain.security.SocialAccount;
+import org.encuestame.persistence.domain.security.UserAccount;
+import org.encuestame.persistence.domain.security.SocialAccount.TypeAuth;
+import org.encuestame.persistence.domain.social.SocialProvider;
+import org.encuestame.persistence.exception.EnMeExpcetion;
+import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
+import org.encuestame.persistence.exception.IllegalSocialActionException;
+import org.encuestame.utils.security.SocialAccountBean;
+
+import twitter4j.Twitter;
+import twitter4j.TwitterException;
+import twitter4j.TwitterFactory;
+import twitter4j.User;
+import twitter4j.http.AccessToken;
+
+/**
+ * Social service layer.
+ * @author Picado, Juan juanATencuestame.org
+ * @since Mar 7, 2011
+ */
+public class AbstractSocialService extends AbstractConfigurationService {
+
+    /**
+     * Log.
+     */
+    private Logger log = Logger.getLogger(this.getClass());
+
+    /** Twitter Service. **/
+    private ITwitterService twitterService;
+
+   /**
+    * Twitter error code.
+    */
+   private static int TWITTER_AUTH_ERROR = 401;
+
+
+    /**
+     * Update OAuth Secret Twitter Credentials.
+     * @param accountBean {@link SocialAccountBean}
+     * @param username username logged
+     * @throws EnMeExpcetion exception
+     */
+    public void updateSecretTwitterCredentials(final SocialAccountBean accountBean,
+            final String username) throws EnMeExpcetion{
+         //TODO: we should search twitter account filter by username
+         final SocialAccount twitterAccount = this.getSocialAccount(accountBean.getAccountId()); //TODO: filter by Username Too
+         //twitterAccount.setConsumerKey(accountBean.getKey());
+         //twitterAccount.setConsumerSecret(accountBean.getSecret());
+         twitterAccount.setType(ConvertDomainBean.convertStringToEnum(accountBean.getType()));
+         if(accountBean.getPin() != null && !accountBean.getPin().isEmpty()){
+             log.debug("PIN Exists {"+accountBean.getPin());
+             //twitterAccount.setTwitterPin(Integer.valueOf(accountBean.getPin()));
+            //If exist pin, we can verify credentials
+            log.debug("Verify OAuth Credentials");
+                if(verifyCredentials(
+                        //Token and Secret token should be always from database
+                        twitterAccount.getToken(),
+                        twitterAccount.getSecretToken(),
+                        //consumer key's
+                        accountBean.getKey(),
+                        accountBean.getSecret(),
+                        //pin, update by the user.
+                        accountBean.getPin())){
+                    twitterAccount.setVerfied(Boolean.TRUE);
+                } else {
+                    twitterAccount.setVerfied(Boolean.FALSE);
+                }
+         } else {
+             log.info("Account not verified, pin not found");
+             //twitterAccount.setTwitterPin(null);
+             twitterAccount.setVerfied(Boolean.FALSE);
+         }
+        log.debug("Update Secret Twitter Credentials");
+        getAccountDao().saveOrUpdate(twitterAccount);
+        log.info("update Twitter Account");
+    }
+
+    /**
+     * Change state social account.
+     * @param accountId
+     * @param username
+     * @param action
+     * @throws EnMeNoResultsFoundException
+     * @throws IllegalSocialActionException
+     */
+    public void changeStateSocialAccount(
+            final Long accountId,
+            final String username,
+            final String action) throws EnMeNoResultsFoundException, IllegalSocialActionException{
+        final UserAccount userAccount = getUserAccount(username);
+        final SocialAccount social = getAccountDao().getSocialAccount(accountId, userAccount.getAccount());
+        if(social == null){
+            throw new EnMeNoResultsFoundException("social accout not found");
+        }
+        if("default".equals(action)){
+           log.info("update social twitter account");
+           social.setDefaultSelected(!social.getDefaultSelected());
+           getAccountDao().saveOrUpdate(social);
+        } else if("remove".equals(action)){
+            getAccountDao().delete(social);
+        } else if("valid".equals(action)){
+            social.setVerfied(!social.getVerfied());
+            getAccountDao().saveOrUpdate(social);
+        } else {
+            throw new IllegalSocialActionException();
+        }
+    }
+
+    /**
+     * Verify OAuth Credentials
+     * @param token token stored
+     * @param secretToken secret Token
+     * @param pin pin
+     * @return
+     * @throws TwitterException
+     */
+    public Boolean verifyCredentials(final String token,
+                                     final String tokenSecret,
+                                     final String consumerKey,
+                                     final String consumerSecret,
+                final String pin){
+        Boolean verified = false;
+        log.debug("verifyCredentials OAuth");
+        log.debug("Token {"+token);
+        log.debug("secretToken {"+tokenSecret);
+        log.debug("pin {"+pin);
+        log.debug("consumerKey {"+consumerKey);
+        log.debug("consumerSecret {"+consumerSecret);
+        Twitter twitter = null;
+        try {
+             twitter = new TwitterFactory().getInstance();
+            if(token == null || token.isEmpty()){
+                verified = false;
+            } else {
+                log.debug("Exist Previous Token.");
+                final AccessToken accessToken = new AccessToken(token, tokenSecret);
+                log.debug("Created Token "+accessToken);
+                twitter = new TwitterFactory().getOAuthAuthorizedInstance(consumerKey, consumerSecret, accessToken);
+                log.debug("Verifying Credentials");
+                final User user = twitter.verifyCredentials();
+                log.debug("Verifying Credentials User "+user);
+                if (user != null) {
+                    log.debug("Verify OAuth User " + user.getId());
+                    verified = true;
+                }
+            }
+        } catch (TwitterException te) {
+            log.error("Twitter Error "+te.getMessage());
+            if (AbstractSocialService.TWITTER_AUTH_ERROR == te.getStatusCode()) {
+                log.error("Twitter Error "+te.getStatusCode());
+                verified = false;
+            } else {
+                log.error(te);
+            }
+            log.error("Verify OAuth Error " + te.getLocalizedMessage());
+        }
+        log.debug("verified "+verified);
+        return verified;
+    }
+
+
+    /**
+     * Update OAuth Token/Secret Social Account.
+     * @param socialAccountId
+     * @param token
+     * @param tokenSecret
+     * @param username
+     * @param account
+     * @param socialProvider
+     * @throws EnMeExpcetion
+     */
+    public void addOrUpdateOAuthTokenSocialAccount(
+            final Long socialAccountId,
+            final String token,
+            final String tokenSecret,
+            final String username,
+            final UserAccount account,
+            final SocialProvider socialProvider) throws EnMeExpcetion{
+            SocialAccount socialAccount = getAccountDao().getSocialAccount(socialProvider, socialAccountId);
+            if (socialAccount == null) {
+                log.info("adding new social account");
+                socialAccount = new SocialAccount();
+            }
+            log.debug("Updating  Token to {"+token);
+            log.debug("Updating Secret Token to {"+tokenSecret);
+            socialAccount.setToken(token);
+            socialAccount.setVerfied(Boolean.TRUE);
+            socialAccount.setAccounType(socialProvider);
+            socialAccount.setSecUsers(account.getAccount());
+            socialAccount.setSocialAccountName(username);
+            socialAccount.setType(TypeAuth.OAUTH);
+            socialAccount.setSecretToken(tokenSecret);
+            socialAccount.setSocialUserId(socialAccountId);
+            getAccountDao().saveOrUpdate(socialAccount);
+            log.debug("Updated Token");
+    }
+
+
+    /**
+     * Get Twitter Account.
+     * @param twitterAccountId
+     * @return
+     */
+    public SocialAccountBean getTwitterAccount(final Long twitterAccountId){
+        return ConvertDomainBean.convertSocialAccountToBean(getAccountDao().getTwitterAccount(twitterAccountId));
+    }
+
+
+    /**
+     * Get User Logged Scocial Accounts.
+     * @param username
+     * @param provider
+     * @return
+     * @throws EnMeNoResultsFoundException
+     */
+    public List<SocialAccountBean> getUserLoggedSocialAccount(final String username, final SocialProvider provider)
+           throws EnMeNoResultsFoundException{
+         return ConvertDomainBean.convertListSocialAccountsToBean(getAccountDao()
+                                 .getTwitterAccountByUser(getUserAccount(username).getAccount(), provider));
+    }
+
+    /**
+     * Get User Logged Verified Social Accounts.
+     * @param username username
+     * @return list of social accounts.
+     * @throws EnMeNoResultsFoundException exception
+     */
+    public List<SocialAccountBean> getUserLoggedVerifiedTwitterAccount(final String username, final SocialProvider provider)
+             throws EnMeNoResultsFoundException{
+        final List<SocialAccountBean> comfirmedSocialAccounts = new ArrayList<SocialAccountBean>();
+        final List<SocialAccount> socialAccounts = getAccountDao()
+                .getTwitterVerifiedAccountByUser(getUserAccount(username).getAccount(), provider);
+        for (SocialAccount socialAccount : socialAccounts) {
+            log.debug("getTwitterService() "+getTwitterService());
+            if(getTwitterService().verifyCredentials(socialAccount)){
+                log.debug("Confirmed Account  -- "+socialAccount.getSocialAccountName());
+                comfirmedSocialAccounts.add(ConvertDomainBean.convertSocialAccountToBean(socialAccount));
+            }
+        }
+        log.debug("social provider verified "+comfirmedSocialAccounts.size());
+        return comfirmedSocialAccounts;
+   }
+
+   /**
+    * Get social account by id.
+    * @param accountId
+    * @return
+    */
+   protected SocialAccount getSocialAccount(final Long accountId){
+        return  getAccountDao().getTwitterAccount(accountId); //TODO: ENCUESTAME-113
+   }
+
+   /**
+    * Update Twitter Account.
+    * @param accountBean account
+    * @param password password
+    * TODO: this method is close to be deprecated, twitter don't allow password login.
+    */
+   @Deprecated
+   public void updateTwitterAccount(
+           final SocialAccountBean accountBean,
+           final String password,
+           final Boolean verify){
+       if(accountBean.getAccountId() != null){
+           final SocialAccount twitterAccount = getAccountDao().getTwitterAccount(accountBean.getAccountId());
+           if(twitterAccount != null){
+               //twitterAccount.setTwitterPassword(password);
+               twitterAccount.setVerfied(verify);
+               log.debug("Updating twitter password account");
+               getAccountDao().saveOrUpdate(twitterAccount);
+           }
+       }
+       log.info("update Twitter Account");
+   }
+
+   /**
+    * @return the twitterService
+    */
+   public ITwitterService getTwitterService() {
+       return twitterService;
+   }
+
+   /**
+    * @param twitterService the twitterService to set
+    */
+   public void setTwitterService(final ITwitterService twitterService) {
+       this.twitterService = twitterService;
+   }
+}

encuestame-business/src/main/java/org/encuestame/business/service/AbstractSurveyService.java

 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 import org.encuestame.persistence.exception.EnMeExpcetion;
 import org.encuestame.utils.web.UnitAnswersBean;
-import org.encuestame.utils.web.UnitHashTag;
+import org.encuestame.utils.web.HashTagBean;
 import org.encuestame.utils.web.UnitPatternBean;
-import org.encuestame.utils.web.UnitQuestionBean;
+import org.encuestame.utils.web.QuestionBean;
 import org.encuestame.utils.web.UnitTweetPoll;
 import org.encuestame.utils.web.UnitTweetPollResult;
 import org.hibernate.HibernateException;
 @Service
 public class AbstractSurveyService extends AbstractChartService {
 
-    /** Twitter Service. **/
-    private ITwitterService twitterService;
-
     /** AnswerPoll Path. **/
     private String answerPollPath;
 
 
     /**
      * Create Question.
-     * @param questionBean {@link UnitQuestionBean}.
+     * @param questionBean {@link QuestionBean}.
      * @throws EnMeExpcetion exception
      */
-    public Question createQuestion(final UnitQuestionBean questionBean) throws EnMeExpcetion{
+    public Question createQuestion(final QuestionBean questionBean) throws EnMeExpcetion{
               final Question question = new Question();
             try{
 
      * @return
      * @throws EnMeExpcetion exception.
      */
-    public HashTag createHashTag(final UnitHashTag unitHashTag) throws EnMeExpcetion{
+    public HashTag createHashTag(final HashTagBean unitHashTag) throws EnMeExpcetion{
         try{
             final HashTag tag = new HashTag();
             tag.setHashTag(unitHashTag.getHashTagName());
 
     /**
      * Load all questions.
-     * @return List of {@link UnitQuestionBean}
+     * @return List of {@link QuestionBean}
      * @throws EnMeExpcetion exception
      */
-    public List<UnitQuestionBean> loadAllQuestions() throws EnMeExpcetion {
-        final List<UnitQuestionBean> listQuestionBean = new LinkedList<UnitQuestionBean>();
+    public List<QuestionBean> loadAllQuestions() throws EnMeExpcetion {
+        final List<QuestionBean> listQuestionBean = new LinkedList<QuestionBean>();
         try {
             final  List<Question> questionsList = getQuestionDao()
                     .loadAllQuestions();
             if (questionsList.size() > 0) {
 
                for (Question questions : questionsList) {
-                    final UnitQuestionBean q = new UnitQuestionBean();
+                    final QuestionBean q = new QuestionBean();
                     q.setId(Long.valueOf(questions.getQid().toString()));
                     q.setQuestionName(questions.getQuestion());
                     listQuestionBean.add(q);
      * @return unitQuestionBean
      * @throws EnMeNoResultsFoundException
      */
-    public List<UnitQuestionBean> listSuggestQuestion(final String questionKeyword, final String username) throws EnMeNoResultsFoundException{
-        final List<UnitQuestionBean> unitQuestionBean = new ArrayList<UnitQuestionBean>();
+    public List<QuestionBean> listSuggestQuestion(final String questionKeyword, final String username) throws EnMeNoResultsFoundException{
+        final List<QuestionBean> unitQuestionBean = new ArrayList<QuestionBean>();
         final List<Question> questionsList = getQuestionDao().retrieveIndexQuestionsByKeyword(questionKeyword, getPrimaryUser(username));
         log.info("listSuggestQuestion "+questionsList.size());
         for (Question question : questionsList) {
     }
 
     /**
-     * List Suggested Hash Tags.
-     * @param hashTagKeyWord
-     * @param maxResults
-     * @return
-     */
-    public List<UnitHashTag> listSuggestHashTags(final String hashTagKeyWord, final Integer maxResults){
-        final List<HashTag> tags = getHashTagDao().getListHashTagsByKeyword(hashTagKeyWord, maxResults);
-        log.debug("Hash Tag Suggested size "+tags.size());
-        return ConvertDomainBean.convertListHashTagsToBean(tags);
-    }
-
-    /**
      * Validate TweetPoll IP.
      * @param ipVote  ipVote
      * @param tweetPoll tweetPoll
      * @param unitQuestionPoll
      * @throws EnMeExpcetion  Exception
      */
-     public void updateQuestion(final UnitQuestionBean unitQuestionPoll) throws EnMeExpcetion{
+     public void updateQuestion(final QuestionBean unitQuestionPoll) throws EnMeExpcetion{
          final Question question = getQuestionDao().retrieveQuestionById(unitQuestionPoll.getId());
          if (question == null){
              throw new EnMeExpcetion("question not found");
      }
 
     /**
-     * @return the twitterService
-     */
-    public ITwitterService getTwitterService() {
-        return twitterService;
-    }
-
-    /**
-     * @param twitterService the twitterService to set
-     */
-    public void setTwitterService(final ITwitterService twitterService) {
-        this.twitterService = twitterService;
-    }
-
-    /**
      * @return the answerPollPath
      */
     public String getAnswerPollPath() {

encuestame-business/src/main/java/org/encuestame/business/service/ApplicationServices.java

 import org.encuestame.business.service.imp.IPictureService;
 import org.encuestame.business.service.imp.IPollService;
 import org.encuestame.business.service.imp.IProjectService;
-import org.encuestame.business.service.imp.ISecurityService;
+import org.encuestame.business.service.imp.SecurityOperations;
 import org.encuestame.business.service.imp.ISurveyService;
 import org.encuestame.business.service.imp.ITweetPollService;
 import org.springframework.stereotype.Service;
 public class ApplicationServices extends AbstractBaseService implements IApplicationServices {
 
     /** {@link SecurityService}. **/
-    private ISecurityService securityService;
+    private SecurityOperations securityService;
     /** {@link SurveyService}. **/
     private ISurveyService surveyService;
     /** {@link PollService}. **/
     /**
      * @return the securityService
      */
-    public ISecurityService getSecurityService() {
+    public SecurityOperations getSecurityService() {
         return securityService;
     }
 
     /**
      * @param securityService the securityService to set
      */
-    public void setSecurityService(ISecurityService securityService) {
+    public void setSecurityService(SecurityOperations securityService) {
         this.securityService = securityService;
     }
 

encuestame-business/src/main/java/org/encuestame/business/service/PollService.java

 import org.encuestame.utils.web.UnitFolder;
 import org.encuestame.utils.web.UnitLists;
 import org.encuestame.utils.web.UnitPoll;
-import org.encuestame.utils.web.UnitQuestionBean;
+import org.encuestame.utils.web.QuestionBean;
 import org.springframework.stereotype.Service;
 
 /**
     public void updateAnswersPoll( ){
     }
 
-    public void updateQuestionPoll(UnitQuestionBean unitQuestionPoll)
+    public void updateQuestionPoll(QuestionBean unitQuestionPoll)
             throws EnMeExpcetion {
         // TODO Auto-generated method stub
 

encuestame-business/src/main/java/org/encuestame/business/service/SearchService.java

  * @since February 09, 2011
  * @version $Id$
  */
-public class SearchService extends ISearchService {
+public class SearchService extends AbstractIndexService  implements ISearchService {
 
     private Search search;
 
     public List<Poll> searchPolls(String searchString, String path, String fieldName,
             int results) throws IOException, ParseException {
         List<Poll> pollList = new ArrayList<Poll>();
-        IndexReader reader = IndexReader.open(path, true);
-        Searcher searcher = new IndexSearcher(reader);
+        //IndexReader reader = IndexReader.open(path, true);
+        //IndexReader reader = IndexReader.open(path);
+        //Searcher searcher = new IndexSearcher(reader);
+        Searcher searcher = null;
         QueryParser qp = new QueryParser(Version.LUCENE_29, fieldName,
                 new StandardAnalyzer(Version.LUCENE_29));
         Query query = qp.parse(searchString);
             throws IOException, ParseException {
         Map<String, Object> map = new HashMap<String, Object>();
         List<Poll> articles = new ArrayList<Poll>();
-        Searcher searcher = new IndexSearcher(IndexReader.open(path));
+        //Searcher searcher = new IndexSearcher(IndexReader.open(path));
+        //IndexReader reader = IndexReader.open(path);
+        //Searcher searcher = new IndexSearcher(reader);
+        Searcher searcher = null;
         QueryParser qp = new QueryParser(Version.LUCENE_29, fieldName,
                 new StandardAnalyzer(Version.LUCENE_29));
         Query query = qp.parse(searchString);
     public List<Poll> searchArticle(String searchString, String path, String fieldName,
             int results) throws IOException, ParseException {
         List<Poll> articles = new ArrayList<Poll>();
-        IndexReader reader = IndexReader.open(path);
-        Searcher searcher = new IndexSearcher(reader);
+        //IndexReader reader = IndexReader.open(path);
+        //Searcher searcher = new IndexSearcher(reader);
+        Searcher searcher = null;
         QueryParser qp = new QueryParser(Version.LUCENE_29, fieldName,
                 new StandardAnalyzer(Version.LUCENE_29));
         Query query = qp.parse(searchString);

encuestame-business/src/main/java/org/encuestame/business/service/SecurityService.java

 import java.util.Set;
 
 import org.apache.log4j.Logger;
-import org.encuestame.business.service.imp.ISecurityService;
+import org.encuestame.business.service.imp.SecurityOperations;
 import org.encuestame.core.security.util.EnMePasswordUtils;
 import org.encuestame.core.security.util.PasswordGenerator;
 import org.encuestame.core.util.ConvertDomainBean;
 import org.encuestame.persistence.domain.security.Account;
 import org.encuestame.persistence.domain.security.Group;
 import org.encuestame.persistence.domain.security.Permission;
-import org.encuestame.persistence.domain.security.SocialAccount;
-import org.encuestame.persistence.domain.security.SocialAccount.TypeAuth;
 import org.encuestame.persistence.domain.security.UserAccount;
-import org.encuestame.persistence.domain.social.SocialProvider;
-import org.encuestame.persistence.exception.EnMeIllegalProviderException;
-import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 import org.encuestame.persistence.exception.EnMeExpcetion;
+import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 import org.encuestame.persistence.exception.EnmeFailOperation;
 import org.encuestame.utils.security.SignUpBean;
-import org.encuestame.utils.security.SocialAccountBean;
 import org.encuestame.utils.web.UnitGroupBean;
 import org.encuestame.utils.web.UnitLists;
 import org.encuestame.utils.web.UnitPermission;
  * @since 27/04/2009 11:35:01
  */
 @Service
-public class SecurityService extends AbstractBaseService implements ISecurityService {
+public class SecurityService extends AbstractBaseService implements SecurityOperations {
 
     private Logger log = Logger.getLogger(this.getClass());
 
     /** Default User Permission **/
-    private static final String DEFAULT = EnMePermission.ENCUESTAME_USER.name();
+    private static final EnMePermission DEFAULT = EnMePermission.ENCUESTAME_USER;
 
     /** Default User Permission **/
-    private static final String ADMIN = EnMePermission.ENCUESTAME_ADMIN.name();
+    private static final EnMePermission ADMIN = EnMePermission.ENCUESTAME_ADMIN;
 
     /** Default User Permission **/
-    private static final String EDITOR = EnMePermission.ENCUESTAME_EDITOR.name();
+    private static final EnMePermission EDITOR = EnMePermission.ENCUESTAME_EDITOR;
 
     /** Default User Permission **/
-    private static final String OWNER = EnMePermission.ENCUESTAME_OWNER.name();
+    private static final EnMePermission OWNER = EnMePermission.ENCUESTAME_OWNER;
 
     /** Default User Permission **/
-    private static final String PUBLISHER = EnMePermission.ENCUESTAME_PUBLISHER.name();
+    private static final EnMePermission PUBLISHER = EnMePermission.ENCUESTAME_PUBLISHER;
 
 
     private final Integer DEFAULT_LENGTH_PASSWORD = 8;
     }
 
     /**
-     * Update Twitter Account.
-     * @param accountBean account
-     * @param password password
-     * TODO: this method is close to be deprecated, twitter don't allow password login.
-     */
-    @Deprecated
-    public void updateTwitterAccount(
-            final SocialAccountBean accountBean,
-            final String password,
-            final Boolean verify){
-        if(accountBean.getAccountId() != null){
-            final SocialAccount twitterAccount = getAccountDao().getTwitterAccount(accountBean.getAccountId());
-            if(twitterAccount != null){
-                //twitterAccount.setTwitterPassword(password);
-                twitterAccount.setVerfied(verify);
-                log.debug("Updating twitter password account");
-                getAccountDao().saveOrUpdate(twitterAccount);
-            }
-        }
-        log.info("update Twitter Account");
-    }
-
-    /**
-     *
-     * @param accountId
-     * @return
-     */
-    private SocialAccount getSocialAccount(final Long accountId){
-         return  getAccountDao().getTwitterAccount(accountId); //TODO: filter by Username Too
-    }
-
-    /**
-     * Update OAuth Secret Twitter Credentials.
-     * @param accountBean {@link SocialAccountBean}
-     * @param username username logged
-     * @throws EnMeExpcetion exception
-     */
-    public void updateSecretTwitterCredentials(final SocialAccountBean accountBean,
-            final String username) throws EnMeExpcetion{
-         //TODO: we should search twitter account filter by username
-         final SocialAccount twitterAccount = this.getSocialAccount(accountBean.getAccountId()); //TODO: filter by Username Too
-         //twitterAccount.setConsumerKey(accountBean.getKey());
-         //twitterAccount.setConsumerSecret(accountBean.getSecret());
-         twitterAccount.setType(ConvertDomainBean.convertStringToEnum(accountBean.getType()));
-         if(accountBean.getPin() != null && !accountBean.getPin().isEmpty()){
-             log.debug("PIN Exists {"+accountBean.getPin());
-             //twitterAccount.setTwitterPin(Integer.valueOf(accountBean.getPin()));
-            //If exist pin, we can verify credentials
-            log.debug("Verify OAuth Credentials");
-                if(verifyCredentials(
-                        //Token and Secret token should be always from database
-                        twitterAccount.getToken(),
-                        twitterAccount.getSecretToken(),
-                        //consumer key's
-                        accountBean.getKey(),
-                        accountBean.getSecret(),
-                        //pin, update by the user.
-                        accountBean.getPin())){
-                    twitterAccount.setVerfied(Boolean.TRUE);
-                } else {
-                    twitterAccount.setVerfied(Boolean.FALSE);
-                }
-         } else {
-             log.info("Account not verified, pin not found");
-             //twitterAccount.setTwitterPin(null);
-             twitterAccount.setVerfied(Boolean.FALSE);
-         }
-        log.debug("Update Secret Twitter Credentials");
-        getAccountDao().saveOrUpdate(twitterAccount);
-        log.info("update Twitter Account");
-    }
-
-
-    /**
-     * Update OAuth Token/Secret Social Account.
-     * @param socialAccountId
-     * @param token
-     * @param tokenSecret
-     * @param username
-     * @param account
-     * @throws EnMeExpcetion
-     */
-    public void addOAuthTokenSocialAccount(
-            final Long socialAccountId,
-            final String token,
-            final String tokenSecret,
-            final String username,
-            final UserAccount account) throws EnMeExpcetion{
-        final SocialAccount socialAccount = new SocialAccount();
-            log.debug("Updating  Token to {"+token);
-            log.debug("Updating Secret Token to {"+tokenSecret);
-            socialAccount.setToken(token);
-            socialAccount.setVerfied(Boolean.TRUE);
-            socialAccount.setSecUsers(account.getAccount());
-            socialAccount.setSocialAccountName(username);
-            socialAccount.setType(TypeAuth.OAUTH);
-            socialAccount.setSecretToken(tokenSecret);
-            socialAccount.setSocialUserId(socialAccountId);
-            getAccountDao().saveOrUpdate(socialAccount);
-            log.debug("Updated Token");
-    }
-
-
-    /**
-     * Get Twitter Account.
-     * @param twitterAccountId
-     * @return
-     */
-    public SocialAccountBean getTwitterAccount(final Long twitterAccountId){
-        return ConvertDomainBean.convertSocialAccountToBean(getAccountDao().getTwitterAccount(twitterAccountId));
-    }
-
-    /**
      * Assing Group to User.
      * @param user user
      * @param group group
     }
 
     /**
-     * Get Permission By Name
-     * @param permission permission
-     * @return {@link Permission}
-     */
-    public Permission getPermissionByName(final String permission){
-        final Permission permission2 = getPermissionDao().loadPermission(
-              EnMePermission.getPermissionString(permission));
-        return permission2;
-    }
-
-    /**
      * Get Permission by {@link EnMePermission}.
      * @param permission permission.
      * @return
     }
 
     /**
-     * Get User Logged Scocial Accounts.
-     * @return
-     * @throws EnMeNoResultsFoundException
-     */
-    public List<SocialAccountBean> getUserLoggedSocialAccount(final String username) throws EnMeNoResultsFoundException{
-         return ConvertDomainBean.convertListSocialAccountsToBean(getAccountDao()
-                                 .getTwitterAccountByUser(getUserAccount(username).getAccount()));
-    }
-
-    /**
-     * Get User Logged Verified Social Accounts.
-     * @param username username
-     * @return list of social accounts.
-     * @throws EnMeNoResultsFoundException exception
-     */
-    public List<SocialAccountBean> getUserLoggedVerifiedTwitterAccount(final String username, final SocialProvider provider)
-             throws EnMeNoResultsFoundException{
-        final List<SocialAccountBean> socialAccounts = ConvertDomainBean.convertListSocialAccountsToBean(getAccountDao()
-                .getTwitterVerifiedAccountByUser(getUserAccount(username).getAccount(), provider));
-        log.debug("social provider verified "+socialAccounts.size());
-        return socialAccounts;
-   }
-
-    /**
      * Invite some users to register in the system.
      * @param email list of users
      * @param code code
      * @return default user permission.
      */
     public String getDefaultUserPermission() {
-        return  DEFAULT;
+        return  DEFAULT.name();
     }
 
     /**

encuestame-business/src/main/java/org/encuestame/business/service/SurveyService.java

 import org.encuestame.utils.web.UnitAnswersBean;
 import org.encuestame.utils.web.UnitFolder;
 import org.encuestame.utils.web.UnitPatternBean;
-import org.encuestame.utils.web.UnitQuestionBean;
+import org.encuestame.utils.web.QuestionBean;
 import org.encuestame.utils.web.UnitSurvey;
 import org.encuestame.utils.web.UnitSurveySection;
 import org.hibernate.HibernateException;
 
     /**
      * Create Question.
-     * @param questionBean {@link UnitQuestionBean}.
+     * @param questionBean {@link QuestionBean}.
      * @throws EnMeExpcetion exception
      */
-    public Question createQuestion(final UnitQuestionBean questionBean) throws EnMeExpcetion{
+    public Question createQuestion(final QuestionBean questionBean) throws EnMeExpcetion{
             final Question question = new Question();
             try{
 
 
     /**
      * Load all questions.
-     * @return List of {@link UnitQuestionBean}
+     * @return List of {@link QuestionBean}
      * @throws EnMeExpcetion exception
      */
-    public List<UnitQuestionBean> loadAllQuestions() throws EnMeExpcetion {
-        final List<UnitQuestionBean> listQuestionBean = new LinkedList<UnitQuestionBean>();
+    public List<QuestionBean> loadAllQuestions() throws EnMeExpcetion {
+        final List<QuestionBean> listQuestionBean = new LinkedList<QuestionBean>();
         try {
             final  List<Question> questionsList = getQuestionDao()
                     .loadAllQuestions();
             if (questionsList.size() > 0) {
 
                for (Question questions : questionsList) {
-                    final UnitQuestionBean q = new UnitQuestionBean();
+                    final QuestionBean q = new QuestionBean();
                     q.setId(Long.valueOf(questions.getQid().toString()));
                     q.setQuestionName(questions.getQuestion());
                     listQuestionBean.add(q);
         try {
             final SurveySection surveySectionDomain = new SurveySection();
             surveySectionDomain.setDescSection(surveySectionBean.getName());
-            for (final UnitQuestionBean questionBean : surveySectionBean.getListQuestions()) {
+            for (final QuestionBean questionBean : surveySectionBean.getListQuestions()) {
                 this.saveQuestions(questionBean);
             }
         } catch (Exception e) {
      * Save Questions.
      * @param questionBean
      */
-    public void saveQuestions(final UnitQuestionBean questionBean){
+    public void saveQuestions(final QuestionBean questionBean){
         final Question question = new Question();
         question.setQuestion(questionBean.getQuestionName());
         //	question.setQidKey();

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

 import org.encuestame.persistence.exception.EnmeFailOperation;
 import org.encuestame.utils.security.SocialAccountBean;
 import org.encuestame.utils.web.UnitFolder;
-import org.encuestame.utils.web.UnitHashTag;
+import org.encuestame.utils.web.HashTagBean;
 import org.encuestame.utils.web.UnitTweetPoll;
 import org.encuestame.utils.web.UnitTweetPollResult;
 
             }
             //Save Hash Tags for this tweetPoll.
             log.debug("HashTag Size"+tweetPollBean.getHashTags().size());
-            for (UnitHashTag unitHashTag : tweetPollBean.getHashTags()) {
+            for (HashTagBean unitHashTag : tweetPollBean.getHashTags()) {
                 HashTag hashTag = getHashTagDao().getHashTagByName(unitHashTag.getHashTagName().toLowerCase());
                 //If is null, create new hashTag.
                 if(hashTag == null){