Fixes issue 23385: Organization is generated even
authorJavier Etxarri <javier.echarri@openbravo.com>
Fri, 31 May 2013 12:25:02 +0200
changeset 20504 6792989a9124
parent 20503 ada107be4fd6
child 20505 ec1c4db1c441
Fixes issue 23385: Organization is generated even
if the Initial Org Setup ends with errors
src/org/openbravo/erpCommon/ad_forms/InitialOrgSetup.java
src/org/openbravo/erpCommon/businessUtility/InitialOrgSetup.java
--- a/src/org/openbravo/erpCommon/ad_forms/InitialOrgSetup.java	Fri May 31 12:13:27 2013 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/InitialOrgSetup.java	Fri May 31 12:25:02 2013 +0200
@@ -30,6 +30,7 @@
 import org.openbravo.base.secureApp.OrgTree;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.businessUtility.WindowTabs;
 import org.openbravo.erpCommon.modules.ModuleReferenceDataOrgTree;
 import org.openbravo.erpCommon.utility.LeftTabsBar;
@@ -41,6 +42,7 @@
 
 public class InitialOrgSetup extends HttpSecureAppServlet {
   private static final long serialVersionUID = 1L;
+  private static final String OKTYPE = "Success";
 
   @Override
   public void doPost(HttpServletRequest request, HttpServletResponse response)
@@ -72,6 +74,9 @@
           strParentOrg, strcLocationId, strPassword, strModules, isTrue(strCreateAccounting),
           fileCoAFilePath, strCurrency, bBPartner, bProduct, bProject, bCampaign, bSalesRegion,
           vars.getSessionValue("#SOURCEPATH"));
+      if (!obeResult.getType().equals(OKTYPE)) {
+        OBDal.getInstance().rollbackAndClose();
+      }
       vars.setSessionValue("#USER_ORG", vars.getSessionValue("#USER_ORG") + ", '" + ios.getOrgId()
           + "'");
       vars.setSessionValue("#ORG_CLIENT",
--- a/src/org/openbravo/erpCommon/businessUtility/InitialOrgSetup.java	Fri May 31 12:13:27 2013 +0200
+++ b/src/org/openbravo/erpCommon/businessUtility/InitialOrgSetup.java	Fri May 31 12:25:02 2013 +0200
@@ -160,7 +160,6 @@
     OBContext.getOBContext().getWritableOrganizations();
     try {
       OBDal.getInstance().flush();
-      OBDal.getInstance().commitAndClose();
       org = OBDal.getInstance().get(Organization.class, strOrgId);
       client = org.getClient();
       if (strcLocationId != null && !strcLocationId.equals(""))
@@ -249,6 +248,7 @@
 
     obResult.setType(OKTYPE);
     obResult.setMessage("@" + OKTYPE + "@");
+    OBDal.getInstance().commitAndClose();
 
     return obResult;