diff --git a/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBAuthenticationException.java b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBAuthenticationException.java new file mode 100644 index 0000000000..edaa770e12 --- /dev/null +++ b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBAuthenticationException.java @@ -0,0 +1,59 @@ +/* + * Copyright Siemens AG, 2025. Part of the SW360 Portal Project. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.sw360.rest.resourceserver.licensedb.exception; + +/** + * Exception thrown when OAuth2 authentication with LicenseDB fails. + * + *
This exception is thrown when the SW360 application cannot authenticate + * with the LicenseDB service using OAuth2 Machine-to-Machine credentials. + * This could be due to:
+ *Example usage:
+ *
+ * try {
+ * accessToken = oauth2Service.getAccessToken();
+ * } catch (LicenseDBAuthenticationException e) {
+ * log.error("OAuth2 authentication failed: {}", e.getMessage());
+ * // Handle authentication error
+ * }
+ *
+ */
+public class LicenseDBAuthenticationException extends LicenseDBException {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String ERROR_CODE = "AUTHENTICATION_ERROR";
+
+ /**
+ * Constructs a new LicenseDBAuthenticationException with the specified message.
+ *
+ * @param message the error message describing the authentication failure
+ */
+ public LicenseDBAuthenticationException(String message) {
+ super(message, ERROR_CODE);
+ }
+
+ /**
+ * Constructs a new LicenseDBAuthenticationException with the specified message and cause.
+ *
+ * @param message the error message describing the authentication failure
+ * @param cause the underlying cause of the authentication failure
+ */
+ public LicenseDBAuthenticationException(String message, Throwable cause) {
+ super(message, ERROR_CODE, cause);
+ }
+}
\ No newline at end of file
diff --git a/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBConnectionException.java b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBConnectionException.java
new file mode 100644
index 0000000000..b243daa797
--- /dev/null
+++ b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBConnectionException.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright Siemens AG, 2025. Part of the SW360 Portal Project.
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.sw360.rest.resourceserver.licensedb.exception;
+
+/**
+ * Exception thrown when connection to LicenseDB server fails.
+ *
+ * This exception is thrown when the SW360 application cannot establish + * a connection to the LicenseDB service. This could be due to:
+ *Example usage:
+ *
+ * try {
+ * licenses = licenseDBClient.getAllLicenses();
+ * } catch (LicenseDBConnectionException e) {
+ * log.error("Failed to connect to LicenseDB: {}", e.getMessage());
+ * // Handle connection error
+ * }
+ *
+ */
+public class LicenseDBConnectionException extends LicenseDBException {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String ERROR_CODE = "CONNECTION_ERROR";
+
+ /**
+ * Constructs a new LicenseDBConnectionException with the specified message.
+ *
+ * @param message the error message describing the connection failure
+ */
+ public LicenseDBConnectionException(String message) {
+ super(message, ERROR_CODE);
+ }
+
+ /**
+ * Constructs a new LicenseDBConnectionException with the specified message and cause.
+ *
+ * @param message the error message describing the connection failure
+ * @param cause the underlying cause of the connection failure
+ */
+ public LicenseDBConnectionException(String message, Throwable cause) {
+ super(message, ERROR_CODE, cause);
+ }
+}
\ No newline at end of file
diff --git a/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBDataException.java b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBDataException.java
new file mode 100644
index 0000000000..339a91c237
--- /dev/null
+++ b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBDataException.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright Siemens AG, 2025. Part of the SW360 Portal Project.
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.sw360.rest.resourceserver.licensedb.exception;
+
+/**
+ * Exception thrown when LicenseDB data validation fails.
+ *
+ * This exception is thrown when the data received from LicenseDB + * does not match the expected format or fails validation. This could be due to:
+ *Example usage:
+ *
+ * try {
+ * License license = transformer.transform(licenseDbData);
+ * } catch (LicenseDBDataException e) {
+ * log.error("Invalid license data: {}", e.getMessage());
+ * // Handle data validation error
+ * }
+ *
+ */
+public class LicenseDBDataException extends LicenseDBException {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String ERROR_CODE = "DATA_ERROR";
+
+ /**
+ * Constructs a new LicenseDBDataException with the specified message.
+ *
+ * @param message the error message describing the data validation failure
+ */
+ public LicenseDBDataException(String message) {
+ super(message, ERROR_CODE);
+ }
+
+ /**
+ * Constructs a new LicenseDBDataException with the specified message and cause.
+ *
+ * @param message the error message describing the data validation failure
+ * @param cause the underlying cause of the data validation failure
+ */
+ public LicenseDBDataException(String message, Throwable cause) {
+ super(message, ERROR_CODE, cause);
+ }
+}
\ No newline at end of file
diff --git a/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBException.java b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBException.java
new file mode 100644
index 0000000000..916483ace3
--- /dev/null
+++ b/rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/LicenseDBException.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright Siemens AG, 2025. Part of the SW360 Portal Project.
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.sw360.rest.resourceserver.licensedb.exception;
+
+/**
+ * Base exception for all LicenseDB-related errors.
+ *
+ * This exception serves as the parent class for all LicenseDB-specific + * exceptions in the SW360 application. It provides a common structure for + * error handling when interacting with the LicenseDB service.
+ * + *Subclasses include:
+ *