Merge branch 'KON-225_EMail_in_Haupttabelle' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.contactBaseData.backend into DEVELOP
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/controller/AddressController.java b/src/main/java/org/eclipse/openk/contactbasedata/controller/AddressController.java
index 7f25a06..1de9cc9 100644
--- a/src/main/java/org/eclipse/openk/contactbasedata/controller/AddressController.java
+++ b/src/main/java/org/eclipse/openk/contactbasedata/controller/AddressController.java
@@ -23,11 +23,12 @@
 import org.eclipse.openk.contactbasedata.viewmodel.AddressDto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
-import org.springframework.security.access.annotation.Secured;
 import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.annotation.Secured;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+
 import java.net.URI;
 import java.util.List;
 import java.util.UUID;
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/controller/AddressTypeController.java b/src/main/java/org/eclipse/openk/contactbasedata/controller/AddressTypeController.java
index 8d68b41..480a444 100644
--- a/src/main/java/org/eclipse/openk/contactbasedata/controller/AddressTypeController.java
+++ b/src/main/java/org/eclipse/openk/contactbasedata/controller/AddressTypeController.java
@@ -19,6 +19,7 @@
 import io.swagger.annotations.ApiResponses;
 import lombok.extern.log4j.Log4j2;
 import org.eclipse.openk.contactbasedata.exceptions.BadRequestException;
+import org.eclipse.openk.contactbasedata.exceptions.ConflictException;
 import org.eclipse.openk.contactbasedata.service.AddressTypeService;
 import org.eclipse.openk.contactbasedata.viewmodel.AddressTypeDto;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -107,9 +108,15 @@
     @ApiResponses(value = {
             @ApiResponse(code = 204, message = "Erfolgreich durchgeführt"),
             @ApiResponse(code = 400, message = "Ungültige Anfrage"),
-            @ApiResponse(code = 404, message = "Nicht gefunden")})
+            @ApiResponse(code = 404, message = "Nicht gefunden"),
+            @ApiResponse(code = 409, message = "Datensatz konnte nicht gelöscht werden")})
     public void removeAddressType(@PathVariable UUID uuid) {
-        addressTypeService.removeAddressType(uuid);
+        try {
+            addressTypeService.removeAddressType(uuid);
+        }
+        catch( Exception ex ) {
+            throw new ConflictException("Address type couldn't be deleted");
+        }
     }
 
 }
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/controller/CommunicationTypeController.java b/src/main/java/org/eclipse/openk/contactbasedata/controller/CommunicationTypeController.java
index c9852ca..db4285e 100644
--- a/src/main/java/org/eclipse/openk/contactbasedata/controller/CommunicationTypeController.java
+++ b/src/main/java/org/eclipse/openk/contactbasedata/controller/CommunicationTypeController.java
@@ -19,6 +19,7 @@
 import io.swagger.annotations.ApiResponses;
 import lombok.extern.log4j.Log4j2;
 import org.eclipse.openk.contactbasedata.exceptions.BadRequestException;
+import org.eclipse.openk.contactbasedata.exceptions.ConflictException;
 import org.eclipse.openk.contactbasedata.service.CommunicationTypeService;
 import org.eclipse.openk.contactbasedata.viewmodel.CommunicationTypeDto;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -103,9 +104,15 @@
     @ApiResponses(value = {
             @ApiResponse(code = 204, message = "Erfolgreich durchgeführt"),
             @ApiResponse(code = 400, message = "Ungültige Anfrage"),
-            @ApiResponse(code = 404, message = "Nicht gefunden")})
+            @ApiResponse(code = 404, message = "Nicht gefunden"),
+            @ApiResponse(code = 409, message = "Datensatz konnte nicht gelöscht werden")})
     public void removeComunicationType(@PathVariable UUID uuid) {
-        communicationTypeService.removeCommunicationType(uuid);
+        try {
+            communicationTypeService.removeCommunicationType(uuid);
+        }
+        catch( Exception ex ) {
+            throw new ConflictException("Communication type couldn't be deleted");
+        }
     }
 }
 
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/controller/PersonTypeController.java b/src/main/java/org/eclipse/openk/contactbasedata/controller/PersonTypeController.java
index c56aec8..d9bef9f 100644
--- a/src/main/java/org/eclipse/openk/contactbasedata/controller/PersonTypeController.java
+++ b/src/main/java/org/eclipse/openk/contactbasedata/controller/PersonTypeController.java
@@ -19,6 +19,7 @@
 import io.swagger.annotations.ApiResponses;
 import lombok.extern.log4j.Log4j2;
 import org.eclipse.openk.contactbasedata.exceptions.BadRequestException;
+import org.eclipse.openk.contactbasedata.exceptions.ConflictException;
 import org.eclipse.openk.contactbasedata.service.PersonTypeService;
 import org.eclipse.openk.contactbasedata.viewmodel.PersonTypeDto;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -107,9 +108,16 @@
     @ApiResponses(value = {
             @ApiResponse(code = 204, message = "Erfolgreich durchgeführt"),
             @ApiResponse(code = 400, message = "Ungültige Anfrage"),
-            @ApiResponse(code = 404, message = "Nicht gefunden")})
+            @ApiResponse(code = 404, message = "Nicht gefunden"),
+            @ApiResponse(code = 409, message = "Datensatz konnte nicht gelöscht werden")})
     public void removePersonType(@PathVariable UUID uuid) {
-        personTypeService.removePersonType(uuid);
+
+        try {
+            personTypeService.removePersonType(uuid);
+        }
+        catch( Exception ex ) {
+            throw new ConflictException("Person type couldn't be deleted");
+        }
     }
 
 }
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/controller/SalutationController.java b/src/main/java/org/eclipse/openk/contactbasedata/controller/SalutationController.java
index 83a437d..6021788 100644
--- a/src/main/java/org/eclipse/openk/contactbasedata/controller/SalutationController.java
+++ b/src/main/java/org/eclipse/openk/contactbasedata/controller/SalutationController.java
@@ -19,6 +19,7 @@
 import io.swagger.annotations.ApiResponses;
 import lombok.extern.log4j.Log4j2;
 import org.eclipse.openk.contactbasedata.exceptions.BadRequestException;
+import org.eclipse.openk.contactbasedata.exceptions.ConflictException;
 import org.eclipse.openk.contactbasedata.service.SalutationService;
 import org.eclipse.openk.contactbasedata.viewmodel.SalutationDto;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -107,9 +108,15 @@
     @ApiResponses(value = {
             @ApiResponse(code = 204, message = "Erfolgreich durchgeführt"),
             @ApiResponse(code = 400, message = "Ungültige Anfrage"),
-            @ApiResponse(code = 404, message = "Nicht gefunden")})
+            @ApiResponse(code = 404, message = "Nicht gefunden"),
+            @ApiResponse(code = 409, message = "Datensatz konnte nicht gelöscht werden")})
     public void removeSalutation(@PathVariable UUID uuid) {
-        salutationService.removeSalutation(uuid);
+        try {
+            salutationService.removeSalutation(uuid);
+        }
+        catch( Exception ex ) {
+            throw new ConflictException("Salutation couldn't be deleted");
+        }
     }
 
 }
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/exceptions/ConflictException.java b/src/main/java/org/eclipse/openk/contactbasedata/exceptions/ConflictException.java
new file mode 100644
index 0000000..a0398b5
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/contactbasedata/exceptions/ConflictException.java
@@ -0,0 +1,30 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+ */
+package org.eclipse.openk.contactbasedata.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(code = HttpStatus.CONFLICT)
+public class ConflictException extends RuntimeException{
+
+    public ConflictException() {
+
+    }
+
+    public ConflictException(String message) {
+        super(message);
+    }
+}