Author: mputz
Date: 2015-01-09 05:00:30 -0500 (Fri, 09 Jan 2015)
New Revision: 9330
Modified:
epp/portal/branches/EPP_5_2_2_GA_BZ1180232/component/identity/src/main/java/org/exoplatform/services/organization/idm/AbstractDAOImpl.java
epp/portal/branches/EPP_5_2_2_GA_BZ1180232/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java
Log:
Backport fixes related to GTNPORTAL-2928
Modified:
epp/portal/branches/EPP_5_2_2_GA_BZ1180232/component/identity/src/main/java/org/exoplatform/services/organization/idm/AbstractDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_2_GA_BZ1180232/component/identity/src/main/java/org/exoplatform/services/organization/idm/AbstractDAOImpl.java 2015-01-09
09:22:22 UTC (rev 9329)
+++
epp/portal/branches/EPP_5_2_2_GA_BZ1180232/component/identity/src/main/java/org/exoplatform/services/organization/idm/AbstractDAOImpl.java 2015-01-09
10:00:30 UTC (rev 9330)
@@ -67,6 +67,8 @@
{
log.warn("Unable to set Transaction status to be rollback only",
tre);
}
+ } else {
+ orgService.recoverFromIDMError();
}
}
}
Modified:
epp/portal/branches/EPP_5_2_2_GA_BZ1180232/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_2_GA_BZ1180232/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java 2015-01-09
09:22:22 UTC (rev 9329)
+++
epp/portal/branches/EPP_5_2_2_GA_BZ1180232/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java 2015-01-09
10:00:30 UTC (rev 9330)
@@ -30,6 +30,7 @@
import org.exoplatform.services.organization.BaseOrganizationService;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
+import org.picketlink.idm.api.Transaction;
import org.picocontainer.Startable;
import javax.naming.InitialContext;
@@ -197,14 +198,21 @@
{
if (idmService_.getIdentitySession().getTransaction().isActive())
{
- idmService_.getIdentitySession().save();
+ try {
+ if (idmService_.getIdentitySession().getTransaction().isActive()) {
+ idmService_.getIdentitySession().save();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ recoverFromIDMError();
+ }
}
}
}
catch (Exception e)
{
- e.printStackTrace();
+ log.error(e.getMessage(), e);
}
}
@@ -224,16 +232,38 @@
}
else
{
- idmService_.getIdentitySession().getTransaction().commit();
+ try {
+ if (idmService_.getIdentitySession().getTransaction().isActive()) {
+ idmService_.getIdentitySession().getTransaction().commit();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ recoverFromIDMError();
+ }
}
}
catch (Exception e)
{
- e.printStackTrace();
+ log.error(e.getMessage(), e);
}
}
+ // Should be used only for non-JTA environment
+ public void recoverFromIDMError() {
+ try {
+ // We need to restart Hibernate transaction if it's available. First
rollback old one and then start new one
+ Transaction idmTransaction =
idmService_.getIdentitySession().getTransaction();
+ if (idmTransaction.isActive()) {
+ idmTransaction.rollback();
+ idmTransaction.start();
+ log.info("IDM error recovery finished. Old transaction has been
rolled-back and new transaction has been started");
+ }
+ } catch (Exception e1) {
+ log.warn("Error during recovery of old error", e1);
+ }
+ }
+
public Config getConfiguration()
{
return configuration;
Show replies by date