Author: thomas.heute(a)jboss.com
Date: 2010-05-06 11:59:04 -0400 (Thu, 06 May 2010)
New Revision: 3000
Modified:
portal/branches/EPP_5_0_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java
portal/branches/EPP_5_0_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
Log:
JBEPP-338: OrganizationService failed to start when EPP5 is executed with different value
of LANG environment variable
Modified:
portal/branches/EPP_5_0_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java
===================================================================
---
portal/branches/EPP_5_0_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java 2010-05-06
15:56:13 UTC (rev 2999)
+++
portal/branches/EPP_5_0_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java 2010-05-06
15:59:04 UTC (rev 3000)
@@ -22,10 +22,13 @@
import org.exoplatform.services.organization.MembershipType;
import org.exoplatform.services.organization.MembershipTypeHandler;
import org.exoplatform.services.organization.impl.MembershipTypeImpl;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.RoleType;
import java.text.DateFormat;
+import java.text.ParseException;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -52,6 +55,8 @@
private PicketLinkIDMService service_;
private PicketLinkIDMOrganizationServiceImpl orgService;
+
+ private static Logger log = LoggerFactory.getLogger(MembershipTypeDAOImpl.class);
public MembershipTypeDAOImpl(PicketLinkIDMOrganizationServiceImpl orgService,
PicketLinkIDMService service)
{
@@ -142,9 +147,9 @@
Map<String, String> props = new HashMap<String, String>();
props.put(MEMBERSHIP_DESCRIPTION, mt.getDescription());
- props.put(MEMBERSHIP_CREATE_DATE, mt.getCreatedDate() == null ? null :
dateFormat.format(mt.getCreatedDate()));
+ props.put(MEMBERSHIP_CREATE_DATE, mt.getCreatedDate() == null ? null : ""
+ mt.getCreatedDate().getTime());
props
- .put(MEMBERSHIP_MODIFIED_DATE, mt.getModifiedDate() == null ? null :
dateFormat.format(mt.getModifiedDate()));
+ .put(MEMBERSHIP_MODIFIED_DATE, mt.getModifiedDate() == null ? null :
"" + mt.getModifiedDate().getTime());
props.put(MEMBERSHIP_OWNER, mt.getOwner());
getIdentitySession().getRoleManager().setProperties(rt, props);
@@ -167,12 +172,44 @@
if (cd != null)
{
- mt.setCreatedDate(dateFormat.parse(cd));
+ try
+ {
+ long date = Long.parseLong(cd);
+ mt.setCreatedDate(new Date(date));
+ }
+ catch (NumberFormatException e)
+ {
+ try
+ {
+ // For backward compatibility with GateIn 3.0 and EPP 5 Beta
+ mt.setCreatedDate(dateFormat.parse(cd));
+ }
+ catch (ParseException e2)
+ {
+ log.error("Cannot parse the membership type creation date for: "
+ mt.getName());
+ }
+ }
}
if (md != null)
{
- mt.setModifiedDate(dateFormat.parse(md));
+ try
+ {
+ long date = Long.parseLong(md);
+ mt.setModifiedDate(new Date(date));
+ }
+ catch (NumberFormatException e)
+ {
+ // For backward compatibility with GateIn 3.0 and EPP 5 Beta
+ try
+ {
+ mt.setModifiedDate(dateFormat.parse(md));
+ }
+ catch (ParseException e2)
+ {
+ log.error("Cannot parse the membership type modification date for:
" + mt.getName());
+ }
+ }
}
return;
Modified:
portal/branches/EPP_5_0_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
===================================================================
---
portal/branches/EPP_5_0_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2010-05-06
15:56:13 UTC (rev 2999)
+++
portal/branches/EPP_5_0_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2010-05-06
15:59:04 UTC (rev 3000)
@@ -28,30 +28,32 @@
import org.exoplatform.services.organization.UserEventListener;
import org.exoplatform.services.organization.UserHandler;
import org.exoplatform.services.organization.impl.UserImpl;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.Attribute;
import org.picketlink.idm.api.AttributesManager;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.query.UserQueryBuilder;
import org.picketlink.idm.common.exception.IdentityException;
import org.picketlink.idm.impl.api.SimpleAttribute;
-import org.slf4j.LoggerFactory;
import java.text.DateFormat;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
+import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Logger;
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
*/
public class UserDAOImpl implements UserHandler
{
- private static org.slf4j.Logger log = LoggerFactory.getLogger(UserDAOImpl.class);
+ private static Logger log = LoggerFactory.getLogger(UserDAOImpl.class);
private final PicketLinkIDMService service_;
@@ -76,7 +78,7 @@
public static final DateFormat dateFormat = DateFormat.getInstance();
private PicketLinkIDMOrganizationServiceImpl orgService;
-
+
static
{
Set<String> keys = new HashSet<String>();
@@ -412,11 +414,11 @@
if (user.getCreatedDate() != null)
{
- attributes.add(new SimpleAttribute(USER_CREATED_DATE,
dateFormat.format(user.getCreatedDate())));
+ attributes.add(new SimpleAttribute(USER_CREATED_DATE, "" +
user.getCreatedDate().getTime()));
}
if (user.getLastLoginTime() != null)
{
- attributes.add(new SimpleAttribute(USER_LAST_LOGIN_TIME,
dateFormat.format(user.getLastLoginTime())));
+ attributes.add(new SimpleAttribute(USER_LAST_LOGIN_TIME, "" +
user.getLastLoginTime().getTime()));
}
if (user.getEmail() != null)
{
@@ -522,7 +524,23 @@
{
if (attrs.containsKey(USER_CREATED_DATE))
{
-
user.setCreatedDate(dateFormat.parse(attrs.get(USER_CREATED_DATE).getValue().toString()));
+ try
+ {
+ long date =
Long.parseLong(attrs.get(USER_CREATED_DATE).getValue().toString());
+ user.setCreatedDate(new Date(date));
+ }
+ catch (NumberFormatException e)
+ {
+ // For backward compatibility with GateIn 3.0 and EPP 5 Beta
+ try
+ {
+
user.setCreatedDate(dateFormat.parse(attrs.get(USER_CREATED_DATE).getValue().toString()));
+ }
+ catch (ParseException e2)
+ {
+ log.error("Cannot parse the creation date for: " +
user.getUserName());
+ }
+ }
}
if (attrs.containsKey(USER_EMAIL))
{
@@ -534,7 +552,23 @@
}
if (attrs.containsKey(USER_LAST_LOGIN_TIME))
{
-
user.setLastLoginTime(dateFormat.parse(attrs.get(USER_LAST_LOGIN_TIME).getValue().toString()));
+ try
+ {
+ long date =
Long.parseLong(attrs.get(USER_LAST_LOGIN_TIME).getValue().toString());
+ user.setLastLoginTime(new Date(date));
+ }
+ catch (NumberFormatException e)
+ {
+ // For backward compatibility with GateIn 3.0 and EPP 5 Beta
+ try
+ {
+
user.setLastLoginTime(dateFormat.parse(attrs.get(USER_LAST_LOGIN_TIME).getValue().toString()));
+ }
+ catch (ParseException e2)
+ {
+ log.error("Cannot parse the last login date for: " +
user.getUserName());
+ }
+ }
}
if (attrs.containsKey(USER_LAST_NAME))
{
Show replies by date