Commits

Juan Carlos Picado Herrera committed d6dc982
  • Participants
  • Parent commits 0eb0671

Comments (0)

Files changed (12)

File BUILD.txt

-## Default Profile 
-mvn clean install
-
-## With Profile
-mvn -PprofileName clean install

File encuestame-business/src/main/java/org/encuestame/business/security/filter/VerifyAuthenticationFilter.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.business.security.filter;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.log4j.Logger;
-import org.encuestame.persistence.domain.EnMePermission;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.context.SecurityContext;
-import org.springframework.security.core.context.SecurityContextHolder;
-
-/**
- * Verify Authentication Filter.
- * @author Picado, Juan juanATencuestameDOTorg
- * @since Aug 21, 2010 10:41:38 PM
- */
-@Deprecated
-public class VerifyAuthenticationFilter implements Filter {
-
-    private Log log = LogFactory.getLog(this.getClass());
-
-    private  String loginUrl = "/user/signin";
-
-    private  String redirectUrl = "/user/dashboard";
-
-    /**
-     * Do Filter.
-     */
-    public void doFilter(ServletRequest request, ServletResponse response,
-            FilterChain chain) throws IOException, ServletException {
-
-         final HttpServletRequest httpServletRequest = ((HttpServletRequest) request);
-         final HttpServletResponse responseHttp = (HttpServletResponse) response;
-         final String pauthUrl = httpServletRequest.getRequestURI();
-
-         try{
-             final SecurityContext securityContext = SecurityContextHolder.getContext();
-             final Authentication authentication = securityContext.getAuthentication();
-
-             if(authentication != null && authentication.isAuthenticated()){
-                 final StringBuffer loginUrlPath = new StringBuffer();
-                 loginUrlPath.append(httpServletRequest.getContextPath());
-                 loginUrlPath.append(loginUrl);
-                 //TODO: login, remember password and sign up should be in this condition
-                 if(pauthUrl.equals(loginUrlPath.toString())){
-                      log.debug("redirect processing");
-                      response.reset();
-                      response.resetBuffer();
-                      final Collection<? extends GrantedAuthority>  authorities = authentication
-                      .getAuthorities();
-                      for (GrantedAuthority grantedAuthority : authorities) {
-                          if(grantedAuthority.getAuthority().equals(EnMePermission.ENCUESTAME_USER.name())){
-                              final StringBuffer redirectUrlPath = new StringBuffer();
-                              redirectUrlPath.append(httpServletRequest.getContextPath());
-                              redirectUrlPath.append(this.redirectUrl);
-                              responseHttp.sendRedirect(redirectUrlPath.toString());
-                          }
-                          else{
-                              log.debug("not access role");
-                          }
-                      }
-                 }
-             }
-             else{
-                 log.debug("not logged");
-             }
-         }catch (Exception e) {
-            log.error("error on validation filter "+e.getMessage());
-        }
-
-         // Forward the request to the next resource in the chain
-         chain.doFilter(request, response);
-    }
-
-    public void destroy() {
-        //nothing
-    }
-
-    public void init(FilterConfig filterConfig) throws ServletException {
-        //nothing
-    }
-
-}

File encuestame-business/src/main/java/org/encuestame/business/security/filter/package-info.java

-/**
- * Contains the Filter Class for Authentication.
- *
- */
-package org.encuestame.business.security.filter;

File encuestame-core/src/main/java/org/encuestame/core/service/SecurityService.java

         final List<SocialAccount> socialAccounts = getAccountDao()
                 .getSocialVerifiedAccountByUserAccount(getUserAccount(getUserPrincipalUsername()).getAccount(), provider);
         log.debug("social provider verified:{"+socialAccounts.size());
-        final List<SocialAccountBean> accounts = new ArrayList<SocialAccountBean>();
+        List<SocialAccountBean> accounts = new ArrayList<SocialAccountBean>();
         if ( addStats) {
-            accounts.addAll(this.addSocialStats(socialAccounts));
+            accounts = this.addSocialStats(socialAccounts);
         } else {
-            accounts.addAll(ConvertDomainBean.convertListSocialAccountsToBean(socialAccounts));
+            accounts = ConvertDomainBean.convertListSocialAccountsToBean(socialAccounts);
         }
