Update of
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/person
In directory
james.mmbase.org:/tmp/cvs-serv1498/src/java/com/finalist/cmsc/services/community/person
Modified Files:
PersonHibernateService.java PersonService.java
Log Message:
CMSC-1265 Community: improve import and export options of community users
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-1265
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.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- PersonHibernateService.java 23 Feb 2009 09:11:50 -0000 1.26
+++ PersonHibernateService.java 3 Mar 2009 06:23:55 -0000 1.27
@@ -502,4 +502,68 @@
criteria = criteria.setResultTransformer(criteria.DISTINCT_ROOT_ENTITY);
return criteria.list();
}
+ @Transactional
+ public void ImportDataFromFileRecord(String level,
+ PersonExportImportVO importPerson) {
+ Person p =
getPersonByUserId(importPerson.getAuthentication().getUserId());
+ if ("over".equals(level)) {
+ if(p != null) {
+
authenticationService.updateAuthenticationPassword(importPerson.getAuthentication().getUserId(),
importPerson.getAuthentication().getPassword());
+ p.setEmail(importPerson.getEmail());
+ p.setActive(importPerson.getActive());
+ updatePerson(p);
+ }
+ else {
+ Authentication authentication =
authenticationService.createAuthentication(importPerson.getAuthentication());
+ if (authentication.getId() != null) {
+ if(importPerson.getAuthorityId()>0 ){
+ Authority authority =
this.getAuthorityById(importPerson.getAuthorityId());
+ if (null!=authentication.getAuthorities()) {
+ authentication.getAuthorities().add(authority);
+ }
+ }
+ addPerson(importPerson, authentication);
+ }
+ }
+ }
+ else{
+ // add new users or put user to another group
+ createNewPerson(importPerson);
+ }
+
+ }
+ @Transactional
+ private void addPerson(PersonExportImportVO importPerson,
+ Authentication authentication) {
+ Person person = new Person();
+ person.setEmail(importPerson.getEmail());
+ person.setActive(importPerson.getActive());
+ person.setAuthenticationId(authentication.getId());
+ getSession().saveOrUpdate(authentication);
+ updatePerson(person);
+ }
+ @Transactional(propagation = Propagation.REQUIRED)
+ private void createNewPerson(PersonExportImportVO xperson) {
+
+ Authentication authentication = xperson.getAuthentication();
+
if(authenticationService.authenticationExists(authentication.getUserId()) &&
xperson.getAuthorityId()>0 ){
+ Authority authority = this.getAuthorityById(xperson.getAuthorityId());
+ if(null!=authority){
+ authentication =
authenticationService.getAuthenticationById(authenticationService.getAuthenticationIdForUserId(authentication.getUserId()));
+ authentication.getAuthorities().add(authority);
+ getSession().saveOrUpdate(authentication);
+ }
+ }
+ else
if(!authenticationService.authenticationExists(authentication.getUserId())){
+ authentication =
authenticationService.createAuthentication(authentication);
+ if(xperson.getAuthorityId()>0 ){
+ Authority authority =
this.getAuthorityById(xperson.getAuthorityId());
+ if (null!=authentication.getAuthorities()) {
+ authentication.getAuthorities().add(authority);
+ }
+ }
+ addPerson(xperson, authentication);
+ }
+
+ }
}
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.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- PersonService.java 23 Feb 2009 09:11:50 -0000 1.19
+++ PersonService.java 3 Mar 2009 06:23:55 -0000 1.20
@@ -88,4 +88,6 @@
public List<PersonExportImportVO> getPersonExportImportVO(String group);
public List<Authority> getAllAuthorities();
+
+ public void ImportDataFromFileRecord(String level, PersonExportImportVO
importPerson);
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs