From be7acc5052815b9d785ca0260c83e0c0c5460bf5 Mon Sep 17 00:00:00 2001 From: Ameya Pandilwar Date: Sun, 19 Jun 2016 02:23:53 -0400 Subject: [PATCH 01/18] Upgrade Spring IO Platform to 2.0.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 13040a701..edd91d5b1 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ UTF-8 - 2.0.3.RELEASE + 2.0.5.RELEASE 1.1.0.RELEASE From 50f46fdd0e54c889b7f997e22441f57ea66a7ae3 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Fri, 24 Jun 2016 21:22:15 +0200 Subject: [PATCH 02/18] Remove outdated HTML files --- src/main/java/overview.html | 7 ----- src/main/java/test.html | 53 ------------------------------------- 2 files changed, 60 deletions(-) delete mode 100644 src/main/java/overview.html delete mode 100644 src/main/java/test.html diff --git a/src/main/java/overview.html b/src/main/java/overview.html deleted file mode 100644 index df4f4d6b7..000000000 --- a/src/main/java/overview.html +++ /dev/null @@ -1,7 +0,0 @@ - - -

- The Spring Data Binding framework, an internal library used by Spring Web Flow. -

- - \ No newline at end of file diff --git a/src/main/java/test.html b/src/main/java/test.html deleted file mode 100644 index 8c5cb2cf3..000000000 --- a/src/main/java/test.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - -

Organisation

- -

Speakers

- - - - - - - - - -
- Sergiu Bodiu - -

Sergiu Bodiu

- -

Java Consultant at Bank of America

- Seasoned consultant experienced in large-scale e-commerce projects, passionate about - providing innovative technology solutions to solve complex business problems, have extensive knowledge and - experience delivering enterprise wide applications. He is skilled in software design, data modeling, - stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement, - test and maintain software product components with strong focus on design elegance and software reuse. -
- Sergiu Bodiu - -

Sergiu Bodiu

- -

Java Consultant at Bank of America

- Seasoned consultant experienced in large-scale e-commerce projects, passionate about - providing innovative technology solutions to solve complex business problems, have extensive knowledge and - experience delivering enterprise wide applications. He is skilled in software design, data modeling, - stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement, - test and maintain software product components with strong focus on design elegance and software reuse. -
From a2849f75f2b4020a5807626a310d434d819164aa Mon Sep 17 00:00:00 2001 From: Dapeng Date: Mon, 27 Jun 2016 17:06:47 +0800 Subject: [PATCH 03/18] =?UTF-8?q?Simplify=20jsp=20layout=20management=20ab?= =?UTF-8?q?stract=20the=20page=20layout=20into=20=E2=80=9Clayout.tag?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/WEB-INF/jsp/exception.jsp | 34 +--- .../jsp/owners/createOrUpdateOwnerForm.jsp | 66 +++---- .../webapp/WEB-INF/jsp/owners/findOwners.jsp | 57 ++---- .../WEB-INF/jsp/owners/ownerDetails.jsp | 183 ++++++++---------- .../webapp/WEB-INF/jsp/owners/ownersList.jsp | 65 +++---- .../jsp/pets/createOrUpdatePetForm.jsp | 36 ++-- .../jsp/pets/createOrUpdateVisitForm.jsp | 36 ++-- src/main/webapp/WEB-INF/jsp/vets/vetList.jsp | 68 +++---- src/main/webapp/WEB-INF/jsp/welcome.jsp | 34 +--- .../fragments/footer.jsp => tags/footer.tag} | 0 .../htmlHeader.jsp => tags/htmlHeader.tag} | 0 src/main/webapp/WEB-INF/tags/layout.tag | 27 +++ src/main/webapp/WEB-INF/tags/menu.tag | 68 +++---- src/main/webapp/WEB-INF/tags/menuItem.tag | 13 ++ 14 files changed, 282 insertions(+), 405 deletions(-) rename src/main/webapp/WEB-INF/{jsp/fragments/footer.jsp => tags/footer.tag} (100%) rename src/main/webapp/WEB-INF/{jsp/fragments/htmlHeader.jsp => tags/htmlHeader.tag} (100%) create mode 100644 src/main/webapp/WEB-INF/tags/layout.tag create mode 100644 src/main/webapp/WEB-INF/tags/menuItem.tag diff --git a/src/main/webapp/WEB-INF/jsp/exception.jsp b/src/main/webapp/WEB-INF/jsp/exception.jsp index a4fde6ca3..d030d595d 100644 --- a/src/main/webapp/WEB-INF/jsp/exception.jsp +++ b/src/main/webapp/WEB-INF/jsp/exception.jsp @@ -1,34 +1,14 @@ - - -<%@ page session="false" %> +<%@ page session="false" trimDirectiveWhitespaces="true" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - - + - - -
-
+ + - - +