-        return ConvertDomainBean.convertListSocialAccountsToBean(socialAccounts);
+        return accounts;
    }
 
     /**
     private List<SocialAccountBean> addSocialStats(final List<SocialAccount> socialAccounts) {
         final List<SocialAccountBean> accounts = new ArrayList<SocialAccountBean>();
         for (SocialAccount socialAccount : socialAccounts) {
+            log.debug("addSocialStats to "+socialAccount.getId());
             final HashMap<String, Long> stats = getAccountDao().getSocialAccountStats(socialAccount);
+            log.debug("addSocialStats stats: "+stats);
             final SocialAccountBean bean = ConvertDomainBean.convertSocialAccountToBean(socialAccount);
+            log.debug("addSocialStats stats tweetpoll: "+stats.get("tweetpoll"));
+            log.debug("addSocialStats stats poll: "+stats.get("poll"));
+            log.debug("addSocialStats stats survey: "+stats.get("survey"));
             bean.setTweetpoll(stats.get("tweetpoll"));
             bean.setPoll(stats.get("poll"));
             bean.setSurvey(stats.get("survey"));
+            log.debug("addSocialStats bean: "+bean.toString());
             accounts.add(bean);
         }
         return accounts;

File encuestame-core/src/main/java/org/encuestame/core/util/ConvertDomainBean.java

      * @return
      */
     public static final  List<SocialAccountBean> convertListSocialAccountsToBean(final List<SocialAccount> accounts) {
+        log.debug("convertListSocialAccountsToBean "+accounts.size());
         final List<SocialAccountBean> loadListPermission = new ArrayList<SocialAccountBean>();
         for (SocialAccount account : accounts) {
+            log.debug("convertListSocialAccountsToBean account "+account.getId());
             loadListPermission.add(ConvertDomainBean.convertSocialAccountToBean(account));
         }
         return loadListPermission;

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

         log.debug("getSocialAccountStats "+socialAccount.getId());
         final DetachedCriteria criteria = DetachedCriteria.forClass(TweetPollSavedPublishedStatus.class);
         criteria.add(Restrictions.eq("socialAccount", socialAccount));
-        criteria.setProjection(Projections.id());
+        criteria.setProjection(Projections.rowCount());
         final List<Long> tweetPollstats = getHibernateTemplate().findByCriteria(criteria);
         log.debug("getSocialAccountStats "+tweetPollstats.size());
         log.debug("getSocialAccountStats "+tweetPollstats);

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

     public void testgetSocialAccountStats() {
         createTweetPollPublicated(true, true, null, userAccount, createQuestion("test", this.userAccount.getAccount()));
         createTweetPollSavedPublishedSTatus(tweetPoll, "12345", this.socialAccount, "hello encuestame");
+        createTweetPollSavedPublishedSTatus(tweetPoll, "12346", this.socialAccount, "hello encuestame 1");
+        createTweetPollSavedPublishedSTatus(tweetPoll, "12347", this.socialAccount, "hello encuestame 2");
+        createTweetPollSavedPublishedSTatus(tweetPoll, "12348", this.socialAccount, "hello encuestame 3");
         final HashMap<String, Long> d = getAccountDao().getSocialAccountStats(this.socialAccount);
+        System.out.println(d);
     }
 
     /**

File encuestame-utils/src/main/java/org/encuestame/utils/json/GlobalStats.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.utils.json;
-
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/**
- * Global stats..
- * @author Picado, Juan juanATencuestame.org
- * @since 28/07/2011
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-public abstract class GlobalStats {
-
-    @JsonProperty(value = "tweetpoll")
-    private Long tweetpoll;
-    @JsonProperty(value = "poll")
-    private Long poll;
-    @JsonProperty(value = "survey")
-    private Long survey;
-    /**
-     * @return the tweetpoll
-     */
-    @JsonIgnore
-    public Long getTweetpoll() {
-        return tweetpoll;
-    }
-    /**
-     * @param tweetpoll the tweetpoll to set
-     */
-    public void setTweetpoll(final Long tweetpoll) {
-        this.tweetpoll = tweetpoll;
-    }
-    /**
-     * @return the poll
-     */
-    @JsonIgnore
-    public Long getPoll() {
-        return poll;
-    }
-    /**
-     * @param poll the poll to set
-     */
-    public void setPoll(final Long poll) {
-        this.poll = poll;
-    }
-    /**
-     * @return the survey
-     */
-    @JsonIgnore
-    public Long getSurvey() {
-        return survey;
-    }
-    /**
-     * @param survey the survey to set
-     */
-    public void setSurvey(final Long survey) {
-        this.survey = survey;
-    }
-}

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

  */
 
 @JsonIgnoreProperties(ignoreUnknown = true)
