Author: mposolda
Date: 2012-06-26 10:25:04 -0400 (Tue, 26 Jun 2012)
New Revision: 8747
Added:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/AbstractDAOImpl.java
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserProfileDAOImpl.java
Log:
Bug 835580 - UserTransaction should be marked for rollback if IdentityException is thrown.
Added new abstract class for general operations like exception handling.
Added:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/AbstractDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/AbstractDAOImpl.java
(rev 0)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/AbstractDAOImpl.java 2012-06-26
14:25:04 UTC (rev 8747)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.idm;
+
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+/**
+ * Abstract superclass for other DAO classes
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+public class AbstractDAOImpl
+{
+ protected final PicketLinkIDMService service_;
+
+ protected final PicketLinkIDMOrganizationServiceImpl orgService;
+
+ protected final Logger log = LoggerFactory.getLogger(getClass());
+
+ public AbstractDAOImpl(PicketLinkIDMOrganizationServiceImpl orgService,
PicketLinkIDMService idmService)
+ {
+ service_ = idmService;
+ this.orgService = orgService;
+ }
+
+ public void handleException(String messageToLog, Exception e)
+ {
+ log.info(messageToLog, e);
+
+ // Mark JTA transaction to rollback-only if JTA setup is enabled
+ if (orgService.getConfiguration().isUseJTA())
+ {
+ try
+ {
+ UserTransaction tx = orgService.getUserTransaction();
+ if (tx.getStatus() == Status.STATUS_ACTIVE)
+ {
+ tx.setRollbackOnly();
+ }
+ }
+ catch (Exception tre)
+ {
+ log.warn("Unable to set Transaction status to be rollback only",
tre);
+ }
+ }
+ }
+}
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2012-06-26
14:22:40 UTC (rev 8746)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2012-06-26
14:25:04 UTC (rev 8747)
@@ -45,27 +45,20 @@
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
*/
-public class GroupDAOImpl implements GroupHandler
+public class GroupDAOImpl extends AbstractDAOImpl implements GroupHandler
{
- private static Logger log = LoggerFactory.getLogger(GroupDAOImpl.class);
-
public static final String GROUP_LABEL = "label";
public static final String GROUP_DESCRIPTION = "description";
- private PicketLinkIDMService service_;
-
private List<GroupEventListener> listeners_;
- private PicketLinkIDMOrganizationServiceImpl orgService;
-
private static final String CYCLIC_ID =
"org.gatein.portal.identity.LOOPED_GROUP_ID";
public GroupDAOImpl(PicketLinkIDMOrganizationServiceImpl orgService,
PicketLinkIDMService service)
{
- service_ = service;
- this.orgService = orgService;
+ super(orgService, service);
listeners_ = new ArrayList<GroupEventListener>();
}
@@ -149,7 +142,7 @@
}
catch (Exception e)
{
- log.info("Cannot obtain group: " + parentPLGroupName, e);
+ handleException("Cannot obtain group: " + parentPLGroupName, e);
}
@@ -186,7 +179,7 @@
}
catch (Exception e)
{
- log.info("Cannot associate groups: ", e);
+ handleException("Cannot associate groups: ", e);
}
if (broadcast)
@@ -257,7 +250,7 @@
}
catch (Exception e)
{
- log.info("Cannot obtain group: " + plGroupName + "; ", e);
+ handleException("Cannot obtain group: " + plGroupName + ";
", e);
}
if (jbidGroup == null)
@@ -304,7 +297,7 @@
}
catch (Exception e)
{
- log.info("Cannot clear group relationships: " + plGroupName + ";
", e);
+ handleException("Cannot clear group relationships: " + plGroupName +
"; ", e);
}
try
@@ -314,7 +307,7 @@
}
catch (Exception e)
{
- log.info("Cannot remove group: " + plGroupName + "; ", e);
+ handleException("Cannot remove group: " + plGroupName + ";
", e);
}
if (broadcast)
@@ -349,7 +342,7 @@
}
catch (Exception e)
{
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
Set<Group> exoGroups = new HashSet<Group>();
@@ -376,7 +369,7 @@
}
catch (Exception e)
{
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
for (org.picketlink.idm.api.Group group : groups)
@@ -484,7 +477,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
@@ -509,7 +502,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -529,7 +522,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
}
@@ -639,7 +632,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -690,7 +683,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -707,7 +700,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
}
@@ -799,7 +792,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
String gtnGroupName = getGtnGroupName(jbidGroup.getName());
@@ -924,7 +917,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
// Check if there is cross reference so we ended in a loop and break the process.
@@ -1044,7 +1037,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
if (jbidGroup == null)
@@ -1058,7 +1051,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
@@ -1089,7 +1082,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
@@ -1166,7 +1159,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
if (rootGroup == null)
@@ -1182,7 +1175,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2012-06-26
14:22:40 UTC (rev 8746)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2012-06-26
14:25:04 UTC (rev 8747)
@@ -48,21 +48,15 @@
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
*/
-public class MembershipDAOImpl implements MembershipHandler
+public class MembershipDAOImpl extends AbstractDAOImpl implements MembershipHandler
{
- private static Logger log = LoggerFactory.getLogger(MembershipDAOImpl.class);
- private PicketLinkIDMService service_;
-
private List listeners_;
- private PicketLinkIDMOrganizationServiceImpl orgService;
-
public MembershipDAOImpl(PicketLinkIDMOrganizationServiceImpl orgService,
PicketLinkIDMService service)
{
- service_ = service;
+ super(orgService, service);
listeners_ = new ListenerStack(5);
- this.orgService = orgService;
}
public void addMembershipEventListener(MembershipEventListener listener)
@@ -233,7 +227,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -257,7 +251,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
@@ -270,7 +264,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
@@ -315,7 +309,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -328,7 +322,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
if (!hasRole &&
@@ -352,7 +346,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
@@ -368,7 +362,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
@@ -407,7 +401,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -448,7 +442,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -464,7 +458,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
@@ -512,7 +506,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -531,7 +525,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -620,7 +614,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -647,7 +641,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -701,7 +695,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -742,7 +736,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -840,7 +834,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -872,7 +866,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -954,7 +948,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -979,7 +973,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java 2012-06-26
14:22:40 UTC (rev 8746)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java 2012-06-26
14:25:04 UTC (rev 8747)
@@ -42,7 +42,7 @@
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
*/
-public class MembershipTypeDAOImpl implements MembershipTypeHandler
+public class MembershipTypeDAOImpl extends AbstractDAOImpl implements
MembershipTypeHandler
{
public static final String MEMBERSHIP_DESCRIPTION = "description";
@@ -55,19 +55,12 @@
public static final DateFormat dateFormat = DateFormat.getInstance();
- private PicketLinkIDMService service_;
-
- private PicketLinkIDMOrganizationServiceImpl orgService;
-
- private static Logger log = LoggerFactory.getLogger(MembershipTypeDAOImpl.class);
-
private List listeners_;
public MembershipTypeDAOImpl(PicketLinkIDMOrganizationServiceImpl orgService,
PicketLinkIDMService service)
{
- service_ = service;
+ super(orgService, service);
listeners_ = new ListenerStack(5);
- this.orgService = orgService;
}
public void addMembershipTypeEventListener(MembershipTypeEventListener listener)
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java 2012-06-26
14:22:40 UTC (rev 8746)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java 2012-06-26
14:25:04 UTC (rev 8747)
@@ -282,7 +282,7 @@
// It's fine to reuse same instance of UserTransaction as UserTransaction is
singleton in JBoss and most other AS.
// And new InitialContext().lookup("java:comp/UserTransaction") is quite
expensive operation
- private UserTransaction getUserTransaction() throws Exception
+ protected UserTransaction getUserTransaction() throws Exception
{
if (userTransaction == null)
{
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2012-06-26
14:22:40 UTC (rev 8746)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2012-06-26
14:25:04 UTC (rev 8747)
@@ -50,12 +50,9 @@
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
*/
-public class UserDAOImpl implements UserHandler
+public class UserDAOImpl extends AbstractDAOImpl implements UserHandler
{
- private static Logger log = LoggerFactory.getLogger(UserDAOImpl.class);
- private final PicketLinkIDMService service_;
-
private List<UserEventListener> listeners_ = new
ArrayList<UserEventListener>(3);
public static final String USER_PASSWORD = "password";
@@ -77,8 +74,6 @@
public static final Set<String> USER_NON_PROFILE_KEYS;
public static final DateFormat dateFormat = DateFormat.getInstance();
-
- private PicketLinkIDMOrganizationServiceImpl orgService;
static
{
@@ -98,8 +93,7 @@
public UserDAOImpl(PicketLinkIDMOrganizationServiceImpl orgService,
PicketLinkIDMService idmService)
throws Exception
{
- service_ = idmService;
- this.orgService = orgService;
+ super(orgService, idmService);
}
final public List getUserEventListeners()
@@ -165,7 +159,7 @@
}
catch (IdentityException e)
{
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
@@ -241,7 +235,7 @@
}
catch (IdentityException e)
{
- log.info("Cannot obtain user: " + userName + "; ", e);
+ handleException("Cannot obtain user: " + userName + "; ",
e);
}
@@ -258,7 +252,7 @@
}
catch (Exception e)
{
- log.info("Cannot cleanup user relationships: " + userName + ";
", e);
+ handleException("Cannot cleanup user relationships: " + userName +
"; ", e);
}
@@ -275,7 +269,7 @@
}
catch (IdentityException e)
{
- log.info("Cannot remove user: " + userName + "; ", e);
+ handleException("Cannot remove user: " + userName + "; ",
e);
}
@@ -410,7 +404,7 @@
}
catch (Exception e)
{
- log.info("Cannot authenticate user: " + username + "; ",
e);
+ handleException("Cannot authenticate user: " + username + ";
", e);
}
}
@@ -616,7 +610,7 @@
}
catch (IdentityException e)
{
- log.info("Cannot find user by email: " + email + "; ", e );
+ handleException("Cannot find user by email: " + email + ";
", e );
}
@@ -666,7 +660,7 @@
}
catch (Exception e)
{
- log.info("Cannot obtain group: " + groupId + "; ", e);
+ handleException("Cannot obtain group: " + groupId + "; ",
e);
}
@@ -774,7 +768,7 @@
}
catch (IdentityException e)
{
- log.info("Cannot update password: " + user.getUserName() +
"; ", e);
+ handleException("Cannot update password: " + user.getUserName()
+ "; ", e);
}
}
@@ -789,7 +783,7 @@
}
catch (IdentityException e)
{
- log.info("Cannot update attributes for user: " + user.getUserName() +
"; ", e);
+ handleException("Cannot update attributes for user: " +
user.getUserName() + "; ", e);
}
@@ -807,7 +801,7 @@
}
catch (IdentityException e)
{
- log.info("Cannot obtain user: " + userName + "; ", e);
+ handleException("Cannot obtain user: " + userName + "; ",
e);
}
@@ -839,7 +833,7 @@
catch (IdentityException e)
{
- log.info("Cannot obtain attributes for user: " + user.getUserName() +
"; ", e);
+ handleException("Cannot obtain attributes for user: " +
user.getUserName() + "; ", e);
}
@@ -965,7 +959,7 @@
}
catch (IdentityException e)
{
- log.error("Cannot remove displayName attribute of user: " +
user.getUserName() + "; ", e);
+ handleException("Cannot remove displayName attribute of user: " +
user.getUserName() + "; ", e);
}
}
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserProfileDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserProfileDAOImpl.java 2012-06-26
14:22:40 UTC (rev 8746)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserProfileDAOImpl.java 2012-06-26
14:25:04 UTC (rev 8747)
@@ -43,25 +43,18 @@
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
*/
-public class UserProfileDAOImpl implements UserProfileHandler
+public class UserProfileDAOImpl extends AbstractDAOImpl implements UserProfileHandler
{
- private static Logger log = LoggerFactory.getLogger(UserProfileDAOImpl.class);
-
static private UserProfile NOT_FOUND = new UserProfileImpl();
- private PicketLinkIDMService service_;
-
private List<UserProfileEventListener> listeners_;
- private PicketLinkIDMOrganizationServiceImpl orgService;
-
public UserProfileDAOImpl(PicketLinkIDMOrganizationServiceImpl orgService,
PicketLinkIDMService service)
throws Exception
{
- service_ = service;
+ super(orgService, service);
listeners_ = new ArrayList<UserProfileEventListener>(3);
- this.orgService = orgService;
}
public void addUserProfileEventListener(UserProfileEventListener listener)
@@ -159,7 +152,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
if (foundUser == null)
@@ -242,7 +235,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
if (u == null)
@@ -259,7 +252,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
if (attrs == null || attrs.isEmpty())
@@ -320,7 +313,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}
@@ -340,7 +333,7 @@
catch (Exception e)
{
//TODO:
- log.info("Identity operation error: ", e);
+ handleException("Identity operation error: ", e);
}
}