Something happened...

-

Something happened...

+

${exception.message}

-

${exception.message}

- - - -
-
- - - - +
diff --git a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp index 77826de8a..d0aa9d5a2 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp @@ -1,5 +1,3 @@ - - <%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> @@ -8,43 +6,29 @@ <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - - - - - - - -
-
-

- New Owner -

- -
- - - - - + +

+ New Owner +

+ +
+ + + + + +
+
+
+ + + + + + + +
-
-
- - - - - - - - -
-
- - -
-
- - - - +
+ + diff --git a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp index e9f9b9061..13b9a3dfa 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp @@ -1,5 +1,3 @@ - - <%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> @@ -7,45 +5,30 @@ <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - + - +

Find Owners

- - -
-
- -

Find Owners

- - - -
-
- -
- - -
+ + +
+
+ +
+ +
-
-
- -
+
+
+
+
+
- + -
- Add Owner - - -
-
- - - - - +
+ Add Owner + diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp index 54eade30a..3cfbddede 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp @@ -1,5 +1,3 @@ - - <%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> @@ -8,109 +6,94 @@ <%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - + - - - - -
-
- -

Owner Information

+

Owner Information

- +
+ + + + + + + + + + + + + + + + +
Name
Address
City
Telephone
+ + + + + Edit Owner + + + + + Add New Pet + +
+
+
+

Pets and Visits

+ + + + - - - - - - - - - - - - - - - -
Name
Address
City
Telephone
- - - - - Edit Owner - - - - - Add New Pet - -
-
-
-

Pets and Visits

- - - - - - - + - -
-
-
Name
-
-
Birth Date
-
-
Type
-
-
-
- - + + - + + + + + +
+
+
Name
+
+
Birth Date
+
+
Type
+
+
+
+ + + + + + + + - - + + - - - - - - - - - - - -
Visit DateDescription
Visit DateDescription
- - - - - Edit Pet - - - - - - Add Visit -
-
+ + + + + Edit Pet + + + + + + Add Visit +
+
+ + - -
-
- - - - - - +
diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp index 1824a288c..c33f3d265 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp @@ -1,5 +1,3 @@ - - <%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> @@ -8,43 +6,28 @@ <%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - + +

Owners

- - - - -
-
-

Owners

- - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp index e4f20e9ff..21b651f71 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp @@ -1,20 +1,18 @@ - - <%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - - - - - - - -
-
+ + + + +

New Pet

@@ -49,17 +47,5 @@ - - -
-
- - - - - - + + diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp index d1f901701..df70223c0 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp @@ -1,6 +1,4 @@ - - -<%@ page session="false" %> +<%@ page session="false" trimDirectiveWhitespaces="true" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> @@ -9,15 +7,15 @@ <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - - - - - - - -
-
+ + + + +

New Visit

Pet @@ -68,16 +66,6 @@ +
- -
-
- - - - - + diff --git a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp index e3cdde22c..d8e48e853 100644 --- a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp +++ b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp @@ -1,50 +1,34 @@ - - -<%@ page session="false" %> +<%@ page session="false" trimDirectiveWhitespaces="true" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - + +

Veterinarians

- + + + + + + + + + none + + - - -
-
-

Veterinarians

- - - - - - - - - - none - - - - - - - - -
- ">View as XML - - ">View as JSON -
- - -
-
- - - - + + + + + +
+ ">View as XML + + ">View as JSON +
+
diff --git a/src/main/webapp/WEB-INF/jsp/welcome.jsp b/src/main/webapp/WEB-INF/jsp/welcome.jsp index ee9974590..b801ec67d 100644 --- a/src/main/webapp/WEB-INF/jsp/welcome.jsp +++ b/src/main/webapp/WEB-INF/jsp/welcome.jsp @@ -1,32 +1,14 @@ - - -<%@ page session="false" %> +<%@ page session="false" trimDirectiveWhitespaces="true" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - - - - - - - - -
-
-

-
-
- - -
+ +