-public class SocialAccountBean extends GlobalStats implements Serializable {
+public class SocialAccountBean implements Serializable {
 
     /**
      * Serial.
     private String socialProfileUrl;
 
     /**
+    *
+    */
+   @JsonProperty(value = "tweetpoll_stats")
+   private Long tweetpoll;
+   /**
+    *
+    */
+   @JsonProperty(value = "poll_stats")
+   private Long poll;
+   /**
+    *
+    */
+   @JsonProperty(value = "survey_stats")
+   private Long survey;
+
+    /**
      * Constructor.
      */
     public SocialAccountBean() {
         this.socialProfileUrl = socialProfileUrl;
     }
 
+    /**
+     * @return the tweetpoll
+     */
+    @JsonIgnore
+    public Long getTweetpoll() {
+        return tweetpoll;
+    }
+    /**
+     * @param tweetpoll the tweetpoll to set
+     */
+    public void setTweetpoll(final Long tweetpoll) {
+        this.tweetpoll = tweetpoll;
+    }
+    /**
+     * @return the poll
+     */
+    @JsonIgnore
+    public Long getPoll() {
+        return poll;
+    }
+    /**
+     * @param poll the poll to set
+     */
+    public void setPoll(final Long poll) {
+        this.poll = poll;
+    }
+    /**
+     * @return the survey
+     */
+    @JsonIgnore
+    public Long getSurvey() {
+        return survey;
+    }
+    /**
+     * @param survey the survey to set
+     */
+    public void setSurvey(final Long survey) {
+        this.survey = survey;
+    }
 
     /* (non-Javadoc)
      * @see java.lang.Object#toString()
      */
     @Override
     public String toString() {
-        return "SocialAccountBean [accountId=" + accountId + ", account="
-                + account + ", type=" + type + ", typeAccount=" + typeAccount
-                + ", descriptionProfile=" + descriptionProfile + ", email="
-                + email + ", defaultSelected=" + defaultSelected
-                + ", addedAccount=" + addedAccount + ", prictureUrl="
-                + prictureUrl + ", profilePictureUrl=" + profilePictureUrl
-                + ", profileThumbnailPictureUrl=" + profileThumbnailPictureUrl
-                + ", realName=" + realName + ", socialAccountName="
-                + socialAccountName + ", socialProfileUrl=" + socialProfileUrl
-                + "]";
+        return "SocialAccountBean [accountId=" + accountId + ", type=" + type
+                + ", typeAccount=" + typeAccount + ", email=" + email
+                + ", defaultSelected=" + defaultSelected
+                + ", socialAccountName=" + socialAccountName
+                + ", getTweetpoll()=" + tweetpoll + ", getPoll()="
+                + poll + ", getSurvey()=" + survey + "]";
     }
 }

File encuestame-war/pom.xml

                             </classpath>
                             <jvmarg value="-Xmx512M"/>
                             <arg value="build.js"/>
-                            <arg value="version=1.6.0"/>
+                            <arg value="version=1.6.1"/>
                             <arg value="profileFile=${basedir}/src/main/webapp/resource/js/encuestame.profile.js"/>
                             <arg value="action=clean,release"/>
                             <arg value="releaseDir=${project.build.directory}/dojo-compiled"/>

File encuestame-war/src/main/webapp/resource/js/encuestame/org/core/commons/social/SocialAccounts.js

 
             postCreate : function(){
               console.debug("account", this.account);
+              if (this._removeButton) {
+                  if (this.account.tweetpoll_stats > 0 || this.account.poll_stats > 0 || this.account.survey_stats > 0) {
+                      console.debug("remove this button ", this._removeButton);
+                      dojo.destroy(this._removeButton.domNode);
+                  } else {
+                      console.debug("add this button ", this._removeButton);
+                      dojo.connect(this._removeButton, "onClick", dojo.hitch(this, "_remove"));
+                  }
+              }
               dojo.subscribe("/encuestame/social/account/row/show", this, function(widget){
                   if (this.id != widget.id) {
                       this._secrets = true;

File encuestame-war/src/main/webapp/resource/js/encuestame/org/core/commons/social/templates/socialAccountRow.html

                         <td>
                             <a href="${account.url}" target="_blank">${account.url}</a>
                         </td>
+                     </tr>published with this account
+                     <tr>
+                        <td>
+                            <div><label>Tweetpoll published with this account:</label> ${account.tweetpoll_stats}</div>
+                            <div><label>Survey published with this account:</label> ${account.survey_stats}</div>
+                            <div><label>Poll published with this account:</label> ${account.poll_stats}</div>
+                        </td>
                      </tr>
                </table>
                <div class="option-button">
-                   <button id="${id}_remove" dojoType="dijit.form.Button" type="button" dojoAttachEvent="onClick:_remove">
+                   <button id="${id}_remove" dojoType="dijit.form.Button" type="button" dojoAttachPoint="_removeButton">
                             Remove
                    </button>
-                   <button id="${id}_statusAccount" dojoType="dijit.form.Button" type="button" dojoAttachEvent="onClick:_changeStatusAccount">
+<!--                    <button id="${id}_statusAccount" dojoType="dijit.form.Button" type="button" dojoAttachEvent="onClick:_changeStatusAccount">
                             Disable
-                   </button>
+                   </button> -->
                    <button id="${id}_default" dojoType="dijit.form.Button" type="button" dojoAttachEvent="onClick:_changeStatusAccount">
                             Set as Default
                    </button>