Juan Carlos Picado Herrera avatar Juan Carlos Picado Herrera committed d1f331f Merge

Merge branch 'development' into dianmorales

Comments (0)

Files changed (9)

encuestame-business/src/main/resources/org/encuestame/business/sqlscripts/postgres/install/demo.sql

 (1, 'nFboU4T1Zhv8cqMC4cP0ug', 'GwOPUEJEaCbNBiBzq6J8StDhb7FOmwDcjfX6zMe0', 'testEncuesta', 'testEncuesta123', 4189783);
 
 --- User Account
------- username: demo
+------ username: admin
 ------ password: 12345
-INSERT INTO userAccount (uid, name, date_new, invite_code, password, email, status, twitter, username, account_uid, last_ip_logged, last_time_logged) VALUES
-(1, 'Demo User', '2010-01-20 12:47:40', '', '6xAX8siGWDJXfkJUVxWLqsk0rz8U+aG6Y8yA1IokxuhEIZ8+RugleJtLUYbdGxc+', 'demo@demo.com', '', NULL, 'demo', 1, NULL, '2010-09-26 10:07:25');
-
+INSERT INTO useraccount (
+uid,
+name,
+date_new,
+invite_code,
+last_ip_logged,
+last_time_logged,
+password,
+email,
+userprofilepicture,
+status,
+twitter,
+username,
+account_uid,
+groupid)
+VALUES
+(1,
+'Demo User',
+'2010-01-20 12:47:40',
+'',
+NULL,
+'2011-03-22 15:51:08.389',
+'6xAX8siGWDJXfkJUVxWLqsk0rz8U+aG6Y8yA1IokxuhEIZ8+RugleJtLUYbdGxc+',
+'demo@demo.org',
+NULL,
+true,
+NULL,
+'admin',
+1,
+NULL);
 -- Default Permissions
+
 INSERT INTO userAccount_permission (sec_id_secondary, sec_id_permission) VALUES
 (1, 1),
 (1, 2),

encuestame-core/src/main/java/org/encuestame/core/security/EnMeUserServiceImp.java

      * @param username
      *            username return {@link UserDetails}
      */
-    public UserDetails loadUserByUsername(final String username)
-            throws UsernameNotFoundException, DataAccessException {
-        //log.debug("username "+username);
+    public UserDetails loadUserByUsername(final String username){
+        log.debug("loggin with username: {"+username+"}");
+        log.debug("loggin with user dao instance: {"+this.accountDao+"}");
         final UserAccount user = this.accountDao.getUserByUsername(username);
+        log.debug("fetch username: {"+user+"}");
         if (user == null) {
-            //log.error("user not found");
+            log.error("user not found");
             throw new UsernameNotFoundException("user not found");
         } else {
+            log.debug("Loggin with username: {"+user.getUsername()+" id: "+user.getUid()+"}");
             this.updateLoggedInfo(user);
             return SecurityUtils.convertUserAccount(user, this.roleUserAuth);
         }
     private void updateLoggedInfo(final UserAccount secUserSecondary){
         final Calendar calendar = Calendar.getInstance();
         secUserSecondary.setLastTimeLogged(calendar.getTime());
-        //log.debug("Updating logged time "+calendar.getTime());
+        log.debug("Updating logged time: "+calendar.getTime());
         accountDao.saveOrUpdate(secUserSecondary);
     }
 }

encuestame-core/src/main/java/org/encuestame/core/security/SecurityUtils.java

         // sec permissions
         if (roleUserAuth) {
             authorities.addAll(ConvertDomainsToSecurityContext.convertEnMePermission(user.getSecUserPermissions()));
+            log.debug("EnMeUserDetails: Authorities size :"+authorities.size());
         }
 
          //creating user details
          );
          userDetails.setAccountNonExpired(true);
          userDetails.setAccountNonLocked(true);
-         //log.debug("user details "+userDetails.getPassword());
-         //log.debug("user details "+userDetails.getPassword());
-         //log.debug("user details "+userDetails.getAuthorities());
-         //log.debug("user details "+userDetails.getUserEmail());
+         log.debug("EnMeUserDetails : user password "+userDetails.getPassword());
+         log.debug("EnMeUserDetails : user authorities "+userDetails.getAuthorities());
+         log.debug("EnMeUserDetails : user email "+userDetails.getUserEmail());
          return userDetails;
     }
 

encuestame-persistence/pom.xml

              <groupId>joda-time</groupId>
              <artifactId>joda-time</artifactId>
          </dependency>
+        <dependency>
+          <groupId>commons-dbcp</groupId>
+          <artifactId>commons-dbcp</artifactId>
+        </dependency>
     </dependencies>
 </project>

encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/AccountDaoImp.java

            setSessionFactory(sessionFactory);
     }
 
-   /**
-     * Find All Users.
-     * @return list of all users
-     * @throws HibernateException hibernate
-     */
+   /*
+    * (non-Javadoc)
+    * @see org.encuestame.persistence.dao.IAccountDao#findAll()
+    */
     public List<UserAccount> findAll() throws HibernateException {
         return getHibernateTemplate().find("from UserAccount");
     }
 
-    /**
-     * Retrieve List of Secondary users without owner account.
-     * @param secUsers {@link Account}.
-     * @return List of {@link UserAccount}
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#retrieveListOwnerUsers(org.encuestame.persistence.domain.security.Account, java.lang.Integer, java.lang.Integer)
      */
     public List<UserAccount> retrieveListOwnerUsers(final Account account,
                final Integer maxResults, final Integer start){
         return getHibernateTemplate().findByCriteria(criteria, start, maxResults);
     }
 
-    /**
-     * Retrieve Total Users.
-     * @param secUsers
-     * @return
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#retrieveTotalUsers(org.encuestame.persistence.domain.security.Account)
      */
     public Long retrieveTotalUsers(final Account account){
          Long resultsSize = 0L;
          return resultsSize;
      }
 
-    /**
-     * Get User By Id.
-     *
-     * @param userId userId
-     * @return SecUserSecondary
-     * @throws HibernateException hibernate exception
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getUserAccountById(java.lang.Long)
      */
     public UserAccount getUserAccountById(final Long userId){
             return (UserAccount) (getHibernateTemplate().get(UserAccount.class, userId));
     }
 
-    /**
-     * Get Twitter Account.
-     * @param twitterAccountId
-     * @return
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getTwitterAccount(java.lang.Long)
      */
     public SocialAccount getTwitterAccount(final Long twitterAccountId){
         return (SocialAccount) (getHibernateTemplate().get(SocialAccount.class, twitterAccountId));
     }
 
-    /**
-     * Get Social Account.
-     * @param socialProvider
-     * @param socialAccountId
-     * @return
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getSocialAccount(org.encuestame.persistence.domain.social.SocialProvider, java.lang.Long)
      */
     public SocialAccount getSocialAccount(final SocialProvider socialProvider, final Long socialAccountId){
         final DetachedCriteria criteria = DetachedCriteria.forClass(SocialAccount.class);
         return (SocialAccount) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
     }
 
-    /**
-     * Get Social Account.
-     * @param socialAccountId
-     * @param account
-     * @return
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getSocialAccount(java.lang.Long, org.encuestame.persistence.domain.security.Account)
      */
     public SocialAccount getSocialAccount(final Long socialAccountId, final Account account){
         log.debug("account "+account.getUid());
         return (SocialAccount) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
     }
 
-    /**
-     * Get Primary User By Id.
-     * @param userId user id
-     * @return {@link Account}
-     * @throws HibernateException exception
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getUserById(java.lang.Long)
      */
     public Account getUserById(final Long userId) throws HibernateException {
             return (Account) getHibernateTemplate().get(Account.class, userId);
     }
 
-    /**
-     * Get one user by username.
-     * @param username username
-     * @return list of users
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getUserByUsername(java.lang.String)
      */
     public UserAccount getUserByUsername(final String username)throws HibernateException {
-            final DetachedCriteria criteria = DetachedCriteria.forClass(UserAccount.class);
-            criteria.add(Restrictions.eq("username", username) );
-            return (UserAccount) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
+        final DetachedCriteria criteria = DetachedCriteria.forClass(UserAccount.class);
+        criteria.add(Restrictions.eq("username", username));
+        final UserAccount userAccount = (UserAccount) DataAccessUtils
+                .uniqueResult(getHibernateTemplate().findByCriteria(criteria));
+        log.debug("getUserByUsername: "+userAccount);
+        return userAccount;
     }
 
-    /**
-     * Get one user by email.
-     * @param email
-     * @return
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getUserByEmail(java.lang.String)
      */
     public UserAccount getUserByEmail(final String email){
         final DetachedCriteria criteria = DetachedCriteria.forClass(UserAccount.class);
                 .findByCriteria(criteria));
     }
 
-    /**
-     * Get list of users by username.
-     * @param username username
-     * @return list of users
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getUsersByUsername(java.lang.String)
      */
     public List<UserAccount> getUsersByUsername(final String username) {
             final DetachedCriteria criteria = DetachedCriteria.forClass(UserAccount.class);
             return   getHibernateTemplate().findByCriteria(criteria);
     }
 