+
+
+ +
- -
-
- - - - + diff --git a/src/main/webapp/WEB-INF/jsp/fragments/footer.jsp b/src/main/webapp/WEB-INF/tags/footer.tag similarity index 100% rename from src/main/webapp/WEB-INF/jsp/fragments/footer.jsp rename to src/main/webapp/WEB-INF/tags/footer.tag diff --git a/src/main/webapp/WEB-INF/jsp/fragments/htmlHeader.jsp b/src/main/webapp/WEB-INF/tags/htmlHeader.tag similarity index 100% rename from src/main/webapp/WEB-INF/jsp/fragments/htmlHeader.jsp rename to src/main/webapp/WEB-INF/tags/htmlHeader.tag diff --git a/src/main/webapp/WEB-INF/tags/layout.tag b/src/main/webapp/WEB-INF/tags/layout.tag new file mode 100644 index 000000000..870c735b2 --- /dev/null +++ b/src/main/webapp/WEB-INF/tags/layout.tag @@ -0,0 +1,27 @@ +<%@ tag trimDirectiveWhitespaces="true" %> +<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> + +<%@ attribute name="pageName" required="true" %> +<%@ attribute name="customScript" required="false" fragment="true"%> + + + + + + + + +
+
+ + + + +
+
+ + + + + + diff --git a/src/main/webapp/WEB-INF/tags/menu.tag b/src/main/webapp/WEB-INF/tags/menu.tag index 066f75aa5..f7e8652b2 100644 --- a/src/main/webapp/WEB-INF/tags/menu.tag +++ b/src/main/webapp/WEB-INF/tags/menu.tag @@ -1,10 +1,9 @@ <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core_1_1" %> - +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> <%@ attribute name="name" required="true" rtexprvalue="true" description="Name of the active menu: home, owners, vets or error" %> -<%-- Static navbar --%>
+
diff --git a/src/main/webapp/WEB-INF/tags/menuItem.tag b/src/main/webapp/WEB-INF/tags/menuItem.tag new file mode 100644 index 000000000..8c14dbbc5 --- /dev/null +++ b/src/main/webapp/WEB-INF/tags/menuItem.tag @@ -0,0 +1,13 @@ +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> + +<%@ attribute name="active" required="true" rtexprvalue="true" %> +<%@ attribute name="url" required="true" rtexprvalue="true" %> +<%@ attribute name="title" required="false" rtexprvalue="true" %> + +
  • + " + title="${fn:escapeXml(title)}"> + + +
  • From 647985cdaf1ec1d584d55a24315fbf1f78ebab8a Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Mon, 27 Jun 2016 17:57:03 +0200 Subject: [PATCH 04/18] Add a reference to the Spring Boot branch --- readme.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/readme.md b/readme.md index 27523ac19..5cf6aeef4 100644 --- a/readme.md +++ b/readme.md @@ -162,6 +162,11 @@ File -> Import -> Maven -> Existing Maven project OthersFiles + + Spring Boot branch + + See here + Gradle branch From 4c722465d8091cfa29b54674138c24c199259172 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Tue, 28 Jun 2016 08:11:40 +0200 Subject: [PATCH 05/18] Update vetsXml test using xpath --- .../samples/petclinic/web/VetController.java | 4 +-- .../petclinic/web/VetControllerTests.java | 28 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/web/VetController.java b/src/main/java/org/springframework/samples/petclinic/web/VetController.java index 3121e60e8..45e650ff1 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/VetController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/VetController.java @@ -41,7 +41,7 @@ public class VetController { this.clinicService = clinicService; } - @RequestMapping(value = {"/vets.xml", "/vets.html"}) + @RequestMapping(value = { "/vets.html"}) public String showVetList(Map model) { // Here we are returning an object of type 'Vets' rather than a collection of Vet objects // so it is simpler for Object-Xml mapping @@ -51,7 +51,7 @@ public class VetController { return "vets/vetList"; } - @RequestMapping("/vets.json") + @RequestMapping(value = { "/vets.json", "/vets.xml"}) public @ResponseBody Vets showResourcesVetList() { diff --git a/src/test/java/org/springframework/samples/petclinic/web/VetControllerTests.java b/src/test/java/org/springframework/samples/petclinic/web/VetControllerTests.java index 5446c0718..8b76fd254 100644 --- a/src/test/java/org/springframework/samples/petclinic/web/VetControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/web/VetControllerTests.java @@ -1,8 +1,5 @@ package org.springframework.samples.petclinic.web; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -16,6 +13,10 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import static org.hamcrest.xml.HasXPath.hasXPath; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + /** * Test class for the {@link VetController} */ @@ -35,14 +36,12 @@ public class VetControllerTests { this.mockMvc = MockMvcBuilders.standaloneSetup(vetController).build(); } - @Test - public void testShowVetListXml() throws Exception { - testShowVetList("/vets.xml"); - } - @Test public void testShowVetListHtml() throws Exception { - testShowVetList("/vets.html"); + mockMvc.perform(get("/vets.html")) + .andExpect(status().isOk()) + .andExpect(model().attributeExists("vets")) + .andExpect(view().name("vets/vetList")); } @Test @@ -53,12 +52,13 @@ public class VetControllerTests { .andExpect(jsonPath("$.vetList[0].id").value(1)); } - private void testShowVetList(String url) throws Exception { - mockMvc.perform(get(url)) + @Test + public void testShowVetListXml() throws Exception { + mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML)) .andExpect(status().isOk()) - .andExpect(model().attributeExists("vets")) - .andExpect(view().name("vets/vetList")); + .andExpect(content().contentType(MediaType.APPLICATION_XML_VALUE)) + .andExpect(content().node(hasXPath("/vets/vetList[id=1]/id"))); } - } + From 078bdc6cfbada99413041d859fdeb3d63685c40b Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Tue, 28 Jun 2016 18:47:51 +0200 Subject: [PATCH 06/18] #149 JdbcPetRepositoryImpl:: findById() simplification --- .../repository/jdbc/JdbcPetRepositoryImpl.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java index 885c2bc2f..74cbc06b5 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java @@ -82,26 +82,16 @@ public class JdbcPetRepositoryImpl implements PetRepository { @Override public Pet findById(int id) throws DataAccessException { - JdbcPet pet; + Integer ownerId; try { Map params = new HashMap<>(); params.put("id", id); - pet = this.namedParameterJdbcTemplate.queryForObject( - "SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id", - params, - new JdbcPetRowMapper()); + ownerId = this.namedParameterJdbcTemplate.queryForObject("SELECT owner_id FROM pets WHERE id=:id", params, Integer.class); } catch (EmptyResultDataAccessException ex) { throw new ObjectRetrievalFailureException(Pet.class, id); } - Owner owner = this.ownerRepository.findById(pet.getOwnerId()); - owner.addPet(pet); - pet.setType(EntityUtils.getById(findPetTypes(), PetType.class, pet.getTypeId())); - - List visits = this.visitRepository.findByPetId(pet.getId()); - for (Visit visit : visits) { - pet.addVisit(visit); - } - return pet; + Owner owner = this.ownerRepository.findById(ownerId); + return EntityUtils.getById(owner.getPets(), Pet.class, id); } @Override From 6be7ec558e3f34d5d3cef2ea5fc415c82768e8be Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Tue, 28 Jun 2016 19:41:53 +0200 Subject: [PATCH 07/18] Add the generated/ directory for easier switching between master and develop branches --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 9c9642b1d..6dec04c57 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ target/* .idea *.iml /target + +generated/ From 1e412c602046004e1953bce8e94b0e5cc6e355ef Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Wed, 29 Jun 2016 08:46:56 +0200 Subject: [PATCH 08/18] Add some missing trimDirectiveWhitespaces on JSPs --- src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp | 2 +- src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp | 2 +- src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp | 2 +- src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp | 2 +- src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp index d0aa9d5a2..d7e9e1ab9 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp @@ -1,4 +1,4 @@ -<%@ page session="false" %> +<%@ page session="false" trimDirectiveWhitespaces="true" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> diff --git a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp index 13b9a3dfa..f9a3e54a2 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp @@ -1,4 +1,4 @@ -<%@ page session="false" %> +<%@ page session="false" trimDirectiveWhitespaces="true" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp index 3cfbddede..7ca50f673 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp @@ -1,4 +1,4 @@ -<%@ page session="false" %> +<%@ page session="false" trimDirectiveWhitespaces="true" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp index c33f3d265..2f862488f 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp @@ -1,4 +1,4 @@ -<%@ page session="false" %> +<%@ page session="false" trimDirectiveWhitespaces="true" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp index 21b651f71..8a0b34a30 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp @@ -1,4 +1,4 @@ -<%@ page session="false" %> +<%@ page session="false" trimDirectiveWhitespaces="true" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> From 835f53da3097f7f1f564becf2107d0399a299ae5 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Tue, 5 Jul 2016 18:28:09 +0200 Subject: [PATCH 09/18] Remove spring-boot dependencies --- pom.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index edd91d5b1..c93b6c002 100644 --- a/pom.xml +++ b/pom.xml @@ -96,12 +96,8 @@ - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-data-jpa + org.springframework.data + spring-data-jpa From 1a6572d1ac0c7659d9243405074f3f19f9a93328 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Tue, 5 Jul 2016 18:31:47 +0200 Subject: [PATCH 10/18] Replace web.xml by PetclinicInitializer --- readme.md | 4 +- .../petclinic/PetclinicInitializer.java | 111 ++++++++++++++++ src/main/webapp/WEB-INF/web.xml | 118 ------------------ 3 files changed, 113 insertions(+), 120 deletions(-) create mode 100644 src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java delete mode 100644 src/main/webapp/WEB-INF/web.xml diff --git a/readme.md b/readme.md index 5cf6aeef4..4b6a0f4cd 100644 --- a/readme.md +++ b/readme.md @@ -96,7 +96,7 @@ File -> Import -> Maven -> Existing Maven project ownersList.jsp vetList.jsp - web.xml + PetclinicInitializer.java datatables.properties @@ -135,7 +135,7 @@ File -> Import -> Maven -> Existing Maven project business-config.xml ClinicServiceJdbcTests.java - web.xml + PetclinicInitializer.java diff --git a/src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java b/src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java new file mode 100644 index 000000000..d1c759db9 --- /dev/null +++ b/src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java @@ -0,0 +1,111 @@ +/* + * Copyright 2002-2016 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; + +import com.github.dandelion.core.web.DandelionFilter; +import com.github.dandelion.core.web.DandelionServlet; +import com.github.dandelion.datatables.core.web.filter.DatatablesFilter; +import org.springframework.util.Assert; +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.XmlWebApplicationContext; +import org.springframework.web.filter.CharacterEncodingFilter; +import org.springframework.web.servlet.DispatcherServlet; +import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer; + +import javax.servlet.*; +import java.util.EnumSet; + + +/** + * In Servlet 3.0+ environments, this class replaces the traditional {@code web.xml}-based approach in order to configure the + * {@link ServletContext} programmatically. + *

    + * Create the Spring "root" application context.
    + * Register a {@link DispatcherServlet} and a {@link DandelionServlet} in the servlet context.
    + * For both servlets, register a {@link CharacterEncodingFilter}, a {@link DandelionFilter} an a {@link DatatablesFilter}. + *

    + * + * @author Antoine Rey + */ +public class PetclinicInitializer extends AbstractDispatcherServletInitializer { + + /** + * Spring profile used to choose the persistence layer implementation. + *

    + * When using Spring jpa, use: jpa + * When using Spring JDBC, use: jdbc + * When using Spring Data JPA, use: spring-data-jpa + */ + private static final String SPRING_PROFILE = "jpa"; + + private static final String DANDELION_SERVLET = "dandelionServlet"; + + @Override + public void onStartup(ServletContext servletContext) throws ServletException { + super.onStartup(servletContext); + registerDandelionServlet(servletContext); + } + + @Override + protected WebApplicationContext createRootApplicationContext() { + XmlWebApplicationContext rootAppContext = new XmlWebApplicationContext(); + rootAppContext.setConfigLocations("classpath:spring/business-config.xml", "classpath:spring/tools-config.xml"); + rootAppContext.getEnvironment().setActiveProfiles(SPRING_PROFILE); + return rootAppContext; + } + + + @Override + protected WebApplicationContext createServletApplicationContext() { + XmlWebApplicationContext webAppContext = new XmlWebApplicationContext(); + webAppContext.setConfigLocation("classpath:spring/mvc-core-config.xml"); + return webAppContext; + } + + @Override + protected String[] getServletMappings() { + return new String[]{"/"}; + } + + @Override + protected Filter[] getServletFilters() { + // Used to provide the ability to enter Chinese characters inside the Owner Form + CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter("UTF-8", true); + + // Dandelion filter definition and mapping --> + DandelionFilter dandelionFilter = new DandelionFilter(); + + // Dandelion-Datatables filter, used for basic export --> + DatatablesFilter datatablesFilter = new DatatablesFilter(); + + return new Filter[]{characterEncodingFilter, dandelionFilter, datatablesFilter}; + } + + @Override + protected FilterRegistration.Dynamic registerServletFilter(ServletContext servletContext, Filter filter) { + FilterRegistration.Dynamic registration = super.registerServletFilter(servletContext, filter); + registration.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE), false, DANDELION_SERVLET); + return registration; + } + + private void registerDandelionServlet(ServletContext servletContext) { + DandelionServlet dandelionServlet = new DandelionServlet(); + ServletRegistration.Dynamic registration = servletContext.addServlet(DANDELION_SERVLET, dandelionServlet); + registration.setLoadOnStartup(2); + registration.addMapping("/dandelion-assets/*"); + } +} diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index ea965de25..000000000 --- a/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - Spring PetClinic - Spring PetClinic sample application - - - - spring.profiles.active - jpa - - - - - - - - - - - - contextConfigLocation - classpath:spring/business-config.xml, classpath:spring/tools-config.xml - - - - org.springframework.web.context.ContextLoaderListener - - - - - petclinic - org.springframework.web.servlet.DispatcherServlet - - contextConfigLocation - classpath:spring/mvc-core-config.xml - - 1 - - - - petclinic - / - - - - - dandelionServlet - com.github.dandelion.core.web.DandelionServlet - 2 - - - dandelionServlet - /dandelion-assets/* - - - - - encodingFilter - org.springframework.web.filter.CharacterEncodingFilter - - encoding - UTF-8 - - - forceEncoding - true - - - - - encodingFilter - /* - - - - - dandelionFilter - com.github.dandelion.core.web.DandelionFilter - - - dandelionFilter - /* - - - - - datatables - com.github.dandelion.datatables.core.web.filter.DatatablesFilter - - - datatables - /* - - - - - From 2f3e035c60551cb5caf2005b9caea8126a59a52e Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Wed, 6 Jul 2016 18:18:40 +0200 Subject: [PATCH 11/18] The maven-war-plugin does not failed on missing web.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index c93b6c002..d964c0c67 100644 --- a/pom.xml +++ b/pom.xml @@ -312,6 +312,7 @@ 2.3 petclinic + false From d77f31c96e9e82d6245d1e244dd5a91b444295a0 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Wed, 6 Jul 2016 19:00:32 +0200 Subject: [PATCH 12/18] Fix Jetty 9 startup --- src/main/webapp/WEB-INF/jetty-web.xml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/webapp/WEB-INF/jetty-web.xml diff --git a/src/main/webapp/WEB-INF/jetty-web.xml b/src/main/webapp/WEB-INF/jetty-web.xml new file mode 100644 index 000000000..5bb92f033 --- /dev/null +++ b/src/main/webapp/WEB-INF/jetty-web.xml @@ -0,0 +1,7 @@ + + + + + + true + From eddc72cfa8ec1f010b3b21e80e661d8d8ba33cf1 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sat, 9 Jul 2016 12:06:26 +0200 Subject: [PATCH 13/18] Upgrade Spring IO Platform to 2.0.6 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d964c0c67..afcc6db8d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.springframework.samples spring-petclinic - 4.2.5-SNAPSHOT + 4.2.6-SNAPSHOT petclinic war @@ -17,7 +17,7 @@ UTF-8 - 2.0.5.RELEASE + 2.0.6.RELEASE 1.1.0.RELEASE From ed0ab2af41b9cd5ae832cd605a564b34dc223904 Mon Sep 17 00:00:00 2001 From: Mike Eltsufin Date: Fri, 22 Jul 2016 11:31:12 -0400 Subject: [PATCH 14/18] Use build finalName instead of warName in pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index afcc6db8d..abfd976af 100644 --- a/pom.xml +++ b/pom.xml @@ -272,6 +272,7 @@ install + petclinic @@ -311,7 +312,6 @@ maven-war-plugin 2.3 - petclinic false From fa466855ef1f4651ef416c0c02de72a92932c80e Mon Sep 17 00:00:00 2001 From: AndrejGajdos Date: Thu, 28 Jul 2016 13:50:07 +0200 Subject: [PATCH 15/18] responsive menu fix responsive menu fix - data-target attribute added --- src/main/webapp/WEB-INF/tags/menu.tag | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/WEB-INF/tags/menu.tag b/src/main/webapp/WEB-INF/tags/menu.tag index f7e8652b2..6afb0f3f5 100644 --- a/src/main/webapp/WEB-INF/tags/menu.tag +++ b/src/main/webapp/WEB-INF/tags/menu.tag @@ -8,14 +8,14 @@

    -