details:   https://code.openbravo.com/erp/devel/pi/rev/0eb0853e3d48
changeset: 28117:0eb0853e3d48
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Mon Nov 23 10:20:38 2015 +0100
summary:   Fixes issue 31519: Opens the API of SystemService

There three new public methods in the SystemService class:
- killConnectionsAndSafeMode
- resetSafeMode
- getModelFromDatabase

The first two where private methods that have been made public. The third one 
has been extracted from code that used to be within the disableConstraints 
method.

diffstat:

 src/org/openbravo/service/system/SystemService.java |  34 +++++++++++++++++---
 1 files changed, 28 insertions(+), 6 deletions(-)

diffs (65 lines):

diff -r ef24b25b675a -r 0eb0853e3d48 
src/org/openbravo/service/system/SystemService.java
--- a/src/org/openbravo/service/system/SystemService.java       Thu Dec 10 
07:11:19 2015 +0100
+++ b/src/org/openbravo/service/system/SystemService.java       Mon Nov 23 
10:20:38 2015 +0100
@@ -386,7 +386,14 @@
     }
   }
 
-  private void resetSafeMode(Connection con) {
+  /**
+   * Callend after killConnectionsAndSafeMode, it disables the restriction to 
log only with the
+   * System Administrator role
+   * 
+   * @param con
+   *          Connection used to make the queries
+   */
+  public void resetSafeMode(Connection con) {
 
     try {
       PreparedStatement ps2 = null;
@@ -403,7 +410,14 @@
     }
   }
 
-  private void killConnectionsAndSafeMode(Connection con) {
+  /**
+   * Kills the active sessions for the current user and sets the System Admin 
role as the only one
+   * available
+   * 
+   * @param con
+   *          the Connection used to execute the queries
+   */
+  public void killConnectionsAndSafeMode(Connection con) {
     try {
       PreparedStatement updateSession = null;
       try {
@@ -452,10 +466,7 @@
 
   private void disableConstraints(Platform platform) throws 
FileNotFoundException, IOException {
     log4j.info("Disabling constraints...");
-    ExcludeFilter excludeFilter = DBSMOBUtil.getInstance().getExcludeFilter(
-        new File(OBPropertiesProvider.getInstance().getOpenbravoProperties()
-            .getProperty("source.path")));
-    Database xmlModel = platform.loadModelFromDatabase(excludeFilter);
+    Database xmlModel = getModelFromDatabase(platform);
     Connection con = null;
     try {
       con = platform.borrowConnection();
@@ -474,6 +485,17 @@
     }
   }
 
+  /**
+   * Given a org.apache.ddlutils.Platform, builds a 
org.apache.ddlutils.model.Database after
+   * applying the exclude filters
+   */
+  public Database getModelFromDatabase(Platform platform) {
+    ExcludeFilter excludeFilter = DBSMOBUtil.getInstance().getExcludeFilter(
+        new File(OBPropertiesProvider.getInstance().getOpenbravoProperties()
+            .getProperty("source.path")));
+    return platform.loadModelFromDatabase(excludeFilter);
+  }
+
   private void enableConstraints(Platform platform) {
     Properties obProp = 
OBPropertiesProvider.getInstance().getOpenbravoProperties();
     String obDir = obProp.getProperty("source.path");

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to