From e9836e634a8b9006157949be82ad552f2b7faa65 Mon Sep 17 00:00:00 2001
From: Antoine Rey <antoine.rey@gmail.com>
Date: Mon, 24 Oct 2016 10:16:27 +0200
Subject: [PATCH] Cross Origin support

---
 .../web/AbstractResourceController.java       | 25 +++++++++++++++++++
 .../samples/petclinic/web/OwnerResource.java  |  2 +-
 .../samples/petclinic/web/PetResource.java    |  2 +-
 .../samples/petclinic/web/VetResource.java    |  2 +-
 .../samples/petclinic/web/VisitResource.java  |  2 +-
 5 files changed, 29 insertions(+), 4 deletions(-)
 create mode 100644 springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/AbstractResourceController.java

diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/AbstractResourceController.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/AbstractResourceController.java
new file mode 100644
index 00000000..60fe88ca
--- /dev/null
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/AbstractResourceController.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.springframework.samples.petclinic.web;
+
+import org.springframework.web.bind.annotation.CrossOrigin;
+
+/**
+ * @author Antoine Rey
+ */
+@CrossOrigin
+abstract class AbstractResourceController {
+}
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java
index 2c3a1d8d..e37ac350 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java
@@ -40,7 +40,7 @@ import javax.validation.Valid;
  * @author Michael Isvy
  */
 @RestController
-public class OwnerResource {
+public class OwnerResource extends AbstractResourceController {
 
     private final ClinicService clinicService;
 
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/PetResource.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/PetResource.java
index d3394751..192bbfb2 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/PetResource.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/PetResource.java
@@ -35,7 +35,7 @@ import java.util.Map;
  * @author Arjen Poutsma
  */
 @RestController
-public class PetResource {
+public class PetResource extends AbstractResourceController {
 
     private final ClinicService clinicService;
 
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VetResource.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VetResource.java
index 7661e97f..b476a43c 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VetResource.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VetResource.java
@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RestController;
  * @author Arjen Poutsma
  */
 @RestController
-public class VetResource {
+public class VetResource extends AbstractResourceController {
 
     private final ClinicService clinicService;
 
diff --git a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VisitResource.java b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VisitResource.java
index 68798f79..12db83c7 100644
--- a/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VisitResource.java
+++ b/springboot-petclinic-server/src/main/java/org/springframework/samples/petclinic/web/VisitResource.java
@@ -35,7 +35,7 @@ import javax.validation.Valid;
  * @author Michael Isvy
  */
 @RestController
-public class VisitResource {
+public class VisitResource extends AbstractResourceController {
 
     private final ClinicService clinicService;
 
-- 
GitLab