Update of 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person
In directory 
james.mmbase.org:/tmp/cvs-serv12548/community/src/java/com/finalist/cmsc/services/community/person

Modified Files:
      Tag: b1_4
        PersonHibernateService.java PersonService.java Person.java 
Log Message:
CMSC-830 - Add Send Password functionality and improve Community source code, 
not fully ready, but big steps are made.


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person
See also: http://www.mmbase.org/jira/browse/CMSC-830


Index: PersonHibernateService.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person/PersonHibernateService.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -b -r1.2.2.1 -r1.2.2.2
--- PersonHibernateService.java 25 Feb 2008 16:26:17 -0000      1.2.2.1
+++ PersonHibernateService.java 21 Mar 2008 16:46:29 -0000      1.2.2.2
@@ -9,11 +9,14 @@
  */
 package com.finalist.cmsc.services.community.person;
 
+import java.util.Collections;
 import java.util.List;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.Criteria;
+import org.hibernate.criterion.Example;
 import org.hibernate.criterion.Restrictions;
 import org.springframework.beans.factory.annotation.Required;
 import org.springframework.transaction.annotation.Transactional;
@@ -33,40 +36,79 @@
        /** [EMAIL PROTECTED] */
        @Transactional(readOnly = true)
        public Person getPersonByUserId(String userId) {
+               if (StringUtils.isBlank(userId)) { 
+                       throw new IllegalArgumentException("UserId is not 
filled in. "); 
+               }
                return findPersonByUserId(userId);
        }
 
        /** [EMAIL PROTECTED] */
        @Transactional
-       public void createPerson(String firstName, String infix, String 
lastName, String userId) {
-               Long authenticationId = 
authenticationService.getAuthenticationIdForUserId(userId);
+       @SuppressWarnings("unchecked")
+       public List<Person> getPerson(Person person){
+               if (person == null) 
+                       return Collections.emptyList();
+               
+               List personList = getSession()
+                       .createCriteria(Person.class)
+                       .add(Example.create(person))
+                       .list();
+               return personList;
+
+       }
+
+       /** [EMAIL PROTECTED] */
+       @Transactional
+       public Person createPerson(String firstName, String infix, String 
lastName, Long authenticationId) {
+               if (firstName == null) { 
+                       throw new IllegalArgumentException("Firstname is null. 
"); 
+               }
+               if (lastName == null) { 
+                       throw new IllegalArgumentException("Lastname is null. 
"); 
+               }
+               if (authenticationId == null) { 
+                       throw new IllegalArgumentException("authenticationId is 
not filled in. "); 
+               }
+
                if (authenticationId != null) {
                        Person person = new Person();
                        person.setFirstName(firstName);
                        person.setInfix(infix);
                        person.setLastName(lastName);
-                       person.setAuthenticationId(authenticationId);
+                       person.setAuthenticationId(authenticationId); //used to 
find account
                        getSession().save(person);
+                       return person;
                }
+               return null;
        }
 
        /** [EMAIL PROTECTED] */
        @Transactional
-       public void deletePersonByUserId(String userId) {
-               if (userId != null) {
+   public void updatePerson(Person person) {
+      getSession().saveOrUpdate(person);
+   }
+
+
+       /** [EMAIL PROTECTED] */
+       @Transactional
+       public boolean deletePersonByUserId(String userId) {
+               if (!StringUtils.isBlank(userId)) {
                        Person person = findPersonByUserId(userId);
                        if (person != null) {
                                getSession().delete(person);
+                               return true;
                        }
                }
+               return false;
        }
 
        private Person findPersonByUserId(String userId) {
                Long authenticationId = 
authenticationService.getAuthenticationIdForUserId(userId);
                Person person = null;
                if (authenticationId != null) {
-                       Criteria criteria = 
getSession().createCriteria(Person.class).add(
-                                       Restrictions.eq("authenticationId", 
authenticationId));
+                       Criteria criteria = getSession()
+                                                                       
.createCriteria(Person.class)
+                                                                       
.add(Restrictions.eq("authenticationId", authenticationId));
                        person = findPersonByCriteria(criteria);
                }
                return person;
@@ -82,4 +124,5 @@
        public void setAuthenticationService(AuthenticationService 
authenticationService) {
                this.authenticationService = authenticationService;
        }
+
 }


Index: PersonService.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person/PersonService.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -b -r1.2 -r1.2.2.1
--- PersonService.java  29 Jan 2008 09:59:40 -0000      1.2
+++ PersonService.java  21 Mar 2008 16:46:29 -0000      1.2.2.1
@@ -9,6 +9,8 @@
 */
 package com.finalist.cmsc.services.community.person;
 
+import java.util.List;
+
 /**
  * This service encapsulates the management of people and groups.
  * 
@@ -23,8 +25,14 @@
 
     Person getPersonByUserId(String userId);
     
-    void createPerson(String firstName, String infix, String lastName, String 
userId);
+    List<Person> getPerson(Person person);
+    
+    Person createPerson(String firstName, String infix, String lastName, Long 
authenticationId);
+    
+    /* Save or update the person to the database
+     */
+    void updatePerson(Person person);
 
-    void deletePersonByUserId(String userId);
+    boolean deletePersonByUserId(String userId);
 
 }


Index: Person.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person/Person.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -b -r1.2 -r1.2.2.1
--- Person.java 29 Jan 2008 09:59:40 -0000      1.2
+++ Person.java 21 Mar 2008 16:46:29 -0000      1.2.2.1
@@ -25,7 +25,7 @@
     @GeneratedValue
     private Long id;
 
-    private Long authenticationId; // his/her credentials (usually an e-mail 
adress and password)
+   private Long authenticationId; // his/her credentials (usually an e-mail 
address and password)
 
     private String firstName;
     private String lastName;
@@ -121,6 +121,4 @@
                return true;
        }
        
-       
-
 }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to