From 7cb834810e73e9a57579ecfc3aff3cb2ae60a603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A1n=20Magnoli?= Date: Wed, 8 Apr 2026 15:56:51 -0300 Subject: [PATCH] Feature ETP-1917: replace OBException with local DBSMException in DBSMOBUtil --- .../ddlutils/util/DBSMException.java | 49 +++++++++++++++++++ .../openbravo/ddlutils/util/DBSMOBUtil.java | 10 ++-- 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 src/org/openbravo/ddlutils/util/DBSMException.java diff --git a/src/org/openbravo/ddlutils/util/DBSMException.java b/src/org/openbravo/ddlutils/util/DBSMException.java new file mode 100644 index 0000000..3ec1b4a --- /dev/null +++ b/src/org/openbravo/ddlutils/util/DBSMException.java @@ -0,0 +1,49 @@ +/* + ************************************************************************************ + * Copyright (C) 2001-2020 Openbravo S.L.U. + * Licensed under the Apache Software License version 2.0 + * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + ************************************************************************************ + */ + +package org.openbravo.ddlutils.util; + +/** + * Exception specific to errors related to DB Source Manager (DBSM). + *

+ * This exception extends {@link RuntimeException}, making it an unchecked exception + * that does not need to be declared in method signatures. + *

+ * + *

+ * It is used to wrap errors that occur during DB Source Manager operations, + * such as schema generation, validation, or script execution. + *

+ */ +public class DBSMException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** + * Constructs a new {@code DBSMException} with the specified detail message. + * + * @param message the detail message describing the error + */ + public DBSMException(String message) { + super(message); + } + + /** + * Constructs a new {@code DBSMException} with the specified detail message and cause. + * + * @param message the detail message describing the error + * @param cause the original cause of the exception + */ + public DBSMException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/org/openbravo/ddlutils/util/DBSMOBUtil.java b/src/org/openbravo/ddlutils/util/DBSMOBUtil.java index 851053a..8f1ab1d 100644 --- a/src/org/openbravo/ddlutils/util/DBSMOBUtil.java +++ b/src/org/openbravo/ddlutils/util/DBSMOBUtil.java @@ -56,7 +56,7 @@ import org.apache.log4j.Logger; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; -import org.openbravo.base.exception.OBException; + import org.openbravo.ddlutils.task.DatabaseUtils; public class DBSMOBUtil { @@ -648,17 +648,17 @@ private Connection getUnpooledConnection() { File sslRootCertFile = new File(sslRootCert); if (sslRootCertFile.exists() && sslRootCertFile.isFile()) { if (!sslRootCertFile.canRead()) { - throw new OBException("SSL root certificate file is not readable: " + sslRootCertFile.getAbsolutePath()); + throw new DBSMException("SSL root certificate file is not readable: " + sslRootCertFile.getAbsolutePath()); } connProps.setProperty("sslrootcert", sslRootCertFile.getAbsolutePath()); } else { - throw new OBException("SSL root certificate file not found: " + sslRootCert); + throw new DBSMException("SSL root certificate file not found: " + sslRootCert); } } else { // If the mode requires verification, the certificate is mandatory. if (StringUtils.equals("verify-full", (connProps.getProperty(SSLMODE))) || StringUtils.equals("verify-ca", (connProps.getProperty(SSLMODE)))) { - throw new OBException("bbdd.sslrootcert property is required when bbdd.sslfactory is not set and sslmode is " + connProps.getProperty( + throw new DBSMException("bbdd.sslrootcert property is required when bbdd.sslfactory is not set and sslmode is " + connProps.getProperty( SSLMODE)); } } @@ -677,7 +677,7 @@ private Connection getUnpooledConnection() { errorMsg.append(", sslfactory=").append(sslFactory != null ? sslFactory : "not set"); errorMsg.append(", sslrootcert=").append(sslRootCert != null ? sslRootCert : "not set"); getLog().error("Error while retrieving an unpooled connection: " + errorMsg.toString(), e); - throw new OBException(errorMsg.toString(), e); + throw new DBSMException(errorMsg.toString(), e); } return connection; }