-    /**
-     * Get Twitter Accounts.
-     * @param secUsers {@link Account}.
-     * @param provider
-     * @return List {@link SocialAccount}.
-     *
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getTwitterAccountByUser(org.encuestame.persistence.domain.security.Account, org.encuestame.persistence.domain.social.SocialProvider)
      */
     public List<SocialAccount> getTwitterAccountByUser(
             final Account secUsers,
         return   getHibernateTemplate().findByCriteria(criteria);
     }
 
-    /**
-     * Get Twitter Verified Accounts.
-     * @param secUsers {@link AccountDaoImp}
-     * @param provider
-     * @return List {@link SocialAccount}.
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getTwitterVerifiedAccountByUser(org.encuestame.persistence.domain.security.Account, org.encuestame.persistence.domain.social.SocialProvider)
      */
     public List<SocialAccount> getTwitterVerifiedAccountByUser(
             final Account secUsers,
         return getHibernateTemplate().findByCriteria(criteria);
     }
 
-    /**
-     * Search user by email
-     * @param email email
-     * @return
-     */
+   /*
+    * (non-Javadoc)
+    * @see org.encuestame.persistence.dao.IAccountDao#searchUsersByEmail(java.lang.String)
+    */
     public List<UserAccount> searchUsersByEmail(final String email){
         final DetachedCriteria criteria = DetachedCriteria.forClass(UserAccount.class);
         criteria.add(Restrictions.like("userEmail", email) );
     }
 
 
-    /**
-     * Get {@link UserAccount} but {@link Account} id.
-     * @param userId user id
-     * @return secondary user list
+    /*
+     * (non-Javadoc)
+     * @see org.encuestame.persistence.dao.IAccountDao#getSecondaryUsersByUserId(java.lang.Long)
      */
     public List<UserAccount> getSecondaryUsersByUserId(final Long userId){
             return getHibernateTemplate().findByNamedParam("from UserAccount"

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

        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
+     <bean id="jdbcDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+        <property name="driverClassName" value="${datasource.classname}"/>
+        <property name="url" value="${datasource.urldb}"/>
+        <property name="username" value="${datasource.userbd}"/>
+        <property name="password" value="${datasource.pass}"/>
+    </bean>
+
+    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
+        <property name="dataSource" ref="jdbcDataSource"/>
+    </bean>
+
     <bean id="dataSource"
         class="org.springframework.jdbc.datasource.DriverManagerDataSource">
         <property name="driverClassName" value="${datasource.classname}" />

encuestame-war/pom.xml

                  <systemProperties>
                       <systemProperty>
                          <name>encuestame.custom.config</name>
-                         <value>${project.basedir}/src/main/resources/encuestame-config-custom.properties</value>
+                         <value>${encuestame.local.properties}</value>
                      </systemProperty>
                   </systemProperties>
                     <connectors>

encuestame-war/src/main/resources/encuestame-config-custom.properties

-# Custom Database configuration settings
-datasource.userbd = postgres
-datasource.pass= postgres
-datasource.classname = org.postgresql.Driver
-datasource.dialect = org.hibernate.dialect.PostgreSQLDialect
-datasource.showsql=false
-datasource.database = postgres
-datasource.delimited =
-datasource.hbm2ddl.auto = none
-datasource.urldb = jdbc:postgresql://localhost/test2
                 </property>
             </activation>
             <properties>
+		<encuestame.local.properties>${user.home}/encuestame-config-custom.properties</encuestame.local.properties>
                 <encuestame.logs.path>logs</encuestame.logs.path>
                 <surefire.failures.ignore>true</surefire.failures.ignore>
                 <app.proxypass>false</app.proxypass>
                 </property>
             </activation>
             <properties>
+ 		<encuestame.local.properties>${user.home}/encuestame-config-custom.properties</encuestame.local.properties>	        
                 <encuestame.logs.path>logs</encuestame.logs.path>
                 <surefire.failures.ignore>false</surefire.failures.ignore>
                 <app.proxypass>true</app.proxypass>
                 </property>
             </activation>
             <properties>
+		<encuestame.local.properties>${user.home}/encuestame-config-custom.properties</encuestame.local.properties>
                 <encuestame.logs.path>logs</encuestame.logs.path>
                 <surefire.failures.ignore>true</surefire.failures.ignore>
                 <app.proxypass>false</app.proxypass>
         </profile>
     </profiles>
     <activeProfiles>
-        <activeProfile>default</activeProfile>
+        <activeProfile>postgres</activeProfile>
     </activeProfiles>
 </profilesXml>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.