diff --git a/algorithms-modules/algorithms-miscellaneous-4/README.md b/algorithms-modules/algorithms-miscellaneous-4/README.md index 2649df9fc9..e2ae542bf8 100644 --- a/algorithms-modules/algorithms-miscellaneous-4/README.md +++ b/algorithms-modules/algorithms-miscellaneous-4/README.md @@ -11,4 +11,5 @@ This module contains articles about algorithms. Some classes of algorithms, e.g. - [Find the Longest Substring without Repeating Characters](https://www.baeldung.com/java-longest-substring-without-repeated-characters) - [Permutations of an Array in Java](https://www.baeldung.com/java-array-permutations) - [Find the Smallest Missing Integer in an Array](https://www.baeldung.com/java-smallest-missing-integer-in-array) +- [Permutations of a String in Java](https://www.baeldung.com/java-string-permutations) - More articles: [[<-- prev]](/algorithms-miscellaneous-3) [[next -->]](/algorithms-miscellaneous-5) diff --git a/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/ArrayHelper.java b/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/Helper.java similarity index 54% rename from algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/ArrayHelper.java rename to algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/Helper.java index 6b4f1fcb12..8d769b16af 100644 --- a/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/ArrayHelper.java +++ b/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/Helper.java @@ -1,14 +1,20 @@ package com.baeldung.algorithms.stringpermutation; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; -public class ArrayHelper { +public class Helper { - private ArrayHelper() { + private Helper() { } static List toCharacterList(final String string) { return string.chars().mapToObj(s -> ((char) s)).collect(Collectors.toList()); } + + static String toString(Collection collection) { + return collection.stream().map(Object::toString).collect(Collectors.joining()); + } + } diff --git a/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsApache.java b/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsApache.java index c2522a6ec5..97abca64cd 100644 --- a/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsApache.java +++ b/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsApache.java @@ -1,20 +1,29 @@ package com.baeldung.algorithms.stringpermutation; -import java.util.Collection; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.iterators.PermutationIterator; public class StringPermutationsApache { - public Collection> eagerPermutationWithRepetitions(final String string) { - final List characters = ArrayHelper.toCharacterList(string); - return CollectionUtils.permutations(characters); + public List eagerPermutationWithRepetitions(final String string) { + final List characters = Helper.toCharacterList(string); + return CollectionUtils.permutations(characters) + .stream() + .map(Helper::toString) + .collect(Collectors.toList()); } - public PermutationIterator lazyPermutationWithoutRepetitions(final String string) { - final List characters = ArrayHelper.toCharacterList(string); - return new PermutationIterator<>(characters); + public List lazyPermutationWithoutRepetitions(final String string) { + final List characters = Helper.toCharacterList(string); + final PermutationIterator permutationIterator = new PermutationIterator<>(characters); + final List result = new ArrayList<>(); + while (permutationIterator.hasNext()) { + result.add(Helper.toString(permutationIterator.next())); + } + return result; } } diff --git a/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsCombinatoricsLib.java b/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsCombinatoricsLib.java index 78182f8045..45e4aae1fb 100644 --- a/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsCombinatoricsLib.java +++ b/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsCombinatoricsLib.java @@ -7,19 +7,21 @@ import org.paukov.combinatorics3.PermutationGenerator.TreatDuplicatesAs; public class StringPermutationsCombinatoricsLib { - public List> permutationWithoutRepetitions(final String string) { - List chars = ArrayHelper.toCharacterList(string); - return Generator.permutation(chars) - .simple() - .stream() - .collect(Collectors.toList()); - } +public List permutationWithoutRepetitions(final String string) { + List chars = Helper.toCharacterList(string); + return Generator.permutation(chars) + .simple() + .stream() + .map(Helper::toString) + .collect(Collectors.toList()); +} - public List> permutationWithRepetitions(final String string) { - List chars = ArrayHelper.toCharacterList(string); + public List permutationWithRepetitions(final String string) { + List chars = Helper.toCharacterList(string); return Generator.permutation(chars) .simple(TreatDuplicatesAs.IDENTICAL) .stream() + .map(Helper::toString) .collect(Collectors.toList()); } diff --git a/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsGuava.java b/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsGuava.java index d055381bf1..07ac1a2abf 100644 --- a/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsGuava.java +++ b/algorithms-modules/algorithms-miscellaneous-4/src/main/java/com/baeldung/algorithms/stringpermutation/StringPermutationsGuava.java @@ -1,18 +1,22 @@ package com.baeldung.algorithms.stringpermutation; import com.google.common.collect.Collections2; -import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; public class StringPermutationsGuava { - public Collection> permutationWithRepetitions(final String string) { - final List characters = ArrayHelper.toCharacterList(string); - return Collections2.permutations(characters); + public List permutationWithRepetitions(final String string) { + final List characters = Helper.toCharacterList(string); + return Collections2.permutations(characters).stream() + .map(Helper::toString) + .collect(Collectors.toList()); + } + public List permutationWithoutRepetitions(final String string) { + final List characters = Helper.toCharacterList(string); + return Collections2.orderedPermutations(characters).stream() + .map(Helper::toString) + .collect(Collectors.toList()); } -public Collection> permutationWithoutRepetitions(final String string) { - final List characters = ArrayHelper.toCharacterList(string); - return Collections2.orderedPermutations(characters); -} } diff --git a/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/HelperUnitTest.java b/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/HelperUnitTest.java new file mode 100644 index 0000000000..450713fac4 --- /dev/null +++ b/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/HelperUnitTest.java @@ -0,0 +1,36 @@ +package com.baeldung.algorithms.stringpermutation; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class HelperUnitTest { + + @ParameterizedTest + @MethodSource("stringProvider") + void toListTest(String value, List expected) { + final List actual = Helper.toCharacterList(value); + assertThat(expected).isEqualTo(actual); + } + + @ParameterizedTest + @MethodSource("stringProvider") + void toStringTest(String expected, List value) { + final String actual = Helper.toString(value); + assertThat(expected).isEqualTo(actual); + } + + static Stream stringProvider() { + return Stream.of( + Arguments.of("hello", Arrays.asList('h', 'e', 'l', 'l', 'o')), + Arguments.of("abc", Arrays.asList('a','b','c')), + Arguments.of("12345", Arrays.asList('1', '2', '3', '4', '5')) + ); + } + +} \ No newline at end of file diff --git a/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsApacheUnitTest.java b/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsApacheUnitTest.java index d0deb85887..9686287721 100644 --- a/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsApacheUnitTest.java +++ b/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsApacheUnitTest.java @@ -2,22 +2,19 @@ package com.baeldung.algorithms.stringpermutation; import static org.assertj.core.api.Assertions.assertThat; -import java.util.Collection; import java.util.List; -import org.apache.commons.collections4.iterators.PermutationIterator; -import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; class StringPermutationsApacheUnitTest { + @ParameterizedTest @CsvSource({"abc, 6", "hello, 120", "aaaaaa, 720"}) - @DisplayName("Apache permutation for ") void testPermutationsWithRepetitions(String string, int numberOfPermutations) { StringPermutationsApache permutationGenerator = new StringPermutationsApache(); - final Collection> permutations = permutationGenerator.eagerPermutationWithRepetitions(string); + final List permutations = permutationGenerator.eagerPermutationWithRepetitions(string); final int size = permutations.size(); assertThat(permutations) .as("\"%s\" should have %d permutation, but had %d", string, numberOfPermutations, size) @@ -30,12 +27,8 @@ class StringPermutationsApacheUnitTest { "aaaaaa, 720"}) void testPermutationsWithoutRepetitions(String string, int numberOfPermutations) { StringPermutationsApache permutationGenerator = new StringPermutationsApache(); - final PermutationIterator permutations = permutationGenerator.lazyPermutationWithoutRepetitions(string); - int size = 0; - while (permutations.hasNext()) { - permutations.next(); - ++size; - } + final List permutations = permutationGenerator.lazyPermutationWithoutRepetitions(string); + int size = permutations.size(); assertThat(size) .as("\"%s\" should have %d permutation, but had %d", string, numberOfPermutations, size) .isEqualTo(numberOfPermutations); diff --git a/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsCombinatoricsLibUnitTest.java b/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsCombinatoricsLibUnitTest.java index faca3d8f30..8911ef559c 100644 --- a/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsCombinatoricsLibUnitTest.java +++ b/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsCombinatoricsLibUnitTest.java @@ -14,7 +14,7 @@ class StringPermutationsCombinatoricsLibUnitTest { "aaaaaa, 720"}) void testPermutationsWithRepetitions(String string, int numberOfPermutations) { StringPermutationsCombinatoricsLib permutationGenerator = new StringPermutationsCombinatoricsLib(); - final List> permutations = permutationGenerator.permutationWithRepetitions(string); + final List permutations = permutationGenerator.permutationWithRepetitions(string); final int size = permutations.size(); assertThat(permutations) .as("\"%s\" should have %d permutation, but had %d", string, numberOfPermutations, size) @@ -27,7 +27,7 @@ class StringPermutationsCombinatoricsLibUnitTest { "aaaaaa, 1"}) void testPermutationsWithoutRepetitions(String string, int numberOfPermutations) { StringPermutationsCombinatoricsLib permutationGenerator = new StringPermutationsCombinatoricsLib(); - final List> permutations = permutationGenerator.permutationWithoutRepetitions(string); + final List permutations = permutationGenerator.permutationWithoutRepetitions(string); final int size = permutations.size(); assertThat(permutations) .as("\"%s\" should have %d permutation, but had %d", string, numberOfPermutations, size) diff --git a/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsGuavaUnitTest.java b/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsGuavaUnitTest.java index d2da100997..31c3ce8d12 100644 --- a/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsGuavaUnitTest.java +++ b/algorithms-modules/algorithms-miscellaneous-4/src/test/java/com/baeldung/algorithms/stringpermutation/StringPermutationsGuavaUnitTest.java @@ -2,7 +2,6 @@ package com.baeldung.algorithms.stringpermutation; import static org.assertj.core.api.Assertions.assertThat; -import java.util.Collection; import java.util.List; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; @@ -15,7 +14,7 @@ class StringPermutationsGuavaUnitTest { "aaaaaa, 720"}) void testPermutationsWithRepetitions(String string, int numberOfPermutations) { StringPermutationsGuava permutationGenerator = new StringPermutationsGuava(); - final Collection> permutations = permutationGenerator.permutationWithRepetitions(string); + final List permutations = permutationGenerator.permutationWithRepetitions(string); final int size = permutations.size(); assertThat(permutations) .as("\"%s\" should have %d permutation, but had %d", string, numberOfPermutations, size) @@ -28,7 +27,7 @@ class StringPermutationsGuavaUnitTest { "aaaaaa, 1"}) void testPermutationsWithoutRepetitions(String string, int numberOfPermutations) { StringPermutationsGuava permutationGenerator = new StringPermutationsGuava(); - final Collection> permutations = permutationGenerator.permutationWithoutRepetitions(string); + final List permutations = permutationGenerator.permutationWithoutRepetitions(string); final int size = permutations.size(); assertThat(permutations) .as("\"%s\" should have %d permutation, but had %d", string, numberOfPermutations, size) diff --git a/algorithms-modules/algorithms-miscellaneous-7/README.md b/algorithms-modules/algorithms-miscellaneous-7/README.md new file mode 100644 index 0000000000..918fcd21dd --- /dev/null +++ b/algorithms-modules/algorithms-miscellaneous-7/README.md @@ -0,0 +1,4 @@ +### Relevant Articles: + +- [Algorithm to Identify and Validate a Credit Card Number](https://www.baeldung.com/java-validate-cc-number) +- More articles: [[<-- prev]](/algorithms-miscellaneous-6) diff --git a/algorithms-modules/algorithms-miscellaneous-7/pom.xml b/algorithms-modules/algorithms-miscellaneous-7/pom.xml new file mode 100644 index 0000000000..3703ea5a16 --- /dev/null +++ b/algorithms-modules/algorithms-miscellaneous-7/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + algorithms-miscellaneous-7 + 0.0.1-SNAPSHOT + algorithms-miscellaneous-7 + + + com.baeldung + algorithms-modules + 1.0.0-SNAPSHOT + + + \ No newline at end of file diff --git a/algorithms-modules/algorithms-miscellaneous-7/src/main/java/com/baeldung/algorithms/luhn/LuhnChecker.java b/algorithms-modules/algorithms-miscellaneous-7/src/main/java/com/baeldung/algorithms/luhn/LuhnChecker.java new file mode 100644 index 0000000000..8f8bed4261 --- /dev/null +++ b/algorithms-modules/algorithms-miscellaneous-7/src/main/java/com/baeldung/algorithms/luhn/LuhnChecker.java @@ -0,0 +1,73 @@ +package com.baeldung.algorithms.luhn; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LuhnChecker { + + private static final Logger LOGGER = LoggerFactory.getLogger(LuhnChecker.class); + + /* + * Starting from the rightmost digit, we add all the digits together, performing + * a special step for every second digit. + * + * If the result is not divisible by 10, then the card number must not be valid. + * + * We can form a number that passes the Luhn Check by subtracting the result of + * the Luhn algorithm from 10. + * + * This is how the final digit of a credit card is calculated. + */ + public static boolean checkLuhn(String cardNumber) { + int sum = 0; + + try { + for (int i = cardNumber.length() - 1; i >= 0; i--) { + int digit = Integer.parseInt(cardNumber.substring(i, i + 1)); + + if ((cardNumber.length() - i) % 2 == 0) { + digit = doubleAndSumDigits(digit); + } + + sum += digit; + } + + LOGGER.info("Luhn Algorithm sum of digits is " + sum); + + } catch (NumberFormatException e) { + LOGGER.error("NumberFormatException - Card number probably contained some non-numeric characters, returning false"); + return false; + } catch (NullPointerException e) { + LOGGER.error("Null pointer - Card number was probably null, returning false"); + return false; + } + + boolean result = sum % 10 == 0; + + LOGGER.info("Luhn check result (sum divisible by 10): " + result); + + return result; + } + + /* + * We apply this method to every second number from the right of the card + * number. First, we double the digit, then we sum the digits. + * + * Note: subtracting 9 is equivalent to doubling and summing digits (when + * starting with a single digit) 0-4 -> produce single digit when doubled + * 5*2 = 10 -> 1+0 = 1 = 10-9 + * 6*2 = 12 -> 1+3 = 3 = 12-9 + * 7*2 = 14 -> 1+5 = 5 = 14-9 + * 8*2 = 16 -> 1+7 = 7 = 16-9 + * 9*2 = 18 -> 1+9 = 9 = 18-9 + */ + public static int doubleAndSumDigits(int digit) { + int ret = digit * 2; + + if (ret > 9) { + ret -= 9; + } + + return ret; + } +} diff --git a/apache-shiro/src/main/resources/logback.xml b/algorithms-modules/algorithms-miscellaneous-7/src/main/resources/logback.xml similarity index 100% rename from apache-shiro/src/main/resources/logback.xml rename to algorithms-modules/algorithms-miscellaneous-7/src/main/resources/logback.xml diff --git a/algorithms-modules/algorithms-miscellaneous-7/src/test/java/com/baeldung/algorithms/luhn/LuhnCheckerUnitTest.java b/algorithms-modules/algorithms-miscellaneous-7/src/test/java/com/baeldung/algorithms/luhn/LuhnCheckerUnitTest.java new file mode 100644 index 0000000000..dd1b184b81 --- /dev/null +++ b/algorithms-modules/algorithms-miscellaneous-7/src/test/java/com/baeldung/algorithms/luhn/LuhnCheckerUnitTest.java @@ -0,0 +1,63 @@ +package com.baeldung.algorithms.luhn; + +import org.junit.Assert; +import org.junit.Test; + +public class LuhnCheckerUnitTest { + + @Test + public void whenCardNumberDoesMeetLuhnCriteria_thenCheckLuhnReturnsTrue() { + String cardNumber = "8649"; + boolean result = LuhnChecker.checkLuhn(cardNumber); + Assert.assertTrue(result); + } + + @Test + public void whenCardNumberDoesNotMeetLuhnCriteria_thenCheckLuhnReturnsFalse() { + String cardNumber = "8642"; + boolean result = LuhnChecker.checkLuhn(cardNumber); + Assert.assertFalse(result); + } + + @Test + public void whenCardNumberHasNoSecondDigits_thenCheckLuhnCalculatesCorrectly() { + String cardNumber = "0505050505050505"; + boolean result = LuhnChecker.checkLuhn(cardNumber); + Assert.assertTrue(result); + } + + @Test + public void whenCardNumberHasSecondDigits_thenCheckLuhnCalculatesCorrectly() { + String cardNumber = "75757575757575"; + boolean result = LuhnChecker.checkLuhn(cardNumber); + Assert.assertTrue(result); + } + + @Test + public void whenDoubleAndSumDigitsIsCalled_thenOutputIsCorrect() { + Assert.assertEquals(LuhnChecker.doubleAndSumDigits(0), 0); + Assert.assertEquals(LuhnChecker.doubleAndSumDigits(1), 2); + Assert.assertEquals(LuhnChecker.doubleAndSumDigits(2), 4); + Assert.assertEquals(LuhnChecker.doubleAndSumDigits(3), 6); + Assert.assertEquals(LuhnChecker.doubleAndSumDigits(4), 8); + Assert.assertEquals(LuhnChecker.doubleAndSumDigits(5), 1); + Assert.assertEquals(LuhnChecker.doubleAndSumDigits(6), 3); + Assert.assertEquals(LuhnChecker.doubleAndSumDigits(7), 5); + Assert.assertEquals(LuhnChecker.doubleAndSumDigits(8), 7); + Assert.assertEquals(LuhnChecker.doubleAndSumDigits(9), 9); + } + + @Test + public void whenCardNumberNonNumeric_thenCheckLuhnReturnsFalse() { + String cardNumber = "test"; + boolean result = LuhnChecker.checkLuhn(cardNumber); + Assert.assertFalse(result); + } + + @Test + public void whenCardNumberIsNull_thenCheckLuhnReturnsFalse() { + String cardNumber = null; + boolean result = LuhnChecker.checkLuhn(cardNumber); + Assert.assertFalse(result); + } +} diff --git a/algorithms-modules/pom.xml b/algorithms-modules/pom.xml index 4ba819cfe3..4a5f36c944 100644 --- a/algorithms-modules/pom.xml +++ b/algorithms-modules/pom.xml @@ -21,6 +21,7 @@ algorithms-miscellaneous-4 algorithms-miscellaneous-5 algorithms-miscellaneous-6 + algorithms-miscellaneous-7 algorithms-searching algorithms-sorting algorithms-sorting-2 diff --git a/apache-cxf-modules/pom.xml b/apache-cxf-modules/pom.xml index fc1cf4fa0f..63c4e16747 100644 --- a/apache-cxf-modules/pom.xml +++ b/apache-cxf-modules/pom.xml @@ -5,7 +5,7 @@ 4.0.0 apache-cxf-modules 0.0.1-SNAPSHOT - apache-cxf + apache-cxf-modules pom diff --git a/apache-kafka-2/README.md b/apache-kafka-2/README.md new file mode 100644 index 0000000000..ec9e8e2adc --- /dev/null +++ b/apache-kafka-2/README.md @@ -0,0 +1,9 @@ +## Apache Kafka + +This module contains articles about Apache Kafka. + +##### Building the project +You can build the project from the command line using: *mvn clean install*, or in an IDE. + +### Relevant Articles: +- [Guide to Check if Apache Kafka Server Is Running](https://www.baeldung.com/apache-kafka-check-server-is-running) diff --git a/apache-kafka-2/log4j.properties b/apache-kafka-2/log4j.properties new file mode 100644 index 0000000000..2173c5d96f --- /dev/null +++ b/apache-kafka-2/log4j.properties @@ -0,0 +1 @@ +log4j.rootLogger=INFO, stdout diff --git a/apache-kafka-2/pom.xml b/apache-kafka-2/pom.xml new file mode 100644 index 0000000000..45a3620598 --- /dev/null +++ b/apache-kafka-2/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + apache-kafka-2 + apache-kafka-2 + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.apache.kafka + kafka-clients + ${kafka.version} + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + org.slf4j + slf4j-log4j12 + ${org.slf4j.version} + + + com.google.guava + guava + ${guava.version} + + + org.testcontainers + kafka + ${testcontainers-kafka.version} + test + + + org.testcontainers + junit-jupiter + ${testcontainers-jupiter.version} + test + + + net.java.dev.jna + jna + 5.7.0 + test + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + + 2.8.0 + 1.15.3 + 1.15.3 + + + \ No newline at end of file diff --git a/apache-kafka-2/src/main/java/com/baeldung/kafka/KafkaAdminClient.java b/apache-kafka-2/src/main/java/com/baeldung/kafka/KafkaAdminClient.java new file mode 100644 index 0000000000..e86dd74bda --- /dev/null +++ b/apache-kafka-2/src/main/java/com/baeldung/kafka/KafkaAdminClient.java @@ -0,0 +1,35 @@ +package com.baeldung.kafka; + +import java.util.Collection; +import java.util.Properties; +import java.util.concurrent.ExecutionException; + +import org.apache.kafka.clients.admin.AdminClient; +import org.apache.kafka.common.Node; + +public class KafkaAdminClient { + private final AdminClient client; + + public KafkaAdminClient(String bootstrap) { + Properties props = new Properties(); + props.put("bootstrap.servers", bootstrap); + props.put("request.timeout.ms", 3000); + props.put("connections.max.idle.ms", 5000); + + this.client = AdminClient.create(props); + } + + public boolean verifyConnection() throws ExecutionException, InterruptedException { + Collection nodes = this.client.describeCluster() + .nodes() + .get(); + return nodes != null && nodes.size() > 0; + } + + public static void main(String[] args) throws ExecutionException, InterruptedException { + String defaultBootStrapServer = "localhost:9092"; + KafkaAdminClient kafkaAdminClient = new KafkaAdminClient(defaultBootStrapServer); + System.out.println(kafkaAdminClient.verifyConnection()); + } + +} diff --git a/apache-kafka-2/src/test/java/com/baeldung/kafka/KafkaConnectionLiveTest.java b/apache-kafka-2/src/test/java/com/baeldung/kafka/KafkaConnectionLiveTest.java new file mode 100644 index 0000000000..8ce604c37f --- /dev/null +++ b/apache-kafka-2/src/test/java/com/baeldung/kafka/KafkaConnectionLiveTest.java @@ -0,0 +1,39 @@ +package com.baeldung.kafka; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.testcontainers.containers.KafkaContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.utility.DockerImageName; + +import static org.assertj.core.api.Assertions.assertThat; + +// This live test needs a running Docker instance so that a kafka container can be created + +@Testcontainers +class KafkaConnectionLiveTest { + + @Container + private static final KafkaContainer KAFKA_CONTAINER = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:5.4.3")); + private KafkaAdminClient kafkaAdminClient; + + @BeforeEach + void setup() { + KAFKA_CONTAINER.addExposedPort(9092); + this.kafkaAdminClient = new KafkaAdminClient(KAFKA_CONTAINER.getBootstrapServers()); + } + + @AfterEach + void destroy() { + KAFKA_CONTAINER.stop(); + } + + @Test + void givenKafkaIsRunning_whenCheckedForConnection_thenConnectionIsVerified() throws Exception { + boolean alive = kafkaAdminClient.verifyConnection(); + assertThat(alive).isTrue(); + } + +} \ No newline at end of file diff --git a/apache-kafka/pom.xml b/apache-kafka/pom.xml index b373d78dd1..7bde041f32 100644 --- a/apache-kafka/pom.xml +++ b/apache-kafka/pom.xml @@ -173,7 +173,6 @@ 0.8.1-spark3.0-s_2.12 2.5.2 1.6.0-M1 - 1.18.20 \ No newline at end of file diff --git a/apache-olingo/src/main/resources/application.yml b/apache-olingo/src/main/resources/application.yml index 3e09ea8dd5..e97fec0031 100644 --- a/apache-olingo/src/main/resources/application.yml +++ b/apache-olingo/src/main/resources/application.yml @@ -1,16 +1,19 @@ server: port: 8080 - + spring: jersey: application-path: /odata - + jpa: defer-datasource-initialization: true show-sql: true open-in-view: false hibernate: ddl-auto: update + properties: + hibernate: + globally_quoted_identifiers: true sql: init: diff --git a/apache-olingo/src/main/resources/data.sql b/apache-olingo/src/main/resources/data.sql index 327f2688c5..e872cec10f 100644 --- a/apache-olingo/src/main/resources/data.sql +++ b/apache-olingo/src/main/resources/data.sql @@ -1,12 +1,10 @@ -insert into car_maker(id,name) values (1,'Special Motors'); -insert into car_maker(id,name) values (2,'BWM'); -insert into car_maker(id,name) values (3,'Dolores'); +insert into "car_maker"("id", "name") values (1,'Special Motors'); +insert into "car_maker"("id", "name") values (2,'BWM'); +insert into "car_maker"("id", "name") values (3,'Dolores'); -insert into car_model(id,maker_fk,name,sku,year) values(1,1,'Muze','SM001',2018); -insert into car_model(id,maker_fk,name,sku,year) values(2,1,'Empada','SM002',2008); +insert into "car_model"("id", "maker_fk", "name", "sku", "year") values(1,1,'Muze','SM001',2018); +insert into "car_model"("id", "maker_fk", "name", "sku", "year") values(2,1,'Empada','SM002',2008); -insert into car_model(id,maker_fk,name,sku,year) values(4,2,'BWM-100','BWM100',2008); -insert into car_model(id,maker_fk,name,sku,year) values(5,2,'BWM-200','BWM200',2009); -insert into car_model(id,maker_fk,name,sku,year) values(6,2,'BWM-300','BWM300',2008); - -alter sequence hibernate_sequence restart with 100; \ No newline at end of file +insert into "car_model"("id", "maker_fk", "name", "sku", "year") values(4,2,'BWM-100','BWM100',2008); +insert into "car_model"("id", "maker_fk", "name", "sku", "year") values(5,2,'BWM-200','BWM200',2009); +insert into "car_model"("id", "maker_fk", "name", "sku", "year") values(6,2,'BWM-300','BWM300',2008); diff --git a/core-java-modules/core-java-collections-list-4/README.md b/core-java-modules/core-java-collections-list-4/README.md index 34b680e7dc..61401f1de7 100644 --- a/core-java-modules/core-java-collections-list-4/README.md +++ b/core-java-modules/core-java-collections-list-4/README.md @@ -8,4 +8,5 @@ This module contains articles about the Java List collection - [Sort a List Alphabetically in Java](https://www.baeldung.com/java-sort-list-alphabetically) - [Arrays.asList() vs Collections.singletonList()](https://www.baeldung.com/java-aslist-vs-singletonlist) - [Replace Element at a Specific Index in a Java ArrayList](https://www.baeldung.com/java-arraylist-replace-at-index) +- [Difference Between Arrays.asList() and List.of()](https://www.baeldung.com/java-arrays-aslist-vs-list-of) - [[<-- Prev]](/core-java-modules/core-java-collections-list-3) diff --git a/core-java-modules/core-java-collections-list-4/pom.xml b/core-java-modules/core-java-collections-list-4/pom.xml index ef815b790d..ab4ba37568 100644 --- a/core-java-modules/core-java-collections-list-4/pom.xml +++ b/core-java-modules/core-java-collections-list-4/pom.xml @@ -64,6 +64,23 @@ 1.2.0 3.0 3.22.0 + 17 + 17 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source.version} + ${maven.compiler.target.version} + + + + - \ No newline at end of file + diff --git a/core-java-modules/core-java-collections-list-4/src/test/java/com/baeldung/list/creation/ArraysAsListUnitTest.java b/core-java-modules/core-java-collections-list-4/src/test/java/com/baeldung/list/creation/ArraysAsListUnitTest.java new file mode 100644 index 0000000000..732dd6a35a --- /dev/null +++ b/core-java-modules/core-java-collections-list-4/src/test/java/com/baeldung/list/creation/ArraysAsListUnitTest.java @@ -0,0 +1,56 @@ +package com.baeldung.list.creation; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +class ArraysAsListUnitTest { + + @Test + void givenAnArrayOfIntegersWhenCreatingAListUsingArraysAsListThenItWillHaveTheSameElementsInTheSameOrder() { + Integer[] array = new Integer[]{1, 2, 3, 4}; + List list = Arrays.asList(array); + assertThat(list).containsExactly(1, 2, 3, 4); + } + + @Test + void givenAnListOfIntegersCreatedUsingArraysAsListWhenChangingTheOriginalArrayTheReturnListWillAlsoChange() { + Integer[] array = new Integer[]{1, 2, 3}; + List list = Arrays.asList(array); + array[0] = 1000; + assertThat(list.get(0)).isEqualTo(1000); + } + + @Test + void givenAnListOfIntegersCreatedUsingArraysAsListWhenChangingTheReturnedListTheOriginalArrayWillAlsoChange() { + Integer[] array = new Integer[]{1, 2, 3}; + List list = Arrays.asList(array); + list.set(0, 1000); + assertThat(array[0]).isEqualTo(1000); + } + + @Test + void givenAnArrayOfIntegersCreatedUsingArraysAsListWhenModifyingAnExistingElementThenModifyIt() { + List list = Arrays.asList(1, 2, 3, 4); + list.set(1, 1000); + assertThat(list.get(1)).isEqualTo(1000); + } + + @Test + void givenAnArrayCreatedWithArraysAsListWhenAddingANewElementThenUnsupportedOperationExceptionIsThrown() { + List list = Arrays.asList(1, 2, 3, 4, 5); + assertThrows(UnsupportedOperationException.class, () -> list.add(6)); + } + + @Test + void givenAnArrayCreatedWithArraysAsListWhenRemovingAnExistingElementThenUnsupportedOperationExceptionIsThrown() { + List list = Arrays.asList(1, 2, 3, 4, 5); + assertThrows(UnsupportedOperationException.class, () -> list.remove(1)); + } + + +} diff --git a/core-java-modules/core-java-collections-list-4/src/test/java/com/baeldung/list/creation/ListOfUnitTest.java b/core-java-modules/core-java-collections-list-4/src/test/java/com/baeldung/list/creation/ListOfUnitTest.java new file mode 100644 index 0000000000..5fe65e965f --- /dev/null +++ b/core-java-modules/core-java-collections-list-4/src/test/java/com/baeldung/list/creation/ListOfUnitTest.java @@ -0,0 +1,51 @@ +package com.baeldung.list.creation; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +class ListOfUnitTest { + + @Test + void givenAnArrayOfStringWhenCreatingAListUsingItsValuesThenItWillHaveTheSameElementsInTheSameOrder() { + String[] array = new String[]{"one", "two", "three"}; + List list = List.of(array); + assertThat(list).containsExactly("one", "two", "three"); + } + + @Test + void givenAnListOfStringCreatedUsingListOfWhenChangingTheOriginalArrayTheReturnListWontChange() { + String[] array = new String[]{"one", "two", "three"}; + List list = List.of(array); + array[0] = "thousand"; + assertThat(list.get(0)).isEqualTo("one"); + } + + @Test + void givenAnArrayCreatedWithListOfWhenAddingANewElementThenUnsupportedOperationExceptionIsThrown() { + List list = List.of("one", "two", "three"); + assertThrows(UnsupportedOperationException.class, () -> list.add("four")); + } + + @Test + void givenAnArrayCreatedWithListOfWhenRemovingAnExistingElementThenUnsupportedOperationExceptionIsThrown() { + List list = List.of("one", "two", "three"); + assertThrows(UnsupportedOperationException.class, () -> list.remove("two")); + } + + @Test + void givenAnArrayCreatedWithListOfWhenModifyingAnExistingElementThenUnsupportedOperationExceptionIsThrown() { + List list = List.of("one", "two", "three"); + assertThrows(UnsupportedOperationException.class, () -> list.set(1, "four")); + } + + @Test + void givenAnArrayContainingNullElementWhenUsingItToCreateListThenNullPointerExceptionIsThrown() { + assertThrows(NullPointerException.class, () -> List.of("one", null, "two")); + } + + +} diff --git a/core-java-modules/core-java-concurrency-advanced-2/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleUnitTest.java b/core-java-modules/core-java-concurrency-advanced-2/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleManualTest.java similarity index 86% rename from core-java-modules/core-java-concurrency-advanced-2/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleUnitTest.java rename to core-java-modules/core-java-concurrency-advanced-2/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleManualTest.java index d2d43f6312..45c5a93d02 100644 --- a/core-java-modules/core-java-concurrency-advanced-2/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleUnitTest.java +++ b/core-java-modules/core-java-concurrency-advanced-2/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleManualTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; -public class CountdownLatchResetExampleUnitTest { +public class CountdownLatchResetExampleManualTest { @Test public void whenCountDownLatch_noReset() { diff --git a/core-java-modules/core-java-concurrency-advanced-4/README.md b/core-java-modules/core-java-concurrency-advanced-4/README.md index b9881fd475..376c5cc711 100644 --- a/core-java-modules/core-java-concurrency-advanced-4/README.md +++ b/core-java-modules/core-java-concurrency-advanced-4/README.md @@ -8,3 +8,4 @@ - [Acquire a Lock by a Key in Java](https://www.baeldung.com/java-acquire-lock-by-key) - [Differences Between set() and lazySet() in Java Atomic Variables](https://www.baeldung.com/java-atomic-set-vs-lazyset) - [Volatile vs. Atomic Variables in Java](https://www.baeldung.com/java-volatile-vs-atomic) +- [What Is “Locked Ownable Synchronizers” in Thread Dump?](https://www.baeldung.com/locked-ownable-synchronizers) diff --git a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/ownablesynchronizers/Application.java b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/ownablesynchronizers/Application.java new file mode 100644 index 0000000000..d09c59fedc --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/ownablesynchronizers/Application.java @@ -0,0 +1,45 @@ +package com.baeldung.ownablesynchronizers; + +import java.util.concurrent.locks.ReentrantLock; + +public class Application { + + public static Thread createThread(ReentrantLock mainLock, ReentrantLock otherLock, String threadName) { + return new Thread(() -> { + try { + mainLock.lock(); + + // synchronized block here allows us to wait for other thread to lock, + // in order to simulate a deadlock + synchronized (Application.class) { + Application.class.notify(); + if (!otherLock.isLocked()) { + Application.class.wait(); + } + } + + // thread will hang here + otherLock.lock(); + + System.out.println(threadName + ": Finished"); + mainLock.unlock(); + otherLock.unlock(); + } catch (InterruptedException e) { + System.out.println(threadName + ": " + e.getMessage()); + } + }); + } + + public static void main(String[] args) throws Exception { + ReentrantLock firstLock = new ReentrantLock(true); + ReentrantLock secondLock = new ReentrantLock(true); + Thread first = createThread(firstLock, secondLock, "Thread-0"); + Thread second = createThread(secondLock, firstLock, "Thread-1"); + + first.start(); + second.start(); + + first.join(); + second.join(); + } +} diff --git a/core-java-modules/core-java-concurrency-simple/pom.xml b/core-java-modules/core-java-concurrency-simple/pom.xml index 153d76d0d5..bbb65f96d4 100644 --- a/core-java-modules/core-java-concurrency-simple/pom.xml +++ b/core-java-modules/core-java-concurrency-simple/pom.xml @@ -2,9 +2,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - java-concurrency-simple + core-java-concurrency-simple 0.1.0-SNAPSHOT - java-concurrency-simple + core-java-concurrency-simple jar @@ -14,7 +14,7 @@ - java-concurrency-simple + core-java-concurrency-simple src/main/resources diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/JarAppUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/JarAppUnitTest.java index dc8c54eb31..707ce79624 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/JarAppUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/JarAppUnitTest.java @@ -7,6 +7,6 @@ public class JarAppUnitTest { @Test public void findClassTest(){ - Assert.assertTrue(JarApp.findObjectMapperClass().endsWith("jackson-databind-2.13.0.jar")); + Assert.assertTrue(JarApp.findObjectMapperClass().endsWith("jackson-databind-2.13.3.jar")); } } diff --git a/core-java-modules/core-java-lang-5/README.md b/core-java-modules/core-java-lang-5/README.md index 9505d02fc2..84e9a575c2 100644 --- a/core-java-modules/core-java-lang-5/README.md +++ b/core-java-modules/core-java-lang-5/README.md @@ -6,3 +6,4 @@ This module contains articles about core features in the Java language - [Difference Between == and equals() in Java](https://www.baeldung.com/java-equals-method-operator-difference) - [Advantages and Disadvantages of Using Java Wildcard Imports](https://www.baeldung.com/java-wildcard-imports) +- [Toggle a Boolean Variable in Java](https://www.baeldung.com/java-toggle-boolean) diff --git a/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/toggleboolean/ToggleBoolean.java b/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/toggleboolean/ToggleBoolean.java new file mode 100644 index 0000000000..e68ff31d05 --- /dev/null +++ b/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/toggleboolean/ToggleBoolean.java @@ -0,0 +1,10 @@ +package com.baeldung.toggleboolean; + +public class ToggleBoolean { + public static Boolean toggle(Boolean b) { + if (b == null) { + return b; + } + return !b; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-lang-5/src/test/java/com/baeldung/toggleboolean/ToggleBooleanUnitTest.java b/core-java-modules/core-java-lang-5/src/test/java/com/baeldung/toggleboolean/ToggleBooleanUnitTest.java new file mode 100644 index 0000000000..2490281477 --- /dev/null +++ b/core-java-modules/core-java-lang-5/src/test/java/com/baeldung/toggleboolean/ToggleBooleanUnitTest.java @@ -0,0 +1,60 @@ +package com.baeldung.toggleboolean; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +class ToggleBooleanUnitTest { + @Test + void givenPrimitiveBoolean_whenUsingNotOperator_shouldToggleTheBoolean() { + boolean b = true; + b = !b; + assertFalse(b); + + b = !b; + assertTrue(b); + } + + @Test + void givenNullBoxedBoolean_whenUsingNotOperator_shouldThrowNPE() { + assertThatThrownBy(() -> { + Boolean b = null; + b = !b; + }).isInstanceOf(NullPointerException.class); + } + + @Test + void givenPrimitiveBoolean_whenUsingXorOperator_shouldToggleTheBoolean() { + boolean b = true; + b ^= true; + assertFalse(b); + + b ^= true; + assertTrue(b); + } + + @Test + void givenBooleanObj_whenToggle_shouldGetExpectedResult() { + //boxed Boolean + Boolean b = true; + b = ToggleBoolean.toggle(b); + assertFalse(b); + + b = ToggleBoolean.toggle(b); + assertTrue(b); + + b = null; + b = ToggleBoolean.toggle(b); + assertNull(b); + + //primitive boolean + boolean bb = true; + bb = ToggleBoolean.toggle(bb); + assertFalse(bb); + bb = ToggleBoolean.toggle(bb); + assertTrue(bb); + } +} diff --git a/core-java-modules/core-java-lang-oop-methods/pom.xml b/core-java-modules/core-java-lang-oop-methods/pom.xml index bba1365719..6f246d78ce 100644 --- a/core-java-modules/core-java-lang-oop-methods/pom.xml +++ b/core-java-modules/core-java-lang-oop-methods/pom.xml @@ -33,7 +33,6 @@ - 1.18.22 2.6 3.10.0 3.0.3 diff --git a/core-java-modules/core-java-networking-3/pom.xml b/core-java-modules/core-java-networking-3/pom.xml index 63385c2334..91ae7ccc3f 100644 --- a/core-java-modules/core-java-networking-3/pom.xml +++ b/core-java-modules/core-java-networking-3/pom.xml @@ -90,7 +90,6 @@ 1.32 0.17 1.6.2 - 31.0-jre \ No newline at end of file diff --git a/core-java-modules/core-java-numbers-5/README.md b/core-java-modules/core-java-numbers-5/README.md index d7e37d0ee7..f54894a227 100644 --- a/core-java-modules/core-java-numbers-5/README.md +++ b/core-java-modules/core-java-numbers-5/README.md @@ -1,3 +1,5 @@ ### Relevant Articles: - [Check if a Number Is Odd or Even](https://www.baeldung.com/java-check-number-parity) - [How to Check Whether an Integer Exists in a Range with Java](https://www.baeldung.com/java-interval-contains-integer) +- [Check if a Number Is Positive or Negative in Java](https://www.baeldung.com/java-check-number-positive-negative) +- [Armstrong Numbers in Java](https://www.baeldung.com/java-armstrong-numbers) diff --git a/core-java-modules/core-java-numbers-5/src/main/java/com/baeldung/armstrong/ArmstrongNumberUtil.java b/core-java-modules/core-java-numbers-5/src/main/java/com/baeldung/armstrong/ArmstrongNumberUtil.java new file mode 100644 index 0000000000..79129db009 --- /dev/null +++ b/core-java-modules/core-java-numbers-5/src/main/java/com/baeldung/armstrong/ArmstrongNumberUtil.java @@ -0,0 +1,44 @@ +package com.baeldung.armstrong; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class ArmstrongNumberUtil { + + public static boolean isArmstrong(int n) { + if (n < 0) { + return false; + } + List digitsList = digitsInList(n); + int len = digitsList.size(); + int sum = digitsList.stream() + .mapToInt(d -> (int) Math.pow(d, len)) + .sum(); + // alternatively, we can use the reduce() method: + // int sum = digits.stream() + // .reduce(0, (subtotal, digit) -> subtotal + (int) Math.pow(digit, len)); + return n == sum; + } + + private static List digitsInList(int n) { + List list = new ArrayList<>(); + while (n > 0) { + list.add(n % 10); + n = n / 10; + } + return list; + } + + public static List getA005188Sequence(int limit) { + if (limit < 0) { + throw new IllegalArgumentException("The limit cannot be a negative number."); + } + return IntStream.range(0, limit) + .boxed() + .filter(ArmstrongNumberUtil::isArmstrong) + .collect(Collectors.toList()); + + } +} diff --git a/core-java-modules/core-java-numbers-5/src/main/java/com/baeldung/positivenegative/PositiveOrNegative.java b/core-java-modules/core-java-numbers-5/src/main/java/com/baeldung/positivenegative/PositiveOrNegative.java new file mode 100644 index 0000000000..a580aa5ac5 --- /dev/null +++ b/core-java-modules/core-java-numbers-5/src/main/java/com/baeldung/positivenegative/PositiveOrNegative.java @@ -0,0 +1,38 @@ +package com.baeldung.positivenegative; + +public class PositiveOrNegative { + enum Result { + POSITIVE, NEGATIVE, ZERO + } + + public static Result byOperator(Integer integer) { + if (integer > 0) { + return Result.POSITIVE; + } else if (integer < 0) { + return Result.NEGATIVE; + } + return Result.ZERO; + } + + public static Result bySignum(Integer integer) { + int result = Integer.signum(integer); + + if (result == 1) { + return Result.POSITIVE; + } else if (result == -1) { + return Result.NEGATIVE; + } + return Result.ZERO; + } + + public static Result bySignum(Float floatNumber) { + float result = Math.signum(floatNumber); + + if (result == 1.0f) { + return Result.POSITIVE; + } else if (result == -1.0f) { + return Result.NEGATIVE; + } + return Result.ZERO; + } +} diff --git a/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/armstrong/ArmstrongNumberUtilUnitTest.java b/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/armstrong/ArmstrongNumberUtilUnitTest.java new file mode 100644 index 0000000000..78d362c8ef --- /dev/null +++ b/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/armstrong/ArmstrongNumberUtilUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.armstrong; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + +class ArmstrongNumberUtilUnitTest { + // @formatter:off +private static final Map ARMSTRONG_MAP = ImmutableMap.of( + 0, true, + 1, true, + 2, true, + 153, true, + 370, true, + 407, true, + 42, false, + 777, false, + 12345, false); + // @formatter:on + + private static final List A005188_SEQ_1K = ImmutableList.of(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407); + private static final List A005188_SEQ_10K = ImmutableList.of(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474); + + @Test + void givenIntegers_whenCheckArmstrong_shouldReturnExpectedResult() { + ARMSTRONG_MAP.forEach((number, result) -> assertEquals(result, ArmstrongNumberUtil.isArmstrong(number))); + } + + @Test + void givenALimit_whenFindArmstrong_shouldReturnExpectedResult() { + assertEquals(A005188_SEQ_1K, ArmstrongNumberUtil.getA005188Sequence(1000)); + assertEquals(A005188_SEQ_10K, ArmstrongNumberUtil.getA005188Sequence(10000)); + } +} diff --git a/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/positivenegative/PositiveOrNegativeUnitTest.java b/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/positivenegative/PositiveOrNegativeUnitTest.java new file mode 100644 index 0000000000..4807e8b928 --- /dev/null +++ b/core-java-modules/core-java-numbers-5/src/test/java/com/baeldung/positivenegative/PositiveOrNegativeUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.positivenegative; + +import org.junit.jupiter.api.Test; + +import static com.baeldung.positivenegative.PositiveOrNegative.Result.*; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class PositiveOrNegativeUnitTest { + @Test + void givenIntegers_whenChkPositiveOrNegativeByOperator_thenReturnExpectedResult() { + assertEquals(POSITIVE, PositiveOrNegative.byOperator(42)); + assertEquals(ZERO, PositiveOrNegative.byOperator(0)); + assertEquals(NEGATIVE, PositiveOrNegative.byOperator(-700)); + } + + @Test + void givenIntegers_whenChkPositiveOrNegativeBySignum_thenReturnExpectedResult() { + assertEquals(POSITIVE, PositiveOrNegative.bySignum(42)); + assertEquals(ZERO, PositiveOrNegative.bySignum(0)); + assertEquals(NEGATIVE, PositiveOrNegative.bySignum(-700)); + } + + @Test + void givenFloats_whenChkPositiveOrNegativeBySignum_thenReturnExpectedResult() { + assertEquals(POSITIVE, PositiveOrNegative.bySignum(4.2f)); + assertEquals(ZERO, PositiveOrNegative.bySignum(0f)); + assertEquals(NEGATIVE, PositiveOrNegative.bySignum(-7.7f)); + } +} diff --git a/core-java-modules/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml index 0c6c921df9..ef29e435a5 100644 --- a/core-java-modules/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -81,7 +81,6 @@ 1.9 0.4 1.8.7 - 1.18.22 \ No newline at end of file diff --git a/core-java-modules/core-java-streams-3/pom.xml b/core-java-modules/core-java-streams-3/pom.xml index c2dfdc392b..3074a647ff 100644 --- a/core-java-modules/core-java-streams-3/pom.xml +++ b/core-java-modules/core-java-streams-3/pom.xml @@ -66,8 +66,4 @@ - - 1.18.20 - - \ No newline at end of file diff --git a/core-java-modules/core-java-streams-4/README.md b/core-java-modules/core-java-streams-4/README.md index 80e4534b0f..212a42e362 100644 --- a/core-java-modules/core-java-streams-4/README.md +++ b/core-java-modules/core-java-streams-4/README.md @@ -3,3 +3,4 @@ - [Count Occurrences Using Java groupingBy Collector](https://www.baeldung.com/java-groupingby-count) - [How to Split a Stream into Multiple Streams](https://www.baeldung.com/java-split-stream) - [Filter Java Stream to 1 and Only 1 Element](https://www.baeldung.com/java-filter-stream-unique-element) +- [Java 8 Streams: Multiple Filters vs. Complex Condition](https://www.baeldung.com/java-streams-multiple-filters-vs-condition) diff --git a/core-java-modules/core-java-streams-4/pom.xml b/core-java-modules/core-java-streams-4/pom.xml index 65de1d666c..ed4603796d 100644 --- a/core-java-modules/core-java-streams-4/pom.xml +++ b/core-java-modules/core-java-streams-4/pom.xml @@ -53,6 +53,12 @@ jmh-generator-annprocess ${jmh-generator.version} + + org.apache.commons + commons-lang3 + 3.12.0 + test + diff --git a/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/MultipleFiltersVsComplexConditionFilterOrderUnitTest.java b/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/MultipleFiltersVsComplexConditionFilterOrderUnitTest.java new file mode 100644 index 0000000000..fcecc36631 --- /dev/null +++ b/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/MultipleFiltersVsComplexConditionFilterOrderUnitTest.java @@ -0,0 +1,89 @@ +package com.baeldung.streams.multiplefilters; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.IntStream; + +import org.junit.Before; +import org.junit.Test; + +public class MultipleFiltersVsComplexConditionFilterOrderUnitTest { + + AtomicInteger numberOfOperations = new AtomicInteger(); + + @Before + public void beforeEach() { + numberOfOperations.set(0); + } + + @Test + public void givenWrongFilterOrder_whenUsingMultipleFilters_shouldEvaluateManyConditions() { + long filteredStreamSize = IntStream.range(0, 100) + .boxed() + .filter(this::isEvenNumber) + .filter(this::isSmallerThanTwenty) + .count(); + + assertThat(filteredStreamSize).isEqualTo(10); + assertThat(numberOfOperations).hasValue(150); + } + + @Test + public void givenWrongFilterOrder_whenUsingSingleFilters_shouldEvaluateManyConditions() { + long filteredStreamSize = IntStream.range(0, 100) + .boxed() + .filter(i -> isEvenNumber(i) && isSmallerThanTwenty(i)) + .count(); + + assertThat(filteredStreamSize).isEqualTo(10); + assertThat(numberOfOperations).hasValue(150); + } + + @Test + public void givenCorrectFilterOrder_whenUsingMultipleFilters_shouldEvaluateFewerConditions() { + long filteredStreamSize = IntStream.range(0, 100) + .boxed() + .filter(this::isSmallerThanTwenty) + .filter(this::isEvenNumber) + .count(); + + assertThat(filteredStreamSize).isEqualTo(10); + assertThat(numberOfOperations).hasValue(120); + } + + @Test + public void givenCorrectFilterOrder_whenUsingHavingASlowCondition_shouldEvaluateFewerConditions() { + long filteredStreamSize = IntStream.range(0, 100) + .boxed() + .filter(this::isSmallerThanTwenty) + .filter(this::isEvenNumber) + .filter(this::verySlowFilter) + .count(); + + assertThat(filteredStreamSize).isEqualTo(10); + assertThat(numberOfOperations).hasValue(130); + } + + private boolean isEvenNumber(int i) { + numberOfOperations.incrementAndGet(); + return i % 2 == 0; + } + + private boolean isSmallerThanTwenty(int i) { + numberOfOperations.incrementAndGet(); + return i < 20; + } + + private boolean verySlowFilter(int i) { + numberOfOperations.incrementAndGet(); + // commented the Thread.sleep() not to slow down the pipeline. + // try { + // Thread.sleep(1000); + // } catch (InterruptedException e) { + // throw new RuntimeException(e); + // } + return true; + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/MultipleFiltersVsComplexConditionFilterPerformanceIntegrationTest.java b/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/MultipleFiltersVsComplexConditionFilterPerformanceIntegrationTest.java new file mode 100644 index 0000000000..1362431b07 --- /dev/null +++ b/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/MultipleFiltersVsComplexConditionFilterPerformanceIntegrationTest.java @@ -0,0 +1,130 @@ +package com.baeldung.streams.multiplefilters; + +import java.text.MessageFormat; +import java.util.function.Function; +import java.util.stream.IntStream; + +import org.apache.commons.lang3.time.StopWatch; +import org.junit.Test; + +public class MultipleFiltersVsComplexConditionFilterPerformanceIntegrationTest { + +// this test is slow, avoid running it on pipeline + @Test + public void measureProcessingTimeForEachSolution() { + + averageMultipleMeasurements("Stream with Multiple Filters", this::measureTimeForMultipleFilters, 10_000); + averageMultipleMeasurements("Stream with Multiple Filters", this::measureTimeForMultipleFilters, 100_000); + averageMultipleMeasurements("Stream with Multiple Filters", this::measureTimeForMultipleFilters, 10_00_000); + averageMultipleMeasurements("Stream with Multiple Filters", this::measureTimeForMultipleFilters, 1_0000_000); + + averageMultipleMeasurements("Stream with Complex Condition", this::measureTimeForComplexCondition, 10_000); + averageMultipleMeasurements("Stream with Complex Condition", this::measureTimeForComplexCondition, 100_000); + averageMultipleMeasurements("Stream with Complex Condition", this::measureTimeForComplexCondition, 10_00_000); + averageMultipleMeasurements("Stream with Complex Condition", this::measureTimeForComplexCondition, 1_0000_000); + + averageMultipleMeasurements("Parallel Stream with Multiple Filters", this::measureTimeForParallelStreamWithMultipleFilters, 10_000); + averageMultipleMeasurements("Parallel Stream with Multiple Filters", this::measureTimeForParallelStreamWithMultipleFilters, 100_000); + averageMultipleMeasurements("Parallel Stream with Multiple Filters", this::measureTimeForParallelStreamWithMultipleFilters, 10_00_000); + averageMultipleMeasurements("Parallel Stream with Multiple Filters", this::measureTimeForParallelStreamWithMultipleFilters, 1_0000_000); + + averageMultipleMeasurements("Parallel Stream with Complex Condition", this::measureTimeForParallelStreamWithComplexCondition, 10_000); + averageMultipleMeasurements("Parallel Stream with Complex Condition", this::measureTimeForParallelStreamWithComplexCondition, 100_000); + averageMultipleMeasurements("Parallel Stream with Complex Condition", this::measureTimeForParallelStreamWithComplexCondition, 10_00_000); + averageMultipleMeasurements("Parallel Stream with Complex Condition", this::measureTimeForParallelStreamWithComplexCondition, 1_0000_000); + + averageMultipleMeasurements("Old For Loop with Complex Condition", this::measureTimeForOlfForLoopWithComplexCondition, 10_000); + averageMultipleMeasurements("Old For Loop with Complex Condition", this::measureTimeForOlfForLoopWithComplexCondition, 100_000); + averageMultipleMeasurements("Old For Loop with Complex Condition", this::measureTimeForOlfForLoopWithComplexCondition, 10_00_000); + averageMultipleMeasurements("Old For Loop with Complex Condition", this::measureTimeForOlfForLoopWithComplexCondition, 1_0000_000); + + } + + private void averageMultipleMeasurements(String measurementName, Function measurement, int range) { + double avgTime = IntStream.range(0, 100) + .mapToLong(i -> measurement.apply(range)) + .average() + .orElseThrow(); + + System.out.println(MessageFormat.format("{0}; Stream size: {1}; Processing Time (ms): {2}", measurementName, range, avgTime)); + } + + public long measureTimeForMultipleFilters(int range) { + StopWatch watch = new StopWatch(); + watch.start(); + + IntStream.range(0, range) + .boxed() + .filter(i -> i != 10) + .filter(i -> i != 20) + .filter(i -> i != 30) + .filter(i -> i != 40) + .filter(i -> i != 50) + .filter(i -> i != 60) + .count(); + + watch.stop(); + return watch.getTime(); + } + + public long measureTimeForParallelStreamWithMultipleFilters(int range) { + StopWatch watch = new StopWatch(); + watch.start(); + + IntStream.range(0, range) + .boxed() + .parallel() + .filter(i -> i != 10) + .filter(i -> i != 20) + .filter(i -> i != 30) + .filter(i -> i != 40) + .filter(i -> i != 50) + .filter(i -> i != 60) + .count(); + + watch.stop(); + return watch.getTime(); + } + + public long measureTimeForComplexCondition(int range) { + StopWatch watch = new StopWatch(); + watch.start(); + + IntStream.range(0, range) + .boxed() + .filter(i -> i != 10 && i != 20 && i != 30 && i != 40 && i != 50 && i != 60) + .count(); + + watch.stop(); + return watch.getTime(); + } + + public long measureTimeForParallelStreamWithComplexCondition(int range) { + StopWatch watch = new StopWatch(); + watch.start(); + + IntStream.range(0, range) + .boxed() + .parallel() + .filter(i -> i != 10 && i != 20 && i != 30 && i != 40 && i != 50 && i != 60) + .count(); + + watch.stop(); + return watch.getTime(); + } + + public long measureTimeForOlfForLoopWithComplexCondition(int range) { + StopWatch watch = new StopWatch(); + watch.start(); + + int count = 0; + for (int i = 0; i <= range; i++) { + if (i != 10 && i != 20 && i != 30 && i != 40 && i != 50 && i != 60) { + count++; + } + } + + watch.stop(); + return watch.getTime(); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/MultipleFiltersVsComplexConditionReadabilityUnitTest.java b/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/MultipleFiltersVsComplexConditionReadabilityUnitTest.java new file mode 100644 index 0000000000..80fdb8a30a --- /dev/null +++ b/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/MultipleFiltersVsComplexConditionReadabilityUnitTest.java @@ -0,0 +1,65 @@ +package com.baeldung.streams.multiplefilters; + +import static java.util.function.Predicate.not; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.Before; +import org.junit.Test; + +public class MultipleFiltersVsComplexConditionReadabilityUnitTest { + + private List students; + private Student mathStudent; + + @Before + public void beforeEach() { + this.mathStudent = new Student(); + mathStudent.setName("John Doe"); + mathStudent.setYear(3); + mathStudent.setProfile(Student.Profile.MATH); + mathStudent.setMarks(List.of(80, 90, 77, 95, 100)); + + Student csStudent = new Student(); + csStudent.setName("Paul Atreides"); + csStudent.setYear(2); + csStudent.setProfile(Student.Profile.COMPUTER_SCIENCE); + csStudent.setMarks(List.of(30, 40, 60)); + + this.students = List.of(mathStudent, csStudent); + } + + @Test + public void whenUsingMultipleFilters_dataShouldBeFiltered() { + List filteredStream = students.stream() + .filter(s -> s.getMarksAverage() > 50) + .filter(s -> s.getMarks().size() > 3) + .filter(not(s -> s.getProfile() == Student.Profile.PHYSICS)) + .collect(Collectors.toList()); + + assertThat(filteredStream).containsExactly(mathStudent); + } + + @Test + public void whenUsingSingleComplexFilter_dataShouldBeFiltered() { + List filteredStream = students.stream() + .filter(s -> s.getMarksAverage() > 50 + && s.getMarks().size() > 3 + && s.getProfile() != Student.Profile.PHYSICS) + .collect(Collectors.toList()); + + assertThat(filteredStream).containsExactly(mathStudent); + } + + @Test + public void whenUsingSingleComplexFilterExtracted_dataShouldBeFiltered() { + List filteredStream = students.stream() + .filter(Student::isEligibleForScholarship) + .collect(Collectors.toList()); + + assertThat(filteredStream).containsExactly(mathStudent); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/Student.java b/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/Student.java new file mode 100644 index 0000000000..0e6b77ae2c --- /dev/null +++ b/core-java-modules/core-java-streams-4/src/test/java/com/baeldung/streams/multiplefilters/Student.java @@ -0,0 +1,60 @@ +package com.baeldung.streams.multiplefilters; + +import java.util.List; +import java.util.stream.Collectors; + +public class Student { + + private String name; + private int year; + private List marks; + private Profile profile; + + public enum Profile { + COMPUTER_SCIENCE, + MATH, + PHYSICS + } + + public double getMarksAverage() { + return marks.stream().collect(Collectors.averagingInt(m -> m)); + } + + public boolean isEligibleForScholarship() { + return getMarksAverage() > 50 + && marks.size() > 3 + && profile != Profile.PHYSICS; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public List getMarks() { + return marks; + } + + public void setMarks(List marks) { + this.marks = marks; + } + + public Profile getProfile() { + return profile; + } + + public void setProfile(Profile profile) { + this.profile = profile; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-string-conversions-2/README.md b/core-java-modules/core-java-string-conversions-2/README.md index 71f35c17b1..19f660534f 100644 --- a/core-java-modules/core-java-string-conversions-2/README.md +++ b/core-java-modules/core-java-string-conversions-2/README.md @@ -12,4 +12,5 @@ This module contains articles about string conversions from/to another type. - [Convert a ByteBuffer to String in Java](https://www.baeldung.com/java-bytebuffer-to-string) - [Convert String to Float and Back in Java](https://www.baeldung.com/java-string-to-float) - [Difference Between parseInt() and valueOf() in Java](https://www.baeldung.com/java-integer-parseint-vs-valueof) +- [Integer.toString() vs String.valueOf() in Java](https://www.baeldung.com/java-tostring-valueof) - More articles: [[<-- prev]](/core-java-modules/core-java-string-conversions) diff --git a/core-java-modules/core-java-string-conversions-2/src/test/java/com/baeldung/inttostring/IntToStringUnitTest.java b/core-java-modules/core-java-string-conversions-2/src/test/java/com/baeldung/inttostring/IntToStringUnitTest.java index b865d0933d..34a4097d05 100644 --- a/core-java-modules/core-java-string-conversions-2/src/test/java/com/baeldung/inttostring/IntToStringUnitTest.java +++ b/core-java-modules/core-java-string-conversions-2/src/test/java/com/baeldung/inttostring/IntToStringUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.chararraytostring; +package com.baeldung.inttostring; import static org.junit.Assert.assertEquals; @@ -23,7 +23,8 @@ public class IntToStringUnitTest { @Test(expected = NullPointerException.class) public void whenNullIntegerObjectIsPassed_thenShouldThrowException() { Integer i = null; - System.out.println(String.valueOf(i)); // it prints "null" - System.out.println(i.toString()); + // NOTE: primitive int can never be null, we are checking this example to check in what case the exception is thrown by these methods. + System.out.println(String.valueOf(i)); // prints "null" as the call goes to String.valueOf(Object obj) method + System.out.println(i.toString()); // throws NPE } } diff --git a/core-java-modules/core-java-string-operations-4/README.md b/core-java-modules/core-java-string-operations-4/README.md index 07af6d23c9..d420edff52 100644 --- a/core-java-modules/core-java-string-operations-4/README.md +++ b/core-java-modules/core-java-string-operations-4/README.md @@ -9,3 +9,4 @@ - [Check if a Character is a Vowel in Java](https://www.baeldung.com/java-check-character-vowel) - [How to Truncate a String in Java](https://www.baeldung.com/java-truncating-strings) - [Remove Whitespace From a String in Java](https://www.baeldung.com/java-string-remove-whitespace) +- [Named Placeholders in String Formatting](https://www.baeldung.com/java-string-formatting-named-placeholders) diff --git a/core-java-modules/core-java-time-measurements/pom.xml b/core-java-modules/core-java-time-measurements/pom.xml index cb2fd9fb40..ac5fb3a5e6 100644 --- a/core-java-modules/core-java-time-measurements/pom.xml +++ b/core-java-modules/core-java-time-measurements/pom.xml @@ -76,7 +76,6 @@ 3.6.1 2.10 - 1.18.22 1.8.9 1.44 4.1.0 diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 981374a4ef..22a7fdec1e 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -37,7 +37,6 @@ core-java-collections-list core-java-collections-list-2 core-java-collections-list-3 - core-java-collections-list-4 core-java-collections-maps core-java-collections-maps-2 core-java-collections-maps-3 diff --git a/docker-modules/docker-caching/multi-module-caching/pom.xml b/docker-modules/docker-caching/multi-module-caching/pom.xml index 7e279dc334..f85f00a28d 100644 --- a/docker-modules/docker-caching/multi-module-caching/pom.xml +++ b/docker-modules/docker-caching/multi-module-caching/pom.xml @@ -26,7 +26,7 @@ 1.8 - 31.0.1-jre + 31.1-jre \ No newline at end of file diff --git a/docker-modules/docker-caching/single-module-caching/pom.xml b/docker-modules/docker-caching/single-module-caching/pom.xml index d7f96e1e7e..aa9720a273 100644 --- a/docker-modules/docker-caching/single-module-caching/pom.xml +++ b/docker-modules/docker-caching/single-module-caching/pom.xml @@ -48,7 +48,7 @@ 8 8 - 31.0.1-jre + 31.1-jre \ No newline at end of file diff --git a/docker-modules/docker-compose/README.md b/docker-modules/docker-compose/README.md index 10554a319d..abafe0d165 100644 --- a/docker-modules/docker-compose/README.md +++ b/docker-modules/docker-compose/README.md @@ -4,4 +4,5 @@ - [How to Get Docker-Compose to Always Use the Latest Image](https://www.baeldung.com/ops/docker-compose-latest-image) - [Communication Between Multiple Docker Compose Projects](https://www.baeldung.com/ops/docker-compose-communication) - [Difference Between links and depends_on in Docker Compose](https://www.baeldung.com/ops/docker-compose-links-depends-on) +- [Mounting Multiple Volumes on a Docker Container](https://www.baeldung.com/ops/docker-mounting-multiple-volumes) diff --git a/gradle-modules/gradle-7/README.md b/gradle-modules/gradle-7/README.md new file mode 100644 index 0000000000..19dfc7b15c --- /dev/null +++ b/gradle-modules/gradle-7/README.md @@ -0,0 +1,4 @@ + +### Relevant Articles: + +- [How to Configure Conditional Dependencies in Gradle](https://www.baeldung.com/gradle-conditional-dependencies) diff --git a/graphql-modules/graphql-error-handling/pom.xml b/graphql-modules/graphql-error-handling/pom.xml index f10bb524fb..d89ff1509d 100644 --- a/graphql-modules/graphql-error-handling/pom.xml +++ b/graphql-modules/graphql-error-handling/pom.xml @@ -36,12 +36,10 @@ org.projectlombok lombok - ${lombok.version} com.h2database h2 - ${h2.version} org.springframework.boot @@ -51,13 +49,12 @@ com.graphql-java graphql-spring-boot-starter-test - test ${graphql-spring-boot-starter.version} + test org.skyscreamer jsonassert - ${jsonassert.version} test @@ -65,7 +62,6 @@ 5.0.2 5.2.4 - 1.5.0 \ No newline at end of file diff --git a/graphql-modules/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/exception/GraphQLErrorAdapter.java b/graphql-modules/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/exception/GraphQLErrorAdapter.java index d982f98db3..94f696a940 100644 --- a/graphql-modules/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/exception/GraphQLErrorAdapter.java +++ b/graphql-modules/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/exception/GraphQLErrorAdapter.java @@ -1,6 +1,6 @@ package com.baeldung.graphql.error.handling.exception; -import graphql.ErrorType; +import graphql.ErrorClassification; import graphql.ExceptionWhileDataFetching; import graphql.GraphQLError; import graphql.language.SourceLocation; @@ -27,7 +27,7 @@ public class GraphQLErrorAdapter implements GraphQLError { } @Override - public ErrorType getErrorType() { + public ErrorClassification getErrorType() { return error.getErrorType(); } diff --git a/jackson-modules/jackson-conversions-2/README.md b/jackson-modules/jackson-conversions-2/README.md index fa3568652a..0490f671dd 100644 --- a/jackson-modules/jackson-conversions-2/README.md +++ b/jackson-modules/jackson-conversions-2/README.md @@ -12,4 +12,5 @@ This module contains articles about Jackson conversions. - [Jackson: java.util.LinkedHashMap cannot be cast to X](https://www.baeldung.com/jackson-linkedhashmap-cannot-be-cast) - [Deserialize Snake Case to Camel Case With Jackson](https://www.baeldung.com/jackson-deserialize-snake-to-camel-case) - [Serialize and Deserialize Booleans as Integers With Jackson](https://www.baeldung.com/jackson-booleans-as-integers) +- [Reading JSON From a URL in Java](https://www.baeldung.com/java-read-json-from-url) - More articles: [[<-- prev]](../jackson-conversions) diff --git a/jackson-modules/jackson-conversions-2/pom.xml b/jackson-modules/jackson-conversions-2/pom.xml index 7e994fb52b..984d9b3a18 100644 --- a/jackson-modules/jackson-conversions-2/pom.xml +++ b/jackson-modules/jackson-conversions-2/pom.xml @@ -32,6 +32,18 @@ jackson-dataformat-csv ${jackson.version} + + + org.mock-server + mockserver-netty + ${mockserver-netty.version} + test + + + org.json + json + ${json.version} + @@ -44,4 +56,9 @@ + + 5.13.2 + 20220320 + + \ No newline at end of file diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/jsonurlreader/JsonUrlReader.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/jsonurlreader/JsonUrlReader.java new file mode 100644 index 0000000000..9c9f1fd7c4 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/jsonurlreader/JsonUrlReader.java @@ -0,0 +1,62 @@ +package com.baeldung.jackson.jsonurlreader; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.Charset; + +import org.apache.commons.io.IOUtils; +import org.json.JSONObject; + +import com.fasterxml.jackson.core.exc.StreamReadException; +import com.fasterxml.jackson.databind.DatabindException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class JsonUrlReader { + + public static void main(String[] args) throws StreamReadException, DatabindException, MalformedURLException, IOException { + String url = args[0]; + + JsonNode node = JsonUrlReader.get(url); + System.out.println(node.toPrettyString()); + } + + public static String stream(String url) throws IOException { + try (InputStream input = new URL(url).openStream()) { + InputStreamReader isr = new InputStreamReader(input, Charset.forName("UTF-8")); + BufferedReader reader = new BufferedReader(isr); + StringBuilder json = new StringBuilder(); + int c; + while ((c = reader.read()) != -1) { + json.append((char) c); + } + return json.toString(); + } + } + + public static JsonNode get(String url) throws StreamReadException, DatabindException, MalformedURLException, IOException { + ObjectMapper mapper = new ObjectMapper(); + JsonNode json = mapper.readTree(new URL(url)); + return json; + } + + public static T get(String url, Class type) throws StreamReadException, DatabindException, MalformedURLException, IOException { + ObjectMapper mapper = new ObjectMapper(); + T entity = mapper.readValue(new URL(url), type); + return entity; + } + + public static String getString(String url) throws StreamReadException, DatabindException, MalformedURLException, IOException { + return get(url).toPrettyString(); + } + + public static JSONObject getJson(String url) throws MalformedURLException, IOException { + String json = IOUtils.toString(new URL(url), Charset.forName("UTF-8")); + JSONObject object = new JSONObject(json); + return object; + } +} diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/jsonurlreader/data/Example.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/jsonurlreader/data/Example.java new file mode 100644 index 0000000000..062ee51b20 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/jsonurlreader/data/Example.java @@ -0,0 +1,40 @@ +package com.baeldung.jackson.jsonurlreader.data; + +public class Example { + private String name; + private Integer n; + private Boolean real; + + public Example() { + } + + public Example(String name, Integer n, Boolean real) { + this.name = name; + this.n = n; + this.real = real; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getN() { + return n; + } + + public void setN(Integer n) { + this.n = n; + } + + public Boolean getReal() { + return real; + } + + public void setReal(Boolean real) { + this.real = real; + } +} diff --git a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/jsonurlreader/JsonMockServer.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/jsonurlreader/JsonMockServer.java new file mode 100644 index 0000000000..5debc73e0f --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/jsonurlreader/JsonMockServer.java @@ -0,0 +1,62 @@ +package com.baeldung.jackson.jsonurlreader; + +import static org.mockserver.integration.ClientAndServer.startClientAndServer; +import static org.mockserver.model.HttpRequest.request; +import static org.mockserver.model.HttpResponse.response; + +import java.io.IOException; +import java.net.ServerSocket; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.mockserver.client.MockServerClient; +import org.mockserver.integration.ClientAndServer; +import org.mockserver.model.HttpStatusCode; + +import com.baeldung.jackson.jsonurlreader.data.Example; + +public class JsonMockServer { + protected static final String JSON_RESPONSE = "{ \"name\": \"A\", \"n\": 1, \"real\": true }"; + protected static final Example OBJECT_RESPONSE = new Example("A", 1, true); + + protected static String serviceUrl; + + private static final String SERVER_ADDRESS = "127.0.0.1"; + private static final String PATH = "/sample-json"; + + private static ClientAndServer mockServer; + private static int serverPort; + + @BeforeAll + static void startServer() throws IOException { + serverPort = getFreePort(); + serviceUrl = "http://" + SERVER_ADDRESS + ":" + serverPort + PATH; + + mockServer = startClientAndServer(serverPort); + + mockJsonRequest(); + } + + @AfterAll + static void stopServer() { + mockServer.stop(); + } + + @SuppressWarnings("resource") + private static void mockJsonRequest() { + new MockServerClient(SERVER_ADDRESS, serverPort) + .when(request() + .withPath(PATH) + .withMethod("GET")) + .respond(response() + .withStatusCode(HttpStatusCode.OK_200.code()) + .withBody(JSON_RESPONSE) + ); + } + + private static int getFreePort() throws IOException { + try (ServerSocket serverSocket = new ServerSocket(0)) { + return serverSocket.getLocalPort(); + } + } +} diff --git a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/jsonurlreader/JsonUrlReaderIntegrationTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/jsonurlreader/JsonUrlReaderIntegrationTest.java new file mode 100644 index 0000000000..b450ed5a83 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/jsonurlreader/JsonUrlReaderIntegrationTest.java @@ -0,0 +1,50 @@ +package com.baeldung.jackson.jsonurlreader; + +import static org.junit.Assert.assertEquals; + +import org.json.JSONObject; +import org.junit.jupiter.api.Test; + +import com.baeldung.jackson.jsonurlreader.data.Example; +import com.fasterxml.jackson.databind.JsonNode; + +public class JsonUrlReaderIntegrationTest extends JsonMockServer { + + @Test + public void whenStreamUrl_thenJsonStringReturned() throws Exception { + String jsonNode = JsonUrlReader.stream(serviceUrl); + + assertEquals(jsonNode, JSON_RESPONSE); + } + + @Test + public void whenGetUrl_thenJsonNodeReturned() throws Exception { + JsonNode jsonNode = JsonUrlReader.get(serviceUrl); + + assertEquals(jsonNode.get("name") + .textValue(), "A"); + assertEquals(jsonNode.get("n") + .intValue(), 1); + assertEquals(jsonNode.get("real") + .booleanValue(), true); + } + + @Test + public void givenType_whenGetUrl_thenTypeReturned() throws Exception { + Example object = JsonUrlReader.get(serviceUrl, Example.class); + + Integer n = 1; + assertEquals(object.getName(), "A"); + assertEquals(object.getN(), n); + assertEquals(object.getReal(), true); + } + + @Test + public void whenGetJsonUrl_thenJsonObjectReturned() throws Exception { + JSONObject jsonObject = JsonUrlReader.getJson(serviceUrl); + + assertEquals(jsonObject.getString("name"), "A"); + assertEquals(jsonObject.getInt("n"), 1); + assertEquals(jsonObject.getBoolean("real"), true); + } +} diff --git a/jhipster-modules/jhipster-microservice/pom.xml b/jhipster-modules/jhipster-microservice/pom.xml index 3d2d682d8e..ae58ad2203 100644 --- a/jhipster-modules/jhipster-microservice/pom.xml +++ b/jhipster-modules/jhipster-microservice/pom.xml @@ -7,7 +7,7 @@ pom - jhipster + jhipster-modules com.baeldung.jhipster 1.0.0-SNAPSHOT diff --git a/jhipster-modules/jhipster-monolithic/pom.xml b/jhipster-modules/jhipster-monolithic/pom.xml index 28cfc16859..ac483fdae6 100644 --- a/jhipster-modules/jhipster-monolithic/pom.xml +++ b/jhipster-modules/jhipster-monolithic/pom.xml @@ -7,7 +7,7 @@ JHipster Monolithic Application - jhipster + jhipster-modules com.baeldung.jhipster 1.0.0-SNAPSHOT diff --git a/jhipster-modules/jhipster-uaa/pom.xml b/jhipster-modules/jhipster-uaa/pom.xml index a59b19d1fd..b90b59047d 100644 --- a/jhipster-modules/jhipster-uaa/pom.xml +++ b/jhipster-modules/jhipster-uaa/pom.xml @@ -7,7 +7,7 @@ pom - jhipster + jhipster-modules com.baeldung.jhipster 1.0.0-SNAPSHOT diff --git a/jhipster-modules/pom.xml b/jhipster-modules/pom.xml index 8954ef0703..789666ffb6 100644 --- a/jhipster-modules/pom.xml +++ b/jhipster-modules/pom.xml @@ -3,9 +3,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.baeldung.jhipster - jhipster + jhipster-modules 1.0.0-SNAPSHOT - jhipster + jhipster-modules pom diff --git a/json-modules/gson/pom.xml b/json-modules/gson/pom.xml index 45054b6664..faa8a48297 100644 --- a/json-modules/gson/pom.xml +++ b/json-modules/gson/pom.xml @@ -67,7 +67,6 @@ 2.8.0 2.9.6 - 11.0.2 \ No newline at end of file diff --git a/json-modules/json/pom.xml b/json-modules/json/pom.xml index 04a00598a3..8a9f4f2c45 100644 --- a/json-modules/json/pom.xml +++ b/json-modules/json/pom.xml @@ -15,17 +15,11 @@ - - org.everit.json - org.everit.json.schema - ${everit.json.schema.version} - - - commons-logging - commons-logging - - - + + com.networknt + json-schema-validator + ${networknt.json.schema.version} + org.json json @@ -72,7 +66,7 @@ - 1.4.1 + 1.0.72 1.0 1.0.1 20211205 diff --git a/json-modules/json/src/test/java/com/baeldung/json/schema/JSONSchemaUnitTest.java b/json-modules/json/src/test/java/com/baeldung/json/schema/JSONSchemaUnitTest.java index 393e052b95..491c320341 100644 --- a/json-modules/json/src/test/java/com/baeldung/json/schema/JSONSchemaUnitTest.java +++ b/json-modules/json/src/test/java/com/baeldung/json/schema/JSONSchemaUnitTest.java @@ -1,32 +1,44 @@ package com.baeldung.json.schema; -import org.everit.json.schema.Schema; -import org.everit.json.schema.ValidationException; -import org.everit.json.schema.loader.SchemaLoader; +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.util.Set; -import org.json.JSONObject; -import org.json.JSONTokener; import org.junit.Test; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.networknt.schema.JsonSchema; +import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SpecVersion; +import com.networknt.schema.ValidationMessage; + public class JSONSchemaUnitTest { - @Test(expected = ValidationException.class) - public void givenInvalidInput_whenValidating_thenInvalid() { + private ObjectMapper mapper = new ObjectMapper(); - JSONObject jsonSchema = new JSONObject(new JSONTokener(JSONSchemaUnitTest.class.getResourceAsStream("/schema.json"))); - JSONObject jsonSubject = new JSONObject(new JSONTokener(JSONSchemaUnitTest.class.getResourceAsStream("/product_invalid.json"))); + @Test + public void givenInvalidInput_whenValidating_thenInvalid() throws IOException { - Schema schema = SchemaLoader.load(jsonSchema); - schema.validate(jsonSubject); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + JsonSchema jsonSchema = factory.getSchema(JSONSchemaUnitTest.class.getResourceAsStream("/schema.json")); + + JsonNode jsonNode = mapper.readTree(JSONSchemaUnitTest.class.getResourceAsStream("/product_invalid.json")); + Set errors = jsonSchema.validate(jsonNode); + assertThat(errors).isNotEmpty() + .asString() + .contains("price: must have a minimum value of 0"); } @Test - public void givenValidInput_whenValidating_thenValid() { + public void givenValidInput_whenValidating_thenValid() throws IOException { - JSONObject jsonSchema = new JSONObject(new JSONTokener(JSONSchemaUnitTest.class.getResourceAsStream("/schema.json"))); - JSONObject jsonSubject = new JSONObject(new JSONTokener(JSONSchemaUnitTest.class.getResourceAsStream("/product_valid.json"))); + JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4); + JsonSchema jsonSchema = factory.getSchema(JSONSchemaUnitTest.class.getResourceAsStream("/schema.json")); - Schema schema = SchemaLoader.load(jsonSchema); - schema.validate(jsonSubject); + JsonNode jsonNode = mapper.readTree(JSONSchemaUnitTest.class.getResourceAsStream("/product_valid.json")); + Set errors = jsonSchema.validate(jsonNode); + assertThat(errors).isEmpty(); } } diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index b0672633c1..56180bf28b 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -249,7 +249,6 @@ 1.78 - 1.18.6 0.43 2.7.2 1.2.3.Final diff --git a/libraries-data-db/pom.xml b/libraries-data-db/pom.xml index c0f2848705..8e5140458e 100644 --- a/libraries-data-db/pom.xml +++ b/libraries-data-db/pom.xml @@ -159,7 +159,6 @@ classname="com.gs.fw.common.mithra.generator.MithraGenerator" /> @@ -268,7 +267,7 @@ 11.11.2 - 16.5.1 + 18.1.0 3.0.0 1.8 5.0 diff --git a/libraries-data-db/src/main/resources/db.sql b/libraries-data-db/src/main/resources/db.sql index e6a9ed3fc2..7bcf6f816e 100644 --- a/libraries-data-db/src/main/resources/db.sql +++ b/libraries-data-db/src/main/resources/db.sql @@ -8,7 +8,7 @@ create table dept( loc varchar(13), constraint pk_dept primary key (deptno) ); - + create table emp( empno numeric, ename varchar(10), @@ -26,25 +26,25 @@ insert into dept values(10, 'ACCOUNTING', 'NEW YORK'); insert into dept values(20, 'RESEARCH', 'DALLAS'); insert into dept values(30, 'SALES', 'CHICAGO'); insert into dept values(40, 'OPERATIONS', 'BOSTON'); - + insert into emp values( 7839, 'KING', 'PRESIDENT', null, - to_date('17-11-1981','dd-mm-yyyy'), + parsedatetime('17-11-1981','dd-MM-yyyy'), 7698, null, 10 ); insert into emp values( 7698, 'BLAKE', 'MANAGER', 7839, - to_date('1-5-1981','dd-mm-yyyy'), + parsedatetime('01-05-1981','dd-MM-yyyy'), 7782, null, 20 ); insert into emp values( 7782, 'CLARK', 'MANAGER', 7839, - to_date('9-6-1981','dd-mm-yyyy'), + parsedatetime('09-06-1981','dd-MM-yyyy'), 7566, null, 30 ); insert into emp values( 7566, 'JONES', 'MANAGER', 7839, - to_date('2-4-1981','dd-mm-yyyy'), + parsedatetime('02-04-1981','dd-MM-yyyy'), 7839, null, 40 ); diff --git a/libraries-files/pom.xml b/libraries-files/pom.xml new file mode 100644 index 0000000000..7e21d127bb --- /dev/null +++ b/libraries-files/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + libraries-files + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + + org.ini4j + ini4j + ${org.ini4j.version} + + + org.apache.commons + commons-configuration2 + ${commons-configuration2} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + + 0.5.4 + 2.8.0 + 2.13.1 + + + diff --git a/libraries-files/src/main/java/com/baeldung/ini/CommonsParser.java b/libraries-files/src/main/java/com/baeldung/ini/CommonsParser.java new file mode 100644 index 0000000000..77a544db16 --- /dev/null +++ b/libraries-files/src/main/java/com/baeldung/ini/CommonsParser.java @@ -0,0 +1,45 @@ +package com.baeldung.ini; + +import org.apache.commons.configuration2.INIConfiguration; +import org.apache.commons.configuration2.SubnodeConfiguration; +import org.apache.commons.configuration2.ex.ConfigurationException; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.*; + +public class CommonsParser { + public static Map> parseIniFile(File fileToParse) throws IOException, ConfigurationException { + Map> iniFileContents = new HashMap<>(); + + INIConfiguration iniConfiguration = new INIConfiguration(); + try (FileReader fileReader = new FileReader(fileToParse)) { + iniConfiguration.read(fileReader); + } + + for (String section : iniConfiguration.getSections()) { + Map subSectionMap = new HashMap<>(); + SubnodeConfiguration confSection = iniConfiguration.getSection(section); + Iterator keyIterator = confSection.getKeys(); + while (keyIterator.hasNext()) { + String key = keyIterator.next(); + String value = confSection.getProperty(key) + .toString(); + subSectionMap.put(key, value); + } + iniFileContents.put(section, subSectionMap); + } + return iniFileContents; + } + + public static String readIniFileValue(File fileToParse, String section, String value) throws IOException, ConfigurationException { + INIConfiguration iniConfiguration = new INIConfiguration(); + try (FileReader fileReader = new FileReader(fileToParse)) { + iniConfiguration.read(fileReader); + } + + return iniConfiguration.getSection(section).getProperty(value).toString(); + } +} diff --git a/libraries-files/src/main/java/com/baeldung/ini/Ini4JParser.java b/libraries-files/src/main/java/com/baeldung/ini/Ini4JParser.java new file mode 100644 index 0000000000..dacb559787 --- /dev/null +++ b/libraries-files/src/main/java/com/baeldung/ini/Ini4JParser.java @@ -0,0 +1,23 @@ +package com.baeldung.ini; + +import org.ini4j.Ini; + +import java.io.File; +import java.io.IOException; +import java.util.*; + +import static java.util.stream.Collectors.toMap; + +public class Ini4JParser { + + public static Map> parseIniFile(File fileToParse) throws IOException { + Ini ini = new Ini(fileToParse); + return ini.entrySet().stream() + .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + + public static String readIniFileValue(File fileToParse, String section, String key) throws IOException { + Ini ini = new Ini(fileToParse); + return ini.get(section, key); + } +} diff --git a/libraries-files/src/main/java/com/baeldung/ini/MyConfiguration.java b/libraries-files/src/main/java/com/baeldung/ini/MyConfiguration.java new file mode 100644 index 0000000000..3d9af04655 --- /dev/null +++ b/libraries-files/src/main/java/com/baeldung/ini/MyConfiguration.java @@ -0,0 +1,109 @@ +package com.baeldung.ini; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +public class MyConfiguration { + + @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class) + public static class Fonts { + private String letter; + private int textSize; + + public String getLetter() { + return letter; + } + + public void setLetter(String letter) { + this.letter = letter; + } + + public int getTextSize() { + return textSize; + } + + public void setTextSize(int textSize) { + this.textSize = textSize; + } + } + + public static class Background { + private String color; + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + } + + @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) + public static class RequestResult { + private int requestCode; + + public int getRequestCode() { + return requestCode; + } + + public void setRequestCode(int requestCode) { + this.requestCode = requestCode; + } + } + + @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) + public static class ResponseResult { + private int resultCode; + + public int getResultCode() { + return resultCode; + } + + public void setResultCode(int resultCode) { + this.resultCode = resultCode; + } + } + + private Fonts fonts; + private Background background; + + @JsonProperty("RequestResult") + private RequestResult requestResult; + + @JsonProperty("ResponseResult") + private ResponseResult responseResult; + + public Fonts getFonts() { + return fonts; + } + + public void setFonts(Fonts fonts) { + this.fonts = fonts; + } + + public Background getBackground() { + return background; + } + + public void setBackground(Background background) { + this.background = background; + } + + public RequestResult getRequestResult() { + return requestResult; + } + + public void setRequestResult(RequestResult requestResult) { + this.requestResult = requestResult; + } + + public ResponseResult getResponseResult() { + return responseResult; + } + + public void setResponseResult(ResponseResult responseResult) { + this.responseResult = responseResult; + } +} diff --git a/libraries-files/src/test/java/com/baeldung/ini/CommonsParserUnitTest.java b/libraries-files/src/test/java/com/baeldung/ini/CommonsParserUnitTest.java new file mode 100644 index 0000000000..b6645da884 --- /dev/null +++ b/libraries-files/src/test/java/com/baeldung/ini/CommonsParserUnitTest.java @@ -0,0 +1,32 @@ +package com.baeldung.ini; + +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.nio.file.Paths; +import java.util.Map; + +import static com.baeldung.ini.CommonsParser.parseIniFile; +import static com.baeldung.ini.CommonsParser.readIniFileValue; +import static org.assertj.core.api.Assertions.assertThat; + +class CommonsParserUnitTest { + + private static final File TEST_FILE = Paths.get("src", "test", "resources", "sample.ini").toFile(); + + @Test + void givenIniFileThenCanParseWithIni4j() throws Exception { + Map> result = + parseIniFile(TEST_FILE); + + assertThat(result.get("fonts")) + .containsEntry("letter", "bold") + .containsEntry("text-size", "28"); + } + + @Test + void givenIniFileThenCanReadKeyWithIni4j() throws Exception { + assertThat(readIniFileValue(TEST_FILE, "fonts", "letter")) + .isEqualTo("bold"); + } +} \ No newline at end of file diff --git a/libraries-files/src/test/java/com/baeldung/ini/Ini4JParserUnitTest.java b/libraries-files/src/test/java/com/baeldung/ini/Ini4JParserUnitTest.java new file mode 100644 index 0000000000..c974e92a87 --- /dev/null +++ b/libraries-files/src/test/java/com/baeldung/ini/Ini4JParserUnitTest.java @@ -0,0 +1,32 @@ +package com.baeldung.ini; + +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.nio.file.Paths; +import java.util.Map; + +import static com.baeldung.ini.Ini4JParser.readIniFileValue; +import static com.baeldung.ini.Ini4JParser.parseIniFile; +import static org.assertj.core.api.Assertions.assertThat; + +class Ini4JParserUnitTest { + + private static final File TEST_FILE = Paths.get("src", "test", "resources", "sample.ini").toFile(); + + @Test + void givenIniFileThenCanParseWithIni4j() throws Exception { + Map> result = + parseIniFile(TEST_FILE); + + assertThat(result.get("fonts")) + .containsEntry("letter", "bold") + .containsEntry("text-size", "28"); + } + + @Test + void givenIniFileThenCanReadKeyFromIt() throws Exception { + assertThat(readIniFileValue(TEST_FILE, "fonts", "letter")) + .isEqualTo("bold"); + } +} \ No newline at end of file diff --git a/libraries-files/src/test/java/com/baeldung/ini/SerializeIntoPojoUnitTest.java b/libraries-files/src/test/java/com/baeldung/ini/SerializeIntoPojoUnitTest.java new file mode 100644 index 0000000000..a91abcb8b3 --- /dev/null +++ b/libraries-files/src/test/java/com/baeldung/ini/SerializeIntoPojoUnitTest.java @@ -0,0 +1,31 @@ +package com.baeldung.ini; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.nio.file.Paths; +import java.util.Map; + +import static com.baeldung.ini.Ini4JParser.parseIniFile; +import static org.assertj.core.api.Assertions.assertThat; + +class SerializeIntoPojoUnitTest { + + private static final File TEST_FILE = Paths.get("src", "test", "resources", "sample.ini").toFile(); + + @Test + void givenAnIniFileThenCanLoadAsPojo() throws Exception { + ObjectMapper objectMapper = new ObjectMapper(); + + Map> iniKeys = parseIniFile(TEST_FILE); + + MyConfiguration config = objectMapper.convertValue(iniKeys, MyConfiguration.class); + + assertThat(config.getFonts().getLetter()).isEqualTo("bold"); + assertThat(config.getFonts().getTextSize()).isEqualTo(28); + assertThat(config.getBackground().getColor()).isEqualTo("white"); + assertThat(config.getRequestResult().getRequestCode()).isEqualTo(1); + assertThat(config.getResponseResult().getResultCode()).isZero(); + } +} diff --git a/libraries-files/src/test/resources/sample.ini b/libraries-files/src/test/resources/sample.ini new file mode 100644 index 0000000000..687cf1daed --- /dev/null +++ b/libraries-files/src/test/resources/sample.ini @@ -0,0 +1,14 @@ +; for 16-bit app support + +[fonts] +letter=bold +text-size=28 + +[background] +color=white + +[RequestResult] +RequestCode=1 + +[ResponseResult] +ResultCode=0 \ No newline at end of file diff --git a/logging-modules/log4j2/README.md b/logging-modules/log4j2/README.md index f53df508bf..87e92e0d48 100644 --- a/logging-modules/log4j2/README.md +++ b/logging-modules/log4j2/README.md @@ -8,3 +8,4 @@ - [System.out.println vs Loggers](https://www.baeldung.com/java-system-out-println-vs-loggers) - [Log4j 2 Plugins](https://www.baeldung.com/log4j2-plugins) - [Printing Thread Info in Log File Using Log4j2](https://www.baeldung.com/log4j2-print-thread-info) +- [Log4j2 – Logging to Both File and Console](https://www.baeldung.com/java-log4j2-file-and-console) diff --git a/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/consoleandfile/Log4j2ConsoleAndFile.java b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/consoleandfile/Log4j2ConsoleAndFile.java new file mode 100644 index 0000000000..56119efd9e --- /dev/null +++ b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/consoleandfile/Log4j2ConsoleAndFile.java @@ -0,0 +1,14 @@ +package com.baeldung.logging.log4j2.consoleandfile; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class Log4j2ConsoleAndFile { + + private static final Logger logger = LogManager.getLogger(Log4j2ConsoleAndFile.class); + + public static void main(String[] args) { + logger.info("Hello World!"); + logger.debug("Hello World!"); + } +} diff --git a/logging-modules/log4j2/src/main/resources/log4j2.properties b/logging-modules/log4j2/src/main/resources/log4j2.properties new file mode 100644 index 0000000000..1d31dd55b5 --- /dev/null +++ b/logging-modules/log4j2/src/main/resources/log4j2.properties @@ -0,0 +1,14 @@ +appender.console.type = Console +appender.console.name = STDOUT +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n + +appender.file.type = File +appender.file.name = LOGFILE +appender.file.fileName=logs/log4j.log +appender.file.layout.type=PatternLayout +appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n +appender.file.filter.threshold.type = ThresholdFilter +appender.file.filter.threshold.level = info + +rootLogger=debug, STDOUT, LOGFILE \ No newline at end of file diff --git a/lombok-modules/pom.xml b/lombok-modules/pom.xml index d5a0a7fb1f..7ca303af9d 100644 --- a/lombok-modules/pom.xml +++ b/lombok-modules/pom.xml @@ -32,8 +32,4 @@ - - 1.18.20 - - \ No newline at end of file diff --git a/maven-modules/maven-repositories/maven-download-artifacts/pom.xml b/maven-modules/maven-repositories/maven-download-artifacts/pom.xml index 678fc32bec..3cf4598ec5 100644 --- a/maven-modules/maven-repositories/maven-download-artifacts/pom.xml +++ b/maven-modules/maven-repositories/maven-download-artifacts/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - maven-repository-download - Maven Release Repository + maven-download-artifacts + maven-download-artifacts 1.0.0-SNAPSHOT diff --git a/maven-modules/maven-repositories/maven-release-repository/pom.xml b/maven-modules/maven-repositories/maven-release-repository/pom.xml index bd7adcbcce..c65c456d3a 100644 --- a/maven-modules/maven-repositories/maven-release-repository/pom.xml +++ b/maven-modules/maven-repositories/maven-release-repository/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 maven-release-repository - Maven Release Repository + maven-release-repository 1.0.0 diff --git a/maven-modules/maven-repositories/maven-snapshot-repository/pom.xml b/maven-modules/maven-repositories/maven-snapshot-repository/pom.xml index 5409e47b8e..9f618c7659 100644 --- a/maven-modules/maven-repositories/maven-snapshot-repository/pom.xml +++ b/maven-modules/maven-repositories/maven-snapshot-repository/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 maven-snapshot-repository - Maven Snapshot Repository + maven-snapshot-repository 1.0.0-SNAPSHOT diff --git a/maven-modules/maven-repositories/pom.xml b/maven-modules/maven-repositories/pom.xml index ba39d00d65..4a64e6a0b2 100644 --- a/maven-modules/maven-repositories/pom.xml +++ b/maven-modules/maven-repositories/pom.xml @@ -5,7 +5,7 @@ 4.0.0 maven-repositories 1.0.0-SNAPSHOT - Maven Repositories + maven-repositories pom diff --git a/helidon/README.md b/microservices-modules/helidon/README.md similarity index 100% rename from helidon/README.md rename to microservices-modules/helidon/README.md diff --git a/helidon/helidon-mp/pom.xml b/microservices-modules/helidon/helidon-mp/pom.xml similarity index 100% rename from helidon/helidon-mp/pom.xml rename to microservices-modules/helidon/helidon-mp/pom.xml diff --git a/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/LibraryApplication.java b/microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/LibraryApplication.java similarity index 100% rename from helidon/helidon-mp/src/main/java/com/baeldung/microprofile/LibraryApplication.java rename to microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/LibraryApplication.java diff --git a/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/model/Book.java b/microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/model/Book.java similarity index 100% rename from helidon/helidon-mp/src/main/java/com/baeldung/microprofile/model/Book.java rename to microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/model/Book.java diff --git a/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookListMessageBodyWriter.java b/microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookListMessageBodyWriter.java similarity index 100% rename from helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookListMessageBodyWriter.java rename to microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookListMessageBodyWriter.java diff --git a/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyReader.java b/microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyReader.java similarity index 100% rename from helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyReader.java rename to microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyReader.java diff --git a/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyWriter.java b/microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyWriter.java similarity index 100% rename from helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyWriter.java rename to microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyWriter.java diff --git a/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/repo/BookManager.java b/microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/repo/BookManager.java similarity index 100% rename from helidon/helidon-mp/src/main/java/com/baeldung/microprofile/repo/BookManager.java rename to microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/repo/BookManager.java diff --git a/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/util/BookMapper.java b/microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/util/BookMapper.java similarity index 100% rename from helidon/helidon-mp/src/main/java/com/baeldung/microprofile/util/BookMapper.java rename to microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/util/BookMapper.java diff --git a/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/web/BookEndpoint.java b/microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/web/BookEndpoint.java similarity index 100% rename from helidon/helidon-mp/src/main/java/com/baeldung/microprofile/web/BookEndpoint.java rename to microservices-modules/helidon/helidon-mp/src/main/java/com/baeldung/microprofile/web/BookEndpoint.java diff --git a/helidon/helidon-mp/src/main/resources/META-INF/beans.xml b/microservices-modules/helidon/helidon-mp/src/main/resources/META-INF/beans.xml similarity index 97% rename from helidon/helidon-mp/src/main/resources/META-INF/beans.xml rename to microservices-modules/helidon/helidon-mp/src/main/resources/META-INF/beans.xml index faae50dfc2..2ac599bc6b 100644 --- a/helidon/helidon-mp/src/main/resources/META-INF/beans.xml +++ b/microservices-modules/helidon/helidon-mp/src/main/resources/META-INF/beans.xml @@ -1,7 +1,7 @@ - - + + diff --git a/bootique/src/main/resources/logback.xml b/microservices-modules/helidon/helidon-mp/src/main/resources/logback.xml similarity index 100% rename from bootique/src/main/resources/logback.xml rename to microservices-modules/helidon/helidon-mp/src/main/resources/logback.xml diff --git a/helidon/helidon-se/pom.xml b/microservices-modules/helidon/helidon-se/pom.xml similarity index 100% rename from helidon/helidon-se/pom.xml rename to microservices-modules/helidon/helidon-se/pom.xml diff --git a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/config/ConfigApplication.java b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/config/ConfigApplication.java similarity index 97% rename from helidon/helidon-se/src/main/java/com/baeldung/helidon/se/config/ConfigApplication.java rename to microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/config/ConfigApplication.java index acfcdb2373..beac5511c1 100644 --- a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/config/ConfigApplication.java +++ b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/config/ConfigApplication.java @@ -1,29 +1,29 @@ -package com.baeldung.helidon.se.config; - -import io.helidon.config.Config; -import io.helidon.config.ConfigSources; -import io.helidon.config.spi.ConfigSource; - -public class ConfigApplication { - - public static void main(String... args) throws Exception { - - ConfigSource configSource = ConfigSources.classpath("application.yaml").build(); - Config config = Config.builder() - .disableSystemPropertiesSource() - .disableEnvironmentVariablesSource() - .sources(configSource) - .build(); - - int port = config.get("server.port").asInt(); - int pageSize = config.get("web.page-size").asInt(); - boolean debug = config.get("web.debug").asBoolean(); - String userHome = config.get("user.home").asString(); - - System.out.println("port: " + port); - System.out.println("pageSize: " + pageSize); - System.out.println("debug: " + debug); - System.out.println("userHome: " + userHome); - } - -} +package com.baeldung.helidon.se.config; + +import io.helidon.config.Config; +import io.helidon.config.ConfigSources; +import io.helidon.config.spi.ConfigSource; + +public class ConfigApplication { + + public static void main(String... args) throws Exception { + + ConfigSource configSource = ConfigSources.classpath("application.yaml").build(); + Config config = Config.builder() + .disableSystemPropertiesSource() + .disableEnvironmentVariablesSource() + .sources(configSource) + .build(); + + int port = config.get("server.port").asInt(); + int pageSize = config.get("web.page-size").asInt(); + boolean debug = config.get("web.debug").asBoolean(); + String userHome = config.get("user.home").asString(); + + System.out.println("port: " + port); + System.out.println("pageSize: " + pageSize); + System.out.println("debug: " + debug); + System.out.println("userHome: " + userHome); + } + +} diff --git a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/Book.java b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/Book.java similarity index 94% rename from helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/Book.java rename to microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/Book.java index 9a591bcc73..90de266717 100644 --- a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/Book.java +++ b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/Book.java @@ -1,49 +1,49 @@ -package com.baeldung.helidon.se.routing; - -public class Book { - private String id; - private String isbn; - private String name; - private String author; - private Integer pages; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getIsbn() { - return isbn; - } - - public void setIsbn(String isbn) { - this.isbn = isbn; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public Integer getPages() { - return pages; - } - - public void setPages(Integer pages) { - this.pages = pages; - } +package com.baeldung.helidon.se.routing; + +public class Book { + private String id; + private String isbn; + private String name; + private String author; + private Integer pages; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsbn() { + return isbn; + } + + public void setIsbn(String isbn) { + this.isbn = isbn; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public Integer getPages() { + return pages; + } + + public void setPages(Integer pages) { + this.pages = pages; + } } \ No newline at end of file diff --git a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookManager.java b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookManager.java similarity index 96% rename from helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookManager.java rename to microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookManager.java index 2e6e694041..1ac77c49c9 100644 --- a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookManager.java +++ b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookManager.java @@ -1,49 +1,49 @@ -package com.baeldung.helidon.se.routing; - -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicInteger; - -public class BookManager { - - private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM"); - private AtomicInteger bookIdGenerator = new AtomicInteger(0); - - private ConcurrentMap inMemoryStore = new ConcurrentHashMap<>(); - - public BookManager() { - Book book = new Book(); - book.setId(getNextId()); - book.setName("Building Microservice With Oracle Helidon"); - book.setIsbn("11223344"); - book.setAuthor("baeldung"); - book.setPages(560); - inMemoryStore.put(book.getId(), book); - } - - private String getNextId() { - String date = LocalDate.now().format(formatter); - return String.format("%04d-%s", bookIdGenerator.incrementAndGet(), date); - } - - public String add(Book book) { - String id = getNextId(); - book.setId(id); - inMemoryStore.put(id, book); - return id; - } - - public Book get(String id) { - return inMemoryStore.get(id); - } - - public List getAll() { - List books = new ArrayList<>(); - books.addAll(inMemoryStore.values()); - return books; - } +package com.baeldung.helidon.se.routing; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicInteger; + +public class BookManager { + + private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM"); + private AtomicInteger bookIdGenerator = new AtomicInteger(0); + + private ConcurrentMap inMemoryStore = new ConcurrentHashMap<>(); + + public BookManager() { + Book book = new Book(); + book.setId(getNextId()); + book.setName("Building Microservice With Oracle Helidon"); + book.setIsbn("11223344"); + book.setAuthor("baeldung"); + book.setPages(560); + inMemoryStore.put(book.getId(), book); + } + + private String getNextId() { + String date = LocalDate.now().format(formatter); + return String.format("%04d-%s", bookIdGenerator.incrementAndGet(), date); + } + + public String add(Book book) { + String id = getNextId(); + book.setId(id); + inMemoryStore.put(id, book); + return id; + } + + public Book get(String id) { + return inMemoryStore.get(id); + } + + public List getAll() { + List books = new ArrayList<>(); + books.addAll(inMemoryStore.values()); + return books; + } } \ No newline at end of file diff --git a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookResource.java b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookResource.java similarity index 96% rename from helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookResource.java rename to microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookResource.java index 0648930841..b0db191851 100644 --- a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookResource.java +++ b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/BookResource.java @@ -1,58 +1,58 @@ -package com.baeldung.helidon.se.routing; - -import io.helidon.webserver.Routing; -import io.helidon.webserver.ServerRequest; -import io.helidon.webserver.ServerResponse; -import io.helidon.webserver.Service; - -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonArrayBuilder; -import javax.json.JsonObject; -import java.util.List; - -public class BookResource implements Service { - - private BookManager bookManager = new BookManager(); - - @Override - public void update(Routing.Rules rules) { - rules - .get("/", this::books) - .get("/{id}", this::bookById); - } - - private void bookById(ServerRequest serverRequest, ServerResponse serverResponse) { - //get the book with the given id - String id = serverRequest.path().param("id"); - Book book = bookManager.get(id); - JsonObject jsonObject = from(book); - serverResponse.send(jsonObject); - } - - private void books(ServerRequest serverRequest, ServerResponse serverResponse) { - //get all books - List books = bookManager.getAll(); - JsonArray jsonArray = from(books); - serverResponse.send(jsonArray); - } - - private JsonObject from(Book book) { - JsonObject jsonObject = Json.createObjectBuilder() - .add("id", book.getId()) - .add("isbn", book.getIsbn()) - .add("name", book.getName()) - .add("author", book.getAuthor()) - .add("pages", book.getPages()) - .build(); - return jsonObject; - } - - private JsonArray from(List books) { - JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder(); - books.forEach(book -> { - jsonArrayBuilder.add(from(book)); - }); - return jsonArrayBuilder.build(); - } -} +package com.baeldung.helidon.se.routing; + +import io.helidon.webserver.Routing; +import io.helidon.webserver.ServerRequest; +import io.helidon.webserver.ServerResponse; +import io.helidon.webserver.Service; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; +import java.util.List; + +public class BookResource implements Service { + + private BookManager bookManager = new BookManager(); + + @Override + public void update(Routing.Rules rules) { + rules + .get("/", this::books) + .get("/{id}", this::bookById); + } + + private void bookById(ServerRequest serverRequest, ServerResponse serverResponse) { + //get the book with the given id + String id = serverRequest.path().param("id"); + Book book = bookManager.get(id); + JsonObject jsonObject = from(book); + serverResponse.send(jsonObject); + } + + private void books(ServerRequest serverRequest, ServerResponse serverResponse) { + //get all books + List books = bookManager.getAll(); + JsonArray jsonArray = from(books); + serverResponse.send(jsonArray); + } + + private JsonObject from(Book book) { + JsonObject jsonObject = Json.createObjectBuilder() + .add("id", book.getId()) + .add("isbn", book.getIsbn()) + .add("name", book.getName()) + .add("author", book.getAuthor()) + .add("pages", book.getPages()) + .build(); + return jsonObject; + } + + private JsonArray from(List books) { + JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder(); + books.forEach(book -> { + jsonArrayBuilder.add(from(book)); + }); + return jsonArrayBuilder.build(); + } +} diff --git a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/WebApplicationRouting.java b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/WebApplicationRouting.java similarity index 96% rename from helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/WebApplicationRouting.java rename to microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/WebApplicationRouting.java index 1f32d3c528..17bf2bcc8f 100644 --- a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/WebApplicationRouting.java +++ b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/routing/WebApplicationRouting.java @@ -1,29 +1,29 @@ -package com.baeldung.helidon.se.routing; - -import io.helidon.webserver.Routing; -import io.helidon.webserver.ServerConfiguration; -import io.helidon.webserver.WebServer; -import io.helidon.webserver.json.JsonSupport; - -public class WebApplicationRouting { - - public static void main(String... args) throws Exception { - - ServerConfiguration serverConfig = ServerConfiguration.builder() - .port(9080) - .build(); - - Routing routing = Routing.builder() - .register(JsonSupport.get()) - .register("/books", new BookResource()) - .get("/greet", (request, response) -> response.send("Hello World !")) - .build(); - - WebServer.create(serverConfig, routing) - .start() - .thenAccept(ws -> - System.out.println("Server started at: http://localhost:" + ws.port()) - ); - } - -} +package com.baeldung.helidon.se.routing; + +import io.helidon.webserver.Routing; +import io.helidon.webserver.ServerConfiguration; +import io.helidon.webserver.WebServer; +import io.helidon.webserver.json.JsonSupport; + +public class WebApplicationRouting { + + public static void main(String... args) throws Exception { + + ServerConfiguration serverConfig = ServerConfiguration.builder() + .port(9080) + .build(); + + Routing routing = Routing.builder() + .register(JsonSupport.get()) + .register("/books", new BookResource()) + .get("/greet", (request, response) -> response.send("Hello World !")) + .build(); + + WebServer.create(serverConfig, routing) + .start() + .thenAccept(ws -> + System.out.println("Server started at: http://localhost:" + ws.port()) + ); + } + +} diff --git a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/MyUser.java b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/MyUser.java similarity index 95% rename from helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/MyUser.java rename to microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/MyUser.java index e8009a98ad..d1a8446f6a 100644 --- a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/MyUser.java +++ b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/MyUser.java @@ -1,33 +1,33 @@ -package com.baeldung.helidon.se.security; - -import io.helidon.security.provider.httpauth.UserStore; - -import java.util.Collection; - -public class MyUser implements UserStore.User { - - private String login; - private char[] password; - private Collection roles; - - public MyUser(String login, char[] password, Collection roles) { - this.login = login; - this.password = password; - this.roles = roles; - } - - @Override - public String getLogin() { - return login; - } - - @Override - public char[] getPassword() { - return password; - } - - @Override - public Collection getRoles() { - return roles; - } -} +package com.baeldung.helidon.se.security; + +import io.helidon.security.provider.httpauth.UserStore; + +import java.util.Collection; + +public class MyUser implements UserStore.User { + + private String login; + private char[] password; + private Collection roles; + + public MyUser(String login, char[] password, Collection roles) { + this.login = login; + this.password = password; + this.roles = roles; + } + + @Override + public String getLogin() { + return login; + } + + @Override + public char[] getPassword() { + return password; + } + + @Override + public Collection getRoles() { + return roles; + } +} diff --git a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/WebApplicationSecurity.java b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/WebApplicationSecurity.java similarity index 97% rename from helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/WebApplicationSecurity.java rename to microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/WebApplicationSecurity.java index 9a67f3d716..4eb7c6c01f 100644 --- a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/WebApplicationSecurity.java +++ b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/security/WebApplicationSecurity.java @@ -1,61 +1,61 @@ -package com.baeldung.helidon.se.security; - -import io.helidon.config.Config; -import io.helidon.security.Security; -import io.helidon.security.SubjectType; -import io.helidon.security.provider.httpauth.HttpBasicAuthProvider; -import io.helidon.security.provider.httpauth.UserStore; -import io.helidon.security.webserver.WebSecurity; -import io.helidon.webserver.Routing; -import io.helidon.webserver.ServerConfiguration; -import io.helidon.webserver.WebServer; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -public class WebApplicationSecurity { - - public static void main(String... args) throws Exception { - - Config config = Config.create(); - ServerConfiguration serverConfig = - ServerConfiguration.fromConfig(config.get("server")); - - Map users = new HashMap<>(); - users.put("user", new MyUser("user", "user".toCharArray(), Arrays.asList("ROLE_USER"))); - users.put("admin", new MyUser("admin", "admin".toCharArray(), Arrays.asList("ROLE_USER", "ROLE_ADMIN"))); - UserStore store = user -> Optional.ofNullable(users.get(user)); - - HttpBasicAuthProvider httpBasicAuthProvider = HttpBasicAuthProvider.builder() - .realm("myRealm") - .subjectType(SubjectType.USER) - .userStore(store) - .build(); - - //1. Using Builder Pattern or Config Pattern - Security security = Security.builder() - .addAuthenticationProvider(httpBasicAuthProvider) - .build(); - //Security security = Security.fromConfig(config); - - //2. WebSecurity from Security or from Config - // WebSecurity webSecurity = WebSecurity.from(security) - // .securityDefaults(WebSecurity.authenticate()); - - WebSecurity webSecurity = WebSecurity.from(config); - - Routing routing = Routing.builder() - .register(webSecurity) - .get("/user", (request, response) -> response.send("Hello, I'm a Helidon SE user with ROLE_USER")) - .get("/admin", (request, response) -> response.send("Hello, I'm a Helidon SE user with ROLE_ADMIN")) - .build(); - - WebServer webServer = WebServer.create(serverConfig, routing); - - webServer.start().thenAccept(ws -> - System.out.println("Server started at: http://localhost:" + ws.port()) - ); - } -} +package com.baeldung.helidon.se.security; + +import io.helidon.config.Config; +import io.helidon.security.Security; +import io.helidon.security.SubjectType; +import io.helidon.security.provider.httpauth.HttpBasicAuthProvider; +import io.helidon.security.provider.httpauth.UserStore; +import io.helidon.security.webserver.WebSecurity; +import io.helidon.webserver.Routing; +import io.helidon.webserver.ServerConfiguration; +import io.helidon.webserver.WebServer; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +public class WebApplicationSecurity { + + public static void main(String... args) throws Exception { + + Config config = Config.create(); + ServerConfiguration serverConfig = + ServerConfiguration.fromConfig(config.get("server")); + + Map users = new HashMap<>(); + users.put("user", new MyUser("user", "user".toCharArray(), Arrays.asList("ROLE_USER"))); + users.put("admin", new MyUser("admin", "admin".toCharArray(), Arrays.asList("ROLE_USER", "ROLE_ADMIN"))); + UserStore store = user -> Optional.ofNullable(users.get(user)); + + HttpBasicAuthProvider httpBasicAuthProvider = HttpBasicAuthProvider.builder() + .realm("myRealm") + .subjectType(SubjectType.USER) + .userStore(store) + .build(); + + //1. Using Builder Pattern or Config Pattern + Security security = Security.builder() + .addAuthenticationProvider(httpBasicAuthProvider) + .build(); + //Security security = Security.fromConfig(config); + + //2. WebSecurity from Security or from Config + // WebSecurity webSecurity = WebSecurity.from(security) + // .securityDefaults(WebSecurity.authenticate()); + + WebSecurity webSecurity = WebSecurity.from(config); + + Routing routing = Routing.builder() + .register(webSecurity) + .get("/user", (request, response) -> response.send("Hello, I'm a Helidon SE user with ROLE_USER")) + .get("/admin", (request, response) -> response.send("Hello, I'm a Helidon SE user with ROLE_ADMIN")) + .build(); + + WebServer webServer = WebServer.create(serverConfig, routing); + + webServer.start().thenAccept(ws -> + System.out.println("Server started at: http://localhost:" + ws.port()) + ); + } +} diff --git a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/webserver/SimpleWebApplication.java b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/webserver/SimpleWebApplication.java similarity index 96% rename from helidon/helidon-se/src/main/java/com/baeldung/helidon/se/webserver/SimpleWebApplication.java rename to microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/webserver/SimpleWebApplication.java index 0a603a5123..a9a92cf1b9 100644 --- a/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/webserver/SimpleWebApplication.java +++ b/microservices-modules/helidon/helidon-se/src/main/java/com/baeldung/helidon/se/webserver/SimpleWebApplication.java @@ -1,26 +1,26 @@ -package com.baeldung.helidon.se.webserver; - -import io.helidon.webserver.Routing; -import io.helidon.webserver.ServerConfiguration; -import io.helidon.webserver.WebServer; - -public class SimpleWebApplication { - - public static void main(String... args) throws Exception { - - ServerConfiguration serverConfig = ServerConfiguration.builder() - .port(9001) - .build(); - - Routing routing = Routing.builder() - .get("/greet", (request, response) -> response.send("Hello World !")) - .build(); - - WebServer.create(serverConfig, routing) - .start() - .thenAccept(ws -> - System.out.println("Server started at: http://localhost:" + ws.port()) - ); - } - -} +package com.baeldung.helidon.se.webserver; + +import io.helidon.webserver.Routing; +import io.helidon.webserver.ServerConfiguration; +import io.helidon.webserver.WebServer; + +public class SimpleWebApplication { + + public static void main(String... args) throws Exception { + + ServerConfiguration serverConfig = ServerConfiguration.builder() + .port(9001) + .build(); + + Routing routing = Routing.builder() + .get("/greet", (request, response) -> response.send("Hello World !")) + .build(); + + WebServer.create(serverConfig, routing) + .start() + .thenAccept(ws -> + System.out.println("Server started at: http://localhost:" + ws.port()) + ); + } + +} diff --git a/helidon/helidon-se/src/main/resources/application.json b/microservices-modules/helidon/helidon-se/src/main/resources/application.json similarity index 100% rename from helidon/helidon-se/src/main/resources/application.json rename to microservices-modules/helidon/helidon-se/src/main/resources/application.json diff --git a/helidon/helidon-se/src/main/resources/application.properties b/microservices-modules/helidon/helidon-se/src/main/resources/application.properties similarity index 95% rename from helidon/helidon-se/src/main/resources/application.properties rename to microservices-modules/helidon/helidon-se/src/main/resources/application.properties index 062047de4a..2074c4a836 100644 --- a/helidon/helidon-se/src/main/resources/application.properties +++ b/microservices-modules/helidon/helidon-se/src/main/resources/application.properties @@ -1,4 +1,4 @@ -server.port=9080 -web.debug=true -web.page-size=15 +server.port=9080 +web.debug=true +web.page-size=15 user.home=C:/Users/app \ No newline at end of file diff --git a/helidon/helidon-se/src/main/resources/application.yaml b/microservices-modules/helidon/helidon-se/src/main/resources/application.yaml similarity index 100% rename from helidon/helidon-se/src/main/resources/application.yaml rename to microservices-modules/helidon/helidon-se/src/main/resources/application.yaml diff --git a/helidon/pom.xml b/microservices-modules/helidon/pom.xml similarity index 92% rename from helidon/pom.xml rename to microservices-modules/helidon/pom.xml index 36466203a8..ca2cafb7d3 100644 --- a/helidon/pom.xml +++ b/microservices-modules/helidon/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + microservices-modules 1.0.0-SNAPSHOT diff --git a/micronaut/.mvn/jvm.config b/microservices-modules/micronaut/.mvn/jvm.config similarity index 100% rename from micronaut/.mvn/jvm.config rename to microservices-modules/micronaut/.mvn/jvm.config diff --git a/micronaut/.mvn/wrapper/MavenWrapperDownloader.java b/microservices-modules/micronaut/.mvn/wrapper/MavenWrapperDownloader.java similarity index 100% rename from micronaut/.mvn/wrapper/MavenWrapperDownloader.java rename to microservices-modules/micronaut/.mvn/wrapper/MavenWrapperDownloader.java diff --git a/micronaut/.mvn/wrapper/maven-wrapper.jar b/microservices-modules/micronaut/.mvn/wrapper/maven-wrapper.jar similarity index 100% rename from micronaut/.mvn/wrapper/maven-wrapper.jar rename to microservices-modules/micronaut/.mvn/wrapper/maven-wrapper.jar diff --git a/micronaut/.mvn/wrapper/maven-wrapper.properties b/microservices-modules/micronaut/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from micronaut/.mvn/wrapper/maven-wrapper.properties rename to microservices-modules/micronaut/.mvn/wrapper/maven-wrapper.properties diff --git a/micronaut/Dockerfile b/microservices-modules/micronaut/Dockerfile similarity index 100% rename from micronaut/Dockerfile rename to microservices-modules/micronaut/Dockerfile diff --git a/micronaut/README.md b/microservices-modules/micronaut/README.md similarity index 100% rename from micronaut/README.md rename to microservices-modules/micronaut/README.md diff --git a/micronaut/micronaut-cli.yml b/microservices-modules/micronaut/micronaut-cli.yml similarity index 100% rename from micronaut/micronaut-cli.yml rename to microservices-modules/micronaut/micronaut-cli.yml diff --git a/micronaut/mvnw b/microservices-modules/micronaut/mvnw old mode 100755 new mode 100644 similarity index 100% rename from micronaut/mvnw rename to microservices-modules/micronaut/mvnw diff --git a/micronaut/mvnw.cmd b/microservices-modules/micronaut/mvnw.cmd old mode 100755 new mode 100644 similarity index 97% rename from micronaut/mvnw.cmd rename to microservices-modules/micronaut/mvnw.cmd index 03d90e960b..830073a17e --- a/micronaut/mvnw.cmd +++ b/microservices-modules/micronaut/mvnw.cmd @@ -1,161 +1,161 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar" -FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - echo Found %WRAPPER_JAR% -) else ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" - echo Finished downloading %WRAPPER_JAR% -) -@REM End of extension - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/micronaut/pom.xml b/microservices-modules/micronaut/pom.xml similarity index 99% rename from micronaut/pom.xml rename to microservices-modules/micronaut/pom.xml index a04fc5c99c..8647d1a3a7 100644 --- a/micronaut/pom.xml +++ b/microservices-modules/micronaut/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + microservices-modules 1.0.0-SNAPSHOT diff --git a/micronaut/src/main/java/com/baeldung/micronaut/helloworld/client/ConcreteGreetingClient.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/client/ConcreteGreetingClient.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/helloworld/client/ConcreteGreetingClient.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/client/ConcreteGreetingClient.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/helloworld/client/GreetingClient.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/client/GreetingClient.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/helloworld/client/GreetingClient.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/client/GreetingClient.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/ServerApplication.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/ServerApplication.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/ServerApplication.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/ServerApplication.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/controller/AsyncGreetController.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/controller/AsyncGreetController.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/controller/AsyncGreetController.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/controller/AsyncGreetController.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/controller/GreetController.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/controller/GreetController.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/controller/GreetController.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/controller/GreetController.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/EnglishGreetingService.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/EnglishGreetingService.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/EnglishGreetingService.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/EnglishGreetingService.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/GreetingService.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/GreetingService.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/GreetingService.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/GreetingService.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/SpanishGreetingService.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/SpanishGreetingService.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/SpanishGreetingService.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/helloworld/server/service/SpanishGreetingService.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/CompareApplication.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/CompareApplication.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/CompareApplication.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/CompareApplication.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/client/ArithmeticClient.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/client/ArithmeticClient.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/client/ArithmeticClient.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/client/ArithmeticClient.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/client/ArithmeticClientImpl.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/client/ArithmeticClientImpl.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/client/ArithmeticClientImpl.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/client/ArithmeticClientImpl.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/controller/ArithmeticController.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/controller/ArithmeticController.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/controller/ArithmeticController.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/controller/ArithmeticController.java diff --git a/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/service/ArithmeticService.java b/microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/service/ArithmeticService.java similarity index 100% rename from micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/service/ArithmeticService.java rename to microservices-modules/micronaut/src/main/java/com/baeldung/micronaut/vs/springboot/service/ArithmeticService.java diff --git a/micronaut/src/main/resources/application.yml b/microservices-modules/micronaut/src/main/resources/application.yml similarity index 100% rename from micronaut/src/main/resources/application.yml rename to microservices-modules/micronaut/src/main/resources/application.yml diff --git a/micronaut/src/main/resources/logback.xml b/microservices-modules/micronaut/src/main/resources/logback.xml similarity index 100% rename from micronaut/src/main/resources/logback.xml rename to microservices-modules/micronaut/src/main/resources/logback.xml diff --git a/micronaut/src/test/java/com/baeldung/micronaut/helloworld/client/ConcreteGreetingClientUnitTest.java b/microservices-modules/micronaut/src/test/java/com/baeldung/micronaut/helloworld/client/ConcreteGreetingClientUnitTest.java similarity index 100% rename from micronaut/src/test/java/com/baeldung/micronaut/helloworld/client/ConcreteGreetingClientUnitTest.java rename to microservices-modules/micronaut/src/test/java/com/baeldung/micronaut/helloworld/client/ConcreteGreetingClientUnitTest.java diff --git a/micronaut/src/test/java/com/baeldung/micronaut/helloworld/client/GreetingClientUnitTest.java b/microservices-modules/micronaut/src/test/java/com/baeldung/micronaut/helloworld/client/GreetingClientUnitTest.java similarity index 100% rename from micronaut/src/test/java/com/baeldung/micronaut/helloworld/client/GreetingClientUnitTest.java rename to microservices-modules/micronaut/src/test/java/com/baeldung/micronaut/helloworld/client/GreetingClientUnitTest.java diff --git a/micronaut/src/test/java/com/baeldung/micronaut/vs/springboot/ArithmeticClientUnitTest.java b/microservices-modules/micronaut/src/test/java/com/baeldung/micronaut/vs/springboot/ArithmeticClientUnitTest.java similarity index 100% rename from micronaut/src/test/java/com/baeldung/micronaut/vs/springboot/ArithmeticClientUnitTest.java rename to microservices-modules/micronaut/src/test/java/com/baeldung/micronaut/vs/springboot/ArithmeticClientUnitTest.java diff --git a/microprofile/README.md b/microservices-modules/microprofile/README.md similarity index 100% rename from microprofile/README.md rename to microservices-modules/microprofile/README.md diff --git a/microprofile/pom.xml b/microservices-modules/microprofile/pom.xml similarity index 98% rename from microprofile/pom.xml rename to microservices-modules/microprofile/pom.xml index 54ed3a9930..24803cb4a4 100644 --- a/microprofile/pom.xml +++ b/microservices-modules/microprofile/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + microservices-modules 1.0.0-SNAPSHOT diff --git a/microprofile/src/main/java/com/baeldung/microprofile/LibraryApplication.java b/microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/LibraryApplication.java similarity index 100% rename from microprofile/src/main/java/com/baeldung/microprofile/LibraryApplication.java rename to microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/LibraryApplication.java diff --git a/microprofile/src/main/java/com/baeldung/microprofile/model/Book.java b/microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/model/Book.java similarity index 100% rename from microprofile/src/main/java/com/baeldung/microprofile/model/Book.java rename to microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/model/Book.java diff --git a/microprofile/src/main/java/com/baeldung/microprofile/providers/BookListMessageBodyWriter.java b/microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/providers/BookListMessageBodyWriter.java similarity index 100% rename from microprofile/src/main/java/com/baeldung/microprofile/providers/BookListMessageBodyWriter.java rename to microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/providers/BookListMessageBodyWriter.java diff --git a/microprofile/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyReader.java b/microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyReader.java similarity index 100% rename from microprofile/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyReader.java rename to microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyReader.java diff --git a/microprofile/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyWriter.java b/microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyWriter.java similarity index 100% rename from microprofile/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyWriter.java rename to microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/providers/BookMessageBodyWriter.java diff --git a/microprofile/src/main/java/com/baeldung/microprofile/repo/BookManager.java b/microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/repo/BookManager.java similarity index 100% rename from microprofile/src/main/java/com/baeldung/microprofile/repo/BookManager.java rename to microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/repo/BookManager.java diff --git a/microprofile/src/main/java/com/baeldung/microprofile/util/BookMapper.java b/microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/util/BookMapper.java similarity index 100% rename from microprofile/src/main/java/com/baeldung/microprofile/util/BookMapper.java rename to microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/util/BookMapper.java diff --git a/microprofile/src/main/java/com/baeldung/microprofile/web/BookEndpoint.java b/microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/web/BookEndpoint.java similarity index 100% rename from microprofile/src/main/java/com/baeldung/microprofile/web/BookEndpoint.java rename to microservices-modules/microprofile/src/main/java/com/baeldung/microprofile/web/BookEndpoint.java diff --git a/microprofile/src/main/liberty/config/server.xml b/microservices-modules/microprofile/src/main/liberty/config/server.xml similarity index 100% rename from microprofile/src/main/liberty/config/server.xml rename to microservices-modules/microprofile/src/main/liberty/config/server.xml diff --git a/cas/cas-secured-app/src/main/resources/logback.xml b/microservices-modules/microprofile/src/main/resources/logback.xml similarity index 100% rename from cas/cas-secured-app/src/main/resources/logback.xml rename to microservices-modules/microprofile/src/main/resources/logback.xml diff --git a/msf4j/README.md b/microservices-modules/msf4j/README.md similarity index 100% rename from msf4j/README.md rename to microservices-modules/msf4j/README.md diff --git a/msf4j/pom.xml b/microservices-modules/msf4j/pom.xml similarity index 96% rename from msf4j/pom.xml rename to microservices-modules/msf4j/pom.xml index 99e25dbcbf..642795e5fe 100644 --- a/msf4j/pom.xml +++ b/microservices-modules/msf4j/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + microservices-modules 1.0.0-SNAPSHOT diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4japi/Application.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4japi/Application.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4japi/Application.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4japi/Application.java diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4japi/Meal.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4japi/Meal.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4japi/Meal.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4japi/Meal.java diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4japi/MenuService.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4japi/MenuService.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4japi/MenuService.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4japi/MenuService.java diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4jintro/Application.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jintro/Application.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4jintro/Application.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jintro/Application.java diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4jintro/SimpleService.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jintro/SimpleService.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4jintro/SimpleService.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jintro/SimpleService.java diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/Application.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/Application.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/Application.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/Application.java diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/configuration/PortConfiguration.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/configuration/PortConfiguration.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/configuration/PortConfiguration.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/configuration/PortConfiguration.java diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/domain/Meal.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/domain/Meal.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/domain/Meal.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/domain/Meal.java diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/repositories/MealRepository.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/repositories/MealRepository.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/repositories/MealRepository.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/repositories/MealRepository.java diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/resources/MealResource.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/resources/MealResource.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/resources/MealResource.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/resources/MealResource.java diff --git a/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/services/MealService.java b/microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/services/MealService.java similarity index 100% rename from msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/services/MealService.java rename to microservices-modules/msf4j/src/main/java/com/baeldung/msf4j/msf4jspring/services/MealService.java diff --git a/jjwt/src/main/resources/application.properties b/microservices-modules/msf4j/src/main/resources/application.properties similarity index 100% rename from jjwt/src/main/resources/application.properties rename to microservices-modules/msf4j/src/main/resources/application.properties diff --git a/google-web-toolkit/src/main/resources/logback.xml b/microservices-modules/msf4j/src/main/resources/logback.xml similarity index 100% rename from google-web-toolkit/src/main/resources/logback.xml rename to microservices-modules/msf4j/src/main/resources/logback.xml diff --git a/msf4j/src/main/resources/templates/meals.mustache b/microservices-modules/msf4j/src/main/resources/templates/meals.mustache similarity index 100% rename from msf4j/src/main/resources/templates/meals.mustache rename to microservices-modules/msf4j/src/main/resources/templates/meals.mustache diff --git a/open-liberty/README.md b/microservices-modules/open-liberty/README.md similarity index 100% rename from open-liberty/README.md rename to microservices-modules/open-liberty/README.md diff --git a/microservices-modules/open-liberty/pom.xml b/microservices-modules/open-liberty/pom.xml new file mode 100644 index 0000000000..e7a94eab39 --- /dev/null +++ b/microservices-modules/open-liberty/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + com.baeldung + open-liberty + 1.0-SNAPSHOT + war + + + com.baeldung + microservices-modules + 1.0.0-SNAPSHOT + + + + + jakarta.platform + jakarta.jakartaee-web-api + ${version.jakarta.jakartaee-web-api} + provided + + + org.eclipse.microprofile + microprofile + ${version.microprofile} + pom + provided + + + org.apache.derby + derby + ${version.derby} + provided + + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test + + + org.eclipse + yasson + ${version.yasson} + test + + + org.apache.cxf + cxf-rt-rs-client + ${version.cxf-rt-rs-client} + test + + + org.glassfish + javax.json + ${version.javax.json} + test + + + org.apache.cxf + cxf-rt-rs-mp-client + ${version.cxf-rt-rs-mp-client} + test + + + + + ${project.artifactId} + + + + io.openliberty.tools + liberty-maven-plugin + ${version.liberty-maven-plugin} + + + ${project.build.directory}/liberty/wlp/usr/shared/resources/ + + org.apache.derby + derby + ${version.derby} + + + + + + org.apache.maven.plugins + maven-war-plugin + ${version.maven-war-plugin} + + + + + + 1.8 + 1.8 + UTF-8 + UTF-8 + false + + 8.0.0 + 3.2 + 10.14.2.0 + 3.3-M3 + 3.2.3 + 1.0.5 + 3.2.6 + 1.0.4 + 3.3.1 + + openliberty + 9080 + 9443 + 7070 + 5.8.1 + + + \ No newline at end of file diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/person/dao/PersonDao.java b/microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/person/dao/PersonDao.java similarity index 100% rename from open-liberty/src/main/java/com/baeldung/openliberty/person/dao/PersonDao.java rename to microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/person/dao/PersonDao.java diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/person/model/Person.java b/microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/person/model/Person.java similarity index 100% rename from open-liberty/src/main/java/com/baeldung/openliberty/person/model/Person.java rename to microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/person/model/Person.java diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/person/resource/PersonResource.java b/microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/person/resource/PersonResource.java similarity index 100% rename from open-liberty/src/main/java/com/baeldung/openliberty/person/resource/PersonResource.java rename to microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/person/resource/PersonResource.java diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/rest/ApiApplication.java b/microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/rest/ApiApplication.java similarity index 100% rename from open-liberty/src/main/java/com/baeldung/openliberty/rest/ApiApplication.java rename to microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/rest/ApiApplication.java diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/rest/consumes/RestConsumer.java b/microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/rest/consumes/RestConsumer.java similarity index 100% rename from open-liberty/src/main/java/com/baeldung/openliberty/rest/consumes/RestConsumer.java rename to microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/rest/consumes/RestConsumer.java diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/servlet/AppServlet.java b/microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/servlet/AppServlet.java similarity index 100% rename from open-liberty/src/main/java/com/baeldung/openliberty/servlet/AppServlet.java rename to microservices-modules/open-liberty/src/main/java/com/baeldung/openliberty/servlet/AppServlet.java diff --git a/open-liberty/src/main/liberty/config/server.xml b/microservices-modules/open-liberty/src/main/liberty/config/server.xml similarity index 100% rename from open-liberty/src/main/liberty/config/server.xml rename to microservices-modules/open-liberty/src/main/liberty/config/server.xml diff --git a/open-liberty/src/main/resources/META-INF/persistence.xml b/microservices-modules/open-liberty/src/main/resources/META-INF/persistence.xml similarity index 100% rename from open-liberty/src/main/resources/META-INF/persistence.xml rename to microservices-modules/open-liberty/src/main/resources/META-INF/persistence.xml diff --git a/open-liberty/src/test/java/com/baeldung/openliberty/RestClientTest.java b/microservices-modules/open-liberty/src/test/java/com/baeldung/openliberty/RestClientLiveTest.java similarity index 96% rename from open-liberty/src/test/java/com/baeldung/openliberty/RestClientTest.java rename to microservices-modules/open-liberty/src/test/java/com/baeldung/openliberty/RestClientLiveTest.java index 4978483ca0..f328d61a57 100644 --- a/open-liberty/src/test/java/com/baeldung/openliberty/RestClientTest.java +++ b/microservices-modules/open-liberty/src/test/java/com/baeldung/openliberty/RestClientLiveTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import com.baeldung.openliberty.person.model.Person; import com.baeldung.openliberty.rest.consumes.RestConsumer; -public class RestClientTest { +public class RestClientLiveTest { private static String BASE_URL; diff --git a/microservices-modules/pom.xml b/microservices-modules/pom.xml new file mode 100644 index 0000000000..3f8eddcdb7 --- /dev/null +++ b/microservices-modules/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + microservices-modules + microservices-modules + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + helidon + micronaut + microprofile + msf4j + open-liberty + + + \ No newline at end of file diff --git a/mustache/pom.xml b/mustache/pom.xml index faa8bfd8a1..b5d39ef15e 100644 --- a/mustache/pom.xml +++ b/mustache/pom.xml @@ -55,7 +55,7 @@ - 0.9.2 + 0.9.10 0.8 3.3.7 diff --git a/mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java b/mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java index 8cdf89d08a..d6b3528dcb 100644 --- a/mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java +++ b/mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java @@ -1,12 +1,11 @@ package com.baeldung.springmustache; +import com.samskivert.mustache.DefaultCollector; import com.samskivert.mustache.Mustache; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.mustache.MustacheEnvironmentCollector; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import org.springframework.core.env.Environment; @SpringBootApplication @ComponentScan(basePackages = {"com.baeldung"}) @@ -17,16 +16,11 @@ public class SpringMustacheApplication { } @Bean - public Mustache.Compiler mustacheCompiler(Mustache.TemplateLoader templateLoader, Environment environment) { - - MustacheEnvironmentCollector collector = new MustacheEnvironmentCollector(); - collector.setEnvironment(environment); - + public Mustache.Compiler mustacheCompiler(Mustache.TemplateLoader templateLoader) { return Mustache.compiler() .defaultValue("Some Default Value") .withLoader(templateLoader) - .withCollector(collector); - + .withCollector(new DefaultCollector()); } } diff --git a/open-liberty/pom.xml b/open-liberty/pom.xml deleted file mode 100644 index df54d9f136..0000000000 --- a/open-liberty/pom.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - 4.0.0 - com.baeldung - open-liberty - 1.0-SNAPSHOT - war - - - - jakarta.platform - jakarta.jakartaee-web-api - ${version.jakarta.jakartaee-web-api} - provided - - - org.eclipse.microprofile - microprofile - ${version.microprofile} - pom - provided - - - org.apache.derby - derby - ${version.derby} - provided - - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - - org.eclipse - yasson - ${version.yasson} - test - - - org.apache.cxf - cxf-rt-rs-client - ${version.cxf-rt-rs-client} - test - - - org.glassfish - javax.json - ${version.javax.json} - test - - - org.apache.cxf - cxf-rt-rs-mp-client - ${version.cxf-rt-rs-mp-client} - test - - - - - ${project.artifactId} - - - - io.openliberty.tools - liberty-maven-plugin - ${version.liberty-maven-plugin} - - - ${project.build.directory}/liberty/wlp/usr/shared/resources/ - - org.apache.derby - derby - ${version.derby} - - - - - - org.apache.maven.plugins - maven-war-plugin - ${version.maven-war-plugin} - - - - - - 1.8 - 1.8 - UTF-8 - UTF-8 - false - - 8.0.0 - 3.2 - 10.14.2.0 - 3.3-M3 - 3.2.3 - 1.0.5 - 3.2.6 - 1.0.4 - 3.3.1 - - openliberty - 9080 - 9443 - 7070 - 5.8.1 - - - \ No newline at end of file diff --git a/optaplanner/pom.xml b/optaplanner/pom.xml index 0e5fa9050e..e1653fd749 100644 --- a/optaplanner/pom.xml +++ b/optaplanner/pom.xml @@ -18,10 +18,16 @@ optaplanner-core ${optaplanner-core.version} + + org.optaplanner + optaplanner-test + ${optaplanner-core.version} + test + - 7.9.0.Final + 8.24.0.Final \ No newline at end of file diff --git a/optaplanner/src/main/java/com/baeldung/optaplanner/CourseSchedule.java b/optaplanner/src/main/java/com/baeldung/optaplanner/CourseSchedule.java index 8a820ab56e..357dfe809f 100644 --- a/optaplanner/src/main/java/com/baeldung/optaplanner/CourseSchedule.java +++ b/optaplanner/src/main/java/com/baeldung/optaplanner/CourseSchedule.java @@ -3,7 +3,7 @@ package com.baeldung.optaplanner; import org.optaplanner.core.api.domain.solution.PlanningEntityCollectionProperty; import org.optaplanner.core.api.domain.solution.PlanningScore; import org.optaplanner.core.api.domain.solution.PlanningSolution; -import org.optaplanner.core.api.domain.solution.drools.ProblemFactCollectionProperty; +import org.optaplanner.core.api.domain.solution.ProblemFactCollectionProperty; import org.optaplanner.core.api.domain.valuerange.ValueRangeProvider; import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore; import org.slf4j.Logger; @@ -16,36 +16,36 @@ import java.util.List; public class CourseSchedule { Logger logger = LoggerFactory.getLogger("CourseSchedule"); - + @ValueRangeProvider(id = "availableRooms") + @ProblemFactCollectionProperty private List roomList; + @ValueRangeProvider(id = "availablePeriods") + @ProblemFactCollectionProperty private List periodList; + @PlanningEntityCollectionProperty private List lectureList; + @PlanningScore private HardSoftScore score; + public CourseSchedule(){ roomList = new ArrayList<>(); periodList = new ArrayList<>(); lectureList = new ArrayList<>(); } - @ValueRangeProvider(id = "availableRooms") - @ProblemFactCollectionProperty public List getRoomList() { return roomList; } - @ValueRangeProvider(id = "availablePeriods") - @ProblemFactCollectionProperty public List getPeriodList() { return periodList; } - @PlanningEntityCollectionProperty public List getLectureList() { return lectureList; } - @PlanningScore public HardSoftScore getScore() { return score; } @@ -54,6 +54,18 @@ public class CourseSchedule { this.score = score; } + public void setRoomList(List roomList) { + this.roomList = roomList; + } + + public void setPeriodList(List periodList) { + this.periodList = periodList; + } + + public void setLectureList(List lectureList) { + this.lectureList = lectureList; + } + public void printCourseSchedule() { lectureList.stream() .map(c -> "Lecture in Room " + c.getRoomNumber().toString() + " during Period " + c.getPeriod().toString()) diff --git a/optaplanner/src/main/java/com/baeldung/optaplanner/CourseScheduleConstraintProvider.java b/optaplanner/src/main/java/com/baeldung/optaplanner/CourseScheduleConstraintProvider.java new file mode 100644 index 0000000000..2733806d16 --- /dev/null +++ b/optaplanner/src/main/java/com/baeldung/optaplanner/CourseScheduleConstraintProvider.java @@ -0,0 +1,24 @@ +package com.baeldung.optaplanner; + +import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore; +import org.optaplanner.core.api.score.stream.Constraint; +import org.optaplanner.core.api.score.stream.ConstraintFactory; +import org.optaplanner.core.api.score.stream.ConstraintProvider; +import org.optaplanner.core.api.score.stream.Joiners; + +public class CourseScheduleConstraintProvider implements ConstraintProvider { + + @Override + public Constraint[] defineConstraints(ConstraintFactory constraintFactory) { + return new Constraint[]{ + roomConflict(constraintFactory) + }; + } + + public Constraint roomConflict(ConstraintFactory constraintFactory){ + return constraintFactory + .forEachUniquePair(Lecture.class, + Joiners.equal(Lecture::getRoomNumber), Joiners.equal(Lecture::getPeriod)) + .penalize("Room conflict", HardSoftScore.ONE_HARD); + } +} diff --git a/optaplanner/src/main/java/com/baeldung/optaplanner/Lecture.java b/optaplanner/src/main/java/com/baeldung/optaplanner/Lecture.java index 48af4e89d1..b63bd21030 100644 --- a/optaplanner/src/main/java/com/baeldung/optaplanner/Lecture.java +++ b/optaplanner/src/main/java/com/baeldung/optaplanner/Lecture.java @@ -1,14 +1,24 @@ package com.baeldung.optaplanner; import org.optaplanner.core.api.domain.entity.PlanningEntity; +import org.optaplanner.core.api.domain.lookup.PlanningId; import org.optaplanner.core.api.domain.variable.PlanningVariable; @PlanningEntity public class Lecture { + @PlanningId + private Long id; private Integer roomNumber; private Integer period; + public Lecture(Long i) { + this.id = i; + } + + public Lecture() { + } + @PlanningVariable(valueRangeProviderRefs = {"availablePeriods"}) public Integer getPeriod() { return period; diff --git a/optaplanner/src/main/java/com/baeldung/optaplanner/ScoreCalculator.java b/optaplanner/src/main/java/com/baeldung/optaplanner/ScoreCalculator.java index 11e5e4a5be..3e3747f764 100644 --- a/optaplanner/src/main/java/com/baeldung/optaplanner/ScoreCalculator.java +++ b/optaplanner/src/main/java/com/baeldung/optaplanner/ScoreCalculator.java @@ -1,15 +1,14 @@ package com.baeldung.optaplanner; -import org.optaplanner.core.api.score.Score; import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore; -import org.optaplanner.core.impl.score.director.easy.EasyScoreCalculator; +import org.optaplanner.core.api.score.calculator.EasyScoreCalculator; import java.util.HashSet; -public class ScoreCalculator implements EasyScoreCalculator { +public class ScoreCalculator implements EasyScoreCalculator { @Override - public Score calculateScore(CourseSchedule courseSchedule) { + public HardSoftScore calculateScore(CourseSchedule courseSchedule) { int hardScore = 0; int softScore = 0; @@ -27,6 +26,6 @@ public class ScoreCalculator implements EasyScoreCalculator { } } - return HardSoftScore.valueOf(hardScore, softScore); + return HardSoftScore.of(hardScore, softScore); } } diff --git a/optaplanner/src/main/resources/courseSchedule.drl b/optaplanner/src/main/resources/courseSchedule.drl deleted file mode 100644 index 9372a24976..0000000000 --- a/optaplanner/src/main/resources/courseSchedule.drl +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.optaplanner - -import com.baeldung.optaplanner.Lecture; -import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScoreHolder; - -global HardSoftScoreHolder scoreHolder; - -rule "noNullRoomPeriod" - when - Lecture( roomNumber == null ); - Lecture( period == null ); - then - scoreHolder.addHardConstraintMatch(kcontext, -1); -end \ No newline at end of file diff --git a/optaplanner/src/main/resources/courseScheduleSolverConfigDrools.xml b/optaplanner/src/main/resources/courseScheduleSolverConfigDrools.xml deleted file mode 100644 index 7cf95fdcd3..0000000000 --- a/optaplanner/src/main/resources/courseScheduleSolverConfigDrools.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - courseSchedule.drl - - - - 10 - - \ No newline at end of file diff --git a/optaplanner/src/main/resources/courseScheduleSolverConfiguration.xml b/optaplanner/src/main/resources/courseScheduleSolverConfiguration.xml deleted file mode 100644 index 0ad2264dcd..0000000000 --- a/optaplanner/src/main/resources/courseScheduleSolverConfiguration.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - com.baeldung.optaplanner.ScoreCalculator - - - - 10 - - \ No newline at end of file diff --git a/optaplanner/src/main/resources/logback.xml b/optaplanner/src/main/resources/logback.xml index c109aa19e2..34da901079 100644 --- a/optaplanner/src/main/resources/logback.xml +++ b/optaplanner/src/main/resources/logback.xml @@ -1,3 +1,16 @@ + + + + + %d{HH:mm:ss.SSS} [%-12.12t] %-5p %m%n + + + - \ No newline at end of file + + + + + + diff --git a/optaplanner/src/test/java/com/baeldung/optaplanner/test/CourseScheduleConstraintProviderUnitTest.java b/optaplanner/src/test/java/com/baeldung/optaplanner/test/CourseScheduleConstraintProviderUnitTest.java new file mode 100644 index 0000000000..22de095ce9 --- /dev/null +++ b/optaplanner/src/test/java/com/baeldung/optaplanner/test/CourseScheduleConstraintProviderUnitTest.java @@ -0,0 +1,28 @@ +package com.baeldung.optaplanner.test; + +import com.baeldung.optaplanner.CourseSchedule; +import com.baeldung.optaplanner.CourseScheduleConstraintProvider; +import com.baeldung.optaplanner.Lecture; +import org.junit.jupiter.api.Test; +import org.optaplanner.test.api.score.stream.ConstraintVerifier; + +public class CourseScheduleConstraintProviderUnitTest { + + private final ConstraintVerifier constraintVerifier = + ConstraintVerifier.build(new CourseScheduleConstraintProvider(), CourseSchedule.class, Lecture.class); + + @Test + public void testCourseScheduleConstraint() { + + Lecture lecture = new Lecture(0L); + lecture.setPeriod(1); + lecture.setRoomNumber(1); + Lecture conflictedLecture = new Lecture(1L); + conflictedLecture.setPeriod(1); + conflictedLecture.setRoomNumber(1); + + constraintVerifier.verifyThat(CourseScheduleConstraintProvider::roomConflict) + .given(lecture, conflictedLecture) + .penalizesBy(1); + } +} diff --git a/optaplanner/src/test/java/com/baeldung/optaplanner/test/OptaPlannerUnitTest.java b/optaplanner/src/test/java/com/baeldung/optaplanner/test/OptaPlannerUnitTest.java index 2847a233a5..2b72765074 100644 --- a/optaplanner/src/test/java/com/baeldung/optaplanner/test/OptaPlannerUnitTest.java +++ b/optaplanner/src/test/java/com/baeldung/optaplanner/test/OptaPlannerUnitTest.java @@ -1,16 +1,26 @@ package com.baeldung.optaplanner.test; import com.baeldung.optaplanner.CourseSchedule; +import com.baeldung.optaplanner.CourseScheduleConstraintProvider; import com.baeldung.optaplanner.Lecture; +import com.baeldung.optaplanner.ScoreCalculator; import org.junit.Assert; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.optaplanner.core.api.score.ScoreManager; import org.optaplanner.core.api.solver.Solver; import org.optaplanner.core.api.solver.SolverFactory; +import org.optaplanner.core.config.solver.SolverConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.time.Duration; import java.util.Arrays; public class OptaPlannerUnitTest { + Logger logger = LoggerFactory.getLogger("OptaPlannerUnitTest"); + static CourseSchedule unsolvedCourseSchedule; @BeforeAll @@ -18,8 +28,8 @@ public class OptaPlannerUnitTest { unsolvedCourseSchedule = new CourseSchedule(); - for(int i = 0; i < 10; i++){ - unsolvedCourseSchedule.getLectureList().add(new Lecture()); + for(long i = 0; i < 10; i++) { + unsolvedCourseSchedule.getLectureList().add(new Lecture(i)); } unsolvedCourseSchedule.getPeriodList().addAll(Arrays.asList(new Integer[] { 1, 2, 3 })); @@ -29,7 +39,12 @@ public class OptaPlannerUnitTest { @Test public void test_whenCustomJavaSolver() { - SolverFactory solverFactory = SolverFactory.createFromXmlResource("courseScheduleSolverConfiguration.xml"); + SolverFactory solverFactory = SolverFactory.create(new SolverConfig() + .withSolutionClass(CourseSchedule.class) + .withEntityClasses(Lecture.class) + .withEasyScoreCalculatorClass(ScoreCalculator.class) + .withTerminationSpentLimit(Duration.ofSeconds(1))); + Solver solver = solverFactory.buildSolver(); CourseSchedule solvedCourseSchedule = solver.solve(unsolvedCourseSchedule); @@ -38,13 +53,22 @@ public class OptaPlannerUnitTest { } @Test - public void test_whenDroolsSolver() { + public void test_whenConstraintStreamSolver() { + + SolverFactory solverFactory = SolverFactory.create(new SolverConfig() + .withSolutionClass(CourseSchedule.class) + .withEntityClasses(Lecture.class) + .withConstraintProviderClass(CourseScheduleConstraintProvider.class) + .withTerminationSpentLimit(Duration.ofSeconds(1))); - SolverFactory solverFactory = SolverFactory.createFromXmlResource("courseScheduleSolverConfigDrools.xml"); Solver solver = solverFactory.buildSolver(); CourseSchedule solvedCourseSchedule = solver.solve(unsolvedCourseSchedule); + logger.info(ScoreManager.create(solverFactory).explainScore(solvedCourseSchedule).getSummary()); + Assert.assertNotNull(solvedCourseSchedule.getScore()); - Assert.assertEquals(0, solvedCourseSchedule.getScore().getHardScore()); + Assert.assertEquals(-4, solvedCourseSchedule.getScore().getHardScore()); + } + } diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml index 85f1805a00..1d6c593293 100644 --- a/parent-boot-2/pom.xml +++ b/parent-boot-2/pom.xml @@ -88,8 +88,8 @@ 3.3.0 1.0.22.RELEASE - 2.6.4 + 2.7.2 1.9.1 - \ No newline at end of file + diff --git a/parent-boot-3/pom.xml b/parent-boot-3/pom.xml index 711096fec8..6234b471ce 100644 --- a/parent-boot-3/pom.xml +++ b/parent-boot-3/pom.xml @@ -89,7 +89,6 @@ 3.0.0-M3 5.8.2 3.0.0-M7 - 1.18.22 17 3.17.0 diff --git a/persistence-modules/fauna/README.md b/persistence-modules/fauna/README.md index f0899ceaf7..245c2a613b 100644 --- a/persistence-modules/fauna/README.md +++ b/persistence-modules/fauna/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Building a web app Using Fauna and Spring for Your First web Agency Client](https://www.baeldung.com/faunadb-spring-web-app) +- [Building IoT Applications Using Fauna and Spring](https://www.baeldung.com/fauna-spring-building-iot-applications) diff --git a/persistence-modules/flyway/pom.xml b/persistence-modules/flyway/pom.xml index a339a266e3..67dd0644bd 100644 --- a/persistence-modules/flyway/pom.xml +++ b/persistence-modules/flyway/pom.xml @@ -19,7 +19,6 @@ org.flywaydb flyway-core - ${flyway-core.version} org.springframework.boot @@ -64,8 +63,8 @@ - 8.0.0 - 8.0.0 + 8.5.13 + 2.1.214 \ No newline at end of file diff --git a/persistence-modules/r2dbc/pom.xml b/persistence-modules/r2dbc/pom.xml index 1ce5eb3e96..f32b37974b 100644 --- a/persistence-modules/r2dbc/pom.xml +++ b/persistence-modules/r2dbc/pom.xml @@ -39,7 +39,6 @@ io.r2dbc r2dbc-h2 - ${r2dbc-h2.version} org.springframework.boot @@ -61,8 +60,4 @@ - - 0.8.1.RELEASE - - \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties index a1243dc1df..b030527cca 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties @@ -11,4 +11,5 @@ logging.level.org.hibernate.SQL=INFO logging.level.org.hibernate.type=INFO spring.jpa.properties.hibernate.validator.apply_to_ddl=false spring.jpa.properties.hibernate.enable_lazy_load_no_trans=false +spring.jpa.properties.hibernate.globally_quoted_identifiers=true spring.jpa.open-in-view=false \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties index 2ea89b2ee6..972a7bb0f3 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties @@ -11,4 +11,5 @@ logging.level.org.hibernate.SQL=INFO logging.level.org.hibernate.type=INFO spring.jpa.properties.hibernate.validator.apply_to_ddl=false spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true +spring.jpa.properties.hibernate.globally_quoted_identifiers=true spring.jpa.open-in-view=false \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties index be939ffa69..e745c7455e 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties @@ -8,3 +8,4 @@ spring.h2.console.enabled=true spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.database-platform=org.hibernate.dialect.H2Dialect spring.h2.console.path=/h2-console +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties index 2499d7cd06..4dd2caf075 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties @@ -7,6 +7,8 @@ spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.show-sql=false spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.validator.apply_to_ddl=false +spring.jpa.properties.hibernate.globally_quoted_identifiers=true + #spring.jpa.properties.hibernate.check_nullability=true spring.h2.console.enabled=true spring.h2.console.path=/h2-console diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml index aeb33f797a..1b8cfbb558 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml @@ -12,3 +12,6 @@ spring: driverClassName: org.h2.Driver jpa: spring.jpa.database-platform: org.hibernate.dialect.H2Dialect + properties: + hibernate: + globally_quoted_identifiers: true diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql index 3d04b578d2..2566a8d125 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql @@ -1,5 +1,5 @@ -INSERT INTO countries (id, name) VALUES (1, 'USA'); -INSERT INTO countries (id, name) VALUES (2, 'France'); -INSERT INTO countries (id, name) VALUES (3, 'Brazil'); -INSERT INTO countries (id, name) VALUES (4, 'Italy'); -INSERT INTO countries (id, name) VALUES (5, 'Canada'); \ No newline at end of file +INSERT INTO "countries" VALUES (1, 'USA'); +INSERT INTO "countries" VALUES (2, 'France'); +INSERT INTO "countries" VALUES (3, 'Brazil'); +INSERT INTO "countries" VALUES (4, 'Italy'); +INSERT INTO "countries" VALUES (5, 'Canada'); \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql index e4fda99437..2b4aa92542 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql @@ -1,12 +1,12 @@ -insert into USER values (101, 'user1', 'comment1'); -insert into USER values (102, 'user2', 'comment2'); -insert into USER values (103, 'user3', 'comment3'); -insert into USER values (104, 'user4', 'comment4'); -insert into USER values (105, 'user5', 'comment5'); +insert into "user" values (101, 'user1', 'comment1'); +insert into "user" values (102, 'user2', 'comment2'); +insert into "user" values (103, 'user3', 'comment3'); +insert into "user" values (104, 'user4', 'comment4'); +insert into "user" values (105, 'user5', 'comment5'); -insert into DOCUMENT values (1, 'doc1', 101); -insert into DOCUMENT values (2, 'doc2', 101); -insert into DOCUMENT values (3, 'doc3', 101); -insert into DOCUMENT values (4, 'doc4', 101); -insert into DOCUMENT values (5, 'doc5', 102); -insert into DOCUMENT values (6, 'doc6', 102); \ No newline at end of file +insert into "document" values (1, 'doc1', 101); +insert into "document" values (2, 'doc2', 101); +insert into "document" values (3, 'doc3', 101); +insert into "document" values (4, 'doc4', 101); +insert into "document" values (5, 'doc5', 102); +insert into "document" values (6, 'doc6', 102); \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-mongodb-2/README.md b/persistence-modules/spring-boot-persistence-mongodb-2/README.md index 6a98f05520..d2cfb28843 100644 --- a/persistence-modules/spring-boot-persistence-mongodb-2/README.md +++ b/persistence-modules/spring-boot-persistence-mongodb-2/README.md @@ -5,4 +5,5 @@ - [MongoDB Composite Key With Spring Data](https://www.baeldung.com/spring-data-mongodb-composite-key) - [Unique Field in MongoDB Document in Spring Data](https://www.baeldung.com/spring-data-mongodb-unique) - [Count Documents Using Spring Data MongoDB Repository](https://www.baeldung.com/spring-data-mongodb-count) +- [Spring Data MongoDB – Configure Connection](https://www.baeldung.com/spring-data-mongodb-connection) - More articles: [[<--prev]](../spring-boot-persistence-mongodb) diff --git a/persistence-modules/spring-boot-persistence-mongodb-2/pom.xml b/persistence-modules/spring-boot-persistence-mongodb-2/pom.xml index a745d4efc4..cd7198b931 100644 --- a/persistence-modules/spring-boot-persistence-mongodb-2/pom.xml +++ b/persistence-modules/spring-boot-persistence-mongodb-2/pom.xml @@ -27,13 +27,8 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo - ${embed.mongo.version} test - - 3.2.6 - - \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-mongodb/pom.xml b/persistence-modules/spring-boot-persistence-mongodb/pom.xml index 8b36474777..724fa38f7e 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/pom.xml +++ b/persistence-modules/spring-boot-persistence-mongodb/pom.xml @@ -32,13 +32,8 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo - ${embed.mongo.version} test - - 3.2.6 - - \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java index 6325d2cd2e..d3a09c08ff 100644 --- a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java @@ -66,6 +66,7 @@ public class H2JpaConfig { hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); hibernateProperties.setProperty("hibernate.show_sql", env.getProperty("hibernate.show_sql")); + hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", env.getProperty("hibernate.globally_quoted_identifiers")); return hibernateProperties; } diff --git a/persistence-modules/spring-boot-persistence/src/main/resources/application.properties b/persistence-modules/spring-boot-persistence/src/main/resources/application.properties index 7b5a467a2b..52bfc00712 100644 --- a/persistence-modules/spring-boot-persistence/src/main/resources/application.properties +++ b/persistence-modules/spring-boot-persistence/src/main/resources/application.properties @@ -8,4 +8,6 @@ spring.jpa.hibernate.ddl-auto = create spring.h2.console.enabled=true # Uppercase Table Names -spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl \ No newline at end of file +spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + +hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java index d7bb44e133..226a5a550a 100644 --- a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java @@ -22,7 +22,7 @@ public class SpringBootProfileIntegrationTest { private GenericEntityRepository genericEntityRepository; @Test - public void givenGenericEntityRepository_whenSaveAndRetreiveEntity_thenOK() { + public void givenGenericEntityRepository_whenSaveAndRetrieveEntity_thenOK() { GenericEntity genericEntity = genericEntityRepository.save(new GenericEntity("test")); GenericEntity foundEntity = genericEntityRepository.findById(genericEntity.getId()).orElse(null); assertNotNull(foundEntity); diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java index f73000a10e..515350fe0a 100644 --- a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java @@ -62,6 +62,7 @@ public class H2TestProfileJPAConfig { hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); hibernateProperties.setProperty("hibernate.show_sql", env.getProperty("hibernate.show_sql")); + hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", env.getProperty("hibernate.globally_quoted_identifiers")); return hibernateProperties; } diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootinitialload/tests/SpringBootSqlGroupAnnotationIntegrationTest.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootinitialload/tests/SpringBootSqlGroupAnnotationIntegrationTest.java index 0153d463a2..e584645742 100644 --- a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootinitialload/tests/SpringBootSqlGroupAnnotationIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootinitialload/tests/SpringBootSqlGroupAnnotationIntegrationTest.java @@ -17,8 +17,10 @@ import com.baeldung.boot.repository.EmployeeRepository; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -@SqlGroup({ @Sql(scripts = "/employees_schema.sql", config = @SqlConfig(transactionMode = TransactionMode.ISOLATED)), - @Sql("/import_employees.sql")}) +@SqlGroup({ + @Sql(scripts = "/employees_schema.sql", config = @SqlConfig(transactionMode = TransactionMode.ISOLATED)), + @Sql("/import_employees.sql")} +) public class SpringBootSqlGroupAnnotationIntegrationTest { @Autowired diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/application.properties b/persistence-modules/spring-boot-persistence/src/test/resources/application.properties index b268f46094..9f6f3f60d2 100644 --- a/persistence-modules/spring-boot-persistence/src/test/resources/application.properties +++ b/persistence-modules/spring-boot-persistence/src/test/resources/application.properties @@ -19,6 +19,7 @@ hibernate.hbm2ddl.auto=create-drop hibernate.cache.use_second_level_cache=true hibernate.cache.use_query_cache=true hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory +hibernate.globally_quoted_identifiers=true spring.jpa.properties.hibernate.hbm2ddl.import_files=import_books.sql spring.sql.init.data-locations=import_*_users.sql \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/import_employees.sql b/persistence-modules/spring-boot-persistence/src/test/resources/import_employees.sql index 40442d2804..f234d02fd9 100644 --- a/persistence-modules/spring-boot-persistence/src/test/resources/import_employees.sql +++ b/persistence-modules/spring-boot-persistence/src/test/resources/import_employees.sql @@ -1,3 +1,5 @@ -insert into EMPLOYEES values(1, 'Harsha', 'Developer'); -insert into EMPLOYEES values(2, 'John', 'Tester'); -insert into EMPLOYEES values(3, 'Ram', 'Manager'); \ No newline at end of file +delete from "employees"; + +insert into "employees" values(1, 'Harsha', 'Developer'); +insert into "employees" values(2, 'John', 'Tester'); +insert into "employees" values(3, 'Ram', 'Manager'); \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/import_senior_employees.sql b/persistence-modules/spring-boot-persistence/src/test/resources/import_senior_employees.sql index 3d0819175b..e4af4651a7 100644 --- a/persistence-modules/spring-boot-persistence/src/test/resources/import_senior_employees.sql +++ b/persistence-modules/spring-boot-persistence/src/test/resources/import_senior_employees.sql @@ -1,2 +1,2 @@ -insert into EMPLOYEES values(4, 'Eric', 'Senior Developer'); -insert into EMPLOYEES values(5, 'Vidhyaah', 'Senior Manager'); \ No newline at end of file +insert into "employees" values(4, 'Eric', 'Senior Developer'); +insert into "employees" values(5, 'Vidhyaah', 'Senior Manager'); \ No newline at end of file diff --git a/persistence-modules/spring-data-cassandra-test/pom.xml b/persistence-modules/spring-data-cassandra-test/pom.xml index 5d9bcc63c2..d335c0d4ba 100644 --- a/persistence-modules/spring-data-cassandra-test/pom.xml +++ b/persistence-modules/spring-data-cassandra-test/pom.xml @@ -60,7 +60,6 @@ 2.5.3 - 1.18.18 4.13.0 4.3.1.0 1.15.3 diff --git a/persistence-modules/spring-data-jdbc/src/main/resources/schema.sql b/persistence-modules/spring-data-jdbc/src/main/resources/schema.sql index 5618822bf9..2c431d2340 100644 --- a/persistence-modules/spring-data-jdbc/src/main/resources/schema.sql +++ b/persistence-modules/spring-data-jdbc/src/main/resources/schema.sql @@ -1,5 +1,5 @@ create table person ( - id integer identity primary key, + id int GENERATED ALWAYS AS IDENTITY PRIMARY KEY, first_name varchar(30), last_name varchar(30) ); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-annotations/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java b/persistence-modules/spring-data-jpa-annotations/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java index f456b15652..cfef3a6a5e 100644 --- a/persistence-modules/spring-data-jpa-annotations/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java +++ b/persistence-modules/spring-data-jpa-annotations/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java @@ -13,6 +13,6 @@ public interface CompanyRepository extends JpaRepository { @Query("SELECT C FROM Company C WHERE C.contactPerson.firstName = ?1") List findByContactPersonFirstNameWithJPQL(String firstName); - @Query(value = "SELECT * FROM company WHERE contact_first_name = ?1", nativeQuery = true) + @Query(value = "SELECT * FROM \"company\" WHERE \"contact_first_name\" = ?1", nativeQuery = true) List findByContactPersonFirstNameWithNativeQuery(String firstName); } diff --git a/persistence-modules/spring-data-jpa-annotations/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-annotations/src/main/resources/application.properties index f127dd5e50..6f871a25b7 100644 --- a/persistence-modules/spring-data-jpa-annotations/src/main/resources/application.properties +++ b/persistence-modules/spring-data-jpa-annotations/src/main/resources/application.properties @@ -4,3 +4,5 @@ spring.jpa.properties.hibernate.jdbc.batch_size=4 spring.jpa.properties.hibernate.order_inserts=true spring.jpa.properties.hibernate.order_updates=true spring.jpa.properties.hibernate.generate_statistics=true + +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-data-jpa-crud-2/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-crud-2/src/main/resources/application.properties new file mode 100644 index 0000000000..ead0df89a3 --- /dev/null +++ b/persistence-modules/spring-data-jpa-crud-2/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/boot/daos/user/UserRepository.java b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/boot/daos/user/UserRepository.java index cfa99414c6..a2c816b1c4 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/boot/daos/user/UserRepository.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/boot/daos/user/UserRepository.java @@ -21,7 +21,7 @@ public interface UserRepository extends JpaRepository , UserRepos @Query("SELECT u FROM User u WHERE u.status = 1") Collection findAllActiveUsers(); - + @Query("select u from User u where u.email like '%@gmail.com'") List findUsersWithGmailAddress(); @@ -75,14 +75,14 @@ public interface UserRepository extends JpaRepository , UserRepos @Query(value = "INSERT INTO Users (name, age, email, status, active) VALUES (:name, :age, :email, :status, :active)", nativeQuery = true) @Modifying void insertUser(@Param("name") String name, @Param("age") Integer age, @Param("email") String email, @Param("status") Integer status, @Param("active") boolean active); - + @Modifying @Query(value = "UPDATE Users u SET status = ? WHERE u.name = ?", nativeQuery = true) int updateUserSetStatusForNameNativePostgres(Integer status, String name); - + @Query(value = "SELECT u FROM User u WHERE u.name IN :names") List findUserByNameList(@Param("names") Collection names); - + void deleteAllByCreationDateAfter(LocalDate date); @Modifying(clearAutomatically = true, flushAutomatically = true) @@ -97,6 +97,6 @@ public interface UserRepository extends JpaRepository , UserRepos int deleteDeactivatedUsersWithNoModifyingAnnotation(); @Modifying(clearAutomatically = true, flushAutomatically = true) - @Query(value = "alter table USERS add column deleted int(1) not null default 0", nativeQuery = true) + @Query(value = "alter table USERS add column deleted int not null default 0", nativeQuery = true) void addDeletedColumn(); } diff --git a/persistence-modules/spring-data-jpa-filtering/src/main/java/com/baeldung/config/StudentJpaConfig.java b/persistence-modules/spring-data-jpa-filtering/src/main/java/com/baeldung/config/StudentJpaConfig.java index 08f37ea806..bcb3b2fc8c 100644 --- a/persistence-modules/spring-data-jpa-filtering/src/main/java/com/baeldung/config/StudentJpaConfig.java +++ b/persistence-modules/spring-data-jpa-filtering/src/main/java/com/baeldung/config/StudentJpaConfig.java @@ -62,6 +62,7 @@ public class StudentJpaConfig { hibernateProperties.setProperty("hibernate.show_sql", env.getProperty("hibernate.show_sql")); hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", env.getProperty("hibernate.cache.use_second_level_cache")); hibernateProperties.setProperty("hibernate.cache.use_query_cache", env.getProperty("hibernate.cache.use_query_cache")); + hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", env.getProperty("hibernate.globally_quoted_identifiers")); return hibernateProperties; } diff --git a/persistence-modules/spring-data-jpa-filtering/src/test/resources/persistence-student.properties b/persistence-modules/spring-data-jpa-filtering/src/test/resources/persistence-student.properties index 3b6b580630..a2a83f5dee 100644 --- a/persistence-modules/spring-data-jpa-filtering/src/test/resources/persistence-student.properties +++ b/persistence-modules/spring-data-jpa-filtering/src/test/resources/persistence-student.properties @@ -6,4 +6,6 @@ hibernate.show_sql=true hibernate.hbm2ddl.auto=create hibernate.cache.use_second_level_cache=false -hibernate.cache.use_query_cache=false \ No newline at end of file +hibernate.cache.use_query_cache=false + +hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java index a0d70ed006..64fe4d7724 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java @@ -64,7 +64,7 @@ public class PersistenceConfig { public AuditorAware auditorProvider() { return new AuditorAwareImpl(); } - + @Bean public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); @@ -175,7 +175,7 @@ public class PersistenceConfig { hibernateProperties.setProperty("hibernate.show_sql", "true"); // hibernateProperties.setProperty("hibernate.format_sql", "true"); - // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); // Envers properties hibernateProperties.setProperty("org.hibernate.envers.audit_table_suffix", env.getProperty("envers.audit_table_suffix")); diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml index 1b9a4a191c..dcc3e76cf5 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml @@ -12,8 +12,8 @@ org.hibernate.dialect.MySQLDialect true validate - - + true + diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml index c5f608e1a7..8fe08b10c3 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml @@ -11,6 +11,7 @@ iamtheking org.hibernate.dialect.MySQLDialect true + true diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql b/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql index 330b2e36b0..e0aca9ac41 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql @@ -1,8 +1,8 @@ -insert into Users(id, name, creation_date, last_login_date, active, age, email, status) -values(1, 'John', TO_DATE('01/01/2018', 'DD/MM/YYYY'), TO_DATE('01/01/2020', 'DD/MM/YYYY'), 1, 23, 'john@email.com', 1); +insert into Users(name, creation_date, last_login_date, active, age, email, status) +values('John', PARSEDATETIME('01/01/2018', 'dd/MM/yyyy'), PARSEDATETIME('01/01/2020', 'dd/MM/yyyy'), 1, 23, 'john@email.com', 1); -insert into Users(id, name, creation_date, last_login_date, active, age, email, status) -values(2, 'Bob', TO_DATE('02/02/2019', 'DD/MM/YYYY'), TO_DATE('02/02/2020', 'DD/MM/YYYY'), 1, 56, 'bob@email.com', 1); +insert into Users(name, creation_date, last_login_date, active, age, email, status) +values('Bob', PARSEDATETIME('02/02/2019', 'dd/MM/yyyy'), PARSEDATETIME('02/02/2020', 'dd/MM/yyyy'), 1, 56, 'bob@email.com', 1); -insert into Users(id, name, creation_date, last_login_date, active, age, email, status) -values(3, 'Cindy', TO_DATE('02/02/2019', 'DD/MM/YYYY'), TO_DATE('02/02/2020', 'DD/MM/YYYY'), 1, 18, 'cindy@email.com', 0); \ No newline at end of file +insert into Users(name, creation_date, last_login_date, active, age, email, status) +values('Cindy', PARSEDATETIME('02/02/2019', 'dd/MM/yyyy'), PARSEDATETIME('02/02/2020', 'dd/MM/yyyy'), 1, 18, 'cindy@email.com', 0); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java index 65bf36f8bf..e90207a170 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java @@ -15,7 +15,7 @@ public class HibernateFetchingIntegrationTest { // this loads sample data in the database @Before - public void addFecthingTestData() { + public void addFetchingTestData() { FetchingAppView fav = new FetchingAppView(); fav.createTestData(); } diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml index 4d3ff2ae63..c14a3ecd7a 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml +++ b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml @@ -12,7 +12,8 @@ org.hibernate.dialect.H2Dialect update false - + true + diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml index 8a2bf593cb..ad6ee0ed46 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml +++ b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml @@ -12,6 +12,7 @@ org.hibernate.dialect.H2Dialect update false + true diff --git a/persistence-modules/spring-data-jpa-query-3/src/main/resources/import_entities.sql b/persistence-modules/spring-data-jpa-query-3/src/main/resources/import_entities.sql index 4fe18bf4aa..ce71bc744c 100644 --- a/persistence-modules/spring-data-jpa-query-3/src/main/resources/import_entities.sql +++ b/persistence-modules/spring-data-jpa-query-3/src/main/resources/import_entities.sql @@ -1,3 +1,3 @@ -insert into Article(id, publication_date, publication_time, creation_date_time) values(1, TO_DATE('01/01/2018', 'DD/MM/YYYY'), TO_DATE('15:00', 'HH24:MI'), TO_DATE('31/12/2017 07:30', 'DD/MM/YYYY HH24:MI')); -insert into Article(id, publication_date, publication_time, creation_date_time) values(2, TO_DATE('01/01/2018', 'DD/MM/YYYY'), TO_DATE('15:30', 'HH24:MI'), TO_DATE('15/12/2017 08:00', 'DD/MM/YYYY HH24:MI')); -insert into Article(id, publication_date, publication_time, creation_date_time) values(3, TO_DATE('15/12/2017', 'DD/MM/YYYY'), TO_DATE('16:00', 'HH24:MI'), TO_DATE('01/12/2017 13:45', 'DD/MM/YYYY HH24:MI')); \ No newline at end of file +insert into Article(id, publication_date, publication_time, creation_date_time) values(1, PARSEDATETIME('01/01/2018', 'dd/MM/yyyy'), PARSEDATETIME('15:00', 'HH:mm'), PARSEDATETIME('31/12/2017 07:30', 'dd/MM/yyyy HH:mm')); +insert into Article(id, publication_date, publication_time, creation_date_time) values(2, PARSEDATETIME('01/01/2018', 'dd/MM/yyyy'), PARSEDATETIME('15:30', 'HH:mm'), PARSEDATETIME('15/12/2017 08:00', 'dd/MM/yyyy HH:mm')); +insert into Article(id, publication_date, publication_time, creation_date_time) values(3, PARSEDATETIME('15/12/2017', 'dd/MM/yyyy'), PARSEDATETIME('16:00', 'HH:mm'), PARSEDATETIME('01/12/2017 13:45', 'dd/MM/yyyy HH:mm')); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/aggregation/repository/CommentRepository.java b/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/aggregation/repository/CommentRepository.java index 89e9345e94..5309581638 100644 --- a/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/aggregation/repository/CommentRepository.java +++ b/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/aggregation/repository/CommentRepository.java @@ -21,7 +21,7 @@ public interface CommentRepository extends JpaRepository { @Query("SELECT c.year AS yearComment, COUNT(c.year) AS totalComment FROM Comment AS c GROUP BY c.year ORDER BY c.year DESC") List countTotalCommentsByYearInterface(); - @Query(value = "SELECT c.year AS yearComment, COUNT(c.*) AS totalComment FROM comment AS c GROUP BY c.year ORDER BY c.year DESC", nativeQuery = true) + @Query(value = "SELECT c.\"year\" AS yearComment, COUNT(c.*) AS totalComment FROM \"comment\" AS c GROUP BY c.\"year\" ORDER BY c.\"year\" DESC", nativeQuery = true) List countTotalCommentsByYearNative(); } diff --git a/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties index eb0e519ef0..7850367c64 100644 --- a/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties +++ b/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties @@ -1,2 +1,4 @@ spring.jpa.show-sql=false -spring.jpa.defer-datasource-initialization=true \ No newline at end of file +spring.jpa.defer-datasource-initialization=true + +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-data-jpa-query/src/main/resources/db/import_joins.sql b/persistence-modules/spring-data-jpa-query/src/main/resources/db/import_joins.sql index e4772d6ff2..7598064278 100644 --- a/persistence-modules/spring-data-jpa-query/src/main/resources/db/import_joins.sql +++ b/persistence-modules/spring-data-jpa-query/src/main/resources/db/import_joins.sql @@ -1,13 +1,13 @@ -INSERT INTO department (id, name) VALUES (1, 'Infra'); -INSERT INTO department (id, name) VALUES (2, 'Accounting'); -INSERT INTO department (id, name) VALUES (3, 'Management'); +INSERT INTO "department" ("id", "name") VALUES (1, 'Infra'); +INSERT INTO "department" ("id", "name") VALUES (2, 'Accounting'); +INSERT INTO "department" ("id", "name") VALUES (3, 'Management'); -INSERT INTO joins_employee (id, name, age, department_id) VALUES (1, 'Baeldung', '35', 1); -INSERT INTO joins_employee (id, name, age, department_id) VALUES (2, 'John', '35', 2); -INSERT INTO joins_employee (id, name, age, department_id) VALUES (3, 'Jane', '35', 2); +INSERT INTO "joins_employee" ("id", "name", "age", "department_id") VALUES (1, 'Baeldung', '35', 1); +INSERT INTO "joins_employee" ("id", "name", "age", "department_id") VALUES (2, 'John', '35', 2); +INSERT INTO "joins_employee" ("id", "name", "age", "department_id") VALUES (3, 'Jane', '35', 2); -INSERT INTO phone (id, number, employee_id) VALUES (1, '111', 1); -INSERT INTO phone (id, number, employee_id) VALUES (2, '222', 1); -INSERT INTO phone (id, number, employee_id) VALUES (3, '333', 1); +INSERT INTO "phone" ("id", "number", "employee_id") VALUES (1, '111', 1); +INSERT INTO "phone" ("id", "number", "employee_id") VALUES (2, '222', 1); +INSERT INTO "phone" ("id", "number", "employee_id") VALUES (3, '333', 1); COMMIT; diff --git a/persistence-modules/spring-data-jpa-query/src/test/resources/entitygraph-data.sql b/persistence-modules/spring-data-jpa-query/src/test/resources/entitygraph-data.sql index 685ec2c605..73994d88cc 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/resources/entitygraph-data.sql +++ b/persistence-modules/spring-data-jpa-query/src/test/resources/entitygraph-data.sql @@ -1,7 +1,7 @@ -INSERT INTO Item(id,name) VALUES (1,'Table'); -INSERT INTO Item(id,name) VALUES (2,'Bottle'); +INSERT INTO "item" ("id", "name") VALUES (1,'Table'); +INSERT INTO "item" ("id", "name") VALUES (2,'Bottle'); -INSERT INTO Characteristic(id,item_id, type) VALUES (1,1,'Rigid'); -INSERT INTO Characteristic(id,item_id,type) VALUES (2,1,'Big'); -INSERT INTO Characteristic(id,item_id,type) VALUES (3,2,'Fragile'); -INSERT INTO Characteristic(id,item_id,type) VALUES (4,2,'Small'); \ No newline at end of file +INSERT INTO "characteristic" ("id", "item_id", "type") VALUES (1,1,'Rigid'); +INSERT INTO "characteristic" ("id", "item_id", "type") VALUES (2,1,'Big'); +INSERT INTO "characteristic" ("id", "item_id", "type") VALUES (3,2,'Fragile'); +INSERT INTO "characteristic" ("id", "item_id", "type") VALUES (4,2,'Small'); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query/src/test/resources/test-aggregation-data.sql b/persistence-modules/spring-data-jpa-query/src/test/resources/test-aggregation-data.sql index 12409a124e..ece64240ae 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/resources/test-aggregation-data.sql +++ b/persistence-modules/spring-data-jpa-query/src/test/resources/test-aggregation-data.sql @@ -1,7 +1,7 @@ -INSERT INTO post (id, title, content) VALUES (1, 'Comment 1', 'Content 1'); -INSERT INTO post (id, title, content) VALUES (2, 'Comment 2', 'Content 2'); -INSERT INTO post (id, title, content) VALUES (3, 'Comment 3', 'Content 3'); -INSERT INTO comment (id, year, approved, content, post_id) VALUES (1, 2019, false, 'Comment 1', 1); -INSERT INTO comment (id, year, approved, content, post_id) VALUES (2, 2018, true, 'Comment 2', 1); -INSERT INTO comment (id, year, approved, content, post_id) VALUES (3, 2018, true, 'Comment 3', 2); -INSERT INTO comment (id, year, approved, content, post_id) VALUES (4, 2017, false, 'Comment 4', 3); \ No newline at end of file +INSERT INTO "post" ("id", "title", "content") VALUES (1, 'Comment 1', 'Content 1'); +INSERT INTO "post" ("id", "title", "content") VALUES (2, 'Comment 2', 'Content 2'); +INSERT INTO "post" ("id", "title", "content") VALUES (3, 'Comment 3', 'Content 3'); +INSERT INTO "comment" ("id", "year", "approved", "content", "post_id") VALUES (1, 2019, false, 'Comment 1', 1); +INSERT INTO "comment" ("id", "year", "approved", "content", "post_id") VALUES (2, 2018, true, 'Comment 2', 1); +INSERT INTO "comment" ("id", "year", "approved", "content", "post_id") VALUES (3, 2018, true, 'Comment 3', 2); +INSERT INTO "comment" ("id", "year", "approved", "content", "post_id") VALUES (4, 2017, false, 'Comment 4', 3); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-2/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-repo-2/src/main/resources/application.properties index cb1eab9443..30cc5abbcc 100644 --- a/persistence-modules/spring-data-jpa-repo-2/src/main/resources/application.properties +++ b/persistence-modules/spring-data-jpa-repo-2/src/main/resources/application.properties @@ -1,3 +1,5 @@ spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 spring.datasource.username=sa -spring.datasource.password=sa \ No newline at end of file +spring.datasource.password=sa + +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-cleanup.sql b/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-cleanup.sql index 90aa15307c..0ba0ba0694 100644 --- a/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-cleanup.sql +++ b/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-cleanup.sql @@ -1 +1 @@ -DELETE FROM Movie; \ No newline at end of file +DELETE FROM "movie"; \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-data.sql b/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-data.sql index 37f8e4fe64..0eb9638f43 100644 --- a/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-data.sql +++ b/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-data.sql @@ -1,7 +1,7 @@ -INSERT INTO movie(id, title, director, rating, duration) VALUES(1, 'Godzilla: King of the Monsters', ' Michael Dougherty', 'PG-13', 132); -INSERT INTO movie(id, title, director, rating, duration) VALUES(2, 'Avengers: Endgame', 'Anthony Russo', 'PG-13', 181); -INSERT INTO movie(id, title, director, rating, duration) VALUES(3, 'Captain Marvel', 'Anna Boden', 'PG-13', 123); -INSERT INTO movie(id, title, director, rating, duration) VALUES(4, 'Dumbo', 'Tim Burton', 'PG', 112); -INSERT INTO movie(id, title, director, rating, duration) VALUES(5, 'Booksmart', 'Olivia Wilde', 'R', 102); -INSERT INTO movie(id, title, director, rating, duration) VALUES(6, 'Aladdin', 'Guy Ritchie', 'PG', 128); -INSERT INTO movie(id, title, director, rating, duration) VALUES(7, 'The Sun Is Also a Star', 'Ry Russo-Young', 'PG-13', 100); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(1, 'Godzilla: King of the Monsters', ' Michael Dougherty', 'PG-13', 132); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(2, 'Avengers: Endgame', 'Anthony Russo', 'PG-13', 181); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(3, 'Captain Marvel', 'Anna Boden', 'PG-13', 123); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(4, 'Dumbo', 'Tim Burton', 'PG', 112); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(5, 'Booksmart', 'Olivia Wilde', 'R', 102); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(6, 'Aladdin', 'Guy Ritchie', 'PG', 128); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(7, 'The Sun Is Also a Star', 'Ry Russo-Young', 'PG-13', 100); diff --git a/persistence-modules/spring-data-mongodb-reactive/pom.xml b/persistence-modules/spring-data-mongodb-reactive/pom.xml index ac2bf14635..85c9a4c4b6 100644 --- a/persistence-modules/spring-data-mongodb-reactive/pom.xml +++ b/persistence-modules/spring-data-mongodb-reactive/pom.xml @@ -57,7 +57,6 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo - ${embed.mongo.version} test @@ -127,7 +126,6 @@ 5.3.15 4.5.2 3.3.1.RELEASE - 3.2.6 \ No newline at end of file diff --git a/persistence-modules/spring-data-rest-querydsl/src/main/resources/application.yml b/persistence-modules/spring-data-rest-querydsl/src/main/resources/application.yml index f25c6ea0e3..326bdff8a2 100644 --- a/persistence-modules/spring-data-rest-querydsl/src/main/resources/application.yml +++ b/persistence-modules/spring-data-rest-querydsl/src/main/resources/application.yml @@ -9,3 +9,5 @@ spring: jpa: hibernate: ddl-auto: create + properties: + globally_quoted_identifiers: true diff --git a/persistence-modules/spring-data-rest-querydsl/src/test/resources/application.yml b/persistence-modules/spring-data-rest-querydsl/src/test/resources/application.yml index 33b7231838..57038dc362 100644 --- a/persistence-modules/spring-data-rest-querydsl/src/test/resources/application.yml +++ b/persistence-modules/spring-data-rest-querydsl/src/test/resources/application.yml @@ -8,4 +8,5 @@ spring: ddl-auto: create-drop properties: hibernate: - dialect: org.hibernate.dialect.H2Dialect \ No newline at end of file + dialect: org.hibernate.dialect.H2Dialect + globally_quoted_identifiers: true \ No newline at end of file diff --git a/persistence-modules/spring-jdbc/README.md b/persistence-modules/spring-jdbc/README.md index 437a1312da..22f7fb3d63 100644 --- a/persistence-modules/spring-jdbc/README.md +++ b/persistence-modules/spring-jdbc/README.md @@ -5,3 +5,4 @@ - [Spring JdbcTemplate Unit Testing](https://www.baeldung.com/spring-jdbctemplate-testing) - [Using a List of Values in a JdbcTemplate IN Clause](https://www.baeldung.com/spring-jdbctemplate-in-list) - [Obtaining Auto-generated Keys in Spring JDBC](https://www.baeldung.com/spring-jdbc-autogenerated-keys) +- [Spring JDBC Batch Inserts](https://www.baeldung.com/spring-jdbc-batch-inserts) diff --git a/persistence-modules/spring-jdbc/pom.xml b/persistence-modules/spring-jdbc/pom.xml index 28a858dd43..08e43e8292 100644 --- a/persistence-modules/spring-jdbc/pom.xml +++ b/persistence-modules/spring-jdbc/pom.xml @@ -31,6 +31,11 @@ mysql-connector-java runtime + + org.postgresql + postgresql + runtime + \ No newline at end of file diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java new file mode 100644 index 0000000000..d523717118 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java @@ -0,0 +1,48 @@ +package com.baeldung.spring.jdbc.batch; + +import com.baeldung.spring.jdbc.batch.service.ProductService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +import java.util.Collections; + +@SpringBootApplication +@ComponentScan(basePackages = "com.baeldung.spring.jdbc.batch") +public class SpringJdbcBatchPerformanceApplication implements CommandLineRunner { + + @Autowired + @Qualifier("batchProductService") + private ProductService batchProductService; + @Autowired + @Qualifier("simpleProductService") + private ProductService simpleProductService; + + public static void main(String[] args) { + SpringApplication.run(SpringJdbcBatchPerformanceApplication.class, args); + } + + @Override + public void run(String... args) throws Exception { + int[] recordCounts = { 1, 10, 100, 1000, 10_000, 100_000, 1000_000 }; + + for (int recordCount : recordCounts) { + long regularElapsedTime = simpleProductService.createProducts(recordCount); + long batchElapsedTime = batchProductService.createProducts(recordCount); + + System.out.println(String.join("", Collections.nCopies(50, "-"))); + System.out.format("%-20s%-5s%-10s%-5s%8sms\n", "Regular inserts", "|", recordCount, "|", regularElapsedTime); + System.out.format("%-20s%-5s%-10s%-5s%8sms\n", "Batch inserts", "|", recordCount, "|", batchElapsedTime); + System.out.printf("Total gain: %d %s\n", calculateGainInPercent(regularElapsedTime, batchElapsedTime), "%"); + } + + } + + int calculateGainInPercent(long before, long after) { + return (int) Math.floor(100D * (before - after) / before); + } +} diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java new file mode 100644 index 0000000000..1dd7c63adc --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java @@ -0,0 +1,27 @@ +package com.baeldung.spring.jdbc.batch.config; + +import com.baeldung.spring.jdbc.batch.repo.BatchProductRepository; +import com.baeldung.spring.jdbc.batch.repo.SimpleProductRepository; +import com.baeldung.spring.jdbc.batch.service.ProductService; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import java.time.Clock; +import java.util.Random; + +@Configuration +@PropertySource("classpath:com/baeldung/spring/jdbc/batch/application.properties") +public class AppConfig { + + @Bean + public ProductService simpleProductService(SimpleProductRepository simpleProductRepository) { + return new ProductService(simpleProductRepository, new Random(), Clock.systemUTC()); + } + + @Bean + public ProductService batchProductService(BatchProductRepository batchProductRepository) { + return new ProductService(batchProductRepository, new Random(), Clock.systemUTC()); + } +} diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java new file mode 100644 index 0000000000..6454952fdc --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java @@ -0,0 +1,54 @@ +package com.baeldung.spring.jdbc.batch.model; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +public class Product { + private long id; + private String title; + private LocalDateTime createdTs; + private BigDecimal price; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public LocalDateTime getCreatedTs() { + return createdTs; + } + + public void setCreatedTs(LocalDateTime createdTs) { + this.createdTs = createdTs; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Product{"); + sb.append("id=").append(id); + sb.append(", title='").append(title).append('\''); + sb.append(", createdTs=").append(createdTs); + sb.append(", price=").append(price); + sb.append('}'); + return sb.toString(); + } +} diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java new file mode 100644 index 0000000000..9b4f0208ab --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java @@ -0,0 +1,34 @@ +package com.baeldung.spring.jdbc.batch.repo; + +import com.baeldung.spring.jdbc.batch.model.Product; + +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.PreparedStatement; +import java.sql.Timestamp; +import java.util.List; + +@Repository +public class BatchProductRepository implements ProductRepository { + + private final JdbcTemplate jdbcTemplate; + + public BatchProductRepository(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } + + @Override + @Transactional + public void saveAll(List products) { + jdbcTemplate.batchUpdate("INSERT INTO PRODUCT (TITLE, CREATED_TS, PRICE) VALUES (?, ?, ?)", + products, + 100, + (PreparedStatement ps, Product product) -> { + ps.setString(1, product.getTitle()); + ps.setTimestamp(2, Timestamp.valueOf(product.getCreatedTs())); + ps.setBigDecimal(3, product.getPrice()); + }); + } +} diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java new file mode 100644 index 0000000000..ed193f87dd --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.spring.jdbc.batch.repo; + +import com.baeldung.spring.jdbc.batch.model.Product; + +import java.util.List; + +public interface ProductRepository { + void saveAll(List products); +} diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java new file mode 100644 index 0000000000..4a381dd8b9 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java @@ -0,0 +1,30 @@ +package com.baeldung.spring.jdbc.batch.repo; + +import com.baeldung.spring.jdbc.batch.model.Product; + +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Timestamp; +import java.util.List; + +@Repository +public class SimpleProductRepository implements ProductRepository { + + private final JdbcTemplate jdbcTemplate; + + public SimpleProductRepository(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } + + @Override + @Transactional + public void saveAll(List products) { + for (Product product : products) { + jdbcTemplate.update("INSERT INTO PRODUCT (TITLE, CREATED_TS, PRICE) VALUES (?, ?, ?)", + product.getTitle(), Timestamp.valueOf(product.getCreatedTs()), product.getPrice()); + } + } + +} diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java new file mode 100644 index 0000000000..436764ffcf --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java @@ -0,0 +1,55 @@ +package com.baeldung.spring.jdbc.batch.service; + +import com.baeldung.spring.jdbc.batch.model.Product; +import com.baeldung.spring.jdbc.batch.repo.ProductRepository; + +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.time.Clock; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class ProductService { + + private final ProductRepository productRepository; + private final Random random; + private final Clock clock; + + public ProductService(ProductRepository productRepository, Random random, Clock clock) { + this.productRepository = productRepository; + this.random = random; + this.clock = clock; + } + + @Transactional + public long createProducts(int count) { + List products = generate(count); + long startTime = clock.millis(); + productRepository.saveAll(products); + return clock.millis() - startTime; + } + + private List generate(int count) { + final String[] titles = { "car", "plane", "house", "yacht" }; + final BigDecimal[] prices = { + new BigDecimal("12483.12"), + new BigDecimal("8539.99"), + new BigDecimal("88894"), + new BigDecimal("458694") + }; + + final List products = new ArrayList<>(count); + + for (int i = 0; i < count; i++) { + Product product = new Product(); + product.setCreatedTs(LocalDateTime.now(clock)); + product.setPrice(prices[random.nextInt(4)]); + product.setTitle(titles[random.nextInt(4)]); + products.add(product); + } + return products; + } +} diff --git a/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/batch/application.properties b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/batch/application.properties new file mode 100644 index 0000000000..9898ae022b --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/batch/application.properties @@ -0,0 +1,5 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/sample-baeldung-db +spring.datasource.username=postgres +spring.datasource.password=root +spring.datasource.driver-class-name=org.postgresql.Driver +spring.datasource.hikari.data-source-properties.reWriteBatchedInserts=true \ No newline at end of file diff --git a/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java new file mode 100644 index 0000000000..26a5f64dc0 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java @@ -0,0 +1,76 @@ +package com.baeldung.spring.jdbc.batch.service; + +import com.baeldung.spring.jdbc.batch.model.Product; +import com.baeldung.spring.jdbc.batch.repo.ProductRepository; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.math.BigDecimal; +import java.time.Clock; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.List; +import java.util.Random; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.withSettings; + +@ExtendWith(MockitoExtension.class) +class ProductServiceUnitTest { + + ProductRepository productRepository; + Random random; + Clock clock; + ProductService productService; + + @Captor + ArgumentCaptor> proArgumentCaptor; + + @BeforeEach + void setUp() { + this.productRepository = mock(ProductRepository.class); + this.random = mock(Random.class, withSettings().withoutAnnotations()); + this.clock = mock(Clock.class); + this.productService = new ProductService(this.productRepository, this.random, this.clock); + } + + @Test + void testWhenCreateProductsThenShouldSaveAndReturnElapsedTime() { + when(random.nextInt(4)) + .thenReturn(1, 3, 2, 0); + when(clock.instant()) + .thenReturn(Instant.parse("2022-04-09T10:15:30.00Z")); + when(clock.getZone()) + .thenReturn(ZoneId.of("UTC")); + + when(clock.millis()) + .thenReturn(100L,500L); + + final long actualElapsedTime = productService.createProducts(2); + + assertThat(actualElapsedTime) + .isEqualTo(400L); + + verify(productRepository,times(1)) + .saveAll(proArgumentCaptor.capture()); + + assertThat(proArgumentCaptor.getValue()) + .hasSize(2) + .extracting("title", "createdTs", "price") + .containsExactly( + tuple("yacht", LocalDateTime.parse("2022-04-09T10:15:30"), new BigDecimal("8539.99")), + tuple("car", LocalDateTime.parse("2022-04-09T10:15:30"), new BigDecimal("88894")) + ); + } +} \ No newline at end of file diff --git a/persistence-modules/spring-jpa-2/README.md b/persistence-modules/spring-jpa-2/README.md index 59543cade7..2eee4015a8 100644 --- a/persistence-modules/spring-jpa-2/README.md +++ b/persistence-modules/spring-jpa-2/README.md @@ -6,4 +6,5 @@ - [Transactions with Spring and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring) - [The DAO with Spring and Hibernate](https://www.baeldung.com/persistence-layer-with-spring-and-hibernate) - [Simplify the DAO with Spring and Java Generics](https://www.baeldung.com/simplifying-the-data-access-layer-with-spring-and-java-generics) +- [Multitenancy With Spring Data JPA](https://www.baeldung.com/multitenancy-with-spring-data-jpa/) - More articles: [[<-- prev]](/spring-jpa) diff --git a/persistence-modules/spring-jpa-2/allTenants/tenant_1.properties b/persistence-modules/spring-jpa-2/allTenants/tenant_1.properties new file mode 100644 index 0000000000..141cb8f3d8 --- /dev/null +++ b/persistence-modules/spring-jpa-2/allTenants/tenant_1.properties @@ -0,0 +1,5 @@ +name=tenant_1 +datasource.url=jdbc:postgresql://localhost:5432/tenant1 +datasource.username=postgres +datasource.password=123456 +datasource.driver-class-name=org.postgresql.Driver \ No newline at end of file diff --git a/persistence-modules/spring-jpa-2/allTenants/tenant_2.properties b/persistence-modules/spring-jpa-2/allTenants/tenant_2.properties new file mode 100644 index 0000000000..6069da5822 --- /dev/null +++ b/persistence-modules/spring-jpa-2/allTenants/tenant_2.properties @@ -0,0 +1,5 @@ +name=tenant_2 +datasource.url=jdbc:postgresql://localhost:5432/tenant2 +datasource.username=postgres +datasource.password=123456 +datasource.driver-class-name=org.postgresql.Driver \ No newline at end of file diff --git a/persistence-modules/spring-jpa-2/pom.xml b/persistence-modules/spring-jpa-2/pom.xml index 19f5a8acc2..de42f94856 100644 --- a/persistence-modules/spring-jpa-2/pom.xml +++ b/persistence-modules/spring-jpa-2/pom.xml @@ -21,6 +21,11 @@ spring-boot-starter ${spring-boot.version} + + org.springframework.boot + spring-boot-starter-web + ${spring-boot.version} + org.springframework.boot spring-boot-starter-data-jpa @@ -42,6 +47,16 @@ spring-context ${org.springframework.version} + + org.springframework.boot + spring-boot-starter-security + ${spring-boot.version} + + + io.jsonwebtoken + jjwt + 0.9.1 + org.hibernate @@ -53,6 +68,12 @@ h2 ${h2.version} + + org.postgresql + postgresql + 42.4.0 + runtime + org.apache.tomcat tomcat-dbcp diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/MultiTenantApplication.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/MultiTenantApplication.java new file mode 100644 index 0000000000..236b53f570 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/MultiTenantApplication.java @@ -0,0 +1,14 @@ +package com.baeldung.multitenant; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) +public class MultiTenantApplication { + + public static void main(String[] args) { + SpringApplication.run(MultiTenantApplication.class, args); + } + +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/MultitenantConfiguration.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/MultitenantConfiguration.java new file mode 100644 index 0000000000..64d66f5cc9 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/MultitenantConfiguration.java @@ -0,0 +1,53 @@ +package com.baeldung.multitenant.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; + +import javax.sql.DataSource; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +@Configuration +public class MultitenantConfiguration { + + @Bean + @ConfigurationProperties(prefix = "tenants") + public DataSource dataSource() { + File[] files = Paths.get("allTenants").toFile().listFiles(); + Map resolvedDataSources = new HashMap<>(); + + for (File propertyFile : files) { + Properties tenantProperties = new Properties(); + DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create(); + + try { + tenantProperties.load(new FileInputStream(propertyFile)); + String tenantId = tenantProperties.getProperty("name"); + + dataSourceBuilder.driverClassName(tenantProperties.getProperty("datasource.driver-class-name")); + dataSourceBuilder.username(tenantProperties.getProperty("datasource.username")); + dataSourceBuilder.password(tenantProperties.getProperty("datasource.password")); + dataSourceBuilder.url(tenantProperties.getProperty("datasource.url")); + resolvedDataSources.put(tenantId, dataSourceBuilder.build()); + } catch (IOException exp) { + throw new RuntimeException("Problem in tenant datasource:" + exp); + } + } + + AbstractRoutingDataSource dataSource = new MultitenantDataSource(); + dataSource.setDefaultTargetDataSource(resolvedDataSources.get("tenant_1")); + dataSource.setTargetDataSources(resolvedDataSources); + + dataSource.afterPropertiesSet(); + return dataSource; + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/MultitenantDataSource.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/MultitenantDataSource.java new file mode 100644 index 0000000000..d8bf664488 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/MultitenantDataSource.java @@ -0,0 +1,12 @@ +package com.baeldung.multitenant.config; + +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; + +public class MultitenantDataSource extends AbstractRoutingDataSource { + + @Override + protected String determineCurrentLookupKey() { + return TenantContext.getCurrentTenant(); + } + +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/TenantContext.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/TenantContext.java new file mode 100644 index 0000000000..30bfba7892 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/TenantContext.java @@ -0,0 +1,14 @@ +package com.baeldung.multitenant.config; + +public class TenantContext { + + private static final ThreadLocal CURRENT_TENANT = new ThreadLocal<>(); + + public static String getCurrentTenant() { + return CURRENT_TENANT.get(); + } + + public static void setCurrentTenant(String tenant) { + CURRENT_TENANT.set(tenant); + } +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/TenantFilter.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/TenantFilter.java new file mode 100644 index 0000000000..3fbb5026f7 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/config/TenantFilter.java @@ -0,0 +1,29 @@ +package com.baeldung.multitenant.config; + +import com.baeldung.multitenant.security.AuthenticationService; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +@Component +@Order(1) +class TenantFilter implements Filter { + + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + + String tenant = AuthenticationService.getTenant((HttpServletRequest) request); + TenantContext.setCurrentTenant(tenant); + + try { + chain.doFilter(request, response); + } finally { + TenantContext.setCurrentTenant(""); + } + + } +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/controller/EmployeeController.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/controller/EmployeeController.java new file mode 100644 index 0000000000..91b35a2836 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/controller/EmployeeController.java @@ -0,0 +1,25 @@ +package com.baeldung.multitenant.controller; + +import com.baeldung.multitenant.domain.Employee; +import com.baeldung.multitenant.repository.EmployeeRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Transactional +public class EmployeeController { + + @Autowired + private EmployeeRepository employeeRepository; + + @PostMapping(path = "/employee") + public ResponseEntity createEmployee() { + Employee newEmployee = new Employee(); + newEmployee.setName("Baeldung"); + employeeRepository.save(newEmployee); + return ResponseEntity.ok(newEmployee); + } +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/domain/Employee.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/domain/Employee.java new file mode 100644 index 0000000000..883b70ca01 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/domain/Employee.java @@ -0,0 +1,40 @@ +package com.baeldung.multitenant.domain; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; + +@Entity +@Table(name = "employee") +public class Employee { + + @Id + @Column(name = "id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "name") + private String name; + + public Employee() { + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/repository/EmployeeRepository.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/repository/EmployeeRepository.java new file mode 100644 index 0000000000..4a965fd51a --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/repository/EmployeeRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.multitenant.repository; + +import com.baeldung.multitenant.domain.Employee; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface EmployeeRepository extends JpaRepository { +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/AccountCredentials.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/AccountCredentials.java new file mode 100644 index 0000000000..cadfcb601a --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/AccountCredentials.java @@ -0,0 +1,23 @@ +package com.baeldung.multitenant.security; + +public class AccountCredentials { + + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/AuthenticationFilter.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/AuthenticationFilter.java new file mode 100644 index 0000000000..fa6bcfb5a0 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/AuthenticationFilter.java @@ -0,0 +1,25 @@ +package com.baeldung.multitenant.security; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.filter.GenericFilterBean; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +public class AuthenticationFilter extends GenericFilterBean { + + @Override + public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) + throws IOException, ServletException { + + Authentication authentication = AuthenticationService.getAuthentication((HttpServletRequest) req); + SecurityContextHolder.getContext().setAuthentication(authentication); + + chain.doFilter(req, res); + } +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/AuthenticationService.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/AuthenticationService.java new file mode 100644 index 0000000000..302058882d --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/AuthenticationService.java @@ -0,0 +1,56 @@ +package com.baeldung.multitenant.security; + +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Collections; +import java.util.Date; + +public class AuthenticationService { + + private static final long EXPIRATIONTIME = 864_000_00; // 1 day in milliseconds + private static final String SIGNINGKEY = "SecretKey"; + private static final String PREFIX = "Bearer"; + + public static void addToken(HttpServletResponse res, String username, String tenant) { + String JwtToken = Jwts.builder().setSubject(username) + .setAudience(tenant) + .setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME)) + .signWith(SignatureAlgorithm.HS512, SIGNINGKEY) + .compact(); + res.addHeader("Authorization", PREFIX + " " + JwtToken); + } + + public static Authentication getAuthentication(HttpServletRequest req) { + String token = req.getHeader("Authorization"); + if (token != null) { + String user = Jwts.parser() + .setSigningKey(SIGNINGKEY) + .parseClaimsJws(token.replace(PREFIX, "")) + .getBody() + .getSubject(); + if (user != null) { + return new UsernamePasswordAuthenticationToken(user, null, Collections.emptyList()); + } + } + + return null; + } + + public static String getTenant(HttpServletRequest req) { + String token = req.getHeader("Authorization"); + if (token == null) { + return null; + } + String tenant = Jwts.parser() + .setSigningKey(SIGNINGKEY) + .parseClaimsJws(token.replace(PREFIX, "")) + .getBody() + .getAudience(); + return tenant; + } +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/LoginFilter.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/LoginFilter.java new file mode 100644 index 0000000000..9f6cbe6e16 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/LoginFilter.java @@ -0,0 +1,51 @@ +package com.baeldung.multitenant.security; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; +import org.springframework.security.web.util.matcher.AntPathRequestMatcher; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; + +public class LoginFilter extends AbstractAuthenticationProcessingFilter { + + public LoginFilter(String url, AuthenticationManager authManager) { + super(new AntPathRequestMatcher(url)); + setAuthenticationManager(authManager); + } + + @Override + public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res) + throws AuthenticationException, IOException, ServletException { + + AccountCredentials creds = new ObjectMapper(). + readValue(req.getInputStream(), AccountCredentials.class); + + return getAuthenticationManager().authenticate( + new UsernamePasswordAuthenticationToken(creds.getUsername(), + creds.getPassword(), Collections.emptyList())); + } + + @Override + protected void successfulAuthentication(HttpServletRequest req, HttpServletResponse res, + FilterChain chain, Authentication auth) throws IOException, ServletException { + + Collection authorities = auth.getAuthorities(); + String tenant = ""; + for (GrantedAuthority gauth : authorities) { + tenant = gauth.getAuthority(); + } + + AuthenticationService.addToken(res, auth.getName(), tenant.substring(5)); + } +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/SecurityConfiguration.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/SecurityConfiguration.java new file mode 100644 index 0000000000..98c6a9c58d --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/multitenant/security/SecurityConfiguration.java @@ -0,0 +1,56 @@ +package com.baeldung.multitenant.security; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; + +@Configuration +@EnableWebSecurity +public class SecurityConfiguration extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.inMemoryAuthentication() + .passwordEncoder(passwordEncoder()) + .withUser("user") + .password(passwordEncoder().encode("baeldung")) + .roles("tenant_1"); + + auth.inMemoryAuthentication() + .passwordEncoder(passwordEncoder()) + .withUser("admin") + .password(passwordEncoder().encode("baeldung")) + .roles("tenant_2"); + } + + @Bean + public PasswordEncoder passwordEncoder(){ + return new BCryptPasswordEncoder(); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .antMatchers("/login").permitAll() + .anyRequest().authenticated() + .and() + .sessionManagement() + .sessionCreationPolicy(SessionCreationPolicy.STATELESS) + .and() + .addFilterBefore(new LoginFilter("/login", authenticationManager()), + UsernamePasswordAuthenticationFilter.class) + .addFilterBefore(new AuthenticationFilter(), UsernamePasswordAuthenticationFilter.class) + .csrf().disable() + .headers().frameOptions().disable() + .and() + .httpBasic(); + } +} diff --git a/persistence-modules/spring-jpa-2/src/main/resources/tenant-schema.sql b/persistence-modules/spring-jpa-2/src/main/resources/tenant-schema.sql new file mode 100644 index 0000000000..675a571fe4 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/resources/tenant-schema.sql @@ -0,0 +1 @@ +create table employee (id int8 generated by default as identity, name varchar(255), primary key (id)); \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2264caa99f..8f4ac4d8de 100644 --- a/pom.xml +++ b/pom.xml @@ -338,14 +338,13 @@ apache-cxf-modules apache-kafka + apache-kafka-2 apache-libraries apache-olingo apache-poi apache-poi-2 apache-rocketmq - apache-shiro apache-spark - apache-tapestry apache-thrift apache-tika apache-velocity @@ -362,13 +361,9 @@ azure bazel - blade - bootique - cas cdi checker-plugin - cloud-foundry-uaa code-generation core-groovy-modules @@ -386,7 +381,6 @@ disruptor dozer drools - dropwizard dubbo @@ -396,7 +390,6 @@ geotools google-cloud - google-web-toolkit graphql-modules @@ -406,7 +399,6 @@ guice hazelcast - helidon apache-httpclient httpclient-simple hystrix @@ -414,34 +406,22 @@ jackson-modules jackson-simple java-blockchain - - - javafx java-jdi - java-lite java-rmi java-spi - java-vavr-stream java-websocket - javax-servlets - javax-servlets-2 javax-sound javaxval jaxb - jee-7 - jee-7-security - jakarta-ee jersey jgit jgroups jhipster-5 jib - jjwt jmeter jmh java-native - jooby jsf json-modules jsoup @@ -467,7 +447,6 @@ libraries-server libraries-server-2 libraries-testing - linkrest logging-modules lombok-modules lucene @@ -478,20 +457,14 @@ mesos-marathon metrics - micronaut - microprofile - msf4j + microservices-modules muleesb mustache mybatis netflix-modules netty - ninja - open-liberty - oauth2-framework-impl - optaplanner orika osgi @@ -506,16 +479,16 @@ rabbitmq - ratpack reactor-core - resteasy - restx rsocket rule-engines rxjava-modules atomikos reactive-systems + security-modules slack + vavr-modules + web-modules @@ -561,9 +534,7 @@ parent-java saas - software-security/sql-injection-samples - spark-java spf4j spring-4 @@ -612,7 +583,7 @@ spring-jenkins-pipeline spring-jersey - spring-jinq + spring-jms spring-kafka @@ -639,7 +610,6 @@ spring-threads spring-vault - spring-vertx spring-web-modules spring-webflux-amqp @@ -647,7 +617,6 @@ static-analysis stripe - struts-2 tensorflow-java testing-modules @@ -657,13 +626,10 @@ undertow - vertx - vertx-and-rxjava + vertx-modules video-tutorials - vraptor webrtc - wicket wildfly xml xstream @@ -724,8 +690,7 @@ spring-ejb-modules/ejb-beans vaadin - vavr - vavr-2 + vavr-modules @@ -769,14 +734,13 @@ apache-cxf-modules apache-kafka + apache-kafka-2 apache-libraries apache-olingo apache-poi apache-poi-2 apache-rocketmq - apache-shiro apache-spark - apache-tapestry apache-thrift apache-tika apache-velocity @@ -793,13 +757,9 @@ azure bazel - blade - bootique - cas cdi checker-plugin - cloud-foundry-uaa code-generation core-groovy-modules @@ -817,7 +777,6 @@ disruptor dozer drools - dropwizard dubbo @@ -827,7 +786,6 @@ geotools google-cloud - google-web-toolkit graphql-modules @@ -837,7 +795,6 @@ guice hazelcast - helidon apache-httpclient httpclient-simple hystrix @@ -845,34 +802,22 @@ jackson-modules jackson-simple java-blockchain - - - javafx java-jdi - java-lite java-rmi java-spi - java-vavr-stream java-websocket - javax-servlets - javax-servlets-2 javax-sound javaxval jaxb - jee-7 - jee-7-security - jakarta-ee jersey jgit jgroups jhipster-5 jib - jjwt jmeter jmh java-native - jooby jsf json-modules jsoup @@ -900,7 +845,6 @@ libraries-server libraries-server-2 libraries-testing - linkrest logging-modules lombok-modules lucene @@ -911,20 +855,14 @@ mesos-marathon metrics - micronaut - microprofile - msf4j + microservices-modules muleesb mustache mybatis netflix-modules netty - ninja - open-liberty - oauth2-framework-impl - optaplanner orika osgi @@ -939,16 +877,16 @@ rabbitmq - ratpack reactor-core - resteasy - restx rsocket rule-engines rxjava-modules atomikos reactive-systems + security-modules slack + vavr-modules + web-modules @@ -986,9 +924,7 @@ parent-java saas - software-security/sql-injection-samples - spark-java spf4j spring-4 @@ -1038,7 +974,7 @@ spring-jenkins-pipeline spring-jersey - spring-jinq + spring-jms spring-kafka @@ -1065,7 +1001,6 @@ spring-threads spring-vault - spring-vertx spring-web-modules spring-webflux-amqp @@ -1073,7 +1008,6 @@ static-analysis stripe - struts-2 tensorflow-java testing-modules @@ -1083,13 +1017,10 @@ undertow - vertx - vertx-and-rxjava + vertx-modules video-tutorials - vraptor webrtc - wicket wildfly xml xml-2 @@ -1143,8 +1074,7 @@ spring-ejb-modules/ejb-beans vaadin - vavr - vavr-2 + vavr-modules @@ -1225,6 +1155,7 @@ core-java-modules/core-java-collections-set + core-java-modules/core-java-collections-list-4 core-java-modules/core-java-collections-maps-4 core-java-modules/core-java-date-operations-1 core-java-modules/core-java-datetime-conversion @@ -1246,6 +1177,7 @@ apache-httpclient-2 libraries-concurrency maven-modules/multimodulemavenproject + optaplanner persistence-modules/sirix persistence-modules/spring-data-cassandra-2 quarkus-modules/quarkus-vs-springboot @@ -1297,6 +1229,7 @@ core-java-modules/core-java-collections-set + core-java-modules/core-java-collections-list-4 core-java-modules/core-java-collections-maps-4 core-java-modules/core-java-date-operations-1 core-java-modules/core-java-datetime-conversion @@ -1315,6 +1248,7 @@ apache-httpclient-2 libraries-concurrency maven-modules/multimodulemavenproject + optaplanner persistence-modules/sirix persistence-modules/spring-data-cassandra-2 quarkus-modules/quarkus-vs-springboot @@ -1355,7 +1289,7 @@ 2.2 1.3 4.4.0 - 1.11.20 + 1.12.13 1.7.32 @@ -1367,7 +1301,7 @@ 3.0.0 1.8 1.2.17 - 2.2.2.0 + 2.5.0.0 1.33 1.33 2.21.0 @@ -1375,7 +1309,7 @@ 2.11.0 2.6 3.12.0 - 1.4 + 1.5.0 3.0.0 3.1.0 1.2 @@ -1392,10 +1326,10 @@ 3.12.2 3.0.0 3.13.0 - 1.18.20 + 1.18.24 1.4.200 - 31.0.1-jre + 31.1-jre 3.2.2 - \ No newline at end of file + diff --git a/quarkus-modules/quarkus/pom.xml b/quarkus-modules/quarkus/pom.xml index 65c0cec603..60ce8e47be 100644 --- a/quarkus-modules/quarkus/pom.xml +++ b/quarkus-modules/quarkus/pom.xml @@ -182,7 +182,6 @@ 1.7.0.Final - 1.18.6 3.3.0 diff --git a/apache-shiro/.gitignore b/security-modules/apache-shiro/.gitignore similarity index 100% rename from apache-shiro/.gitignore rename to security-modules/apache-shiro/.gitignore diff --git a/apache-shiro/README.md b/security-modules/apache-shiro/README.md similarity index 100% rename from apache-shiro/README.md rename to security-modules/apache-shiro/README.md diff --git a/apache-shiro/pom.xml b/security-modules/apache-shiro/pom.xml similarity index 97% rename from apache-shiro/pom.xml rename to security-modules/apache-shiro/pom.xml index 850653ef98..2ab168ded5 100644 --- a/apache-shiro/pom.xml +++ b/security-modules/apache-shiro/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/apache-shiro/src/main/java/com/baeldung/comparison/shiro/CustomRealm.java b/security-modules/apache-shiro/src/main/java/com/baeldung/comparison/shiro/CustomRealm.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/comparison/shiro/CustomRealm.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/comparison/shiro/CustomRealm.java diff --git a/apache-shiro/src/main/java/com/baeldung/comparison/shiro/ShiroApplication.java b/security-modules/apache-shiro/src/main/java/com/baeldung/comparison/shiro/ShiroApplication.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/comparison/shiro/ShiroApplication.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/comparison/shiro/ShiroApplication.java diff --git a/apache-shiro/src/main/java/com/baeldung/comparison/shiro/controllers/ShiroController.java b/security-modules/apache-shiro/src/main/java/com/baeldung/comparison/shiro/controllers/ShiroController.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/comparison/shiro/controllers/ShiroController.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/comparison/shiro/controllers/ShiroController.java diff --git a/apache-shiro/src/main/java/com/baeldung/comparison/shiro/models/UserCredentials.java b/security-modules/apache-shiro/src/main/java/com/baeldung/comparison/shiro/models/UserCredentials.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/comparison/shiro/models/UserCredentials.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/comparison/shiro/models/UserCredentials.java diff --git a/apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/Application.java b/security-modules/apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/Application.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/Application.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/Application.java diff --git a/apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/config/SecurityConfig.java b/security-modules/apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/config/SecurityConfig.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/config/SecurityConfig.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/config/SecurityConfig.java diff --git a/apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/web/SpringController.java b/security-modules/apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/web/SpringController.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/web/SpringController.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/comparison/springsecurity/web/SpringController.java diff --git a/apache-shiro/src/main/java/com/baeldung/intro/Main.java b/security-modules/apache-shiro/src/main/java/com/baeldung/intro/Main.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/intro/Main.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/intro/Main.java diff --git a/apache-shiro/src/main/java/com/baeldung/intro/MyCustomRealm.java b/security-modules/apache-shiro/src/main/java/com/baeldung/intro/MyCustomRealm.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/intro/MyCustomRealm.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/intro/MyCustomRealm.java diff --git a/apache-shiro/src/main/java/com/baeldung/intro/ShiroSpringApplication.java b/security-modules/apache-shiro/src/main/java/com/baeldung/intro/ShiroSpringApplication.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/intro/ShiroSpringApplication.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/intro/ShiroSpringApplication.java diff --git a/apache-shiro/src/main/java/com/baeldung/intro/controllers/ShiroSpringController.java b/security-modules/apache-shiro/src/main/java/com/baeldung/intro/controllers/ShiroSpringController.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/intro/controllers/ShiroSpringController.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/intro/controllers/ShiroSpringController.java diff --git a/apache-shiro/src/main/java/com/baeldung/intro/models/UserCredentials.java b/security-modules/apache-shiro/src/main/java/com/baeldung/intro/models/UserCredentials.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/intro/models/UserCredentials.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/intro/models/UserCredentials.java diff --git a/apache-shiro/src/main/java/com/baeldung/permissions/custom/Main.java b/security-modules/apache-shiro/src/main/java/com/baeldung/permissions/custom/Main.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/permissions/custom/Main.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/permissions/custom/Main.java diff --git a/apache-shiro/src/main/java/com/baeldung/permissions/custom/PathPermission.java b/security-modules/apache-shiro/src/main/java/com/baeldung/permissions/custom/PathPermission.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/permissions/custom/PathPermission.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/permissions/custom/PathPermission.java diff --git a/apache-shiro/src/main/java/com/baeldung/permissions/custom/PathPermissionResolver.java b/security-modules/apache-shiro/src/main/java/com/baeldung/permissions/custom/PathPermissionResolver.java similarity index 100% rename from apache-shiro/src/main/java/com/baeldung/permissions/custom/PathPermissionResolver.java rename to security-modules/apache-shiro/src/main/java/com/baeldung/permissions/custom/PathPermissionResolver.java diff --git a/apache-shiro/src/main/resources/application.properties b/security-modules/apache-shiro/src/main/resources/application.properties similarity index 100% rename from apache-shiro/src/main/resources/application.properties rename to security-modules/apache-shiro/src/main/resources/application.properties diff --git a/apache-shiro/src/main/resources/com/baeldung/shiro/permissions/custom/shiro.ini b/security-modules/apache-shiro/src/main/resources/com/baeldung/shiro/permissions/custom/shiro.ini similarity index 100% rename from apache-shiro/src/main/resources/com/baeldung/shiro/permissions/custom/shiro.ini rename to security-modules/apache-shiro/src/main/resources/com/baeldung/shiro/permissions/custom/shiro.ini diff --git a/apache-shiro/src/main/resources/log4j.properties b/security-modules/apache-shiro/src/main/resources/log4j.properties similarity index 100% rename from apache-shiro/src/main/resources/log4j.properties rename to security-modules/apache-shiro/src/main/resources/log4j.properties diff --git a/helidon/helidon-mp/src/main/resources/logback.xml b/security-modules/apache-shiro/src/main/resources/logback.xml similarity index 100% rename from helidon/helidon-mp/src/main/resources/logback.xml rename to security-modules/apache-shiro/src/main/resources/logback.xml diff --git a/apache-shiro/src/main/resources/shiro.ini b/security-modules/apache-shiro/src/main/resources/shiro.ini similarity index 100% rename from apache-shiro/src/main/resources/shiro.ini rename to security-modules/apache-shiro/src/main/resources/shiro.ini diff --git a/apache-shiro/src/main/resources/templates/comparison/home.ftl b/security-modules/apache-shiro/src/main/resources/templates/comparison/home.ftl similarity index 100% rename from apache-shiro/src/main/resources/templates/comparison/home.ftl rename to security-modules/apache-shiro/src/main/resources/templates/comparison/home.ftl diff --git a/apache-shiro/src/main/resources/templates/comparison/index.ftl b/security-modules/apache-shiro/src/main/resources/templates/comparison/index.ftl similarity index 100% rename from apache-shiro/src/main/resources/templates/comparison/index.ftl rename to security-modules/apache-shiro/src/main/resources/templates/comparison/index.ftl diff --git a/apache-shiro/src/main/resources/templates/comparison/login.ftl b/security-modules/apache-shiro/src/main/resources/templates/comparison/login.ftl similarity index 100% rename from apache-shiro/src/main/resources/templates/comparison/login.ftl rename to security-modules/apache-shiro/src/main/resources/templates/comparison/login.ftl diff --git a/apache-shiro/src/main/resources/templates/index.ftl b/security-modules/apache-shiro/src/main/resources/templates/index.ftl similarity index 100% rename from apache-shiro/src/main/resources/templates/index.ftl rename to security-modules/apache-shiro/src/main/resources/templates/index.ftl diff --git a/apache-shiro/src/main/resources/templates/login.ftl b/security-modules/apache-shiro/src/main/resources/templates/login.ftl similarity index 100% rename from apache-shiro/src/main/resources/templates/login.ftl rename to security-modules/apache-shiro/src/main/resources/templates/login.ftl diff --git a/apache-shiro/src/main/resources/templates/secure.ftl b/security-modules/apache-shiro/src/main/resources/templates/secure.ftl similarity index 100% rename from apache-shiro/src/main/resources/templates/secure.ftl rename to security-modules/apache-shiro/src/main/resources/templates/secure.ftl diff --git a/apache-shiro/src/test/java/com/baeldung/comparison/shiro/SpringContextTest.java b/security-modules/apache-shiro/src/test/java/com/baeldung/comparison/shiro/SpringContextTest.java similarity index 100% rename from apache-shiro/src/test/java/com/baeldung/comparison/shiro/SpringContextTest.java rename to security-modules/apache-shiro/src/test/java/com/baeldung/comparison/shiro/SpringContextTest.java diff --git a/apache-shiro/src/test/java/com/baeldung/comparison/springsecurity/SpringContextTest.java b/security-modules/apache-shiro/src/test/java/com/baeldung/comparison/springsecurity/SpringContextTest.java similarity index 100% rename from apache-shiro/src/test/java/com/baeldung/comparison/springsecurity/SpringContextTest.java rename to security-modules/apache-shiro/src/test/java/com/baeldung/comparison/springsecurity/SpringContextTest.java diff --git a/apache-shiro/src/test/resources/logback-test.xml b/security-modules/apache-shiro/src/test/resources/logback-test.xml similarity index 100% rename from apache-shiro/src/test/resources/logback-test.xml rename to security-modules/apache-shiro/src/test/resources/logback-test.xml diff --git a/cas/README.md b/security-modules/cas/README.md similarity index 100% rename from cas/README.md rename to security-modules/cas/README.md diff --git a/cas/cas-secured-app/.gitignore b/security-modules/cas/cas-secured-app/.gitignore similarity index 100% rename from cas/cas-secured-app/.gitignore rename to security-modules/cas/cas-secured-app/.gitignore diff --git a/cas/cas-secured-app/README.md b/security-modules/cas/cas-secured-app/README.md similarity index 100% rename from cas/cas-secured-app/README.md rename to security-modules/cas/cas-secured-app/README.md diff --git a/cas/cas-secured-app/pom.xml b/security-modules/cas/cas-secured-app/pom.xml similarity index 100% rename from cas/cas-secured-app/pom.xml rename to security-modules/cas/cas-secured-app/pom.xml diff --git a/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/CasSecuredApplication.java b/security-modules/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/CasSecuredApplication.java similarity index 100% rename from cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/CasSecuredApplication.java rename to security-modules/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/CasSecuredApplication.java diff --git a/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/config/WebSecurityConfig.java b/security-modules/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/config/WebSecurityConfig.java similarity index 100% rename from cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/config/WebSecurityConfig.java rename to security-modules/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/config/WebSecurityConfig.java diff --git a/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/AuthController.java b/security-modules/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/AuthController.java similarity index 100% rename from cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/AuthController.java rename to security-modules/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/AuthController.java diff --git a/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/IndexController.java b/security-modules/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/IndexController.java similarity index 100% rename from cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/IndexController.java rename to security-modules/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/IndexController.java diff --git a/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/SecuredController.java b/security-modules/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/SecuredController.java similarity index 100% rename from cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/SecuredController.java rename to security-modules/cas/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/SecuredController.java diff --git a/cas/cas-secured-app/src/main/resources/application.properties b/security-modules/cas/cas-secured-app/src/main/resources/application.properties similarity index 100% rename from cas/cas-secured-app/src/main/resources/application.properties rename to security-modules/cas/cas-secured-app/src/main/resources/application.properties diff --git a/java-ee-8-security-api/app-auth-basic-store-db/src/main/resources/logback.xml b/security-modules/cas/cas-secured-app/src/main/resources/logback.xml similarity index 100% rename from java-ee-8-security-api/app-auth-basic-store-db/src/main/resources/logback.xml rename to security-modules/cas/cas-secured-app/src/main/resources/logback.xml diff --git a/cas/cas-secured-app/src/main/resources/templates/auth/logout.ftl b/security-modules/cas/cas-secured-app/src/main/resources/templates/auth/logout.ftl similarity index 100% rename from cas/cas-secured-app/src/main/resources/templates/auth/logout.ftl rename to security-modules/cas/cas-secured-app/src/main/resources/templates/auth/logout.ftl diff --git a/cas/cas-secured-app/src/main/resources/templates/index.ftl b/security-modules/cas/cas-secured-app/src/main/resources/templates/index.ftl similarity index 100% rename from cas/cas-secured-app/src/main/resources/templates/index.ftl rename to security-modules/cas/cas-secured-app/src/main/resources/templates/index.ftl diff --git a/cas/cas-secured-app/src/main/resources/templates/secure/index.ftl b/security-modules/cas/cas-secured-app/src/main/resources/templates/secure/index.ftl similarity index 100% rename from cas/cas-secured-app/src/main/resources/templates/secure/index.ftl rename to security-modules/cas/cas-secured-app/src/main/resources/templates/secure/index.ftl diff --git a/cas/cas-secured-app/src/test/java/com/baeldung/cassecuredapp/CasSecuredApplicationIntegrationTest.java b/security-modules/cas/cas-secured-app/src/test/java/com/baeldung/cassecuredapp/CasSecuredApplicationIntegrationTest.java similarity index 100% rename from cas/cas-secured-app/src/test/java/com/baeldung/cassecuredapp/CasSecuredApplicationIntegrationTest.java rename to security-modules/cas/cas-secured-app/src/test/java/com/baeldung/cassecuredapp/CasSecuredApplicationIntegrationTest.java diff --git a/cas/cas-server/.gitignore b/security-modules/cas/cas-server/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from cas/cas-server/.gitignore rename to security-modules/cas/cas-server/.gitignore diff --git a/cas/cas-server/.mergify.yml b/security-modules/cas/cas-server/.mergify.yml similarity index 100% rename from cas/cas-server/.mergify.yml rename to security-modules/cas/cas-server/.mergify.yml diff --git a/cas/cas-server/.travis.yml b/security-modules/cas/cas-server/.travis.yml similarity index 100% rename from cas/cas-server/.travis.yml rename to security-modules/cas/cas-server/.travis.yml diff --git a/cas/cas-server/Dockerfile b/security-modules/cas/cas-server/Dockerfile similarity index 100% rename from cas/cas-server/Dockerfile rename to security-modules/cas/cas-server/Dockerfile diff --git a/cas/cas-server/LICENSE.txt b/security-modules/cas/cas-server/LICENSE.txt similarity index 100% rename from cas/cas-server/LICENSE.txt rename to security-modules/cas/cas-server/LICENSE.txt diff --git a/cas/cas-server/build.gradle b/security-modules/cas/cas-server/build.gradle similarity index 100% rename from cas/cas-server/build.gradle rename to security-modules/cas/cas-server/build.gradle diff --git a/cas/cas-server/docker-build.sh b/security-modules/cas/cas-server/docker-build.sh old mode 100755 new mode 100644 similarity index 100% rename from cas/cas-server/docker-build.sh rename to security-modules/cas/cas-server/docker-build.sh diff --git a/cas/cas-server/docker-compose.yml b/security-modules/cas/cas-server/docker-compose.yml similarity index 100% rename from cas/cas-server/docker-compose.yml rename to security-modules/cas/cas-server/docker-compose.yml diff --git a/cas/cas-server/docker-push.sh b/security-modules/cas/cas-server/docker-push.sh old mode 100755 new mode 100644 similarity index 100% rename from cas/cas-server/docker-push.sh rename to security-modules/cas/cas-server/docker-push.sh diff --git a/cas/cas-server/docker-run.sh b/security-modules/cas/cas-server/docker-run.sh old mode 100755 new mode 100644 similarity index 100% rename from cas/cas-server/docker-run.sh rename to security-modules/cas/cas-server/docker-run.sh diff --git a/cas/cas-server/etc/cas/config/cas.properties b/security-modules/cas/cas-server/etc/cas/config/cas.properties similarity index 100% rename from cas/cas-server/etc/cas/config/cas.properties rename to security-modules/cas/cas-server/etc/cas/config/cas.properties diff --git a/cas/cas-server/etc/cas/config/log4j2.xml b/security-modules/cas/cas-server/etc/cas/config/log4j2.xml similarity index 100% rename from cas/cas-server/etc/cas/config/log4j2.xml rename to security-modules/cas/cas-server/etc/cas/config/log4j2.xml diff --git a/cas/cas-server/etc/cas/saml/.gitkeep b/security-modules/cas/cas-server/etc/cas/saml/.gitkeep similarity index 100% rename from cas/cas-server/etc/cas/saml/.gitkeep rename to security-modules/cas/cas-server/etc/cas/saml/.gitkeep diff --git a/cas/cas-server/etc/cas/services/.donotdel b/security-modules/cas/cas-server/etc/cas/services/.donotdel similarity index 100% rename from cas/cas-server/etc/cas/services/.donotdel rename to security-modules/cas/cas-server/etc/cas/services/.donotdel diff --git a/cas/cas-server/etc/cas/thekeystore b/security-modules/cas/cas-server/etc/cas/thekeystore similarity index 100% rename from cas/cas-server/etc/cas/thekeystore rename to security-modules/cas/cas-server/etc/cas/thekeystore diff --git a/cas/cas-server/gradle.properties b/security-modules/cas/cas-server/gradle.properties similarity index 100% rename from cas/cas-server/gradle.properties rename to security-modules/cas/cas-server/gradle.properties diff --git a/cas/cas-server/gradle/dockerjib.gradle b/security-modules/cas/cas-server/gradle/dockerjib.gradle similarity index 100% rename from cas/cas-server/gradle/dockerjib.gradle rename to security-modules/cas/cas-server/gradle/dockerjib.gradle diff --git a/cas/cas-server/gradle/springboot.gradle b/security-modules/cas/cas-server/gradle/springboot.gradle similarity index 100% rename from cas/cas-server/gradle/springboot.gradle rename to security-modules/cas/cas-server/gradle/springboot.gradle diff --git a/cas/cas-server/gradle/tasks.gradle b/security-modules/cas/cas-server/gradle/tasks.gradle similarity index 100% rename from cas/cas-server/gradle/tasks.gradle rename to security-modules/cas/cas-server/gradle/tasks.gradle diff --git a/cas/cas-server/gradle/wrapper/gradle-wrapper.properties b/security-modules/cas/cas-server/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from cas/cas-server/gradle/wrapper/gradle-wrapper.properties rename to security-modules/cas/cas-server/gradle/wrapper/gradle-wrapper.properties diff --git a/cas/cas-server/gradlew b/security-modules/cas/cas-server/gradlew old mode 100755 new mode 100644 similarity index 100% rename from cas/cas-server/gradlew rename to security-modules/cas/cas-server/gradlew diff --git a/cas/cas-server/gradlew.bat b/security-modules/cas/cas-server/gradlew.bat similarity index 96% rename from cas/cas-server/gradlew.bat rename to security-modules/cas/cas-server/gradlew.bat index 24467a141f..9618d8d960 100644 --- a/cas/cas-server/gradlew.bat +++ b/security-modules/cas/cas-server/gradlew.bat @@ -1,100 +1,100 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/cas/cas-server/settings.gradle b/security-modules/cas/cas-server/settings.gradle similarity index 100% rename from cas/cas-server/settings.gradle rename to security-modules/cas/cas-server/settings.gradle diff --git a/cas/cas-server/src/main/jib/docker/entrypoint.sh b/security-modules/cas/cas-server/src/main/jib/docker/entrypoint.sh old mode 100755 new mode 100644 similarity index 100% rename from cas/cas-server/src/main/jib/docker/entrypoint.sh rename to security-modules/cas/cas-server/src/main/jib/docker/entrypoint.sh diff --git a/cas/cas-server/src/main/resources/application.properties b/security-modules/cas/cas-server/src/main/resources/application.properties similarity index 100% rename from cas/cas-server/src/main/resources/application.properties rename to security-modules/cas/cas-server/src/main/resources/application.properties diff --git a/cas/cas-server/src/main/resources/create_test_db_and_users_tbl.sql b/security-modules/cas/cas-server/src/main/resources/create_test_db_and_users_tbl.sql similarity index 100% rename from cas/cas-server/src/main/resources/create_test_db_and_users_tbl.sql rename to security-modules/cas/cas-server/src/main/resources/create_test_db_and_users_tbl.sql diff --git a/cas/cas-server/src/main/resources/etc/cas/config/cas.properties b/security-modules/cas/cas-server/src/main/resources/etc/cas/config/cas.properties similarity index 100% rename from cas/cas-server/src/main/resources/etc/cas/config/cas.properties rename to security-modules/cas/cas-server/src/main/resources/etc/cas/config/cas.properties diff --git a/cas/cas-server/src/main/resources/etc/cas/services/casSecuredApp-8900.json b/security-modules/cas/cas-server/src/main/resources/etc/cas/services/casSecuredApp-8900.json similarity index 100% rename from cas/cas-server/src/main/resources/etc/cas/services/casSecuredApp-8900.json rename to security-modules/cas/cas-server/src/main/resources/etc/cas/services/casSecuredApp-8900.json diff --git a/cas/cas-server/src/main/resources/etc/cas/thekeystore b/security-modules/cas/cas-server/src/main/resources/etc/cas/thekeystore similarity index 100% rename from cas/cas-server/src/main/resources/etc/cas/thekeystore rename to security-modules/cas/cas-server/src/main/resources/etc/cas/thekeystore diff --git a/cas/pom.xml b/security-modules/cas/pom.xml similarity index 91% rename from cas/pom.xml rename to security-modules/cas/pom.xml index 2f24e41453..d40f303717 100644 --- a/cas/pom.xml +++ b/security-modules/cas/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/cloud-foundry-uaa/README.md b/security-modules/cloud-foundry-uaa/README.md similarity index 100% rename from cloud-foundry-uaa/README.md rename to security-modules/cloud-foundry-uaa/README.md diff --git a/cloud-foundry-uaa/cf-uaa-config/uaa.yml b/security-modules/cloud-foundry-uaa/cf-uaa-config/uaa.yml similarity index 100% rename from cloud-foundry-uaa/cf-uaa-config/uaa.yml rename to security-modules/cloud-foundry-uaa/cf-uaa-config/uaa.yml diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml similarity index 100% rename from cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml rename to security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/java/com/baeldung/cfuaa/oauth2/client/CFUAAOAuth2ClientApplication.java b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/java/com/baeldung/cfuaa/oauth2/client/CFUAAOAuth2ClientApplication.java similarity index 100% rename from cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/java/com/baeldung/cfuaa/oauth2/client/CFUAAOAuth2ClientApplication.java rename to security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/java/com/baeldung/cfuaa/oauth2/client/CFUAAOAuth2ClientApplication.java diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/java/com/baeldung/cfuaa/oauth2/client/CFUAAOAuth2ClientController.java b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/java/com/baeldung/cfuaa/oauth2/client/CFUAAOAuth2ClientController.java similarity index 97% rename from cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/java/com/baeldung/cfuaa/oauth2/client/CFUAAOAuth2ClientController.java rename to security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/java/com/baeldung/cfuaa/oauth2/client/CFUAAOAuth2ClientController.java index b1631ed327..bc745fc436 100644 --- a/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/java/com/baeldung/cfuaa/oauth2/client/CFUAAOAuth2ClientController.java +++ b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/java/com/baeldung/cfuaa/oauth2/client/CFUAAOAuth2ClientController.java @@ -1,80 +1,80 @@ -package com.baeldung.cfuaa.oauth2.client; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService; -import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken; -import org.springframework.security.oauth2.core.OAuth2AccessToken; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.RestTemplate; - -@RestController -public class CFUAAOAuth2ClientController { - - @Value("${resource.server.url}") - private String remoteResourceServer; - - private RestTemplate restTemplate; - - private OAuth2AuthorizedClientService authorizedClientService; - - public CFUAAOAuth2ClientController(OAuth2AuthorizedClientService authorizedClientService) { - this.authorizedClientService = authorizedClientService; - this.restTemplate = new RestTemplate(); - } - - @RequestMapping("/") - public String index(OAuth2AuthenticationToken authenticationToken) { - OAuth2AuthorizedClient oAuth2AuthorizedClient = this.authorizedClientService.loadAuthorizedClient(authenticationToken.getAuthorizedClientRegistrationId(), authenticationToken.getName()); - OAuth2AccessToken oAuth2AccessToken = oAuth2AuthorizedClient.getAccessToken(); - - String response = "Hello, " + authenticationToken.getPrincipal().getName(); - response += "

"; - response += "Here is your accees token :
" + oAuth2AccessToken.getTokenValue(); - response += "
"; - response += "
You can use it to call these Resource Server APIs:"; - response += "

"; - response += "Call Resource Server Read API"; - response += "
"; - response += "Call Resource Server Write API"; - return response; - } - - @RequestMapping("/read") - public String read(OAuth2AuthenticationToken authenticationToken) { - String url = remoteResourceServer + "/read"; - return callResourceServer(authenticationToken, url); - } - - @RequestMapping("/write") - public String write(OAuth2AuthenticationToken authenticationToken) { - String url = remoteResourceServer + "/write"; - return callResourceServer(authenticationToken, url); - } - - private String callResourceServer(OAuth2AuthenticationToken authenticationToken, String url) { - OAuth2AuthorizedClient oAuth2AuthorizedClient = this.authorizedClientService.loadAuthorizedClient(authenticationToken.getAuthorizedClientRegistrationId(), authenticationToken.getName()); - OAuth2AccessToken oAuth2AccessToken = oAuth2AuthorizedClient.getAccessToken(); - - HttpHeaders headers = new HttpHeaders(); - headers.add("Authorization", "Bearer " + oAuth2AccessToken.getTokenValue()); - - HttpEntity entity = new HttpEntity<>("parameters", headers); - ResponseEntity responseEntity = null; - - String response = null; - try { - responseEntity = restTemplate.exchange(url, HttpMethod.GET, entity, String.class); - response = responseEntity.getBody(); - } catch (HttpClientErrorException e) { - response = e.getMessage(); - } - return response; - } +package com.baeldung.cfuaa.oauth2.client; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; +import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService; +import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken; +import org.springframework.security.oauth2.core.OAuth2AccessToken; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.RestTemplate; + +@RestController +public class CFUAAOAuth2ClientController { + + @Value("${resource.server.url}") + private String remoteResourceServer; + + private RestTemplate restTemplate; + + private OAuth2AuthorizedClientService authorizedClientService; + + public CFUAAOAuth2ClientController(OAuth2AuthorizedClientService authorizedClientService) { + this.authorizedClientService = authorizedClientService; + this.restTemplate = new RestTemplate(); + } + + @RequestMapping("/") + public String index(OAuth2AuthenticationToken authenticationToken) { + OAuth2AuthorizedClient oAuth2AuthorizedClient = this.authorizedClientService.loadAuthorizedClient(authenticationToken.getAuthorizedClientRegistrationId(), authenticationToken.getName()); + OAuth2AccessToken oAuth2AccessToken = oAuth2AuthorizedClient.getAccessToken(); + + String response = "Hello, " + authenticationToken.getPrincipal().getName(); + response += "

"; + response += "Here is your accees token :
" + oAuth2AccessToken.getTokenValue(); + response += "
"; + response += "
You can use it to call these Resource Server APIs:"; + response += "

"; + response += "Call Resource Server Read API"; + response += "
"; + response += "Call Resource Server Write API"; + return response; + } + + @RequestMapping("/read") + public String read(OAuth2AuthenticationToken authenticationToken) { + String url = remoteResourceServer + "/read"; + return callResourceServer(authenticationToken, url); + } + + @RequestMapping("/write") + public String write(OAuth2AuthenticationToken authenticationToken) { + String url = remoteResourceServer + "/write"; + return callResourceServer(authenticationToken, url); + } + + private String callResourceServer(OAuth2AuthenticationToken authenticationToken, String url) { + OAuth2AuthorizedClient oAuth2AuthorizedClient = this.authorizedClientService.loadAuthorizedClient(authenticationToken.getAuthorizedClientRegistrationId(), authenticationToken.getName()); + OAuth2AccessToken oAuth2AccessToken = oAuth2AuthorizedClient.getAccessToken(); + + HttpHeaders headers = new HttpHeaders(); + headers.add("Authorization", "Bearer " + oAuth2AccessToken.getTokenValue()); + + HttpEntity entity = new HttpEntity<>("parameters", headers); + ResponseEntity responseEntity = null; + + String response = null; + try { + responseEntity = restTemplate.exchange(url, HttpMethod.GET, entity, String.class); + response = responseEntity.getBody(); + } catch (HttpClientErrorException e) { + response = e.getMessage(); + } + return response; + } } \ No newline at end of file diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/resources/application.properties b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/resources/application.properties similarity index 100% rename from cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/resources/application.properties rename to security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/resources/application.properties diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/resources/templates/index.html b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/resources/templates/index.html similarity index 100% rename from cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/resources/templates/index.html rename to security-modules/cloud-foundry-uaa/cf-uaa-oauth2-client/src/main/resources/templates/index.html diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml similarity index 100% rename from cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml rename to security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerApplication.java b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerApplication.java similarity index 100% rename from cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerApplication.java rename to security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerApplication.java diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerRestController.java b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerRestController.java similarity index 97% rename from cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerRestController.java rename to security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerRestController.java index 75d8507451..614a92aeb4 100644 --- a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerRestController.java +++ b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerRestController.java @@ -1,28 +1,28 @@ -package com.baeldung.cfuaa.oauth2.resourceserver; - -import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.security.oauth2.jwt.Jwt; -import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.security.Principal; - -@RestController -public class CFUAAOAuth2ResourceServerRestController { - - @GetMapping("/") - public String index(@AuthenticationPrincipal Jwt jwt) { - return String.format("Hello, %s!", jwt.getSubject()); - } - - @GetMapping("/read") - public String read(JwtAuthenticationToken jwtAuthenticationToken) { - return "Hello read: " + jwtAuthenticationToken.getTokenAttributes(); - } - - @GetMapping("/write") - public String write(Principal principal) { - return "Hello write: " + principal.getName(); - } -} +package com.baeldung.cfuaa.oauth2.resourceserver; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.security.oauth2.jwt.Jwt; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.security.Principal; + +@RestController +public class CFUAAOAuth2ResourceServerRestController { + + @GetMapping("/") + public String index(@AuthenticationPrincipal Jwt jwt) { + return String.format("Hello, %s!", jwt.getSubject()); + } + + @GetMapping("/read") + public String read(JwtAuthenticationToken jwtAuthenticationToken) { + return "Hello read: " + jwtAuthenticationToken.getTokenAttributes(); + } + + @GetMapping("/write") + public String write(Principal principal) { + return "Hello write: " + principal.getName(); + } +} diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerSecurityConfiguration.java b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerSecurityConfiguration.java similarity index 97% rename from cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerSecurityConfiguration.java rename to security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerSecurityConfiguration.java index d04d51cda3..95bde8aa8a 100644 --- a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerSecurityConfiguration.java +++ b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerSecurityConfiguration.java @@ -1,21 +1,21 @@ -package com.baeldung.cfuaa.oauth2.resourceserver; - -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@EnableWebSecurity -public class CFUAAOAuth2ResourceServerSecurityConfiguration extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(HttpSecurity http) throws Exception { - http - .authorizeRequests() - .antMatchers("/read/**").hasAuthority("SCOPE_resource.read") - .antMatchers("/write/**").hasAuthority("SCOPE_resource.write") - .anyRequest().authenticated() - .and() - .oauth2ResourceServer() - .jwt(); - } +package com.baeldung.cfuaa.oauth2.resourceserver; + +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@EnableWebSecurity +public class CFUAAOAuth2ResourceServerSecurityConfiguration extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .antMatchers("/read/**").hasAuthority("SCOPE_resource.read") + .antMatchers("/write/**").hasAuthority("SCOPE_resource.write") + .anyRequest().authenticated() + .and() + .oauth2ResourceServer() + .jwt(); + } } \ No newline at end of file diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/resources/application.properties b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/resources/application.properties similarity index 100% rename from cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/resources/application.properties rename to security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/resources/application.properties diff --git a/cloud-foundry-uaa/pom.xml b/security-modules/cloud-foundry-uaa/pom.xml similarity index 92% rename from cloud-foundry-uaa/pom.xml rename to security-modules/cloud-foundry-uaa/pom.xml index 6ae43b2c08..ff26d56dc3 100644 --- a/cloud-foundry-uaa/pom.xml +++ b/security-modules/cloud-foundry-uaa/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2
diff --git a/java-ee-8-security-api/README.md b/security-modules/java-ee-8-security-api/README.md similarity index 100% rename from java-ee-8-security-api/README.md rename to security-modules/java-ee-8-security-api/README.md diff --git a/java-ee-8-security-api/app-auth-basic-store-db/pom.xml b/security-modules/java-ee-8-security-api/app-auth-basic-store-db/pom.xml similarity index 100% rename from java-ee-8-security-api/app-auth-basic-store-db/pom.xml rename to security-modules/java-ee-8-security-api/app-auth-basic-store-db/pom.xml diff --git a/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/AdminServlet.java b/security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/AdminServlet.java similarity index 100% rename from java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/AdminServlet.java rename to security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/AdminServlet.java diff --git a/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/AppConfig.java b/security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/AppConfig.java similarity index 100% rename from java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/AppConfig.java rename to security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/AppConfig.java diff --git a/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/DatabaseSetupServlet.java b/security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/DatabaseSetupServlet.java similarity index 100% rename from java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/DatabaseSetupServlet.java rename to security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/DatabaseSetupServlet.java diff --git a/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/UserServlet.java b/security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/UserServlet.java similarity index 100% rename from java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/UserServlet.java rename to security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/UserServlet.java diff --git a/java-ee-8-security-api/app-auth-basic-store-db/src/main/liberty/config/server.xml b/security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/liberty/config/server.xml similarity index 100% rename from java-ee-8-security-api/app-auth-basic-store-db/src/main/liberty/config/server.xml rename to security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/liberty/config/server.xml diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/resources/logback.xml b/security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/resources/logback.xml similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/resources/logback.xml rename to security-modules/java-ee-8-security-api/app-auth-basic-store-db/src/main/resources/logback.xml diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/pom.xml b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/pom.xml similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/pom.xml rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/pom.xml diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/AppConfig.java b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/AppConfig.java similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/AppConfig.java rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/AppConfig.java diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/InMemoryIdentityStore4Authentication.java b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/InMemoryIdentityStore4Authentication.java similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/InMemoryIdentityStore4Authentication.java rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/InMemoryIdentityStore4Authentication.java diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/InMemoryIdentityStore4Authorization.java b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/InMemoryIdentityStore4Authorization.java similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/InMemoryIdentityStore4Authorization.java rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/InMemoryIdentityStore4Authorization.java diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/LoginBean.java b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/LoginBean.java similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/LoginBean.java rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/LoginBean.java diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/WelcomeServlet.java b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/WelcomeServlet.java similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/WelcomeServlet.java rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/java/com/baeldung/javaee/security/WelcomeServlet.java diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/liberty/config/server.xml b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/liberty/config/server.xml similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/liberty/config/server.xml rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/liberty/config/server.xml diff --git a/java-ee-8-security-api/app-auth-custom-no-store/src/main/resources/logback.xml b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/resources/logback.xml similarity index 100% rename from java-ee-8-security-api/app-auth-custom-no-store/src/main/resources/logback.xml rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/resources/logback.xml diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/WEB-INF/beans.xml b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/WEB-INF/beans.xml rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/WEB-INF/beans.xml diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/WEB-INF/web.xml b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/WEB-INF/web.xml rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/WEB-INF/web.xml diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/login-error.html b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/login-error.html similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/login-error.html rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/login-error.html diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/login.xhtml b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/login.xhtml similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/login.xhtml rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/login.xhtml diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/welcome.xhtml b/security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/welcome.xhtml similarity index 100% rename from java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/welcome.xhtml rename to security-modules/java-ee-8-security-api/app-auth-custom-form-store-custom/src/main/webapp/welcome.xhtml diff --git a/java-ee-8-security-api/app-auth-custom-no-store/pom.xml b/security-modules/java-ee-8-security-api/app-auth-custom-no-store/pom.xml similarity index 100% rename from java-ee-8-security-api/app-auth-custom-no-store/pom.xml rename to security-modules/java-ee-8-security-api/app-auth-custom-no-store/pom.xml diff --git a/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/AdminServlet.java b/security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/AdminServlet.java similarity index 100% rename from java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/AdminServlet.java rename to security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/AdminServlet.java diff --git a/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/AppConfig.java b/security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/AppConfig.java similarity index 100% rename from java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/AppConfig.java rename to security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/AppConfig.java diff --git a/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/CustomAuthentication.java b/security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/CustomAuthentication.java similarity index 100% rename from java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/CustomAuthentication.java rename to security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/CustomAuthentication.java diff --git a/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/CustomPrincipal.java b/security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/CustomPrincipal.java similarity index 100% rename from java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/CustomPrincipal.java rename to security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/CustomPrincipal.java diff --git a/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/UserDetail.java b/security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/UserDetail.java similarity index 100% rename from java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/UserDetail.java rename to security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/java/com/baeldung/javaee/security/UserDetail.java diff --git a/java-ee-8-security-api/app-auth-custom-no-store/src/main/liberty/config/server.xml b/security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/liberty/config/server.xml similarity index 100% rename from java-ee-8-security-api/app-auth-custom-no-store/src/main/liberty/config/server.xml rename to security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/liberty/config/server.xml diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/src/main/resources/logback.xml b/security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/resources/logback.xml similarity index 100% rename from java-ee-8-security-api/app-auth-form-store-ldap/src/main/resources/logback.xml rename to security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/resources/logback.xml diff --git a/java-ee-8-security-api/app-auth-custom-no-store/src/main/webapp/login-error.html b/security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/webapp/login-error.html similarity index 100% rename from java-ee-8-security-api/app-auth-custom-no-store/src/main/webapp/login-error.html rename to security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/webapp/login-error.html diff --git a/java-ee-8-security-api/app-auth-custom-no-store/src/main/webapp/login.html b/security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/webapp/login.html similarity index 100% rename from java-ee-8-security-api/app-auth-custom-no-store/src/main/webapp/login.html rename to security-modules/java-ee-8-security-api/app-auth-custom-no-store/src/main/webapp/login.html diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml b/security-modules/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml similarity index 100% rename from java-ee-8-security-api/app-auth-form-store-ldap/pom.xml rename to security-modules/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/AdminServlet.java b/security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/AdminServlet.java similarity index 100% rename from java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/AdminServlet.java rename to security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/AdminServlet.java diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/AppConfig.java b/security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/AppConfig.java similarity index 100% rename from java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/AppConfig.java rename to security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/AppConfig.java diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/LdapSetupServlet.java b/security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/LdapSetupServlet.java similarity index 100% rename from java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/LdapSetupServlet.java rename to security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/LdapSetupServlet.java diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/UserServlet.java b/security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/UserServlet.java similarity index 100% rename from java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/UserServlet.java rename to security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/java/com/baeldung/javaee/security/UserServlet.java diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/src/main/liberty/config/server.xml b/security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/liberty/config/server.xml similarity index 100% rename from java-ee-8-security-api/app-auth-form-store-ldap/src/main/liberty/config/server.xml rename to security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/liberty/config/server.xml diff --git a/java-lite/src/main/resources/logback.xml b/security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/resources/logback.xml similarity index 100% rename from java-lite/src/main/resources/logback.xml rename to security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/resources/logback.xml diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/src/main/resources/users.ldif b/security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/resources/users.ldif similarity index 100% rename from java-ee-8-security-api/app-auth-form-store-ldap/src/main/resources/users.ldif rename to security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/resources/users.ldif diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/src/main/webapp/login-error.html b/security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/webapp/login-error.html similarity index 100% rename from java-ee-8-security-api/app-auth-form-store-ldap/src/main/webapp/login-error.html rename to security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/webapp/login-error.html diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/src/main/webapp/login.html b/security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/webapp/login.html similarity index 100% rename from java-ee-8-security-api/app-auth-form-store-ldap/src/main/webapp/login.html rename to security-modules/java-ee-8-security-api/app-auth-form-store-ldap/src/main/webapp/login.html diff --git a/java-ee-8-security-api/pom.xml b/security-modules/java-ee-8-security-api/pom.xml similarity index 98% rename from java-ee-8-security-api/pom.xml rename to security-modules/java-ee-8-security-api/pom.xml index c01bedbeee..bcd15ed685 100644 --- a/java-ee-8-security-api/pom.xml +++ b/security-modules/java-ee-8-security-api/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + security-modules 1.0.0-SNAPSHOT diff --git a/jee-7-security/README.md b/security-modules/jee-7-security/README.md similarity index 100% rename from jee-7-security/README.md rename to security-modules/jee-7-security/README.md diff --git a/jee-7-security/pom.xml b/security-modules/jee-7-security/pom.xml similarity index 97% rename from jee-7-security/pom.xml rename to security-modules/jee-7-security/pom.xml index a8ceee8704..71084d6cd1 100644 --- a/jee-7-security/pom.xml +++ b/security-modules/jee-7-security/pom.xml @@ -11,7 +11,7 @@ com.baeldung - parent-modules + security-modules 1.0.0-SNAPSHOT diff --git a/jee-7-security/src/main/java/com/baeldung/springsecurity/SecurityWebApplicationInitializer.java b/security-modules/jee-7-security/src/main/java/com/baeldung/springsecurity/SecurityWebApplicationInitializer.java similarity index 100% rename from jee-7-security/src/main/java/com/baeldung/springsecurity/SecurityWebApplicationInitializer.java rename to security-modules/jee-7-security/src/main/java/com/baeldung/springsecurity/SecurityWebApplicationInitializer.java diff --git a/jee-7-security/src/main/java/com/baeldung/springsecurity/SpringSecurityConfig.java b/security-modules/jee-7-security/src/main/java/com/baeldung/springsecurity/SpringSecurityConfig.java similarity index 100% rename from jee-7-security/src/main/java/com/baeldung/springsecurity/SpringSecurityConfig.java rename to security-modules/jee-7-security/src/main/java/com/baeldung/springsecurity/SpringSecurityConfig.java diff --git a/jee-7-security/src/main/java/com/baeldung/springsecurity/controller/HomeController.java b/security-modules/jee-7-security/src/main/java/com/baeldung/springsecurity/controller/HomeController.java similarity index 100% rename from jee-7-security/src/main/java/com/baeldung/springsecurity/controller/HomeController.java rename to security-modules/jee-7-security/src/main/java/com/baeldung/springsecurity/controller/HomeController.java diff --git a/jee-7-security/src/main/java/com/baeldung/springsecurity/controller/LoginController.java b/security-modules/jee-7-security/src/main/java/com/baeldung/springsecurity/controller/LoginController.java similarity index 100% rename from jee-7-security/src/main/java/com/baeldung/springsecurity/controller/LoginController.java rename to security-modules/jee-7-security/src/main/java/com/baeldung/springsecurity/controller/LoginController.java diff --git a/jee-7-security/src/main/resources/logback.xml b/security-modules/jee-7-security/src/main/resources/logback.xml similarity index 100% rename from jee-7-security/src/main/resources/logback.xml rename to security-modules/jee-7-security/src/main/resources/logback.xml diff --git a/jee-7-security/src/main/webapp/WEB-INF/beans.xml b/security-modules/jee-7-security/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from jee-7-security/src/main/webapp/WEB-INF/beans.xml rename to security-modules/jee-7-security/src/main/webapp/WEB-INF/beans.xml diff --git a/jee-7-security/src/main/webapp/WEB-INF/faces-config.xml b/security-modules/jee-7-security/src/main/webapp/WEB-INF/faces-config.xml similarity index 100% rename from jee-7-security/src/main/webapp/WEB-INF/faces-config.xml rename to security-modules/jee-7-security/src/main/webapp/WEB-INF/faces-config.xml diff --git a/jee-7-security/src/main/webapp/WEB-INF/spring/security.xml b/security-modules/jee-7-security/src/main/webapp/WEB-INF/spring/security.xml similarity index 100% rename from jee-7-security/src/main/webapp/WEB-INF/spring/security.xml rename to security-modules/jee-7-security/src/main/webapp/WEB-INF/spring/security.xml diff --git a/jee-7-security/src/main/webapp/WEB-INF/views/admin.jsp b/security-modules/jee-7-security/src/main/webapp/WEB-INF/views/admin.jsp similarity index 100% rename from jee-7-security/src/main/webapp/WEB-INF/views/admin.jsp rename to security-modules/jee-7-security/src/main/webapp/WEB-INF/views/admin.jsp diff --git a/jee-7-security/src/main/webapp/WEB-INF/views/home.jsp b/security-modules/jee-7-security/src/main/webapp/WEB-INF/views/home.jsp similarity index 100% rename from jee-7-security/src/main/webapp/WEB-INF/views/home.jsp rename to security-modules/jee-7-security/src/main/webapp/WEB-INF/views/home.jsp diff --git a/jee-7-security/src/main/webapp/WEB-INF/views/login.jsp b/security-modules/jee-7-security/src/main/webapp/WEB-INF/views/login.jsp similarity index 100% rename from jee-7-security/src/main/webapp/WEB-INF/views/login.jsp rename to security-modules/jee-7-security/src/main/webapp/WEB-INF/views/login.jsp diff --git a/jee-7-security/src/main/webapp/WEB-INF/views/user.jsp b/security-modules/jee-7-security/src/main/webapp/WEB-INF/views/user.jsp similarity index 100% rename from jee-7-security/src/main/webapp/WEB-INF/views/user.jsp rename to security-modules/jee-7-security/src/main/webapp/WEB-INF/views/user.jsp diff --git a/jee-7-security/src/main/webapp/WEB-INF/web.xml b/security-modules/jee-7-security/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from jee-7-security/src/main/webapp/WEB-INF/web.xml rename to security-modules/jee-7-security/src/main/webapp/WEB-INF/web.xml diff --git a/jee-7-security/src/main/webapp/index.jsp b/security-modules/jee-7-security/src/main/webapp/index.jsp similarity index 100% rename from jee-7-security/src/main/webapp/index.jsp rename to security-modules/jee-7-security/src/main/webapp/index.jsp diff --git a/jee-7-security/src/main/webapp/secure.jsp b/security-modules/jee-7-security/src/main/webapp/secure.jsp similarity index 100% rename from jee-7-security/src/main/webapp/secure.jsp rename to security-modules/jee-7-security/src/main/webapp/secure.jsp diff --git a/jjwt/.gitignore b/security-modules/jjwt/.gitignore similarity index 100% rename from jjwt/.gitignore rename to security-modules/jjwt/.gitignore diff --git a/jjwt/README.md b/security-modules/jjwt/README.md similarity index 100% rename from jjwt/README.md rename to security-modules/jjwt/README.md diff --git a/jjwt/pom.xml b/security-modules/jjwt/pom.xml similarity index 96% rename from jjwt/pom.xml rename to security-modules/jjwt/pom.xml index cc169ba9fc..3ea4a46b8a 100644 --- a/jjwt/pom.xml +++ b/security-modules/jjwt/pom.xml @@ -13,7 +13,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2
diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/JJWTFunApplication.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/JJWTFunApplication.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/JJWTFunApplication.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/JJWTFunApplication.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/CSRFConfig.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/CSRFConfig.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/CSRFConfig.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/CSRFConfig.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/JWTCsrfTokenRepository.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/JWTCsrfTokenRepository.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/JWTCsrfTokenRepository.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/JWTCsrfTokenRepository.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/WebSecurityConfig.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/WebSecurityConfig.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/WebSecurityConfig.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/config/WebSecurityConfig.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/BaseController.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/BaseController.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/BaseController.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/BaseController.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/DynamicJWTController.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/DynamicJWTController.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/DynamicJWTController.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/DynamicJWTController.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/FormController.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/FormController.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/FormController.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/FormController.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/HomeController.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/HomeController.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/HomeController.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/HomeController.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/SecretsController.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/SecretsController.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/SecretsController.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/SecretsController.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/StaticJWTController.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/StaticJWTController.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/StaticJWTController.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller/StaticJWTController.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/model/JwtResponse.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/model/JwtResponse.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/model/JwtResponse.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/model/JwtResponse.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/service/SecretService.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/service/SecretService.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/service/SecretService.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/service/SecretService.java diff --git a/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/util/JWTDecoderUtil.java b/security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/util/JWTDecoderUtil.java similarity index 100% rename from jjwt/src/main/java/io/jsonwebtoken/jjwtfun/util/JWTDecoderUtil.java rename to security-modules/jjwt/src/main/java/io/jsonwebtoken/jjwtfun/util/JWTDecoderUtil.java diff --git a/msf4j/src/main/resources/application.properties b/security-modules/jjwt/src/main/resources/application.properties similarity index 100% rename from msf4j/src/main/resources/application.properties rename to security-modules/jjwt/src/main/resources/application.properties diff --git a/java-vavr-stream/src/main/resources/logback.xml b/security-modules/jjwt/src/main/resources/logback.xml similarity index 100% rename from java-vavr-stream/src/main/resources/logback.xml rename to security-modules/jjwt/src/main/resources/logback.xml diff --git a/jjwt/src/main/resources/templates/expired-jwt.html b/security-modules/jjwt/src/main/resources/templates/expired-jwt.html similarity index 100% rename from jjwt/src/main/resources/templates/expired-jwt.html rename to security-modules/jjwt/src/main/resources/templates/expired-jwt.html diff --git a/jjwt/src/main/resources/templates/fragments/head.html b/security-modules/jjwt/src/main/resources/templates/fragments/head.html similarity index 100% rename from jjwt/src/main/resources/templates/fragments/head.html rename to security-modules/jjwt/src/main/resources/templates/fragments/head.html diff --git a/jjwt/src/main/resources/templates/jwt-csrf-form-result.html b/security-modules/jjwt/src/main/resources/templates/jwt-csrf-form-result.html similarity index 100% rename from jjwt/src/main/resources/templates/jwt-csrf-form-result.html rename to security-modules/jjwt/src/main/resources/templates/jwt-csrf-form-result.html diff --git a/jjwt/src/main/resources/templates/jwt-csrf-form.html b/security-modules/jjwt/src/main/resources/templates/jwt-csrf-form.html similarity index 100% rename from jjwt/src/main/resources/templates/jwt-csrf-form.html rename to security-modules/jjwt/src/main/resources/templates/jwt-csrf-form.html diff --git a/jjwt/src/test/java/io/jsonwebtoken/jjwtfun/DemoApplicationIntegrationTest.java b/security-modules/jjwt/src/test/java/io/jsonwebtoken/jjwtfun/DemoApplicationIntegrationTest.java similarity index 100% rename from jjwt/src/test/java/io/jsonwebtoken/jjwtfun/DemoApplicationIntegrationTest.java rename to security-modules/jjwt/src/test/java/io/jsonwebtoken/jjwtfun/DemoApplicationIntegrationTest.java diff --git a/jjwt/src/test/java/io/jsonwebtoken/jjwtfun/util/JWTDecoderUtilUnitTest.java b/security-modules/jjwt/src/test/java/io/jsonwebtoken/jjwtfun/util/JWTDecoderUtilUnitTest.java similarity index 100% rename from jjwt/src/test/java/io/jsonwebtoken/jjwtfun/util/JWTDecoderUtilUnitTest.java rename to security-modules/jjwt/src/test/java/io/jsonwebtoken/jjwtfun/util/JWTDecoderUtilUnitTest.java diff --git a/oauth2-framework-impl/README.md b/security-modules/oauth2-framework-impl/README.md similarity index 100% rename from oauth2-framework-impl/README.md rename to security-modules/oauth2-framework-impl/README.md diff --git a/oauth2-framework-impl/oauth2-authorization-server/pom.xml b/security-modules/oauth2-framework-impl/oauth2-authorization-server/pom.xml similarity index 100% rename from oauth2-framework-impl/oauth2-authorization-server/pom.xml rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/pom.xml diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/OAuth2ServerApplication.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/OAuth2ServerApplication.java similarity index 100% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/OAuth2ServerApplication.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/OAuth2ServerApplication.java diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/PEMKeyUtils.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/PEMKeyUtils.java similarity index 96% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/PEMKeyUtils.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/PEMKeyUtils.java index dab57b91a7..3947874179 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/PEMKeyUtils.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/PEMKeyUtils.java @@ -1,17 +1,17 @@ -package com.baeldung.oauth2.authorization.server; - -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Paths; - -import static java.lang.Thread.currentThread; - - -public class PEMKeyUtils { - - public static String readKeyAsString(String keyLocation) throws Exception { - URI uri = currentThread().getContextClassLoader().getResource(keyLocation).toURI(); - byte[] byteArray = Files.readAllBytes(Paths.get(uri)); - return new String(byteArray); - } -} +package com.baeldung.oauth2.authorization.server; + +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static java.lang.Thread.currentThread; + + +public class PEMKeyUtils { + + public static String readKeyAsString(String keyLocation) throws Exception { + URI uri = currentThread().getContextClassLoader().getResource(keyLocation).toURI(); + byte[] byteArray = Files.readAllBytes(Paths.get(uri)); + return new String(byteArray); + } +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/AuthorizationEndpoint.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/AuthorizationEndpoint.java similarity index 97% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/AuthorizationEndpoint.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/AuthorizationEndpoint.java index ba5e1ec359..618363c7e1 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/AuthorizationEndpoint.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/AuthorizationEndpoint.java @@ -1,185 +1,185 @@ -package com.baeldung.oauth2.authorization.server.api; - -import com.baeldung.oauth2.authorization.server.handler.AuthorizationGrantTypeHandler; -import com.baeldung.oauth2.authorization.server.model.AppDataRepository; -import com.baeldung.oauth2.authorization.server.model.AuthorizationCode; -import com.baeldung.oauth2.authorization.server.model.Client; -import com.baeldung.oauth2.authorization.server.model.User; - -import javax.annotation.security.RolesAllowed; -import javax.enterprise.context.RequestScoped; -import javax.enterprise.inject.Instance; -import javax.enterprise.inject.literal.NamedLiteral; -import javax.inject.Inject; -import javax.json.JsonObject; -import javax.security.enterprise.SecurityContext; -import javax.security.enterprise.authentication.mechanism.http.FormAuthenticationMechanismDefinition; -import javax.security.enterprise.authentication.mechanism.http.LoginToContinue; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.*; -import javax.ws.rs.core.*; -import java.io.IOException; -import java.net.URI; -import java.security.Principal; -import java.time.LocalDateTime; -import java.util.*; - -@FormAuthenticationMechanismDefinition( - loginToContinue = @LoginToContinue(loginPage = "/login.jsp", errorPage = "/login.jsp") -) -@RolesAllowed("USER") -@RequestScoped -@Path("authorize") -public class AuthorizationEndpoint { - - @Inject - private SecurityContext securityContext; - - @Inject - private AppDataRepository appDataRepository; - - @Inject - Instance authorizationGrantTypeHandlers; - - @GET - @Produces(MediaType.TEXT_HTML) - public Response doGet(@Context HttpServletRequest request, - @Context HttpServletResponse response, - @Context UriInfo uriInfo) throws ServletException, IOException { - MultivaluedMap params = uriInfo.getQueryParameters(); - Principal principal = securityContext.getCallerPrincipal(); - - //error about redirect_uri && client_id ==> forward user, thus to error.jsp. - //otherwise ==> sendRedirect redirect_uri?error=error&error_description=error_description - //1. client_id - String clientId = params.getFirst("client_id"); - if (clientId == null || clientId.isEmpty()) { - return informUserAboutError(request, response, "Invalid client_id :" + clientId); - } - Client client = appDataRepository.getClient(clientId); - if (client == null) { - return informUserAboutError(request, response, "Invalid client_id :" + clientId); - } - //2. Client Authorized Grant Type - String clientError = ""; - if (client.getAuthorizedGrantTypes() != null && !client.getAuthorizedGrantTypes().contains("authorization_code")) { - return informUserAboutError(request, response, "Authorization Grant type, authorization_code, is not allowed for this client :" + clientId); - } - - //3. redirectUri - String redirectUri = params.getFirst("redirect_uri"); - if (client.getRedirectUri() != null && !client.getRedirectUri().isEmpty()) { - if (redirectUri != null && !redirectUri.isEmpty() && !client.getRedirectUri().equals(redirectUri)) { - //sould be in the client.redirectUri - return informUserAboutError(request, response, "redirect_uri is pre-registred and should match"); - } - redirectUri = client.getRedirectUri(); - params.putSingle("resolved_redirect_uri", redirectUri); - } else { - if (redirectUri == null || redirectUri.isEmpty()) { - return informUserAboutError(request, response, "redirect_uri is not pre-registred and should be provided"); - } - params.putSingle("resolved_redirect_uri", redirectUri); - } - request.setAttribute("client", client); - - //4. response_type - String responseType = params.getFirst("response_type"); - if (!"code".equals(responseType) && !"token".equals(responseType)) { - //error = "invalid_grant :" + responseType + ", response_type params should be code or token:"; - //return informUserAboutError(error); - } - - //Save params in session - request.getSession().setAttribute("ORIGINAL_PARAMS", params); - - //4.scope: Optional - String requestedScope = request.getParameter("scope"); - if (requestedScope == null || requestedScope.isEmpty()) { - requestedScope = client.getScope(); - } - User user = appDataRepository.getUser(principal.getName()); - String allowedScopes = checkUserScopes(user.getScopes(), requestedScope); - request.setAttribute("scopes", allowedScopes); - - request.getRequestDispatcher("/authorize.jsp").forward(request, response); - return null; - } - - @POST - @Consumes(MediaType.APPLICATION_FORM_URLENCODED) - @Produces(MediaType.TEXT_HTML) - public Response doPost(@Context HttpServletRequest request, - @Context HttpServletResponse response, - MultivaluedMap params) throws Exception { - MultivaluedMap originalParams = (MultivaluedMap) request.getSession().getAttribute("ORIGINAL_PARAMS"); - if (originalParams == null) { - return informUserAboutError(request, response, "No pending authorization request."); - } - String redirectUri = originalParams.getFirst("resolved_redirect_uri"); - StringBuilder sb = new StringBuilder(redirectUri); - - String approvalStatus = params.getFirst("approval_status"); - if ("NO".equals(approvalStatus)) { - URI location = UriBuilder.fromUri(sb.toString()) - .queryParam("error", "User doesn't approved the request.") - .queryParam("error_description", "User doesn't approved the request.") - .build(); - return Response.seeOther(location).build(); - } - //==> YES - List approvedScopes = params.get("scope"); - if (approvedScopes == null || approvedScopes.isEmpty()) { - URI location = UriBuilder.fromUri(sb.toString()) - .queryParam("error", "User doesn't approved the request.") - .queryParam("error_description", "User doesn't approved the request.") - .build(); - return Response.seeOther(location).build(); - } - - String responseType = originalParams.getFirst("response_type"); - String clientId = originalParams.getFirst("client_id"); - if ("code".equals(responseType)) { - String userId = securityContext.getCallerPrincipal().getName(); - AuthorizationCode authorizationCode = new AuthorizationCode(); - authorizationCode.setClientId(clientId); - authorizationCode.setUserId(userId); - authorizationCode.setApprovedScopes(String.join(" ", approvedScopes)); - authorizationCode.setExpirationDate(LocalDateTime.now().plusMinutes(10)); - authorizationCode.setRedirectUri(redirectUri); - appDataRepository.save(authorizationCode); - String code = authorizationCode.getCode(); - sb.append("?code=").append(code); - } else { - //Implicit: responseType=token - AuthorizationGrantTypeHandler authorizationGrantTypeHandler = authorizationGrantTypeHandlers.select(NamedLiteral.of("implicit")).get(); - JsonObject tokenResponse = authorizationGrantTypeHandler.createAccessToken(clientId, params); - sb.append("#access_token=").append(tokenResponse.getString("access_token")) - .append("&token_type=").append(tokenResponse.getString("token_type")) - .append("&scope=").append(tokenResponse.getString("scope")); - } - String state = originalParams.getFirst("state"); - if (state != null) { - sb.append("&state=").append(state); - } - return Response.seeOther(UriBuilder.fromUri(sb.toString()).build()).build(); - } - - private String checkUserScopes(String userScopes, String requestedScope) { - Set allowedScopes = new LinkedHashSet<>(); - Set rScopes = new HashSet(Arrays.asList(requestedScope.split(" "))); - Set uScopes = new HashSet(Arrays.asList(userScopes.split(" "))); - for (String scope : uScopes) { - if (rScopes.contains(scope)) allowedScopes.add(scope); - } - return String.join(" ", allowedScopes); - } - - private Response informUserAboutError(HttpServletRequest request, HttpServletResponse response, String error) throws ServletException, IOException { - request.setAttribute("error", error); - request.getRequestDispatcher("/error.jsp").forward(request, response); - return null; - } -} +package com.baeldung.oauth2.authorization.server.api; + +import com.baeldung.oauth2.authorization.server.handler.AuthorizationGrantTypeHandler; +import com.baeldung.oauth2.authorization.server.model.AppDataRepository; +import com.baeldung.oauth2.authorization.server.model.AuthorizationCode; +import com.baeldung.oauth2.authorization.server.model.Client; +import com.baeldung.oauth2.authorization.server.model.User; + +import javax.annotation.security.RolesAllowed; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.inject.Instance; +import javax.enterprise.inject.literal.NamedLiteral; +import javax.inject.Inject; +import javax.json.JsonObject; +import javax.security.enterprise.SecurityContext; +import javax.security.enterprise.authentication.mechanism.http.FormAuthenticationMechanismDefinition; +import javax.security.enterprise.authentication.mechanism.http.LoginToContinue; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.*; +import java.io.IOException; +import java.net.URI; +import java.security.Principal; +import java.time.LocalDateTime; +import java.util.*; + +@FormAuthenticationMechanismDefinition( + loginToContinue = @LoginToContinue(loginPage = "/login.jsp", errorPage = "/login.jsp") +) +@RolesAllowed("USER") +@RequestScoped +@Path("authorize") +public class AuthorizationEndpoint { + + @Inject + private SecurityContext securityContext; + + @Inject + private AppDataRepository appDataRepository; + + @Inject + Instance authorizationGrantTypeHandlers; + + @GET + @Produces(MediaType.TEXT_HTML) + public Response doGet(@Context HttpServletRequest request, + @Context HttpServletResponse response, + @Context UriInfo uriInfo) throws ServletException, IOException { + MultivaluedMap params = uriInfo.getQueryParameters(); + Principal principal = securityContext.getCallerPrincipal(); + + //error about redirect_uri && client_id ==> forward user, thus to error.jsp. + //otherwise ==> sendRedirect redirect_uri?error=error&error_description=error_description + //1. client_id + String clientId = params.getFirst("client_id"); + if (clientId == null || clientId.isEmpty()) { + return informUserAboutError(request, response, "Invalid client_id :" + clientId); + } + Client client = appDataRepository.getClient(clientId); + if (client == null) { + return informUserAboutError(request, response, "Invalid client_id :" + clientId); + } + //2. Client Authorized Grant Type + String clientError = ""; + if (client.getAuthorizedGrantTypes() != null && !client.getAuthorizedGrantTypes().contains("authorization_code")) { + return informUserAboutError(request, response, "Authorization Grant type, authorization_code, is not allowed for this client :" + clientId); + } + + //3. redirectUri + String redirectUri = params.getFirst("redirect_uri"); + if (client.getRedirectUri() != null && !client.getRedirectUri().isEmpty()) { + if (redirectUri != null && !redirectUri.isEmpty() && !client.getRedirectUri().equals(redirectUri)) { + //sould be in the client.redirectUri + return informUserAboutError(request, response, "redirect_uri is pre-registred and should match"); + } + redirectUri = client.getRedirectUri(); + params.putSingle("resolved_redirect_uri", redirectUri); + } else { + if (redirectUri == null || redirectUri.isEmpty()) { + return informUserAboutError(request, response, "redirect_uri is not pre-registred and should be provided"); + } + params.putSingle("resolved_redirect_uri", redirectUri); + } + request.setAttribute("client", client); + + //4. response_type + String responseType = params.getFirst("response_type"); + if (!"code".equals(responseType) && !"token".equals(responseType)) { + //error = "invalid_grant :" + responseType + ", response_type params should be code or token:"; + //return informUserAboutError(error); + } + + //Save params in session + request.getSession().setAttribute("ORIGINAL_PARAMS", params); + + //4.scope: Optional + String requestedScope = request.getParameter("scope"); + if (requestedScope == null || requestedScope.isEmpty()) { + requestedScope = client.getScope(); + } + User user = appDataRepository.getUser(principal.getName()); + String allowedScopes = checkUserScopes(user.getScopes(), requestedScope); + request.setAttribute("scopes", allowedScopes); + + request.getRequestDispatcher("/authorize.jsp").forward(request, response); + return null; + } + + @POST + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + @Produces(MediaType.TEXT_HTML) + public Response doPost(@Context HttpServletRequest request, + @Context HttpServletResponse response, + MultivaluedMap params) throws Exception { + MultivaluedMap originalParams = (MultivaluedMap) request.getSession().getAttribute("ORIGINAL_PARAMS"); + if (originalParams == null) { + return informUserAboutError(request, response, "No pending authorization request."); + } + String redirectUri = originalParams.getFirst("resolved_redirect_uri"); + StringBuilder sb = new StringBuilder(redirectUri); + + String approvalStatus = params.getFirst("approval_status"); + if ("NO".equals(approvalStatus)) { + URI location = UriBuilder.fromUri(sb.toString()) + .queryParam("error", "User doesn't approved the request.") + .queryParam("error_description", "User doesn't approved the request.") + .build(); + return Response.seeOther(location).build(); + } + //==> YES + List approvedScopes = params.get("scope"); + if (approvedScopes == null || approvedScopes.isEmpty()) { + URI location = UriBuilder.fromUri(sb.toString()) + .queryParam("error", "User doesn't approved the request.") + .queryParam("error_description", "User doesn't approved the request.") + .build(); + return Response.seeOther(location).build(); + } + + String responseType = originalParams.getFirst("response_type"); + String clientId = originalParams.getFirst("client_id"); + if ("code".equals(responseType)) { + String userId = securityContext.getCallerPrincipal().getName(); + AuthorizationCode authorizationCode = new AuthorizationCode(); + authorizationCode.setClientId(clientId); + authorizationCode.setUserId(userId); + authorizationCode.setApprovedScopes(String.join(" ", approvedScopes)); + authorizationCode.setExpirationDate(LocalDateTime.now().plusMinutes(10)); + authorizationCode.setRedirectUri(redirectUri); + appDataRepository.save(authorizationCode); + String code = authorizationCode.getCode(); + sb.append("?code=").append(code); + } else { + //Implicit: responseType=token + AuthorizationGrantTypeHandler authorizationGrantTypeHandler = authorizationGrantTypeHandlers.select(NamedLiteral.of("implicit")).get(); + JsonObject tokenResponse = authorizationGrantTypeHandler.createAccessToken(clientId, params); + sb.append("#access_token=").append(tokenResponse.getString("access_token")) + .append("&token_type=").append(tokenResponse.getString("token_type")) + .append("&scope=").append(tokenResponse.getString("scope")); + } + String state = originalParams.getFirst("state"); + if (state != null) { + sb.append("&state=").append(state); + } + return Response.seeOther(UriBuilder.fromUri(sb.toString()).build()).build(); + } + + private String checkUserScopes(String userScopes, String requestedScope) { + Set allowedScopes = new LinkedHashSet<>(); + Set rScopes = new HashSet(Arrays.asList(requestedScope.split(" "))); + Set uScopes = new HashSet(Arrays.asList(userScopes.split(" "))); + for (String scope : uScopes) { + if (rScopes.contains(scope)) allowedScopes.add(scope); + } + return String.join(" ", allowedScopes); + } + + private Response informUserAboutError(HttpServletRequest request, HttpServletResponse response, String error) throws ServletException, IOException { + request.setAttribute("error", error); + request.getRequestDispatcher("/error.jsp").forward(request, response); + return null; + } +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/JWKEndpoint.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/JWKEndpoint.java similarity index 97% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/JWKEndpoint.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/JWKEndpoint.java index 9d38c823b9..0fbdbb1891 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/JWKEndpoint.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/JWKEndpoint.java @@ -1,38 +1,38 @@ -package com.baeldung.oauth2.authorization.server.api; - -import com.baeldung.oauth2.authorization.server.PEMKeyUtils; -import com.nimbusds.jose.jwk.JWK; -import org.eclipse.microprofile.config.Config; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.Arrays; - -@Path("jwk") -@ApplicationScoped -public class JWKEndpoint { - - @Inject - private Config config; - - @GET - public Response getKey(@QueryParam("format") String format) throws Exception { - if (format != null && !Arrays.asList("jwk", "pem").contains(format)) { - return Response.status(Response.Status.BAD_REQUEST).entity("Public Key Format should be : jwk or pem").build(); - } - String verificationkey = config.getValue("verificationkey", String.class); - String pemEncodedRSAPublicKey = PEMKeyUtils.readKeyAsString(verificationkey); - if (format == null || format.equals("jwk")) { - JWK jwk = JWK.parseFromPEMEncodedObjects(pemEncodedRSAPublicKey); - return Response.ok(jwk.toJSONString()).type(MediaType.APPLICATION_JSON).build(); - } else if (format.equals("pem")) { - return Response.ok(pemEncodedRSAPublicKey).build(); - } - return null; - } -} +package com.baeldung.oauth2.authorization.server.api; + +import com.baeldung.oauth2.authorization.server.PEMKeyUtils; +import com.nimbusds.jose.jwk.JWK; +import org.eclipse.microprofile.config.Config; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.Arrays; + +@Path("jwk") +@ApplicationScoped +public class JWKEndpoint { + + @Inject + private Config config; + + @GET + public Response getKey(@QueryParam("format") String format) throws Exception { + if (format != null && !Arrays.asList("jwk", "pem").contains(format)) { + return Response.status(Response.Status.BAD_REQUEST).entity("Public Key Format should be : jwk or pem").build(); + } + String verificationkey = config.getValue("verificationkey", String.class); + String pemEncodedRSAPublicKey = PEMKeyUtils.readKeyAsString(verificationkey); + if (format == null || format.equals("jwk")) { + JWK jwk = JWK.parseFromPEMEncodedObjects(pemEncodedRSAPublicKey); + return Response.ok(jwk.toJSONString()).type(MediaType.APPLICATION_JSON).build(); + } else if (format.equals("pem")) { + return Response.ok(pemEncodedRSAPublicKey).build(); + } + return null; + } +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/TokenEndpoint.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/TokenEndpoint.java similarity index 100% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/TokenEndpoint.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/api/TokenEndpoint.java diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AbstractGrantTypeHandler.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AbstractGrantTypeHandler.java similarity index 97% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AbstractGrantTypeHandler.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AbstractGrantTypeHandler.java index 324bacb33f..021ab6bfb8 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AbstractGrantTypeHandler.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AbstractGrantTypeHandler.java @@ -1,87 +1,87 @@ -package com.baeldung.oauth2.authorization.server.handler; - -import com.baeldung.oauth2.authorization.server.PEMKeyUtils; -import com.nimbusds.jose.*; -import com.nimbusds.jose.crypto.RSASSASigner; -import com.nimbusds.jose.crypto.RSASSAVerifier; -import com.nimbusds.jose.jwk.JWK; -import com.nimbusds.jose.jwk.RSAKey; -import com.nimbusds.jwt.JWTClaimsSet; -import com.nimbusds.jwt.SignedJWT; -import org.eclipse.microprofile.config.Config; - -import javax.inject.Inject; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.Arrays; -import java.util.Date; -import java.util.UUID; - -public abstract class AbstractGrantTypeHandler implements AuthorizationGrantTypeHandler { - - //Always RSA 256, but could be parametrized - protected JWSHeader jwsHeader = new JWSHeader.Builder(JWSAlgorithm.RS256).type(JOSEObjectType.JWT).build(); - - @Inject - protected Config config; - - //30 min - protected Long expiresInMin = 30L; - - protected JWSVerifier getJWSVerifier() throws Exception { - String verificationkey = config.getValue("verificationkey", String.class); - String pemEncodedRSAPublicKey = PEMKeyUtils.readKeyAsString(verificationkey); - RSAKey rsaPublicKey = (RSAKey) JWK.parseFromPEMEncodedObjects(pemEncodedRSAPublicKey); - return new RSASSAVerifier(rsaPublicKey); - } - - protected JWSSigner getJwsSigner() throws Exception { - String signingkey = config.getValue("signingkey", String.class); - String pemEncodedRSAPrivateKey = PEMKeyUtils.readKeyAsString(signingkey); - RSAKey rsaKey = (RSAKey) JWK.parseFromPEMEncodedObjects(pemEncodedRSAPrivateKey); - return new RSASSASigner(rsaKey.toRSAPrivateKey()); - } - - protected String getAccessToken(String clientId, String subject, String approvedScope) throws Exception { - //4. Signing - JWSSigner jwsSigner = getJwsSigner(); - - Instant now = Instant.now(); - //Long expiresInMin = 30L; - Date expirationTime = Date.from(now.plus(expiresInMin, ChronoUnit.MINUTES)); - - //3. JWT Payload or claims - JWTClaimsSet jwtClaims = new JWTClaimsSet.Builder() - .issuer("http://localhost:9080") - .subject(subject) - .claim("upn", subject) - .claim("client_id", clientId) - .audience("http://localhost:9280") - .claim("scope", approvedScope) - .claim("groups", Arrays.asList(approvedScope.split(" "))) - .expirationTime(expirationTime) // expires in 30 minutes - .notBeforeTime(Date.from(now)) - .issueTime(Date.from(now)) - .jwtID(UUID.randomUUID().toString()) - .build(); - SignedJWT signedJWT = new SignedJWT(jwsHeader, jwtClaims); - signedJWT.sign(jwsSigner); - return signedJWT.serialize(); - } - - protected String getRefreshToken(String clientId, String subject, String approvedScope) throws Exception { - JWSSigner jwsSigner = getJwsSigner(); - Instant now = Instant.now(); - //6.Build refresh token - JWTClaimsSet refreshTokenClaims = new JWTClaimsSet.Builder() - .subject(subject) - .claim("client_id", clientId) - .claim("scope", approvedScope) - //refresh token for 1 day. - .expirationTime(Date.from(now.plus(1, ChronoUnit.DAYS))) - .build(); - SignedJWT signedRefreshToken = new SignedJWT(jwsHeader, refreshTokenClaims); - signedRefreshToken.sign(jwsSigner); - return signedRefreshToken.serialize(); - } -} +package com.baeldung.oauth2.authorization.server.handler; + +import com.baeldung.oauth2.authorization.server.PEMKeyUtils; +import com.nimbusds.jose.*; +import com.nimbusds.jose.crypto.RSASSASigner; +import com.nimbusds.jose.crypto.RSASSAVerifier; +import com.nimbusds.jose.jwk.JWK; +import com.nimbusds.jose.jwk.RSAKey; +import com.nimbusds.jwt.JWTClaimsSet; +import com.nimbusds.jwt.SignedJWT; +import org.eclipse.microprofile.config.Config; + +import javax.inject.Inject; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Arrays; +import java.util.Date; +import java.util.UUID; + +public abstract class AbstractGrantTypeHandler implements AuthorizationGrantTypeHandler { + + //Always RSA 256, but could be parametrized + protected JWSHeader jwsHeader = new JWSHeader.Builder(JWSAlgorithm.RS256).type(JOSEObjectType.JWT).build(); + + @Inject + protected Config config; + + //30 min + protected Long expiresInMin = 30L; + + protected JWSVerifier getJWSVerifier() throws Exception { + String verificationkey = config.getValue("verificationkey", String.class); + String pemEncodedRSAPublicKey = PEMKeyUtils.readKeyAsString(verificationkey); + RSAKey rsaPublicKey = (RSAKey) JWK.parseFromPEMEncodedObjects(pemEncodedRSAPublicKey); + return new RSASSAVerifier(rsaPublicKey); + } + + protected JWSSigner getJwsSigner() throws Exception { + String signingkey = config.getValue("signingkey", String.class); + String pemEncodedRSAPrivateKey = PEMKeyUtils.readKeyAsString(signingkey); + RSAKey rsaKey = (RSAKey) JWK.parseFromPEMEncodedObjects(pemEncodedRSAPrivateKey); + return new RSASSASigner(rsaKey.toRSAPrivateKey()); + } + + protected String getAccessToken(String clientId, String subject, String approvedScope) throws Exception { + //4. Signing + JWSSigner jwsSigner = getJwsSigner(); + + Instant now = Instant.now(); + //Long expiresInMin = 30L; + Date expirationTime = Date.from(now.plus(expiresInMin, ChronoUnit.MINUTES)); + + //3. JWT Payload or claims + JWTClaimsSet jwtClaims = new JWTClaimsSet.Builder() + .issuer("http://localhost:9080") + .subject(subject) + .claim("upn", subject) + .claim("client_id", clientId) + .audience("http://localhost:9280") + .claim("scope", approvedScope) + .claim("groups", Arrays.asList(approvedScope.split(" "))) + .expirationTime(expirationTime) // expires in 30 minutes + .notBeforeTime(Date.from(now)) + .issueTime(Date.from(now)) + .jwtID(UUID.randomUUID().toString()) + .build(); + SignedJWT signedJWT = new SignedJWT(jwsHeader, jwtClaims); + signedJWT.sign(jwsSigner); + return signedJWT.serialize(); + } + + protected String getRefreshToken(String clientId, String subject, String approvedScope) throws Exception { + JWSSigner jwsSigner = getJwsSigner(); + Instant now = Instant.now(); + //6.Build refresh token + JWTClaimsSet refreshTokenClaims = new JWTClaimsSet.Builder() + .subject(subject) + .claim("client_id", clientId) + .claim("scope", approvedScope) + //refresh token for 1 day. + .expirationTime(Date.from(now.plus(1, ChronoUnit.DAYS))) + .build(); + SignedJWT signedRefreshToken = new SignedJWT(jwsHeader, refreshTokenClaims); + signedRefreshToken.sign(jwsSigner); + return signedRefreshToken.serialize(); + } +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationCodeGrantTypeHandler.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationCodeGrantTypeHandler.java similarity index 97% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationCodeGrantTypeHandler.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationCodeGrantTypeHandler.java index 78128aead6..bd7dbb0d31 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationCodeGrantTypeHandler.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationCodeGrantTypeHandler.java @@ -1,54 +1,54 @@ -package com.baeldung.oauth2.authorization.server.handler; - -import com.baeldung.oauth2.authorization.server.model.AuthorizationCode; - -import javax.inject.Named; -import javax.json.Json; -import javax.json.JsonObject; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MultivaluedMap; -import java.time.LocalDateTime; - -@Named("authorization_code") -public class AuthorizationCodeGrantTypeHandler extends AbstractGrantTypeHandler { - - @PersistenceContext - private EntityManager entityManager; - - @Override - public JsonObject createAccessToken(String clientId, MultivaluedMap params) throws Exception { - //1. code is required - String code = params.getFirst("code"); - if (code == null || "".equals(code)) { - throw new WebApplicationException("invalid_grant"); - } - AuthorizationCode authorizationCode = entityManager.find(AuthorizationCode.class, code); - if (!authorizationCode.getExpirationDate().isAfter(LocalDateTime.now())) { - throw new WebApplicationException("code Expired !"); - } - String redirectUri = params.getFirst("redirect_uri"); - //redirecturi match - if (authorizationCode.getRedirectUri() != null && !authorizationCode.getRedirectUri().equals(redirectUri)) { - //redirectUri params should be the same as the requested redirectUri. - throw new WebApplicationException("invalid_grant"); - } - //client match - if (!clientId.equals(authorizationCode.getClientId())) { - throw new WebApplicationException("invalid_grant"); - } - - //3. JWT Payload or claims - String accessToken = getAccessToken(clientId, authorizationCode.getUserId(), authorizationCode.getApprovedScopes()); - String refreshToken = getRefreshToken(clientId, authorizationCode.getUserId(), authorizationCode.getApprovedScopes()); - - return Json.createObjectBuilder() - .add("token_type", "Bearer") - .add("access_token", accessToken) - .add("expires_in", expiresInMin * 60) - .add("scope", authorizationCode.getApprovedScopes()) - .add("refresh_token", refreshToken) - .build(); - } -} +package com.baeldung.oauth2.authorization.server.handler; + +import com.baeldung.oauth2.authorization.server.model.AuthorizationCode; + +import javax.inject.Named; +import javax.json.Json; +import javax.json.JsonObject; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MultivaluedMap; +import java.time.LocalDateTime; + +@Named("authorization_code") +public class AuthorizationCodeGrantTypeHandler extends AbstractGrantTypeHandler { + + @PersistenceContext + private EntityManager entityManager; + + @Override + public JsonObject createAccessToken(String clientId, MultivaluedMap params) throws Exception { + //1. code is required + String code = params.getFirst("code"); + if (code == null || "".equals(code)) { + throw new WebApplicationException("invalid_grant"); + } + AuthorizationCode authorizationCode = entityManager.find(AuthorizationCode.class, code); + if (!authorizationCode.getExpirationDate().isAfter(LocalDateTime.now())) { + throw new WebApplicationException("code Expired !"); + } + String redirectUri = params.getFirst("redirect_uri"); + //redirecturi match + if (authorizationCode.getRedirectUri() != null && !authorizationCode.getRedirectUri().equals(redirectUri)) { + //redirectUri params should be the same as the requested redirectUri. + throw new WebApplicationException("invalid_grant"); + } + //client match + if (!clientId.equals(authorizationCode.getClientId())) { + throw new WebApplicationException("invalid_grant"); + } + + //3. JWT Payload or claims + String accessToken = getAccessToken(clientId, authorizationCode.getUserId(), authorizationCode.getApprovedScopes()); + String refreshToken = getRefreshToken(clientId, authorizationCode.getUserId(), authorizationCode.getApprovedScopes()); + + return Json.createObjectBuilder() + .add("token_type", "Bearer") + .add("access_token", accessToken) + .add("expires_in", expiresInMin * 60) + .add("scope", authorizationCode.getApprovedScopes()) + .add("refresh_token", refreshToken) + .build(); + } +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationGrantTypeHandler.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationGrantTypeHandler.java similarity index 97% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationGrantTypeHandler.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationGrantTypeHandler.java index a5afe293ef..0568db1b5c 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationGrantTypeHandler.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/AuthorizationGrantTypeHandler.java @@ -1,8 +1,8 @@ -package com.baeldung.oauth2.authorization.server.handler; - -import javax.json.JsonObject; -import javax.ws.rs.core.MultivaluedMap; - -public interface AuthorizationGrantTypeHandler { - JsonObject createAccessToken(String clientId, MultivaluedMap params) throws Exception; -} +package com.baeldung.oauth2.authorization.server.handler; + +import javax.json.JsonObject; +import javax.ws.rs.core.MultivaluedMap; + +public interface AuthorizationGrantTypeHandler { + JsonObject createAccessToken(String clientId, MultivaluedMap params) throws Exception; +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/RefreshTokenGrantTypeHandler.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/RefreshTokenGrantTypeHandler.java similarity index 97% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/RefreshTokenGrantTypeHandler.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/RefreshTokenGrantTypeHandler.java index 63e3552353..433371f0d2 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/RefreshTokenGrantTypeHandler.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/handler/RefreshTokenGrantTypeHandler.java @@ -1,72 +1,72 @@ -package com.baeldung.oauth2.authorization.server.handler; - -import com.nimbusds.jose.JWSVerifier; -import com.nimbusds.jwt.SignedJWT; - -import javax.inject.Named; -import javax.json.Json; -import javax.json.JsonObject; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import java.util.Arrays; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -@Named("refresh_token") -public class RefreshTokenGrantTypeHandler extends AbstractGrantTypeHandler { - - @Override - public JsonObject createAccessToken(String clientId, MultivaluedMap params) throws Exception { - String refreshToken = params.getFirst("refresh_token"); - if (refreshToken == null || "".equals(refreshToken)) { - throw new WebApplicationException("invalid_grant"); - } - - //Decode refresh token - SignedJWT signedRefreshToken = SignedJWT.parse(refreshToken); - JWSVerifier verifier = getJWSVerifier(); - - if (!signedRefreshToken.verify(verifier)) { - throw new WebApplicationException("Invalid refresh token."); - } - if (!(new Date().before(signedRefreshToken.getJWTClaimsSet().getExpirationTime()))) { - throw new WebApplicationException("Refresh token expired."); - } - String refreshTokenClientId = signedRefreshToken.getJWTClaimsSet().getStringClaim("client_id"); - if (!clientId.equals(refreshTokenClientId)) { - throw new WebApplicationException("Invalid client_id."); - } - - //At this point, the refresh token is valid and not yet expired - //So create a new access token from it. - String subject = signedRefreshToken.getJWTClaimsSet().getSubject(); - String approvedScopes = signedRefreshToken.getJWTClaimsSet().getStringClaim("scope"); - - String requestedScopes = params.getFirst("scope"); - if (requestedScopes != null && !requestedScopes.isEmpty()) { - Set rScopes = new HashSet(Arrays.asList(requestedScopes.split(" "))); - Set aScopes = new HashSet(Arrays.asList(approvedScopes.split(" "))); - if (!aScopes.containsAll(rScopes)) { - JsonObject error = Json.createObjectBuilder() - .add("error", "Invalid_request") - .add("error_description", "Requested scopes should be a subset of the original scopes.") - .build(); - Response response = Response.status(Response.Status.BAD_REQUEST).entity(error).build(); - throw new WebApplicationException(response); - } - } else { - requestedScopes = approvedScopes; - } - - String accessToken = getAccessToken(clientId, subject, requestedScopes); - return Json.createObjectBuilder() - .add("token_type", "Bearer") - .add("access_token", accessToken) - .add("expires_in", expiresInMin * 60) - .add("scope", requestedScopes) - .add("refresh_token", refreshToken) - .build(); - } -} +package com.baeldung.oauth2.authorization.server.handler; + +import com.nimbusds.jose.JWSVerifier; +import com.nimbusds.jwt.SignedJWT; + +import javax.inject.Named; +import javax.json.Json; +import javax.json.JsonObject; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +@Named("refresh_token") +public class RefreshTokenGrantTypeHandler extends AbstractGrantTypeHandler { + + @Override + public JsonObject createAccessToken(String clientId, MultivaluedMap params) throws Exception { + String refreshToken = params.getFirst("refresh_token"); + if (refreshToken == null || "".equals(refreshToken)) { + throw new WebApplicationException("invalid_grant"); + } + + //Decode refresh token + SignedJWT signedRefreshToken = SignedJWT.parse(refreshToken); + JWSVerifier verifier = getJWSVerifier(); + + if (!signedRefreshToken.verify(verifier)) { + throw new WebApplicationException("Invalid refresh token."); + } + if (!(new Date().before(signedRefreshToken.getJWTClaimsSet().getExpirationTime()))) { + throw new WebApplicationException("Refresh token expired."); + } + String refreshTokenClientId = signedRefreshToken.getJWTClaimsSet().getStringClaim("client_id"); + if (!clientId.equals(refreshTokenClientId)) { + throw new WebApplicationException("Invalid client_id."); + } + + //At this point, the refresh token is valid and not yet expired + //So create a new access token from it. + String subject = signedRefreshToken.getJWTClaimsSet().getSubject(); + String approvedScopes = signedRefreshToken.getJWTClaimsSet().getStringClaim("scope"); + + String requestedScopes = params.getFirst("scope"); + if (requestedScopes != null && !requestedScopes.isEmpty()) { + Set rScopes = new HashSet(Arrays.asList(requestedScopes.split(" "))); + Set aScopes = new HashSet(Arrays.asList(approvedScopes.split(" "))); + if (!aScopes.containsAll(rScopes)) { + JsonObject error = Json.createObjectBuilder() + .add("error", "Invalid_request") + .add("error_description", "Requested scopes should be a subset of the original scopes.") + .build(); + Response response = Response.status(Response.Status.BAD_REQUEST).entity(error).build(); + throw new WebApplicationException(response); + } + } else { + requestedScopes = approvedScopes; + } + + String accessToken = getAccessToken(clientId, subject, requestedScopes); + return Json.createObjectBuilder() + .add("token_type", "Bearer") + .add("access_token", accessToken) + .add("expires_in", expiresInMin * 60) + .add("scope", requestedScopes) + .add("refresh_token", refreshToken) + .build(); + } +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AppDataRepository.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AppDataRepository.java similarity index 96% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AppDataRepository.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AppDataRepository.java index 6b827d6a3d..00f506fb41 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AppDataRepository.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AppDataRepository.java @@ -1,27 +1,27 @@ -package com.baeldung.oauth2.authorization.server.model; - -import javax.enterprise.context.ApplicationScoped; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.transaction.Transactional; - -@ApplicationScoped -public class AppDataRepository { - - @PersistenceContext - private EntityManager entityManager; - - public Client getClient(String clientId) { - return entityManager.find(Client.class, clientId); - } - - public User getUser(String userId) { - return entityManager.find(User.class, userId); - } - - @Transactional - public AuthorizationCode save(AuthorizationCode authorizationCode) { - entityManager.persist(authorizationCode); - return authorizationCode; - } -} +package com.baeldung.oauth2.authorization.server.model; + +import javax.enterprise.context.ApplicationScoped; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.transaction.Transactional; + +@ApplicationScoped +public class AppDataRepository { + + @PersistenceContext + private EntityManager entityManager; + + public Client getClient(String clientId) { + return entityManager.find(Client.class, clientId); + } + + public User getUser(String userId) { + return entityManager.find(User.class, userId); + } + + @Transactional + public AuthorizationCode save(AuthorizationCode authorizationCode) { + entityManager.persist(authorizationCode); + return authorizationCode; + } +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AuthorizationCode.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AuthorizationCode.java similarity index 95% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AuthorizationCode.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AuthorizationCode.java index a2ec088eb9..c830c561a6 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AuthorizationCode.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/AuthorizationCode.java @@ -1,73 +1,73 @@ -package com.baeldung.oauth2.authorization.server.model; - -import javax.persistence.*; -import java.time.LocalDateTime; - -@Entity -@Table(name = "authorization_code") -public class AuthorizationCode { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "code") - private String code; - @Column(name = "client_id") - private String clientId; - @Column(name = "user_id") - private String userId; - @Column(name = "approved_scopes") - private String approvedScopes; - - @Column(name = "redirect_uri") - private String redirectUri; - - @Column(name = "expiration_date") - private LocalDateTime expirationDate; - - public String getUserId() { - return userId; - } - - public void setUserId(String username) { - this.userId = username; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getApprovedScopes() { - return approvedScopes; - } - - public void setApprovedScopes(String approvedScopes) { - this.approvedScopes = approvedScopes; - } - - public String getRedirectUri() { - return redirectUri; - } - - public void setRedirectUri(String redirectUri) { - this.redirectUri = redirectUri; - } - - public LocalDateTime getExpirationDate() { - return expirationDate; - } - - public void setExpirationDate(LocalDateTime expirationDate) { - this.expirationDate = expirationDate; - } -} +package com.baeldung.oauth2.authorization.server.model; + +import javax.persistence.*; +import java.time.LocalDateTime; + +@Entity +@Table(name = "authorization_code") +public class AuthorizationCode { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "code") + private String code; + @Column(name = "client_id") + private String clientId; + @Column(name = "user_id") + private String userId; + @Column(name = "approved_scopes") + private String approvedScopes; + + @Column(name = "redirect_uri") + private String redirectUri; + + @Column(name = "expiration_date") + private LocalDateTime expirationDate; + + public String getUserId() { + return userId; + } + + public void setUserId(String username) { + this.userId = username; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getApprovedScopes() { + return approvedScopes; + } + + public void setApprovedScopes(String approvedScopes) { + this.approvedScopes = approvedScopes; + } + + public String getRedirectUri() { + return redirectUri; + } + + public void setRedirectUri(String redirectUri) { + this.redirectUri = redirectUri; + } + + public LocalDateTime getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(LocalDateTime expirationDate) { + this.expirationDate = expirationDate; + } +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/Client.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/Client.java similarity index 95% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/Client.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/Client.java index 9b5ad2f904..cb9276d99d 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/Client.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/Client.java @@ -1,62 +1,62 @@ -package com.baeldung.oauth2.authorization.server.model; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "clients") -public class Client { - @Id - @Column(name = "client_id") - private String clientId; - @Column(name = "client_secret") - private String clientSecret; - @Column(name = "redirect_uri") - private String redirectUri; - @Column(name = "scope") - private String scope; - @Column(name = "authorized_grant_types") - private String authorizedGrantTypes; - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getClientSecret() { - return clientSecret; - } - - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - - public String getRedirectUri() { - return redirectUri; - } - - public void setRedirectUri(String redirectUri) { - this.redirectUri = redirectUri; - } - - public String getScope() { - return scope; - } - - public void setScope(String scope) { - this.scope = scope; - } - - public String getAuthorizedGrantTypes() { - return authorizedGrantTypes; - } - - public void setAuthorizedGrantTypes(String authorizedGrantTypes) { - this.authorizedGrantTypes = authorizedGrantTypes; - } -} +package com.baeldung.oauth2.authorization.server.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "clients") +public class Client { + @Id + @Column(name = "client_id") + private String clientId; + @Column(name = "client_secret") + private String clientSecret; + @Column(name = "redirect_uri") + private String redirectUri; + @Column(name = "scope") + private String scope; + @Column(name = "authorized_grant_types") + private String authorizedGrantTypes; + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public String getRedirectUri() { + return redirectUri; + } + + public void setRedirectUri(String redirectUri) { + this.redirectUri = redirectUri; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getAuthorizedGrantTypes() { + return authorizedGrantTypes; + } + + public void setAuthorizedGrantTypes(String authorizedGrantTypes) { + this.authorizedGrantTypes = authorizedGrantTypes; + } +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/User.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/User.java similarity index 95% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/User.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/User.java index b3821715f4..55a60b2009 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/User.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/model/User.java @@ -1,58 +1,58 @@ -package com.baeldung.oauth2.authorization.server.model; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import java.security.Principal; - -@Entity -@Table(name = "users") -public class User implements Principal { - @Id - @Column(name = "user_id") - private String userId; - @Column(name = "password") - private String password; - @Column(name = "roles") - private String roles; - @Column(name = "scopes") - private String scopes; - - public String getUserId() { - return userId; - } - - public void setUserId(String username) { - this.userId = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getRoles() { - return roles; - } - - public void setRoles(String roles) { - this.roles = roles; - } - - public String getScopes() { - return scopes; - } - - public void setScopes(String scopes) { - this.scopes = scopes; - } - - @Override - public String getName() { - return getUserId(); - } -} +package com.baeldung.oauth2.authorization.server.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.security.Principal; + +@Entity +@Table(name = "users") +public class User implements Principal { + @Id + @Column(name = "user_id") + private String userId; + @Column(name = "password") + private String password; + @Column(name = "roles") + private String roles; + @Column(name = "scopes") + private String scopes; + + public String getUserId() { + return userId; + } + + public void setUserId(String username) { + this.userId = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getRoles() { + return roles; + } + + public void setRoles(String roles) { + this.roles = roles; + } + + public String getScopes() { + return scopes; + } + + public void setScopes(String scopes) { + this.scopes = scopes; + } + + @Override + public String getName() { + return getUserId(); + } +} diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/security/UserIdentityStore.java b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/security/UserIdentityStore.java similarity index 97% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/security/UserIdentityStore.java rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/security/UserIdentityStore.java index a32ab32cd4..f1e07c7602 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/security/UserIdentityStore.java +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/java/com/baeldung/oauth2/authorization/server/security/UserIdentityStore.java @@ -1,37 +1,37 @@ -package com.baeldung.oauth2.authorization.server.security; - -import com.baeldung.oauth2.authorization.server.model.AppDataRepository; -import com.baeldung.oauth2.authorization.server.model.User; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.security.enterprise.credential.Credential; -import javax.security.enterprise.credential.UsernamePasswordCredential; -import javax.security.enterprise.identitystore.CredentialValidationResult; -import javax.security.enterprise.identitystore.IdentityStore; -import javax.transaction.Transactional; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Objects; - -import static javax.security.enterprise.identitystore.CredentialValidationResult.INVALID_RESULT; - -@ApplicationScoped -@Transactional -public class UserIdentityStore implements IdentityStore { - - @Inject - private AppDataRepository appDataRepository; - - @Override - public CredentialValidationResult validate(Credential credential) { - UsernamePasswordCredential usernamePasswordCredential = (UsernamePasswordCredential) credential; - String userId = usernamePasswordCredential.getCaller(); - User user = appDataRepository.getUser(userId); - Objects.requireNonNull(user, "User should be not null"); - if (usernamePasswordCredential.getPasswordAsString().equals(user.getPassword())) { - return new CredentialValidationResult(userId, new HashSet<>(Arrays.asList(user.getRoles().split(",")))); - } - return INVALID_RESULT; - } +package com.baeldung.oauth2.authorization.server.security; + +import com.baeldung.oauth2.authorization.server.model.AppDataRepository; +import com.baeldung.oauth2.authorization.server.model.User; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.security.enterprise.credential.Credential; +import javax.security.enterprise.credential.UsernamePasswordCredential; +import javax.security.enterprise.identitystore.CredentialValidationResult; +import javax.security.enterprise.identitystore.IdentityStore; +import javax.transaction.Transactional; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Objects; + +import static javax.security.enterprise.identitystore.CredentialValidationResult.INVALID_RESULT; + +@ApplicationScoped +@Transactional +public class UserIdentityStore implements IdentityStore { + + @Inject + private AppDataRepository appDataRepository; + + @Override + public CredentialValidationResult validate(Credential credential) { + UsernamePasswordCredential usernamePasswordCredential = (UsernamePasswordCredential) credential; + String userId = usernamePasswordCredential.getCaller(); + User user = appDataRepository.getUser(userId); + Objects.requireNonNull(user, "User should be not null"); + if (usernamePasswordCredential.getPasswordAsString().equals(user.getPassword())) { + return new CredentialValidationResult(userId, new HashSet<>(Arrays.asList(user.getRoles().split(",")))); + } + return INVALID_RESULT; + } } \ No newline at end of file diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/liberty/config/server.xml b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/liberty/config/server.xml similarity index 100% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/liberty/config/server.xml rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/liberty/config/server.xml diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/microprofile-config.properties b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/microprofile-config.properties similarity index 100% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/microprofile-config.properties rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/microprofile-config.properties diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/persistence.xml b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/persistence.xml similarity index 98% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/persistence.xml rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/persistence.xml index a10ad3c886..9d7fc96426 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/persistence.xml +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/persistence.xml @@ -1,14 +1,14 @@ - - - - jdbc/OAuth2_DS - - - - - + + + + jdbc/OAuth2_DS + + + + + \ No newline at end of file diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/private-key.pem b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/private-key.pem similarity index 100% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/private-key.pem rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/private-key.pem diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/public-key.pem b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/public-key.pem similarity index 100% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/public-key.pem rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/META-INF/public-key.pem diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/data.sql b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/data.sql similarity index 99% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/resources/data.sql rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/data.sql index ecda0fa2ad..b3342a2168 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/data.sql +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/resources/data.sql @@ -1,3 +1,3 @@ -INSERT INTO `users` (`user_id`, `password`, `roles`, `scopes`) VALUES ('appuser', 'appusersecret', 'USER', 'resource.read resource.write'); - +INSERT INTO `users` (`user_id`, `password`, `roles`, `scopes`) VALUES ('appuser', 'appusersecret', 'USER', 'resource.read resource.write'); + INSERT INTO `clients` (`client_id`, `client_secret`, `redirect_uri`,`scope`,`authorized_grant_types`) VALUES ('webappclient', 'webappclientsecret', 'http://localhost:9180/callback', 'resource.read resource.write', 'authorization_code refresh_token'); \ No newline at end of file diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/WEB-INF/beans.xml b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/WEB-INF/beans.xml rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/WEB-INF/beans.xml diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/authorize.jsp b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/authorize.jsp similarity index 96% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/authorize.jsp rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/authorize.jsp index 41b0582c03..51bad3565e 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/authorize.jsp +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/authorize.jsp @@ -1,54 +1,54 @@ -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - Authorization - - - - -
-

Want to Authorize scopes for client : ${client.clientId} ?

-
- -
- - - - - - - - - -
Scopes : - - ${scope}
-
-
- - -
-
- -
- - - +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + Authorization + + + + +
+

Want to Authorize scopes for client : ${client.clientId} ?

+
+ +
+ + + + + + + + + +
Scopes : + + ${scope}
+
+
+ + +
+
+ +
+ + + diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/error.jsp b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/error.jsp similarity index 94% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/error.jsp rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/error.jsp index edb0bf28b7..db996ea814 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/error.jsp +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/error.jsp @@ -1,25 +1,25 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> - - - - - - Error - - - - - - -
-

${error}

-
- - +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> + + + + + + Error + + + + + + +
+

${error}

+
+ + \ No newline at end of file diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/login-error.jsp b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/login-error.jsp similarity index 100% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/login-error.jsp rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/login-error.jsp diff --git a/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/login.jsp b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/login.jsp similarity index 96% rename from oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/login.jsp rename to security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/login.jsp index 1d2dd93fd0..c2caed961f 100644 --- a/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/login.jsp +++ b/security-modules/oauth2-framework-impl/oauth2-authorization-server/src/main/webapp/login.jsp @@ -1,49 +1,49 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> - - - - - Login Form - - - - -
-

Login Form

-
-
- - - - - - - - - - - - - -
Username
Password
-
- -
- - +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> + + + + + Login Form + + + + +
+

Login Form

+
+
+ + + + + + + + + + + + + +
Username
Password
+
+ +
+ + \ No newline at end of file diff --git a/oauth2-framework-impl/oauth2-client/pom.xml b/security-modules/oauth2-framework-impl/oauth2-client/pom.xml similarity index 100% rename from oauth2-framework-impl/oauth2-client/pom.xml rename to security-modules/oauth2-framework-impl/oauth2-client/pom.xml diff --git a/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AbstractServlet.java b/security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AbstractServlet.java similarity index 97% rename from oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AbstractServlet.java rename to security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AbstractServlet.java index 7059c4f7e1..6e3d958dbd 100644 --- a/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AbstractServlet.java +++ b/security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AbstractServlet.java @@ -1,23 +1,23 @@ -package com.baeldung.oauth2.client; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Base64; - -public abstract class AbstractServlet extends HttpServlet { - - protected void dispatch(String location, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - RequestDispatcher requestDispatcher = request.getRequestDispatcher(location); - requestDispatcher.forward(request, response); - } - - protected String getAuthorizationHeaderValue(String clientId, String clientSecret) { - String token = clientId + ":" + clientSecret; - String encodedString = Base64.getEncoder().encodeToString(token.getBytes()); - return "Basic " + encodedString; - } -} +package com.baeldung.oauth2.client; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Base64; + +public abstract class AbstractServlet extends HttpServlet { + + protected void dispatch(String location, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + RequestDispatcher requestDispatcher = request.getRequestDispatcher(location); + requestDispatcher.forward(request, response); + } + + protected String getAuthorizationHeaderValue(String clientId, String clientSecret) { + String token = clientId + ":" + clientSecret; + String encodedString = Base64.getEncoder().encodeToString(token.getBytes()); + return "Basic " + encodedString; + } +} diff --git a/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AuthorizationCodeServlet.java b/security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AuthorizationCodeServlet.java similarity index 97% rename from oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AuthorizationCodeServlet.java rename to security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AuthorizationCodeServlet.java index a5fdaf07f2..56a72586c8 100644 --- a/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AuthorizationCodeServlet.java +++ b/security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/AuthorizationCodeServlet.java @@ -1,39 +1,39 @@ -package com.baeldung.oauth2.client; - -import org.eclipse.microprofile.config.Config; - -import javax.inject.Inject; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.UUID; - -@WebServlet(urlPatterns = "/authorize") -public class AuthorizationCodeServlet extends HttpServlet { - - @Inject - private Config config; - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - //... - request.getSession().removeAttribute("tokenResponse"); - String state = UUID.randomUUID().toString(); - request.getSession().setAttribute("CLIENT_LOCAL_STATE", state); - - String authorizationUri = config.getValue("provider.authorizationUri", String.class); - String clientId = config.getValue("client.clientId", String.class); - String redirectUri = config.getValue("client.redirectUri", String.class); - String scope = config.getValue("client.scope", String.class); - - String authorizationLocation = authorizationUri + "?response_type=code" - + "&client_id=" + clientId - + "&redirect_uri=" + redirectUri - + "&scope=" + scope - + "&state=" + state; - response.sendRedirect(authorizationLocation); - } -} +package com.baeldung.oauth2.client; + +import org.eclipse.microprofile.config.Config; + +import javax.inject.Inject; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.UUID; + +@WebServlet(urlPatterns = "/authorize") +public class AuthorizationCodeServlet extends HttpServlet { + + @Inject + private Config config; + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + //... + request.getSession().removeAttribute("tokenResponse"); + String state = UUID.randomUUID().toString(); + request.getSession().setAttribute("CLIENT_LOCAL_STATE", state); + + String authorizationUri = config.getValue("provider.authorizationUri", String.class); + String clientId = config.getValue("client.clientId", String.class); + String redirectUri = config.getValue("client.redirectUri", String.class); + String scope = config.getValue("client.scope", String.class); + + String authorizationLocation = authorizationUri + "?response_type=code" + + "&client_id=" + clientId + + "&redirect_uri=" + redirectUri + + "&scope=" + scope + + "&state=" + state; + response.sendRedirect(authorizationLocation); + } +} diff --git a/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/CallbackServlet.java b/security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/CallbackServlet.java similarity index 97% rename from oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/CallbackServlet.java rename to security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/CallbackServlet.java index e72877076c..77f8197b9b 100644 --- a/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/CallbackServlet.java +++ b/security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/CallbackServlet.java @@ -1,67 +1,67 @@ -package com.baeldung.oauth2.client; - -import org.eclipse.microprofile.config.Config; - -import javax.inject.Inject; -import javax.json.JsonObject; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Form; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import java.io.IOException; - -@WebServlet(urlPatterns = "/callback") -public class CallbackServlet extends AbstractServlet { - - @Inject - private Config config; - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - String clientId = config.getValue("client.clientId", String.class); - String clientSecret = config.getValue("client.clientSecret", String.class); - - //Error: - String error = request.getParameter("error"); - if (error != null) { - request.setAttribute("error", error); - dispatch("/", request, response); - return; - } - String localState = (String) request.getSession().getAttribute("CLIENT_LOCAL_STATE"); - if (!localState.equals(request.getParameter("state"))) { - request.setAttribute("error", "The state attribute doesn't match !!"); - dispatch("/", request, response); - return; - } - - String code = request.getParameter("code"); - - Client client = ClientBuilder.newClient(); - WebTarget target = client.target(config.getValue("provider.tokenUri", String.class)); - - Form form = new Form(); - form.param("grant_type", "authorization_code"); - form.param("code", code); - form.param("redirect_uri", config.getValue("client.redirectUri", String.class)); - - try { - JsonObject tokenResponse = target.request(MediaType.APPLICATION_JSON_TYPE) - .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeaderValue(clientId, clientSecret)) - .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), JsonObject.class); - request.getSession().setAttribute("tokenResponse", tokenResponse); - } catch (Exception ex) { - System.out.println(ex.getMessage()); - request.setAttribute("error", ex.getMessage()); - } - dispatch("/", request, response); - } -} +package com.baeldung.oauth2.client; + +import org.eclipse.microprofile.config.Config; + +import javax.inject.Inject; +import javax.json.JsonObject; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Form; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import java.io.IOException; + +@WebServlet(urlPatterns = "/callback") +public class CallbackServlet extends AbstractServlet { + + @Inject + private Config config; + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + String clientId = config.getValue("client.clientId", String.class); + String clientSecret = config.getValue("client.clientSecret", String.class); + + //Error: + String error = request.getParameter("error"); + if (error != null) { + request.setAttribute("error", error); + dispatch("/", request, response); + return; + } + String localState = (String) request.getSession().getAttribute("CLIENT_LOCAL_STATE"); + if (!localState.equals(request.getParameter("state"))) { + request.setAttribute("error", "The state attribute doesn't match !!"); + dispatch("/", request, response); + return; + } + + String code = request.getParameter("code"); + + Client client = ClientBuilder.newClient(); + WebTarget target = client.target(config.getValue("provider.tokenUri", String.class)); + + Form form = new Form(); + form.param("grant_type", "authorization_code"); + form.param("code", code); + form.param("redirect_uri", config.getValue("client.redirectUri", String.class)); + + try { + JsonObject tokenResponse = target.request(MediaType.APPLICATION_JSON_TYPE) + .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeaderValue(clientId, clientSecret)) + .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), JsonObject.class); + request.getSession().setAttribute("tokenResponse", tokenResponse); + } catch (Exception ex) { + System.out.println(ex.getMessage()); + request.setAttribute("error", ex.getMessage()); + } + dispatch("/", request, response); + } +} diff --git a/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/DownstreamCallServlet.java b/security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/DownstreamCallServlet.java similarity index 97% rename from oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/DownstreamCallServlet.java rename to security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/DownstreamCallServlet.java index bbe850917b..c6a7f8b08b 100644 --- a/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/DownstreamCallServlet.java +++ b/security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/DownstreamCallServlet.java @@ -1,49 +1,49 @@ -package com.baeldung.oauth2.client; - -import org.eclipse.microprofile.config.Config; - -import javax.inject.Inject; -import javax.json.JsonObject; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.client.*; -import java.io.IOException; -import java.io.PrintWriter; - -@WebServlet(urlPatterns = "/downstream") -public class DownstreamCallServlet extends HttpServlet { - - @Inject - private Config config; - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException { - resp.setContentType("text/html;charset=UTF-8"); - String action = request.getParameter("action"); - Client client = ClientBuilder.newClient(); - WebTarget webTarget = client.target(config.getValue("resourceServerUri", String.class)); - WebTarget resourceWebTarget; - String response = null; - JsonObject tokenResponse = (JsonObject) request.getSession().getAttribute("tokenResponse"); - if ("read".equals(action)) { - resourceWebTarget = webTarget.path("resource/read"); - Invocation.Builder invocationBuilder = resourceWebTarget.request(); - response = invocationBuilder - .header("authorization", tokenResponse.getString("access_token")) - .get(String.class); - } else if ("write".equals(action)) { - resourceWebTarget = webTarget.path("resource/write"); - Invocation.Builder invocationBuilder = resourceWebTarget.request(); - response = invocationBuilder - .header("authorization", tokenResponse.getString("access_token")) - .post(Entity.text("body string"), String.class); - } - PrintWriter out = resp.getWriter(); - out.println(response); - out.flush(); - out.close(); - } -} +package com.baeldung.oauth2.client; + +import org.eclipse.microprofile.config.Config; + +import javax.inject.Inject; +import javax.json.JsonObject; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.client.*; +import java.io.IOException; +import java.io.PrintWriter; + +@WebServlet(urlPatterns = "/downstream") +public class DownstreamCallServlet extends HttpServlet { + + @Inject + private Config config; + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException { + resp.setContentType("text/html;charset=UTF-8"); + String action = request.getParameter("action"); + Client client = ClientBuilder.newClient(); + WebTarget webTarget = client.target(config.getValue("resourceServerUri", String.class)); + WebTarget resourceWebTarget; + String response = null; + JsonObject tokenResponse = (JsonObject) request.getSession().getAttribute("tokenResponse"); + if ("read".equals(action)) { + resourceWebTarget = webTarget.path("resource/read"); + Invocation.Builder invocationBuilder = resourceWebTarget.request(); + response = invocationBuilder + .header("authorization", tokenResponse.getString("access_token")) + .get(String.class); + } else if ("write".equals(action)) { + resourceWebTarget = webTarget.path("resource/write"); + Invocation.Builder invocationBuilder = resourceWebTarget.request(); + response = invocationBuilder + .header("authorization", tokenResponse.getString("access_token")) + .post(Entity.text("body string"), String.class); + } + PrintWriter out = resp.getWriter(); + out.println(response); + out.flush(); + out.close(); + } +} diff --git a/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/RefreshTokenServlet.java b/security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/RefreshTokenServlet.java similarity index 97% rename from oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/RefreshTokenServlet.java rename to security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/RefreshTokenServlet.java index a519a53070..af01beaa28 100644 --- a/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/RefreshTokenServlet.java +++ b/security-modules/oauth2-framework-impl/oauth2-client/src/main/java/com/baeldung/oauth2/client/RefreshTokenServlet.java @@ -1,57 +1,57 @@ -package com.baeldung.oauth2.client; - -import org.eclipse.microprofile.config.Config; - -import javax.inject.Inject; -import javax.json.JsonObject; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Form; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.IOException; - -@WebServlet(urlPatterns = "/refreshtoken") -public class RefreshTokenServlet extends AbstractServlet { - - @Inject - private Config config; - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - String clientId = config.getValue("client.clientId", String.class); - String clientSecret = config.getValue("client.clientSecret", String.class); - - JsonObject actualTokenResponse = (JsonObject) request.getSession().getAttribute("tokenResponse"); - Client client = ClientBuilder.newClient(); - WebTarget target = client.target(config.getValue("provider.tokenUri", String.class)); - - Form form = new Form(); - form.param("grant_type", "refresh_token"); - form.param("refresh_token", actualTokenResponse.getString("refresh_token")); - - String scope = request.getParameter("scope"); - if (scope != null && !scope.isEmpty()) { - form.param("scope", scope); - } - - Response jaxrsResponse = target.request(MediaType.APPLICATION_JSON_TYPE) - .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeaderValue(clientId, clientSecret)) - .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), Response.class); - JsonObject tokenResponse = jaxrsResponse.readEntity(JsonObject.class); - if (jaxrsResponse.getStatus() == 200) { - request.getSession().setAttribute("tokenResponse", tokenResponse); - } else { - request.setAttribute("error", tokenResponse.getString("error_description", "error!")); - } - dispatch("/", request, response); - } -} +package com.baeldung.oauth2.client; + +import org.eclipse.microprofile.config.Config; + +import javax.inject.Inject; +import javax.json.JsonObject; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Form; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.IOException; + +@WebServlet(urlPatterns = "/refreshtoken") +public class RefreshTokenServlet extends AbstractServlet { + + @Inject + private Config config; + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + String clientId = config.getValue("client.clientId", String.class); + String clientSecret = config.getValue("client.clientSecret", String.class); + + JsonObject actualTokenResponse = (JsonObject) request.getSession().getAttribute("tokenResponse"); + Client client = ClientBuilder.newClient(); + WebTarget target = client.target(config.getValue("provider.tokenUri", String.class)); + + Form form = new Form(); + form.param("grant_type", "refresh_token"); + form.param("refresh_token", actualTokenResponse.getString("refresh_token")); + + String scope = request.getParameter("scope"); + if (scope != null && !scope.isEmpty()) { + form.param("scope", scope); + } + + Response jaxrsResponse = target.request(MediaType.APPLICATION_JSON_TYPE) + .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeaderValue(clientId, clientSecret)) + .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), Response.class); + JsonObject tokenResponse = jaxrsResponse.readEntity(JsonObject.class); + if (jaxrsResponse.getStatus() == 200) { + request.getSession().setAttribute("tokenResponse", tokenResponse); + } else { + request.setAttribute("error", tokenResponse.getString("error_description", "error!")); + } + dispatch("/", request, response); + } +} diff --git a/oauth2-framework-impl/oauth2-client/src/main/liberty/config/server.xml b/security-modules/oauth2-framework-impl/oauth2-client/src/main/liberty/config/server.xml similarity index 100% rename from oauth2-framework-impl/oauth2-client/src/main/liberty/config/server.xml rename to security-modules/oauth2-framework-impl/oauth2-client/src/main/liberty/config/server.xml diff --git a/oauth2-framework-impl/oauth2-client/src/main/resources/META-INF/microprofile-config.properties b/security-modules/oauth2-framework-impl/oauth2-client/src/main/resources/META-INF/microprofile-config.properties similarity index 100% rename from oauth2-framework-impl/oauth2-client/src/main/resources/META-INF/microprofile-config.properties rename to security-modules/oauth2-framework-impl/oauth2-client/src/main/resources/META-INF/microprofile-config.properties diff --git a/oauth2-framework-impl/oauth2-client/src/main/webapp/WEB-INF/beans.xml b/security-modules/oauth2-framework-impl/oauth2-client/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from oauth2-framework-impl/oauth2-client/src/main/webapp/WEB-INF/beans.xml rename to security-modules/oauth2-framework-impl/oauth2-client/src/main/webapp/WEB-INF/beans.xml diff --git a/oauth2-framework-impl/oauth2-client/src/main/webapp/WEB-INF/web.xml b/security-modules/oauth2-framework-impl/oauth2-client/src/main/webapp/WEB-INF/web.xml similarity index 97% rename from oauth2-framework-impl/oauth2-client/src/main/webapp/WEB-INF/web.xml rename to security-modules/oauth2-framework-impl/oauth2-client/src/main/webapp/WEB-INF/web.xml index 0203894c1b..c9e4658ab4 100644 --- a/oauth2-framework-impl/oauth2-client/src/main/webapp/WEB-INF/web.xml +++ b/security-modules/oauth2-framework-impl/oauth2-client/src/main/webapp/WEB-INF/web.xml @@ -1,5 +1,5 @@ - - - index.jsp - + + + index.jsp + \ No newline at end of file diff --git a/oauth2-framework-impl/oauth2-client/src/main/webapp/index.jsp b/security-modules/oauth2-framework-impl/oauth2-client/src/main/webapp/index.jsp similarity index 100% rename from oauth2-framework-impl/oauth2-client/src/main/webapp/index.jsp rename to security-modules/oauth2-framework-impl/oauth2-client/src/main/webapp/index.jsp diff --git a/oauth2-framework-impl/oauth2-resource-server/pom.xml b/security-modules/oauth2-framework-impl/oauth2-resource-server/pom.xml similarity index 97% rename from oauth2-framework-impl/oauth2-resource-server/pom.xml rename to security-modules/oauth2-framework-impl/oauth2-resource-server/pom.xml index d3af2cfd80..d9146c7522 100644 --- a/oauth2-framework-impl/oauth2-resource-server/pom.xml +++ b/security-modules/oauth2-framework-impl/oauth2-resource-server/pom.xml @@ -1,42 +1,42 @@ - - - 4.0.0 - oauth2-resource-server - oauth2-resource-server - war - - - com.baeldung.oauth2 - oauth2-framework-impl - 1.0-SNAPSHOT - - - - - org.eclipse.microprofile.jwt - microprofile-jwt-auth-api - ${microprofile-jwt-auth-api.version} - provided - - - - - - - net.wasdev.wlp.maven.plugins - liberty-maven-plugin - - - - - - 9280 - 8643 - http://localhost:9080 - http://localhost:9280 - 1.1 - - + + + 4.0.0 + oauth2-resource-server + oauth2-resource-server + war + + + com.baeldung.oauth2 + oauth2-framework-impl + 1.0-SNAPSHOT + + + + + org.eclipse.microprofile.jwt + microprofile-jwt-auth-api + ${microprofile-jwt-auth-api.version} + provided + + + + + + + net.wasdev.wlp.maven.plugins + liberty-maven-plugin + + + + + + 9280 + 8643 + http://localhost:9080 + http://localhost:9280 + 1.1 + + \ No newline at end of file diff --git a/oauth2-framework-impl/oauth2-resource-server/src/main/java/com/baeldung/oauth2/resource/server/OAuth2ResourceServerApplication.java b/security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/java/com/baeldung/oauth2/resource/server/OAuth2ResourceServerApplication.java similarity index 100% rename from oauth2-framework-impl/oauth2-resource-server/src/main/java/com/baeldung/oauth2/resource/server/OAuth2ResourceServerApplication.java rename to security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/java/com/baeldung/oauth2/resource/server/OAuth2ResourceServerApplication.java diff --git a/oauth2-framework-impl/oauth2-resource-server/src/main/java/com/baeldung/oauth2/resource/server/secure/ProtectedResource.java b/security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/java/com/baeldung/oauth2/resource/server/secure/ProtectedResource.java similarity index 100% rename from oauth2-framework-impl/oauth2-resource-server/src/main/java/com/baeldung/oauth2/resource/server/secure/ProtectedResource.java rename to security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/java/com/baeldung/oauth2/resource/server/secure/ProtectedResource.java diff --git a/oauth2-framework-impl/oauth2-resource-server/src/main/liberty/config/server.xml b/security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/liberty/config/server.xml similarity index 100% rename from oauth2-framework-impl/oauth2-resource-server/src/main/liberty/config/server.xml rename to security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/liberty/config/server.xml diff --git a/oauth2-framework-impl/oauth2-resource-server/src/main/resources/META-INF/microprofile-config.properties b/security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/resources/META-INF/microprofile-config.properties similarity index 99% rename from oauth2-framework-impl/oauth2-resource-server/src/main/resources/META-INF/microprofile-config.properties rename to security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/resources/META-INF/microprofile-config.properties index be6919ec50..b6811fa8a3 100644 --- a/oauth2-framework-impl/oauth2-resource-server/src/main/resources/META-INF/microprofile-config.properties +++ b/security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/resources/META-INF/microprofile-config.properties @@ -1,2 +1,2 @@ -mp.jwt.verify.publickey.location=/META-INF/public-key.pem +mp.jwt.verify.publickey.location=/META-INF/public-key.pem mp.jwt.verify.issuer=http://localhost:9080 \ No newline at end of file diff --git a/oauth2-framework-impl/oauth2-resource-server/src/main/resources/META-INF/public-key.pem b/security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/resources/META-INF/public-key.pem similarity index 100% rename from oauth2-framework-impl/oauth2-resource-server/src/main/resources/META-INF/public-key.pem rename to security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/resources/META-INF/public-key.pem diff --git a/oauth2-framework-impl/oauth2-resource-server/src/main/webapp/WEB-INF/beans.xml b/security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from oauth2-framework-impl/oauth2-resource-server/src/main/webapp/WEB-INF/beans.xml rename to security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/webapp/WEB-INF/beans.xml diff --git a/oauth2-framework-impl/oauth2-resource-server/src/main/webapp/index.html b/security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/webapp/index.html similarity index 100% rename from oauth2-framework-impl/oauth2-resource-server/src/main/webapp/index.html rename to security-modules/oauth2-framework-impl/oauth2-resource-server/src/main/webapp/index.html diff --git a/oauth2-framework-impl/pom.xml b/security-modules/oauth2-framework-impl/pom.xml similarity index 96% rename from oauth2-framework-impl/pom.xml rename to security-modules/oauth2-framework-impl/pom.xml index 5cfcb22fab..78567c14fd 100644 --- a/oauth2-framework-impl/pom.xml +++ b/security-modules/oauth2-framework-impl/pom.xml @@ -9,6 +9,12 @@ oauth2-framework-impl pom + + com.baeldung + security-modules + 1.0.0-SNAPSHOT + + oauth2-authorization-server oauth2-resource-server diff --git a/security-modules/pom.xml b/security-modules/pom.xml new file mode 100644 index 0000000000..480ee0819e --- /dev/null +++ b/security-modules/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + security-modules + security-modules + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + apache-shiro + cas + cloud-foundry-uaa + + jee-7-security + jjwt + oauth2-framework-impl + sql-injection-samples + + + \ No newline at end of file diff --git a/software-security/sql-injection-samples/.gitignore b/security-modules/sql-injection-samples/.gitignore similarity index 100% rename from software-security/sql-injection-samples/.gitignore rename to security-modules/sql-injection-samples/.gitignore diff --git a/software-security/sql-injection-samples/README.md b/security-modules/sql-injection-samples/README.md similarity index 100% rename from software-security/sql-injection-samples/README.md rename to security-modules/sql-injection-samples/README.md diff --git a/software-security/sql-injection-samples/pom.xml b/security-modules/sql-injection-samples/pom.xml similarity index 100% rename from software-security/sql-injection-samples/pom.xml rename to security-modules/sql-injection-samples/pom.xml diff --git a/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/Account.java b/security-modules/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/Account.java similarity index 100% rename from software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/Account.java rename to security-modules/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/Account.java diff --git a/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDAO.java b/security-modules/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDAO.java similarity index 100% rename from software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDAO.java rename to security-modules/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDAO.java diff --git a/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDTO.java b/security-modules/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDTO.java similarity index 100% rename from software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDTO.java rename to security-modules/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDTO.java diff --git a/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplication.java b/security-modules/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplication.java similarity index 100% rename from software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplication.java rename to security-modules/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplication.java diff --git a/software-security/sql-injection-samples/src/main/resources/application.properties b/security-modules/sql-injection-samples/src/main/resources/application.properties similarity index 100% rename from software-security/sql-injection-samples/src/main/resources/application.properties rename to security-modules/sql-injection-samples/src/main/resources/application.properties diff --git a/javax-servlets-2/src/main/resources/logback.xml b/security-modules/sql-injection-samples/src/main/resources/logback.xml similarity index 100% rename from javax-servlets-2/src/main/resources/logback.xml rename to security-modules/sql-injection-samples/src/main/resources/logback.xml diff --git a/software-security/sql-injection-samples/src/test/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplicationUnitTest.java b/security-modules/sql-injection-samples/src/test/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplicationUnitTest.java similarity index 100% rename from software-security/sql-injection-samples/src/test/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplicationUnitTest.java rename to security-modules/sql-injection-samples/src/test/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplicationUnitTest.java diff --git a/software-security/sql-injection-samples/src/test/resources/application-test.yml b/security-modules/sql-injection-samples/src/test/resources/application-test.yml similarity index 100% rename from software-security/sql-injection-samples/src/test/resources/application-test.yml rename to security-modules/sql-injection-samples/src/test/resources/application-test.yml diff --git a/software-security/sql-injection-samples/src/test/resources/data.sql b/security-modules/sql-injection-samples/src/test/resources/data.sql similarity index 100% rename from software-security/sql-injection-samples/src/test/resources/data.sql rename to security-modules/sql-injection-samples/src/test/resources/data.sql diff --git a/software-security/sql-injection-samples/src/test/resources/logback-test.xml b/security-modules/sql-injection-samples/src/test/resources/logback-test.xml similarity index 100% rename from software-security/sql-injection-samples/src/test/resources/logback-test.xml rename to security-modules/sql-injection-samples/src/test/resources/logback-test.xml diff --git a/software-security/sql-injection-samples/src/test/resources/schema.sql b/security-modules/sql-injection-samples/src/test/resources/schema.sql similarity index 100% rename from software-security/sql-injection-samples/src/test/resources/schema.sql rename to security-modules/sql-injection-samples/src/test/resources/schema.sql diff --git a/spring-batch-2/src/main/resources/schema-all.sql b/spring-batch-2/src/main/resources/schema-all.sql index 9f698f7d81..c17b9f9749 100644 --- a/spring-batch-2/src/main/resources/schema-all.sql +++ b/spring-batch-2/src/main/resources/schema-all.sql @@ -1,7 +1,7 @@ DROP TABLE coffee IF EXISTS; CREATE TABLE coffee ( - coffee_id BIGINT IDENTITY NOT NULL PRIMARY KEY, + coffee_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, brand VARCHAR(20), origin VARCHAR(20), characteristics VARCHAR(30) diff --git a/spring-boot-modules/spring-boot-3/pom.xml b/spring-boot-modules/spring-boot-3/pom.xml index 556168e205..5b1256551c 100644 --- a/spring-boot-modules/spring-boot-3/pom.xml +++ b/spring-boot-modules/spring-boot-3/pom.xml @@ -8,9 +8,9 @@ 0.0.1-SNAPSHOT ../../parent-boot-3
- spring-boot-3-sample + spring-boot-3 0.0.1-SNAPSHOT - spring-boot-3-sample + spring-boot-3 Demo project for Spring Boot diff --git a/spring-boot-modules/spring-boot-data-2/pom.xml b/spring-boot-modules/spring-boot-data-2/pom.xml index cd03d1b9b1..9aaab02925 100644 --- a/spring-boot-modules/spring-boot-data-2/pom.xml +++ b/spring-boot-modules/spring-boot-data-2/pom.xml @@ -41,7 +41,7 @@ - 6.5.3 + 6.6.5 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/annotation/scanner/AnnotationScannerApp.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/annotation/scanner/AnnotationScannerApp.java new file mode 100644 index 0000000000..b215090447 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/annotation/scanner/AnnotationScannerApp.java @@ -0,0 +1,16 @@ +package com.baeldung.annotation.scanner; + +import org.jobrunr.autoconfigure.JobRunrAutoConfiguration; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@EnableAutoConfiguration(exclude = { JobRunrAutoConfiguration.class}) +public class AnnotationScannerApp { + + public static void main(String[] args) { + SpringApplication.run(AnnotationScannerApp.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/JobRunrSpringBootApp.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/JobRunrSpringBootApp.java similarity index 96% rename from spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/JobRunrSpringBootApp.java rename to spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/JobRunrSpringBootApp.java index 3821332132..932ceb249a 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/JobRunrSpringBootApp.java +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/JobRunrSpringBootApp.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.jobrunr; import com.baeldung.jobrunr.service.SampleJobService; import org.jobrunr.scheduling.JobScheduler; diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/config/StorageProviderConfig.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/config/StorageProviderConfig.java similarity index 93% rename from spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/config/StorageProviderConfig.java rename to spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/config/StorageProviderConfig.java index e4b8cf12d7..631ba1834c 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/config/StorageProviderConfig.java +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/config/StorageProviderConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.jobrunr.config; import org.jobrunr.jobs.mappers.JobMapper; import org.jobrunr.storage.InMemoryStorageProvider; diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/OpenApiApplication.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/OpenApiApplication.java new file mode 100644 index 0000000000..3fd8dbd6c5 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/OpenApiApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.openapi; + +import org.jobrunr.autoconfigure.JobRunrAutoConfiguration; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@EnableAutoConfiguration(exclude = { JobRunrAutoConfiguration.class}) +public class OpenApiApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiApplication.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/sprq/SpqrApp.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/sprq/SpqrApp.java new file mode 100644 index 0000000000..ec471aa8eb --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/sprq/SpqrApp.java @@ -0,0 +1,16 @@ +package com.baeldung.sprq; + +import org.jobrunr.autoconfigure.JobRunrAutoConfiguration; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@EnableAutoConfiguration(exclude = { JobRunrAutoConfiguration.class}) +public class SpqrApp { + + public static void main(String[] args) { + SpringApplication.run(SpqrApp.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/annotation/scanner/SampleAnnotationScannerUnitTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/annotation/scanner/SampleAnnotationScannerUnitTest.java index 7c3d01b5e8..c69821d0c0 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/annotation/scanner/SampleAnnotationScannerUnitTest.java +++ b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/annotation/scanner/SampleAnnotationScannerUnitTest.java @@ -13,7 +13,7 @@ import org.springframework.test.context.junit4.SpringRunner; import static org.junit.Assert.*; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(classes = AnnotationScannerApp.class) public class SampleAnnotationScannerUnitTest { @Autowired private List scannerList; diff --git a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/jobrunr/JobRunrLiveTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/jobrunr/JobRunrLiveTest.java index 2c259b6879..b00d1c472f 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/jobrunr/JobRunrLiveTest.java +++ b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/jobrunr/JobRunrLiveTest.java @@ -1,6 +1,5 @@ package com.baeldung.jobrunr; -import org.awaitility.Awaitility; import org.jobrunr.jobs.states.StateName; import org.jobrunr.storage.StorageProvider; import org.junit.Test; @@ -10,8 +9,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.JobRunrSpringBootApp; - import java.net.URI; import java.util.concurrent.TimeUnit; diff --git a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/openapi/OpenApiPetsIntegrationTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/openapi/OpenApiPetsIntegrationTest.java index b56c19d94c..e56ff445d7 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/openapi/OpenApiPetsIntegrationTest.java +++ b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/openapi/OpenApiPetsIntegrationTest.java @@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(classes = OpenApiApplication.class) @AutoConfigureMockMvc public class OpenApiPetsIntegrationTest { diff --git a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/sprq/GraphqlControllerIntegrationTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/sprq/GraphqlControllerIntegrationTest.java index b1054f09f8..ec28b98ac7 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/sprq/GraphqlControllerIntegrationTest.java +++ b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/sprq/GraphqlControllerIntegrationTest.java @@ -16,7 +16,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(classes = SpqrApp.class) @AutoConfigureMockMvc public class GraphqlControllerIntegrationTest { diff --git a/spring-boot-modules/spring-boot-logging-log4j2/pom.xml b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml index 036df19887..c5a9d2f38d 100644 --- a/spring-boot-modules/spring-boot-logging-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml @@ -98,7 +98,7 @@ com.baeldung.springbootlogging.SpringBootLoggingApplication 1.3.8.RELEASE 1.1.16 - 1.18.4 + 1.18.24 4.13.2 5.8.1 diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml index 41baf3bb82..378864a1df 100644 --- a/spring-boot-modules/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -122,7 +122,7 @@ - 2021.0.0 + 2021.0.3 1.10 @ diff --git a/spring-boot-modules/spring-boot-runtime/pom.xml b/spring-boot-modules/spring-boot-runtime/pom.xml index 04c8ddc525..7b2ed6976b 100644 --- a/spring-boot-modules/spring-boot-runtime/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/pom.xml @@ -71,7 +71,6 @@ javax.persistence javax.persistence-api - ${jpa.version} com.google.guava @@ -87,15 +86,12 @@ org.apache.httpcomponents httpclient - ${httpclient.version} - 2.2 3.1.7 - 3.1.0 - 4.5.8 + 3.1.3 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger-2/README.md b/spring-boot-modules/spring-boot-swagger-2/README.md new file mode 100644 index 0000000000..e607b56299 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Swagger: Specify Two Responses with the Same Response Code](https://www.baeldung.com/swagger-two-responses-one-response-code) diff --git a/spring-boot-modules/spring-boot-swagger-2/pom.xml b/spring-boot-modules/spring-boot-swagger-2/pom.xml new file mode 100644 index 0000000000..44555b9e43 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + spring-boot-swagger-2 + 0.1.0-SNAPSHOT + spring-boot-swagger-2 + jar + Module For Spring Boot Swagger + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + + + + 3.0.0 + 3.0.34 + 1.6.10 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springdoc + springdoc-openapi-ui + ${springdoc.version} + + + io.springfox + springfox-oas + ${springfox.version} + + + io.springfox + springfox-swagger-ui + ${springfox.version} + + + javax.validation + validation-api + + + + + + + io.swagger.codegen.v3 + swagger-codegen-maven-plugin + ${swagger-codegen-maven-plugin.version} + + + + generate + + + ${project.basedir}/src/main/resources/static/api_3.yaml + spring + + true + true + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/tworesponses/Application.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/tworesponses/Application.java new file mode 100644 index 0000000000..0932e42747 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/tworesponses/Application.java @@ -0,0 +1,13 @@ +package com.baeldung.tworesponses; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String args[]) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/tworesponses/Config.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/tworesponses/Config.java new file mode 100644 index 0000000000..9238a16698 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/tworesponses/Config.java @@ -0,0 +1,27 @@ +package com.baeldung.tworesponses; + +import org.springdoc.core.SpringDocConfigProperties; +import org.springdoc.core.SpringDocConfiguration; +import org.springdoc.core.providers.ObjectMapperProvider; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class Config { + + @Bean + SpringDocConfiguration springDocConfiguration() { + return new SpringDocConfiguration(); + } + + @Bean + SpringDocConfigProperties springDocConfigProperties() { + return new SpringDocConfigProperties(); + } + + @Bean + ObjectMapperProvider objectMapperProvider(SpringDocConfigProperties springDocConfigProperties) { + return new ObjectMapperProvider(springDocConfigProperties); + } + +} diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/resources/application.properties b/spring-boot-modules/spring-boot-swagger-2/src/main/resources/application.properties new file mode 100644 index 0000000000..03302ebb1c --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/resources/application.properties @@ -0,0 +1,2 @@ +springdoc.api-docs.enabled=false +springdoc.swagger-ui.url=/api_3.yaml diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/resources/static/api_2.yaml b/spring-boot-modules/spring-boot-swagger-2/src/main/resources/static/api_2.yaml new file mode 100644 index 0000000000..c9f7f25d44 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/resources/static/api_2.yaml @@ -0,0 +1,45 @@ +swagger: 2.0.0 +info: + title: Demo api + description: Demo api for the article 'specify two responses with same code based on optional parameter' + version: 0.1.0 +paths: + /vehicle: + get: + responses: + '200': + description: Get a vehicle. Can contain either a Car or a Bike + schema: + $ref: '#/definitions/CarOrBike' + examples: + application/json: + owner: baeldung + plate: AEX305 + speed: +definitions: + Car: + type: object + properties: + owner: + type: string + plate: + type: string + Bike: + type: object + properties: + owner: + type: string + speed: + type: integer + CarOrBike: + description: a car will have an owner and a plate, whereas a bike has an owner and a speed + type: object + required: + - owner + properties: + owner: + type: string + plate: + type: string + speed: + type: integer diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/resources/static/api_3.yaml b/spring-boot-modules/spring-boot-swagger-2/src/main/resources/static/api_3.yaml new file mode 100644 index 0000000000..12de1be39a --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/resources/static/api_3.yaml @@ -0,0 +1,44 @@ +openapi: 3.0.0 +info: + title: Demo api + description: Demo api for the article 'specify two responses with same code based on optional parameter' + version: 0.1.0 +paths: + /vehicle: + get: + responses: + '200': + description: Get a vehicle + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/Car' + - $ref: '#/components/schemas/Bike' + examples: + car: + summary: an example of car + value: + owner: baeldung + plate: AEX305 + bike: + summary: an example of bike + value: + owner: john doe + speed: 25 +components: + schemas: + Car: + type: object + properties: + owner: + type: string + plate: + type: string + Bike: + type: object + properties: + owner: + type: string + speed: + type: integer diff --git a/spring-boot-modules/spring-boot-swagger/README.md b/spring-boot-modules/spring-boot-swagger/README.md index a09df23a80..c3f6578dee 100644 --- a/spring-boot-modules/spring-boot-swagger/README.md +++ b/spring-boot-modules/spring-boot-swagger/README.md @@ -6,3 +6,4 @@ - [Remove Basic Error Controller In SpringFox Swagger-UI](https://www.baeldung.com/spring-swagger-remove-error-controller) - [Setting Example and Description with Swagger](https://www.baeldung.com/swagger-set-example-description) - [Document Enum in Swagger](https://www.baeldung.com/swagger-enum) +- [@ApiOperation vs @ApiResponse in Swagger](https://www.baeldung.com/swagger-apioperation-vs-apiresponse) diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/SwaggerDemoApplication.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/SwaggerDemoApplication.java new file mode 100644 index 0000000000..8dec139917 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/SwaggerDemoApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.swaggerresponses; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SwaggerDemoApplication { + + public static void main(String[] args) { + SpringApplication.run(SwaggerDemoApplication.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/config/SwaggerConfiguration.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/config/SwaggerConfiguration.java new file mode 100644 index 0000000000..5a4d237d97 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/config/SwaggerConfiguration.java @@ -0,0 +1,23 @@ +package com.baeldung.swaggerresponses.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + +@Configuration +public class SwaggerConfiguration { + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2).select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); + } + +} + diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/controller/CustomerController.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/controller/CustomerController.java new file mode 100644 index 0000000000..0811af56ec --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/controller/CustomerController.java @@ -0,0 +1,38 @@ +package com.baeldung.swaggerresponses.controller; + +import com.baeldung.swaggerresponses.response.CustomerResponse; +import com.baeldung.swaggerresponses.response.ErrorResponse; +import com.baeldung.swaggerresponses.service.CustomerService; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Api("Customer Controller") +@RestController +@RequestMapping("/customers") +public class CustomerController { + + private final CustomerService customerService; + + public CustomerController(CustomerService customerService) { + this.customerService = customerService; + } + + @ApiOperation(value = "Gets customer by ID", response = CustomerResponse.class, notes = "Customer must exist") + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied"), + @ApiResponse(code = 404, message = "Customer not found"), + @ApiResponse(code = 500, message = "Internal server error", response = ErrorResponse.class) }) + @GetMapping("/{id}") + public ResponseEntity getCustomer(@PathVariable("id") Long id) { + return ResponseEntity.ok(customerService.getById(id)); + } +} diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/response/CustomerResponse.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/response/CustomerResponse.java new file mode 100644 index 0000000000..9ec96dd4ac --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/response/CustomerResponse.java @@ -0,0 +1,27 @@ +package com.baeldung.swaggerresponses.response; + +public class CustomerResponse { + + private final Long id; + private final String firstName; + private final String lastName; + + public CustomerResponse(Long id, String firstName, String lastName) { + this.id = id; + this.firstName = firstName; + this.lastName = lastName; + } + + public Long getId() { + return id; + } + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + +} diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/response/ErrorResponse.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/response/ErrorResponse.java new file mode 100644 index 0000000000..7779712e6f --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/response/ErrorResponse.java @@ -0,0 +1,23 @@ +package com.baeldung.swaggerresponses.response; + +public class ErrorResponse { + + private String error; + private String message; + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/service/CustomerService.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/service/CustomerService.java new file mode 100644 index 0000000000..92ba1037d3 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/service/CustomerService.java @@ -0,0 +1,8 @@ +package com.baeldung.swaggerresponses.service; + +import com.baeldung.swaggerresponses.response.CustomerResponse; + +public interface CustomerService { + + CustomerResponse getById(Long id); +} diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/service/DefaultCustomerService.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/service/DefaultCustomerService.java new file mode 100644 index 0000000000..ecced541ae --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swaggerresponses/service/DefaultCustomerService.java @@ -0,0 +1,13 @@ +package com.baeldung.swaggerresponses.service; + +import com.baeldung.swaggerresponses.response.CustomerResponse; + +import org.springframework.stereotype.Service; + +@Service +public class DefaultCustomerService implements CustomerService { + @Override + public CustomerResponse getById(Long id) { + return new CustomerResponse(1L, "Jane", "Doe"); + } +} diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java index b4748bcd38..c265d99c9b 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java @@ -14,6 +14,9 @@ public class TestRedisConfiguration { public TestRedisConfiguration(final RedisProperties redisProperties) { this.redisServer = new RedisServer(redisProperties.getRedisPort()); + //Uncomment below if running on windows and can't start redis server +// this.redisServer = RedisServer.builder().setting("maxheap 200m").port(6379).setting("bind localhost").build(); +// redisServer.start(); } @PostConstruct diff --git a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java index 8887510eca..78c826d6cd 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java +++ b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -77,7 +77,7 @@ public class PersistenceConfig { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); return hibernateProperties; } diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java index 3e21af524f..9ef8942634 100644 --- a/spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java @@ -59,8 +59,7 @@ public class ErrorHandlingLiveTest { webClient.getOptions() .setThrowExceptionOnFailingStatusCode(false); HtmlPage page = webClient.getPage(EXCEPTION_ENDPOINT); - assertThat(page.getBody() - .asText()).contains("Whitelabel Error Page"); + assertThat(page.getBody().asNormalizedText()).contains("Whitelabel Error Page"); } } } diff --git a/spring-cloud-modules/pom.xml b/spring-cloud-modules/pom.xml index 6d44cb015b..43ccfd5501 100644 --- a/spring-cloud-modules/pom.xml +++ b/spring-cloud-modules/pom.xml @@ -85,7 +85,7 @@ - 2021.0.0 + 2021.0.3 2.2.3.RELEASE 2.2.3.RELEASE 1.4.7.RELEASE @@ -94,4 +94,4 @@ 3.1.3 - \ No newline at end of file + diff --git a/spring-cloud-modules/spring-cloud-bus/pom.xml b/spring-cloud-modules/spring-cloud-bus/pom.xml index 4caba15ca9..4be1a60062 100644 --- a/spring-cloud-modules/spring-cloud-bus/pom.xml +++ b/spring-cloud-modules/spring-cloud-bus/pom.xml @@ -33,7 +33,7 @@ - 2021.0.0 + 2021.0.3 - \ No newline at end of file + diff --git a/spring-cloud-modules/spring-cloud-config/pom.xml b/spring-cloud-modules/spring-cloud-config/pom.xml index 09be8ae1b8..fc9a989844 100644 --- a/spring-cloud-modules/spring-cloud-config/pom.xml +++ b/spring-cloud-modules/spring-cloud-config/pom.xml @@ -33,7 +33,7 @@ - 2021.0.0 + 2021.0.3 - \ No newline at end of file + diff --git a/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml b/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml index 8af035e1db..4da6ac408b 100644 --- a/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml +++ b/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml @@ -32,6 +32,7 @@ org.springframework.cloud spring-cloud-starter-kubernetes-config + ${spring.cloud.k8s.config.version} org.springframework.boot @@ -54,6 +55,7 @@ org.springframework.cloud spring-cloud-starter-kubernetes-ribbon + ${spring.cloud.k8s.config.version} org.springframework.cloud @@ -83,7 +85,8 @@ - 1.1.8.RELEASE + 2.1.3 + 1.1.10.RELEASE - \ No newline at end of file + diff --git a/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/src/main/java/com/baeldung/spring/cloud/kubernetes/client/Application.java b/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/src/main/java/com/baeldung/spring/cloud/kubernetes/client/Application.java index 24e562c79b..b31e6232ac 100644 --- a/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/src/main/java/com/baeldung/spring/cloud/kubernetes/client/Application.java +++ b/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/src/main/java/com/baeldung/spring/cloud/kubernetes/client/Application.java @@ -3,11 +3,8 @@ package com.baeldung.spring.cloud.kubernetes.client; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; -import org.springframework.cloud.client.loadbalancer.LoadBalanced; -import org.springframework.cloud.netflix.ribbon.RibbonClient; -import org.springframework.context.annotation.Bean; -import org.springframework.web.client.RestTemplate; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.netflix.ribbon.RibbonClient; @SpringBootApplication @EnableDiscoveryClient @@ -15,12 +12,6 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @RibbonClient(name = "travel-agency-service", configuration = RibbonConfiguration.class) public class Application { - @LoadBalanced - @Bean - RestTemplate restTemplate() { - return new RestTemplate(); - } - public static void main(String[] args) { SpringApplication.run(Application.class, args); } diff --git a/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/src/main/resources/application.yaml b/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/src/main/resources/application.yaml index f966fdd7a5..aad4568e87 100644 --- a/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/src/main/resources/application.yaml +++ b/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/client-service/src/main/resources/application.yaml @@ -1,6 +1,15 @@ spring: application.name: client-service - cloud.kubernetes.reload.enabled: true + cloud: + kubernetes: + reload: + enabled: true + discovery: + enabled: true + all-namespaces: false + primary-port-name: "default-http" + discovery-server-url: "http://myapp-discoveryserver" + include-not-ready-addresses: true server.port: 8080 management: endpoint: diff --git a/spring-cloud-modules/spring-cloud-kubernetes/pom.xml b/spring-cloud-modules/spring-cloud-kubernetes/pom.xml index be555d01e9..cffdabd92b 100644 --- a/spring-cloud-modules/spring-cloud-kubernetes/pom.xml +++ b/spring-cloud-modules/spring-cloud-kubernetes/pom.xml @@ -33,7 +33,7 @@ - 2021.0.0 + 2021.0.3 \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-openfeign/README.md b/spring-cloud-modules/spring-cloud-openfeign/README.md index a369da96da..421fa0284f 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/README.md +++ b/spring-cloud-modules/spring-cloud-openfeign/README.md @@ -7,3 +7,4 @@ - [Provide an OAuth2 Token to a Feign Client](https://www.baeldung.com/spring-cloud-feign-oauth-token) - [Retrieve Original Message From Feign ErrorDecoder](https://www.baeldung.com/feign-retrieve-original-message) - [RequestLine with Feign Client](https://www.baeldung.com/feign-requestline) +- [Propagating Exceptions With OpenFeign and Spring](https://www.baeldung.com/spring-openfeign-propagate-exception) diff --git a/spring-cloud-modules/spring-cloud-openfeign/pom.xml b/spring-cloud-modules/spring-cloud-openfeign/pom.xml index 5657577cb0..a6a24c376e 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/pom.xml +++ b/spring-cloud-modules/spring-cloud-openfeign/pom.xml @@ -64,7 +64,7 @@ - 2021.0.0 + 2021.0.3 - \ No newline at end of file + diff --git a/spring-cloud-modules/spring-cloud-ribbon-client/pom.xml b/spring-cloud-modules/spring-cloud-ribbon-client/pom.xml index b78f6ef5cf..5c8fc733dd 100644 --- a/spring-cloud-modules/spring-cloud-ribbon-client/pom.xml +++ b/spring-cloud-modules/spring-cloud-ribbon-client/pom.xml @@ -46,7 +46,7 @@ - 2021.0.0 + 2021.0.3 - \ No newline at end of file + diff --git a/spring-cloud-modules/spring-cloud-security/pom.xml b/spring-cloud-modules/spring-cloud-security/pom.xml index 43eb6e61e8..15b5a9c4bc 100644 --- a/spring-cloud-modules/spring-cloud-security/pom.xml +++ b/spring-cloud-modules/spring-cloud-security/pom.xml @@ -33,7 +33,7 @@ - 2021.0.0 + 2021.0.3 - \ No newline at end of file + diff --git a/spring-cloud-modules/spring-cloud-zuul/pom.xml b/spring-cloud-modules/spring-cloud-zuul/pom.xml index b04a21da1c..6929de0539 100644 --- a/spring-cloud-modules/spring-cloud-zuul/pom.xml +++ b/spring-cloud-modules/spring-cloud-zuul/pom.xml @@ -80,8 +80,8 @@ - 2021.0.0 + 2021.0.3 2.2.7.RELEASE - \ No newline at end of file + diff --git a/spring-jenkins-pipeline/pom.xml b/spring-jenkins-pipeline/pom.xml index 7cd529020a..62e8283c5a 100644 --- a/spring-jenkins-pipeline/pom.xml +++ b/spring-jenkins-pipeline/pom.xml @@ -37,7 +37,6 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo - ${embed.mongo.version} test @@ -82,7 +81,6 @@ 2.17 - 3.2.6 - \ No newline at end of file + diff --git a/spring-kafka/src/main/java/com/baeldung/spring/kafka/Farewell.java b/spring-kafka/src/main/java/com/baeldung/spring/kafka/Farewell.java new file mode 100644 index 0000000000..77b21e9ef8 --- /dev/null +++ b/spring-kafka/src/main/java/com/baeldung/spring/kafka/Farewell.java @@ -0,0 +1,37 @@ +package com.baeldung.spring.kafka; + +public class Farewell { + + private String message; + private Integer remainingMinutes; + + public Farewell() { + } + + public Farewell(String message, Integer remainingMinutes) { + this.message = message; + this.remainingMinutes = remainingMinutes; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Integer getRemainingMinutes() { + return remainingMinutes; + } + + public void setRemainingMinutes(Integer remainingMinutes) { + this.remainingMinutes = remainingMinutes; + } + + @Override + public String toString() { + return message + ". In " + remainingMinutes + "!"; + } + +} diff --git a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplicationMultiListener.java b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplicationMultiListener.java new file mode 100644 index 0000000000..fa81488085 --- /dev/null +++ b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplicationMultiListener.java @@ -0,0 +1,46 @@ +package com.baeldung.spring.kafka; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.kafka.core.KafkaTemplate; + +@SpringBootApplication +public class KafkaApplicationMultiListener { + + public static void main(String[] args) throws Exception { + + ConfigurableApplicationContext context = SpringApplication.run(KafkaApplicationMultiListener.class, args); + + MessageProducer producer = context.getBean(MessageProducer.class); + producer.sendMessages(); + + Thread.sleep(5000); + context.close(); + } + + @Bean + public MessageProducer MessageProducer() { + return new MessageProducer(); + } + + public static class MessageProducer { + + @Autowired + private KafkaTemplate multiTypeKafkaTemplate; + + @Value(value = "${multi.type.topic.name}") + private String multiTypeTopicName; + + public void sendMessages() { + multiTypeKafkaTemplate.send(multiTypeTopicName, new Greeting("Greetings", "World!")); + multiTypeKafkaTemplate.send(multiTypeTopicName, new Farewell("Farewell", 25)); + multiTypeKafkaTemplate.send(multiTypeTopicName, "Simple string message"); + } + + } + +} diff --git a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaConsumerConfig.java b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaConsumerConfig.java index 9495fcf508..5873bf86ce 100644 --- a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaConsumerConfig.java +++ b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaConsumerConfig.java @@ -12,6 +12,10 @@ import org.springframework.kafka.annotation.EnableKafka; import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; import org.springframework.kafka.core.ConsumerFactory; import org.springframework.kafka.core.DefaultKafkaConsumerFactory; +import org.springframework.kafka.support.converter.RecordMessageConverter; +import org.springframework.kafka.support.converter.StringJsonMessageConverter; +import org.springframework.kafka.support.mapping.DefaultJackson2JavaTypeMapper; +import org.springframework.kafka.support.mapping.Jackson2JavaTypeMapper; import org.springframework.kafka.support.serializer.JsonDeserializer; @EnableKafka @@ -85,4 +89,35 @@ public class KafkaConsumerConfig { return factory; } + @Bean + public RecordMessageConverter multiTypeConverter() { + StringJsonMessageConverter converter = new StringJsonMessageConverter(); + DefaultJackson2JavaTypeMapper typeMapper = new DefaultJackson2JavaTypeMapper(); + typeMapper.setTypePrecedence(Jackson2JavaTypeMapper.TypePrecedence.TYPE_ID); + typeMapper.addTrustedPackages("com.baeldung.spring.kafka"); + Map> mappings = new HashMap<>(); + mappings.put("greeting", Greeting.class); + mappings.put("farewell", Farewell.class); + typeMapper.setIdClassMapping(mappings); + converter.setTypeMapper(typeMapper); + return converter; + } + + @Bean + public ConsumerFactory multiTypeConsumerFactory() { + HashMap props = new HashMap<>(); + props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); + props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); + props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class); + return new DefaultKafkaConsumerFactory<>(props); + } + + @Bean + public ConcurrentKafkaListenerContainerFactory multiTypeKafkaListenerContainerFactory() { + ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>(); + factory.setConsumerFactory(multiTypeConsumerFactory()); + factory.setMessageConverter(multiTypeConverter()); + return factory; + } + } diff --git a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaProducerConfig.java b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaProducerConfig.java index 9dff81a09d..0612ade45d 100644 --- a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaProducerConfig.java +++ b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaProducerConfig.java @@ -1,5 +1,8 @@ package com.baeldung.spring.kafka; +import java.util.HashMap; +import java.util.Map; + import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.common.serialization.StringSerializer; import org.springframework.beans.factory.annotation.Value; @@ -10,9 +13,6 @@ import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.ProducerFactory; import org.springframework.kafka.support.serializer.JsonSerializer; -import java.util.HashMap; -import java.util.Map; - @Configuration public class KafkaProducerConfig { @@ -49,4 +49,19 @@ public class KafkaProducerConfig { return new KafkaTemplate<>(greetingProducerFactory()); } + @Bean + public ProducerFactory multiTypeProducerFactory() { + Map configProps = new HashMap<>(); + configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); + configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); + configProps.put(JsonSerializer.TYPE_MAPPINGS, "greeting:com.baeldung.spring.kafka.Greeting, farewell:com.baeldung.spring.kafka.Farewell"); + return new DefaultKafkaProducerFactory<>(configProps); + } + + @Bean + public KafkaTemplate multiTypeKafkaTemplate() { + return new KafkaTemplate<>(multiTypeProducerFactory()); + } + } diff --git a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaTopicConfig.java b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaTopicConfig.java index 8a006a72bc..9f14b5972d 100644 --- a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaTopicConfig.java +++ b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaTopicConfig.java @@ -31,6 +31,9 @@ public class KafkaTopicConfig { @Value(value = "${greeting.topic.name}") private String greetingTopicName; + @Value(value = "${multi.type.topic.name}") + private String multiTypeTopicName; + @Bean public KafkaAdmin kafkaAdmin() { Map configs = new HashMap<>(); @@ -66,4 +69,9 @@ public class KafkaTopicConfig { newTopic.configs(configs); return newTopic; } + + @Bean + public NewTopic multiTypeTopic() { + return new NewTopic(multiTypeTopicName, 1, (short) 1); + } } diff --git a/spring-kafka/src/main/java/com/baeldung/spring/kafka/MultiTypeKafkaListener.java b/spring-kafka/src/main/java/com/baeldung/spring/kafka/MultiTypeKafkaListener.java new file mode 100644 index 0000000000..9afb5ff0b6 --- /dev/null +++ b/spring-kafka/src/main/java/com/baeldung/spring/kafka/MultiTypeKafkaListener.java @@ -0,0 +1,26 @@ +package com.baeldung.spring.kafka; + +import org.springframework.kafka.annotation.KafkaHandler; +import org.springframework.kafka.annotation.KafkaListener; +import org.springframework.stereotype.Component; + +@Component +@KafkaListener(id = "multiGroup", topics = "multitype") +public class MultiTypeKafkaListener { + + @KafkaHandler + public void handleGreeting(Greeting greeting) { + System.out.println("Greeting received: " + greeting); + } + + @KafkaHandler + public void handleF(Farewell farewell) { + System.out.println("Farewell received: " + farewell); + } + + @KafkaHandler(isDefault = true) + public void unknown(Object object) { + System.out.println("Unkown type received: " + object); + } + +} diff --git a/spring-kafka/src/main/resources/application.properties b/spring-kafka/src/main/resources/application.properties index 9a614cbafd..b1dc1ceaf5 100644 --- a/spring-kafka/src/main/resources/application.properties +++ b/spring-kafka/src/main/resources/application.properties @@ -4,14 +4,14 @@ long.message.topic.name=longMessage greeting.topic.name=greeting filtered.topic.name=filtered partitioned.topic.name=partitioned - +multi.type.topic.name=multitype # monitoring - lag analysis monitor.kafka.bootstrap.config=localhost:9092 monitor.kafka.consumer.groupid=baeldungGrp monitor.topic.name=baeldung - # monitoring - simulation monitor.producer.simulate=true monitor.consumer.simulate=true monitor.kafka.consumer.groupid.simulate=baeldungGrpSimulate test.topic=testtopic1 + diff --git a/spring-katharsis/src/main/resources/application.properties b/spring-katharsis/src/main/resources/application.properties index 415ec1723b..5325d47223 100644 --- a/spring-katharsis/src/main/resources/application.properties +++ b/spring-katharsis/src/main/resources/application.properties @@ -5,6 +5,8 @@ spring.jpa.show-sql = false spring.jpa.hibernate.ddl-auto = create-drop spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.H2Dialect +spring.jpa.properties.hibernate.globally_quoted_identifiers=true + server.port=8082 server.servlet.context-path=/spring-katharsis diff --git a/spring-remoting-modules/pom.xml b/spring-remoting-modules/pom.xml index 1981278db8..dc7afa7cc1 100644 --- a/spring-remoting-modules/pom.xml +++ b/spring-remoting-modules/pom.xml @@ -5,7 +5,7 @@ 4.0.0 spring-remoting-modules 1.0-SNAPSHOT - spring-remoting + spring-remoting-modules pom Parent for all projects related to Spring Remoting, except remoting-hessian-burlap + 2.7.2 + + + + org.springframework.boot + spring-boot-starter-security + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + io.projectreactor + reactor-test + test + + + org.springframework.security + spring-security-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + + pkce-auth-server + pkce-client + + diff --git a/spring-security-modules/spring-security-social-login/src/main/resources/application.properties b/spring-security-modules/spring-security-social-login/src/main/resources/application.properties index 57348051ac..02b0cd94c4 100644 --- a/spring-security-modules/spring-security-social-login/src/main/resources/application.properties +++ b/spring-security-modules/spring-security-social-login/src/main/resources/application.properties @@ -3,4 +3,6 @@ spring.social.facebook.appSecret=abefd6497e9cc01ad03be28509617bf0 spring.thymeleaf.cache=false server.servlet.register-default-servlet=true spring.sql.init.mode=always -spring.jpa.defer-datasource-initialization=true \ No newline at end of file +spring.jpa.defer-datasource-initialization=true + +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/spring-security-modules/spring-security-social-login/src/main/resources/data.sql b/spring-security-modules/spring-security-social-login/src/main/resources/data.sql index 3b26afef32..b13a1f143e 100644 --- a/spring-security-modules/spring-security-social-login/src/main/resources/data.sql +++ b/spring-security-modules/spring-security-social-login/src/main/resources/data.sql @@ -1 +1 @@ -insert into User (id, username, password) values (1,'john', '123'); \ No newline at end of file +insert into "user" ("id", "username", "password") values (1,'john', '123'); \ No newline at end of file diff --git a/spring-security-modules/spring-security-web-boot-3/pom.xml b/spring-security-modules/spring-security-web-boot-3/pom.xml index 0984c25e07..5229068dfa 100644 --- a/spring-security-modules/spring-security-web-boot-3/pom.xml +++ b/spring-security-modules/spring-security-web-boot-3/pom.xml @@ -32,7 +32,6 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo - 3.3.1 commons-io diff --git a/spring-soap/README.md b/spring-soap/README.md index ca5f58c67e..aac1845222 100644 --- a/spring-soap/README.md +++ b/spring-soap/README.md @@ -6,3 +6,4 @@ This module contains articles about SOAP APIs with Spring - [Creating a SOAP Web Service with Spring](https://www.baeldung.com/spring-boot-soap-web-service) - [Invoking a SOAP Web Service in Spring](https://www.baeldung.com/spring-soap-web-service) +- [Sending SOAP Request via Postman](https://www.baeldung.com/postman-soap-request) diff --git a/spring-soap/src/main/resources/CountriesPortService.postman_collection.json b/spring-soap/src/main/resources/CountriesPortService.postman_collection.json new file mode 100644 index 0000000000..867186cf79 --- /dev/null +++ b/spring-soap/src/main/resources/CountriesPortService.postman_collection.json @@ -0,0 +1,93 @@ +{ + "info": { + "_postman_id": "46f8f766-3850-44bd-8f6f-58a6da4488de", + "name": "CountriesPortService", + "description": "\n", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "13842218" + }, + "item": [ + { + "name": "getCountry", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "text/xml; charset=utf-8" + } + ], + "body": { + "mode": "raw", + "raw": "\n\n \n \n Spain\n \n \n", + "options": { + "raw": { + "language": "xml" + } + } + }, + "url": { + "raw": "{{CountriesPortSoap11BaseUrl}}/ws", + "host": [ + "{{CountriesPortSoap11BaseUrl}}" + ], + "path": [ + "ws" + ] + } + }, + "response": [ + { + "name": "getCountry response", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "text/xml; charset=utf-8" + } + ], + "body": { + "mode": "raw", + "raw": "\n\n \n The element or type could not be found undefined\n \n\n", + "options": { + "raw": { + "language": "xml" + } + } + }, + "url": { + "raw": "http://localhost:8080/ws", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "ws" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "xml", + "header": [ + { + "key": "Content-Type", + "value": "text/xml; charset=utf-8" + } + ], + "cookie": [], + "body": "\n\n \n The element or type could not be found undefined\n \n\n" + } + ] + } + ], + "variable": [ + { + "key": "CountriesPortSoap11BaseUrl", + "value": "http://localhost:8080", + "type": "any" + } + ] +} \ No newline at end of file diff --git a/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java index 4a4b9eee3f..910afedbac 100644 --- a/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java +++ b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -78,7 +78,7 @@ public class PersistenceConfig { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); return hibernateProperties; } diff --git a/spring-web-modules/spring-rest-query-language/src/main/resources/data.sql b/spring-web-modules/spring-rest-query-language/src/main/resources/data.sql index 5fba12dd85..50fc79a5c9 100644 --- a/spring-web-modules/spring-rest-query-language/src/main/resources/data.sql +++ b/spring-web-modules/spring-rest-query-language/src/main/resources/data.sql @@ -1,5 +1,5 @@ -insert into User (id, firstName, lastName, email, age) values (1, 'john', 'doe', 'john@doe.com', 22); -insert into User (id, firstName, lastName, email, age) values (2, 'tom', 'doe', 'tom@doe.com', 26); +insert into "User" ("id", "firstName", "lastName", "email", "age") values (1, 'john', 'doe', 'john@doe.com', 22); +insert into "User" ("id", "firstName", "lastName", "email", "age") values (2, 'tom', 'doe', 'tom@doe.com', 26); -insert into MyUser (id, firstName, lastName, email, age) values (1, 'john', 'doe', 'john@doe.com', 22); -insert into MyUser (id, firstName, lastName, email, age) values (2, 'tom', 'doe', 'tom@doe.com', 26); +insert into "MyUser" ("id", "firstName", "lastName", "email", "age") values (1, 'john', 'doe', 'john@doe.com', 22); +insert into "MyUser" ("id", "firstName", "lastName", "email", "age") values (2, 'tom', 'doe', 'tom@doe.com', 26); diff --git a/spring-web-modules/spring-session/spring-session-mongodb/pom.xml b/spring-web-modules/spring-session/spring-session-mongodb/pom.xml index e34589c75b..6e5c12d487 100644 --- a/spring-web-modules/spring-session/spring-session-mongodb/pom.xml +++ b/spring-web-modules/spring-session/spring-session-mongodb/pom.xml @@ -37,7 +37,6 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo - ${embed.mongo.version} test @@ -51,8 +50,4 @@ - - 3.2.6 - - - \ No newline at end of file + diff --git a/testing-modules/cucumber/src/test/java/com/baeldung/cucumber/tags/acceptance/commonutil/ScenarioContextUI.java b/testing-modules/cucumber/src/test/java/com/baeldung/cucumber/tags/acceptance/commonutil/ScenarioContextUI.java index 66aabece11..d775c8a152 100644 --- a/testing-modules/cucumber/src/test/java/com/baeldung/cucumber/tags/acceptance/commonutil/ScenarioContextUI.java +++ b/testing-modules/cucumber/src/test/java/com/baeldung/cucumber/tags/acceptance/commonutil/ScenarioContextUI.java @@ -1,5 +1,6 @@ package com.baeldung.cucumber.tags.acceptance.commonutil; +import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.remote.DesiredCapabilities; @@ -34,7 +35,7 @@ public class ScenarioContextUI { } private static WebDriver getRemoteWebDriver(URL url) { - return new RemoteWebDriver(url, DesiredCapabilities.chrome()); + return new RemoteWebDriver(url, new DesiredCapabilities("chrome", "", Platform.ANY)); } private static WebDriver getLocalChromeDriver() { diff --git a/vavr-modules/README.md b/vavr-modules/README.md new file mode 100644 index 0000000000..fa2a448f3a --- /dev/null +++ b/vavr-modules/README.md @@ -0,0 +1,3 @@ +## VAVR + +This module contains modules about vavr. \ No newline at end of file diff --git a/java-vavr-stream/README.md b/vavr-modules/java-vavr-stream/README.md similarity index 100% rename from java-vavr-stream/README.md rename to vavr-modules/java-vavr-stream/README.md diff --git a/java-vavr-stream/pom.xml b/vavr-modules/java-vavr-stream/pom.xml similarity index 94% rename from java-vavr-stream/pom.xml rename to vavr-modules/java-vavr-stream/pom.xml index 8358c29003..cda9d1f734 100644 --- a/java-vavr-stream/pom.xml +++ b/vavr-modules/java-vavr-stream/pom.xml @@ -11,7 +11,7 @@ com.baeldung - parent-modules + vavr-modules 1.0.0-SNAPSHOT diff --git a/java-vavr-stream/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java b/vavr-modules/java-vavr-stream/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java similarity index 100% rename from java-vavr-stream/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java rename to vavr-modules/java-vavr-stream/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java diff --git a/javax-servlets/src/main/resources/logback.xml b/vavr-modules/java-vavr-stream/src/main/resources/logback.xml similarity index 100% rename from javax-servlets/src/main/resources/logback.xml rename to vavr-modules/java-vavr-stream/src/main/resources/logback.xml diff --git a/vavr-modules/pom.xml b/vavr-modules/pom.xml new file mode 100644 index 0000000000..d570df6d34 --- /dev/null +++ b/vavr-modules/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + vavr-modules + vavr-modules + pom + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + vavr + vavr-2 + java-vavr-stream + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + \ No newline at end of file diff --git a/vavr-2/README.md b/vavr-modules/vavr-2/README.md similarity index 100% rename from vavr-2/README.md rename to vavr-modules/vavr-2/README.md diff --git a/vavr-2/pom.xml b/vavr-modules/vavr-2/pom.xml similarity index 74% rename from vavr-2/pom.xml rename to vavr-modules/vavr-2/pom.xml index f3640d7c6e..681886ac11 100644 --- a/vavr-2/pom.xml +++ b/vavr-modules/vavr-2/pom.xml @@ -1,18 +1,17 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 vavr-2 vavr-2 jar - parent-modules com.baeldung + vavr-modules 1.0.0-SNAPSHOT - io.vavr diff --git a/vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java b/vavr-modules/vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java similarity index 100% rename from vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java rename to vavr-modules/vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java diff --git a/vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java b/vavr-modules/vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java similarity index 100% rename from vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java rename to vavr-modules/vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java diff --git a/vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java b/vavr-modules/vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java similarity index 100% rename from vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java rename to vavr-modules/vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java diff --git a/vavr/README.md b/vavr-modules/vavr/README.md similarity index 100% rename from vavr/README.md rename to vavr-modules/vavr/README.md diff --git a/vavr/pom.xml b/vavr-modules/vavr/pom.xml similarity index 96% rename from vavr/pom.xml rename to vavr-modules/vavr/pom.xml index 1604ecc06e..5f6bf4db98 100644 --- a/vavr/pom.xml +++ b/vavr-modules/vavr/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/vavr/src/main/java/com/baeldung/Application.java b/vavr-modules/vavr/src/main/java/com/baeldung/Application.java similarity index 100% rename from vavr/src/main/java/com/baeldung/Application.java rename to vavr-modules/vavr/src/main/java/com/baeldung/Application.java diff --git a/vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java b/vavr-modules/vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java similarity index 100% rename from vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java rename to vavr-modules/vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java diff --git a/vavr/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java b/vavr-modules/vavr/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java similarity index 100% rename from vavr/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java rename to vavr-modules/vavr/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java diff --git a/vavr/src/main/java/com/baeldung/vavr/Person.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/Person.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/Person.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/Person.java diff --git a/vavr/src/main/java/com/baeldung/vavr/PersonValidator.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/PersonValidator.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/PersonValidator.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/PersonValidator.java diff --git a/vavr/src/main/java/com/baeldung/vavr/User.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/User.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/User.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/User.java diff --git a/vavr/src/main/java/com/baeldung/vavr/exception/handling/JavaTryCatch.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/JavaTryCatch.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/exception/handling/JavaTryCatch.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/JavaTryCatch.java diff --git a/vavr/src/main/java/com/baeldung/vavr/exception/handling/VavrTry.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/VavrTry.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/exception/handling/VavrTry.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/VavrTry.java diff --git a/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/ClientException.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/ClientException.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/exception/handling/client/ClientException.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/ClientException.java diff --git a/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/HttpClient.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/HttpClient.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/exception/handling/client/HttpClient.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/HttpClient.java diff --git a/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/Response.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/Response.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/exception/handling/client/Response.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/Response.java diff --git a/vavr/src/main/java/com/baeldung/vavrvalidation/application/Application.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/application/Application.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavrvalidation/application/Application.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/application/Application.java diff --git a/vavr/src/main/java/com/baeldung/vavrvalidation/model/User.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/model/User.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavrvalidation/model/User.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/model/User.java diff --git a/vavr/src/main/java/com/baeldung/vavrvalidation/validator/UserValidator.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/validator/UserValidator.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavrvalidation/validator/UserValidator.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/validator/UserValidator.java diff --git a/jjwt/src/main/resources/logback.xml b/vavr-modules/vavr/src/main/resources/logback.xml similarity index 100% rename from jjwt/src/main/resources/logback.xml rename to vavr-modules/vavr/src/main/resources/logback.xml diff --git a/vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/PropertyBasedLongRunningUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/PropertyBasedLongRunningUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/PropertyBasedLongRunningUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/PropertyBasedLongRunningUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/VavrUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/VavrUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/VavrUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/VavrUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java similarity index 96% rename from vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java index 60359d6803..1bae70a3d4 100644 --- a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java +++ b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java @@ -1,107 +1,107 @@ -package com.baeldung.vavr.collections; - -import static io.vavr.API.Array; -import static io.vavr.API.Failure; -import static io.vavr.API.List; -import static io.vavr.API.None; -import static io.vavr.API.Some; -import static io.vavr.API.Stream; -import static io.vavr.API.Success; -import static io.vavr.API.Tuple; -import static io.vavr.API.Vector; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import io.vavr.Tuple3; -import io.vavr.collection.Array; -import io.vavr.collection.List; -import io.vavr.collection.Stream; -import io.vavr.collection.Vector; -import io.vavr.control.Option; -import io.vavr.control.Try; - -public class CollectionFactoryMethodsUnitTest { - - @Test - public void givenANoneOptionElement_whenCreated_thenCorrect() { - Option none = None(); - assertFalse(none == null); - assertEquals(none, Option.none()); - } - - @Test - public void givenASomeOptionElement_whenCreated_thenCorrect() { - Option some = Some(1); - assertFalse(some == null); - assertTrue(some.contains(1)); - } - - @Test - public void givenATupleElement_whenCreated_thenCorrect() { - Tuple3 tuple = Tuple('a', "chain", 2); - assertTrue(tuple!=null); - assertEquals(tuple._1(), new Character('a')); - assertEquals(tuple._2(), "chain"); - assertEquals(tuple._3().intValue(), 2); - } - - @Test - public void givenASuccessObject_whenEvaluated_thenSuccess() { - Try integer = Success(55); - assertEquals(integer.get().intValue(), 55); - } - @Test - public void givenAFailureObject_whenEvaluated_thenExceptionThrown() { - Try failure = Failure(new Exception("Exception X encapsulated here")); - - try { - Integer i = failure.get();// evaluate a failure raise the exception - System.out.println(i);// not executed - } catch (Exception e) { - assertEquals(e.getMessage(), "Exception X encapsulated here"); - } - } - - @Test - public void givenAList_whenCreated_thenCorrect() { - List list = List(1, 2, 3, 4, 5); - - assertEquals(list.size(), 5); - assertEquals(list.get(0).intValue(), 1); - } - - @Test - public void givenAnEmptyList_whenCreated_thenCorrect() { - List empty = List(); - - assertEquals(empty.size(), 0); - assertEquals(empty, List.empty()); - } - - @Test - public void givenAnArray_whenCreated_thenCorrect() { - Array array = Array(1, 2, 3, 4, 5); - - assertEquals(array.size(), 5); - assertEquals(array.get(0).intValue(), 1); - } - - @Test - public void givenAStream_whenCreated_thenCorrect() { - Stream stream = Stream(1, 2, 3, 4, 5); - - assertEquals(stream.size(), 5); - assertEquals(stream.get(0).intValue(), 1); - } - - @Test - public void givenAVector_whenCreated_thenCorrect() { - Vector vector = Vector(1, 2, 3, 4, 5); - - assertEquals(vector.size(), 5); - assertEquals(vector.get(0).intValue(), 1); - } -} +package com.baeldung.vavr.collections; + +import static io.vavr.API.Array; +import static io.vavr.API.Failure; +import static io.vavr.API.List; +import static io.vavr.API.None; +import static io.vavr.API.Some; +import static io.vavr.API.Stream; +import static io.vavr.API.Success; +import static io.vavr.API.Tuple; +import static io.vavr.API.Vector; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import io.vavr.Tuple3; +import io.vavr.collection.Array; +import io.vavr.collection.List; +import io.vavr.collection.Stream; +import io.vavr.collection.Vector; +import io.vavr.control.Option; +import io.vavr.control.Try; + +public class CollectionFactoryMethodsUnitTest { + + @Test + public void givenANoneOptionElement_whenCreated_thenCorrect() { + Option none = None(); + assertFalse(none == null); + assertEquals(none, Option.none()); + } + + @Test + public void givenASomeOptionElement_whenCreated_thenCorrect() { + Option some = Some(1); + assertFalse(some == null); + assertTrue(some.contains(1)); + } + + @Test + public void givenATupleElement_whenCreated_thenCorrect() { + Tuple3 tuple = Tuple('a', "chain", 2); + assertTrue(tuple!=null); + assertEquals(tuple._1(), new Character('a')); + assertEquals(tuple._2(), "chain"); + assertEquals(tuple._3().intValue(), 2); + } + + @Test + public void givenASuccessObject_whenEvaluated_thenSuccess() { + Try integer = Success(55); + assertEquals(integer.get().intValue(), 55); + } + @Test + public void givenAFailureObject_whenEvaluated_thenExceptionThrown() { + Try failure = Failure(new Exception("Exception X encapsulated here")); + + try { + Integer i = failure.get();// evaluate a failure raise the exception + System.out.println(i);// not executed + } catch (Exception e) { + assertEquals(e.getMessage(), "Exception X encapsulated here"); + } + } + + @Test + public void givenAList_whenCreated_thenCorrect() { + List list = List(1, 2, 3, 4, 5); + + assertEquals(list.size(), 5); + assertEquals(list.get(0).intValue(), 1); + } + + @Test + public void givenAnEmptyList_whenCreated_thenCorrect() { + List empty = List(); + + assertEquals(empty.size(), 0); + assertEquals(empty, List.empty()); + } + + @Test + public void givenAnArray_whenCreated_thenCorrect() { + Array array = Array(1, 2, 3, 4, 5); + + assertEquals(array.size(), 5); + assertEquals(array.get(0).intValue(), 1); + } + + @Test + public void givenAStream_whenCreated_thenCorrect() { + Stream stream = Stream(1, 2, 3, 4, 5); + + assertEquals(stream.size(), 5); + assertEquals(stream.get(0).intValue(), 1); + } + + @Test + public void givenAVector_whenCreated_thenCorrect() { + Vector vector = Vector(1, 2, 3, 4, 5); + + assertEquals(vector.size(), 5); + assertEquals(vector.get(0).intValue(), 1); + } +} diff --git a/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java similarity index 96% rename from vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java index 140593218f..5be2526c0b 100644 --- a/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java +++ b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java @@ -1,87 +1,87 @@ -package com.baeldung.vavr.exception.handling; - -import io.vavr.API; -import io.vavr.CheckedFunction1; -import io.vavr.Value; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -public class VavrExceptionHandlingUnitTest { - - private static final Logger LOG = LoggerFactory.getLogger(VavrExceptionHandlingUnitTest.class); - - private List integers; - private List validIntegersOnly; - - @Before - public void init() { - integers = Arrays.asList(3, 9, 7, 0, 10, 20); - validIntegersOnly = Arrays.asList(3, 9, 7, 5, 10, 20); - } - - @Test - public void exceptionCausingMethod_UsingCheckedFunction_ThenSuccess() { - CheckedFunction1 fn = i -> readFromFile(i); - - validIntegersOnly.stream().map(fn.unchecked()).forEach(i -> LOG.debug("{}", i)); - } - - @Test(expected = IOException.class) - public void exceptionCausingMethod_UsingCheckedFunction_ThenFailure() { - CheckedFunction1 fn = i -> readFromFile(i); - - integers.stream().map(fn.unchecked()).forEach(i -> LOG.debug("{}", i)); - } - - @Test - public void exceptionCausingMethod_UsingAPI_ThenSuccess() { - validIntegersOnly.stream().map(API.unchecked(i -> readFromFile(i))).forEach(i -> LOG.debug("{}", i)); - } - - @Test(expected = IOException.class) - public void exceptionCausingMethod_UsingAPI_ThenFailure() { - integers.stream().map(API.unchecked(i -> readFromFile(i))).forEach(i -> LOG.debug("{}", i)); - } - - @Test - public void exceptionCausingMethod_UsingLift_ThenSuccess() { - validIntegersOnly.stream().map(CheckedFunction1.lift(i -> readFromFile(i))) - .map(i -> i.getOrElse(-1)) - .forEach(i -> { - Assert.assertNotSame(-1, i); - LOG.debug("{}", i); - }); - } - - @Test - public void exceptionCausingMethod_UsingLift_ThenFailure() { - integers.stream() - .map(CheckedFunction1.lift(i -> readFromFile(i))) - .map(i -> i.getOrElse(-1)) - .forEach(i -> LOG.debug("{}", i)); - - } - - @Test - public void exceptionCausingMethod_UsingTry_ThenSuccess() { - integers.stream() - .map(CheckedFunction1.liftTry(VavrExceptionHandlingUnitTest::readFromFile)) - .flatMap(Value::toJavaStream) - .forEach(i -> LOG.debug("{}", i)); - } - - private static Integer readFromFile(Integer i) throws IOException { - if (i == 0) { - throw new IOException(); // mock IOException - } - return i * i; - } - -} +package com.baeldung.vavr.exception.handling; + +import io.vavr.API; +import io.vavr.CheckedFunction1; +import io.vavr.Value; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +public class VavrExceptionHandlingUnitTest { + + private static final Logger LOG = LoggerFactory.getLogger(VavrExceptionHandlingUnitTest.class); + + private List integers; + private List validIntegersOnly; + + @Before + public void init() { + integers = Arrays.asList(3, 9, 7, 0, 10, 20); + validIntegersOnly = Arrays.asList(3, 9, 7, 5, 10, 20); + } + + @Test + public void exceptionCausingMethod_UsingCheckedFunction_ThenSuccess() { + CheckedFunction1 fn = i -> readFromFile(i); + + validIntegersOnly.stream().map(fn.unchecked()).forEach(i -> LOG.debug("{}", i)); + } + + @Test(expected = IOException.class) + public void exceptionCausingMethod_UsingCheckedFunction_ThenFailure() { + CheckedFunction1 fn = i -> readFromFile(i); + + integers.stream().map(fn.unchecked()).forEach(i -> LOG.debug("{}", i)); + } + + @Test + public void exceptionCausingMethod_UsingAPI_ThenSuccess() { + validIntegersOnly.stream().map(API.unchecked(i -> readFromFile(i))).forEach(i -> LOG.debug("{}", i)); + } + + @Test(expected = IOException.class) + public void exceptionCausingMethod_UsingAPI_ThenFailure() { + integers.stream().map(API.unchecked(i -> readFromFile(i))).forEach(i -> LOG.debug("{}", i)); + } + + @Test + public void exceptionCausingMethod_UsingLift_ThenSuccess() { + validIntegersOnly.stream().map(CheckedFunction1.lift(i -> readFromFile(i))) + .map(i -> i.getOrElse(-1)) + .forEach(i -> { + Assert.assertNotSame(-1, i); + LOG.debug("{}", i); + }); + } + + @Test + public void exceptionCausingMethod_UsingLift_ThenFailure() { + integers.stream() + .map(CheckedFunction1.lift(i -> readFromFile(i))) + .map(i -> i.getOrElse(-1)) + .forEach(i -> LOG.debug("{}", i)); + + } + + @Test + public void exceptionCausingMethod_UsingTry_ThenSuccess() { + integers.stream() + .map(CheckedFunction1.liftTry(VavrExceptionHandlingUnitTest::readFromFile)) + .flatMap(Value::toJavaStream) + .forEach(i -> LOG.debug("{}", i)); + } + + private static Integer readFromFile(Integer i) throws IOException { + if (i == 0) { + throw new IOException(); // mock IOException + } + return i * i; + } + +} diff --git a/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrTryUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrTryUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrTryUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrTryUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java diff --git a/vavr/src/test/java/com/baeldung/vavrvalidation/validator/UserValidatorUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavrvalidation/validator/UserValidatorUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavrvalidation/validator/UserValidatorUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavrvalidation/validator/UserValidatorUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavrvalidation/validator/ValidationUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavrvalidation/validator/ValidationUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavrvalidation/validator/ValidationUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavrvalidation/validator/ValidationUnitTest.java diff --git a/vertx-modules/README.md b/vertx-modules/README.md new file mode 100644 index 0000000000..983577b923 --- /dev/null +++ b/vertx-modules/README.md @@ -0,0 +1,3 @@ +## VERTX + +This module contains modules about VERTX. \ No newline at end of file diff --git a/vertx-modules/pom.xml b/vertx-modules/pom.xml new file mode 100644 index 0000000000..8c9c36e73e --- /dev/null +++ b/vertx-modules/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + vertx-modules + vertx-modules + pom + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + vertx + spring-vertx + vertx-and-rxjava + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + \ No newline at end of file diff --git a/spring-vertx/README.md b/vertx-modules/spring-vertx/README.md similarity index 100% rename from spring-vertx/README.md rename to vertx-modules/spring-vertx/README.md diff --git a/spring-vertx/pom.xml b/vertx-modules/spring-vertx/pom.xml similarity index 97% rename from spring-vertx/pom.xml rename to vertx-modules/spring-vertx/pom.xml index e24bb3f1ee..447d31ee55 100644 --- a/spring-vertx/pom.xml +++ b/vertx-modules/spring-vertx/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/VertxSpringApplication.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/VertxSpringApplication.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/VertxSpringApplication.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/VertxSpringApplication.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/entity/Article.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/entity/Article.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/entity/Article.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/entity/Article.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/util/DbBootstrap.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/util/DbBootstrap.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/util/DbBootstrap.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/util/DbBootstrap.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ArticleRecipientVerticle.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ArticleRecipientVerticle.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ArticleRecipientVerticle.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ArticleRecipientVerticle.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java diff --git a/spring-vertx/src/main/resources/application.properties b/vertx-modules/spring-vertx/src/main/resources/application.properties similarity index 100% rename from spring-vertx/src/main/resources/application.properties rename to vertx-modules/spring-vertx/src/main/resources/application.properties diff --git a/spring-vertx/src/main/resources/conf/conf.json b/vertx-modules/spring-vertx/src/main/resources/conf/conf.json similarity index 100% rename from spring-vertx/src/main/resources/conf/conf.json rename to vertx-modules/spring-vertx/src/main/resources/conf/conf.json diff --git a/jooby/src/main/resources/logback.xml b/vertx-modules/spring-vertx/src/main/resources/logback.xml similarity index 100% rename from jooby/src/main/resources/logback.xml rename to vertx-modules/spring-vertx/src/main/resources/logback.xml diff --git a/spring-vertx/src/test/java/com/baeldung/SpringContextTest.java b/vertx-modules/spring-vertx/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-vertx/src/test/java/com/baeldung/SpringContextTest.java rename to vertx-modules/spring-vertx/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java b/vertx-modules/spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java similarity index 100% rename from spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java rename to vertx-modules/spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java diff --git a/vertx-and-rxjava/.gitignore b/vertx-modules/vertx-and-rxjava/.gitignore similarity index 100% rename from vertx-and-rxjava/.gitignore rename to vertx-modules/vertx-and-rxjava/.gitignore diff --git a/vertx-and-rxjava/README.md b/vertx-modules/vertx-and-rxjava/README.md similarity index 100% rename from vertx-and-rxjava/README.md rename to vertx-modules/vertx-and-rxjava/README.md diff --git a/vertx-and-rxjava/pom.xml b/vertx-modules/vertx-and-rxjava/pom.xml similarity index 97% rename from vertx-and-rxjava/pom.xml rename to vertx-modules/vertx-and-rxjava/pom.xml index 1793cff1e7..95bf95020a 100644 --- a/vertx-and-rxjava/pom.xml +++ b/vertx-modules/vertx-and-rxjava/pom.xml @@ -8,7 +8,7 @@ com.baeldung - parent-modules + vertx-modules 1.0.0-SNAPSHOT diff --git a/vertx-and-rxjava/pom.xml.orig b/vertx-modules/vertx-and-rxjava/pom.xml.orig similarity index 100% rename from vertx-and-rxjava/pom.xml.orig rename to vertx-modules/vertx-and-rxjava/pom.xml.orig diff --git a/vertx-and-rxjava/src/test/java/com/baeldung/weather/CityAndDayLength.java b/vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/CityAndDayLength.java similarity index 100% rename from vertx-and-rxjava/src/test/java/com/baeldung/weather/CityAndDayLength.java rename to vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/CityAndDayLength.java diff --git a/vertx-and-rxjava/src/test/java/com/baeldung/weather/MetaWeatherClient.java b/vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/MetaWeatherClient.java similarity index 100% rename from vertx-and-rxjava/src/test/java/com/baeldung/weather/MetaWeatherClient.java rename to vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/MetaWeatherClient.java diff --git a/vertx-and-rxjava/src/test/java/com/baeldung/weather/VertxWithRxJavaIntegrationTest.java b/vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/VertxWithRxJavaIntegrationTest.java similarity index 100% rename from vertx-and-rxjava/src/test/java/com/baeldung/weather/VertxWithRxJavaIntegrationTest.java rename to vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/VertxWithRxJavaIntegrationTest.java diff --git a/vertx-and-rxjava/src/test/resources/cities.txt b/vertx-modules/vertx-and-rxjava/src/test/resources/cities.txt similarity index 100% rename from vertx-and-rxjava/src/test/resources/cities.txt rename to vertx-modules/vertx-and-rxjava/src/test/resources/cities.txt diff --git a/vertx-and-rxjava/src/test/resources/logback-test.xml b/vertx-modules/vertx-and-rxjava/src/test/resources/logback-test.xml similarity index 100% rename from vertx-and-rxjava/src/test/resources/logback-test.xml rename to vertx-modules/vertx-and-rxjava/src/test/resources/logback-test.xml diff --git a/vertx/README.md b/vertx-modules/vertx/README.md similarity index 100% rename from vertx/README.md rename to vertx-modules/vertx/README.md diff --git a/vertx/pom.xml b/vertx-modules/vertx/pom.xml similarity index 98% rename from vertx/pom.xml rename to vertx-modules/vertx/pom.xml index 7608b3e355..f8d72f8ae8 100644 --- a/vertx/pom.xml +++ b/vertx-modules/vertx/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + vertx-modules 1.0.0-SNAPSHOT diff --git a/vertx/src/main/java/com/baeldung/HelloVerticle.java b/vertx-modules/vertx/src/main/java/com/baeldung/HelloVerticle.java similarity index 100% rename from vertx/src/main/java/com/baeldung/HelloVerticle.java rename to vertx-modules/vertx/src/main/java/com/baeldung/HelloVerticle.java diff --git a/vertx/src/main/java/com/baeldung/SimpleServerVerticle.java b/vertx-modules/vertx/src/main/java/com/baeldung/SimpleServerVerticle.java similarity index 100% rename from vertx/src/main/java/com/baeldung/SimpleServerVerticle.java rename to vertx-modules/vertx/src/main/java/com/baeldung/SimpleServerVerticle.java diff --git a/vertx/src/main/java/com/baeldung/model/Article.java b/vertx-modules/vertx/src/main/java/com/baeldung/model/Article.java similarity index 100% rename from vertx/src/main/java/com/baeldung/model/Article.java rename to vertx-modules/vertx/src/main/java/com/baeldung/model/Article.java diff --git a/vertx/src/main/java/com/baeldung/rest/RestServiceVerticle.java b/vertx-modules/vertx/src/main/java/com/baeldung/rest/RestServiceVerticle.java similarity index 100% rename from vertx/src/main/java/com/baeldung/rest/RestServiceVerticle.java rename to vertx-modules/vertx/src/main/java/com/baeldung/rest/RestServiceVerticle.java diff --git a/vertx/src/main/resources/conf/conf.json b/vertx-modules/vertx/src/main/resources/conf/conf.json similarity index 100% rename from vertx/src/main/resources/conf/conf.json rename to vertx-modules/vertx/src/main/resources/conf/conf.json diff --git a/vertx/src/main/resources/logback.xml b/vertx-modules/vertx/src/main/resources/logback.xml similarity index 100% rename from vertx/src/main/resources/logback.xml rename to vertx-modules/vertx/src/main/resources/logback.xml diff --git a/vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java b/vertx-modules/vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java similarity index 100% rename from vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java rename to vertx-modules/vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java diff --git a/vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java b/vertx-modules/vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java similarity index 100% rename from vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java rename to vertx-modules/vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java diff --git a/web-modules/README.md b/web-modules/README.md new file mode 100644 index 0000000000..1329ce18db --- /dev/null +++ b/web-modules/README.md @@ -0,0 +1,3 @@ +## Web + +This module contains web modules. diff --git a/apache-tapestry/README.md b/web-modules/apache-tapestry/README.md similarity index 100% rename from apache-tapestry/README.md rename to web-modules/apache-tapestry/README.md diff --git a/apache-tapestry/pom.xml b/web-modules/apache-tapestry/pom.xml similarity index 99% rename from apache-tapestry/pom.xml rename to web-modules/apache-tapestry/pom.xml index 201b807d9f..d70af20a59 100644 --- a/apache-tapestry/pom.xml +++ b/web-modules/apache-tapestry/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/apache-tapestry/src/main/java/com/baeldung/tapestry/components/Layout.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/components/Layout.java similarity index 100% rename from apache-tapestry/src/main/java/com/baeldung/tapestry/components/Layout.java rename to web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/components/Layout.java diff --git a/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Error404.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Error404.java similarity index 100% rename from apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Error404.java rename to web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Error404.java diff --git a/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Home.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Home.java similarity index 100% rename from apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Home.java rename to web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Home.java diff --git a/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Index.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Index.java similarity index 100% rename from apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Index.java rename to web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Index.java diff --git a/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Login.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Login.java similarity index 100% rename from apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Login.java rename to web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/pages/Login.java diff --git a/apache-tapestry/src/main/java/com/baeldung/tapestry/services/AppModule.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/AppModule.java similarity index 100% rename from apache-tapestry/src/main/java/com/baeldung/tapestry/services/AppModule.java rename to web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/AppModule.java diff --git a/apache-tapestry/src/main/java/com/baeldung/tapestry/services/DevelopmentModule.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/DevelopmentModule.java similarity index 100% rename from apache-tapestry/src/main/java/com/baeldung/tapestry/services/DevelopmentModule.java rename to web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/DevelopmentModule.java diff --git a/apache-tapestry/src/main/java/com/baeldung/tapestry/services/QaModule.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/QaModule.java similarity index 100% rename from apache-tapestry/src/main/java/com/baeldung/tapestry/services/QaModule.java rename to web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/QaModule.java diff --git a/apache-tapestry/src/main/resources/com/baeldung/tapestry/components/Layout.tml b/web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/components/Layout.tml similarity index 100% rename from apache-tapestry/src/main/resources/com/baeldung/tapestry/components/Layout.tml rename to web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/components/Layout.tml diff --git a/apache-tapestry/src/main/resources/com/baeldung/tapestry/logback.xml b/web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/logback.xml similarity index 100% rename from apache-tapestry/src/main/resources/com/baeldung/tapestry/logback.xml rename to web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/logback.xml diff --git a/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Error404.tml b/web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Error404.tml similarity index 100% rename from apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Error404.tml rename to web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Error404.tml diff --git a/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Home.properties b/web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Home.properties similarity index 100% rename from apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Home.properties rename to web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Home.properties diff --git a/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Home.tml b/web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Home.tml similarity index 100% rename from apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Home.tml rename to web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Home.tml diff --git a/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Index.properties b/web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Index.properties similarity index 100% rename from apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Index.properties rename to web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Index.properties diff --git a/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Index.tml b/web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Index.tml similarity index 100% rename from apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Index.tml rename to web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Index.tml diff --git a/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Login.tml b/web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Login.tml similarity index 100% rename from apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Login.tml rename to web-modules/apache-tapestry/src/main/resources/com/baeldung/tapestry/pages/Login.tml diff --git a/apache-tapestry/src/main/resources/log4j.properties b/web-modules/apache-tapestry/src/main/resources/log4j.properties similarity index 100% rename from apache-tapestry/src/main/resources/log4j.properties rename to web-modules/apache-tapestry/src/main/resources/log4j.properties diff --git a/apache-tapestry/src/main/webapp/WEB-INF/app.properties b/web-modules/apache-tapestry/src/main/webapp/WEB-INF/app.properties similarity index 100% rename from apache-tapestry/src/main/webapp/WEB-INF/app.properties rename to web-modules/apache-tapestry/src/main/webapp/WEB-INF/app.properties diff --git a/apache-tapestry/src/main/webapp/WEB-INF/web.xml b/web-modules/apache-tapestry/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from apache-tapestry/src/main/webapp/WEB-INF/web.xml rename to web-modules/apache-tapestry/src/main/webapp/WEB-INF/web.xml diff --git a/apache-tapestry/src/main/webapp/favicon.ico b/web-modules/apache-tapestry/src/main/webapp/favicon.ico similarity index 100% rename from apache-tapestry/src/main/webapp/favicon.ico rename to web-modules/apache-tapestry/src/main/webapp/favicon.ico diff --git a/apache-tapestry/src/main/webapp/images/tapestry.png b/web-modules/apache-tapestry/src/main/webapp/images/tapestry.png similarity index 100% rename from apache-tapestry/src/main/webapp/images/tapestry.png rename to web-modules/apache-tapestry/src/main/webapp/images/tapestry.png diff --git a/apache-tapestry/src/main/webapp/mybootstrap/css/bootstrap-theme.css b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/css/bootstrap-theme.css similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/css/bootstrap-theme.css rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/css/bootstrap-theme.css diff --git a/apache-tapestry/src/main/webapp/mybootstrap/css/bootstrap.css b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/css/bootstrap.css similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/css/bootstrap.css rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/css/bootstrap.css diff --git a/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.eot b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.eot rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.eot diff --git a/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.svg b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.svg rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.svg diff --git a/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.ttf b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.ttf rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.ttf diff --git a/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.woff b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.woff rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.woff diff --git a/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.woff2 b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.woff2 similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.woff2 rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/fonts/glyphicons-halflings-regular.woff2 diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/affix.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/affix.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/affix.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/affix.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/alert.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/alert.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/alert.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/alert.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/button.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/button.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/button.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/button.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/carousel.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/carousel.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/carousel.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/carousel.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/collapse.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/collapse.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/collapse.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/collapse.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/dropdown.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/dropdown.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/dropdown.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/dropdown.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/modal.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/modal.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/modal.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/modal.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/popover.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/popover.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/popover.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/popover.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/scrollspy.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/scrollspy.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/scrollspy.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/scrollspy.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/tab.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/tab.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/tab.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/tab.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/tooltip.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/tooltip.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/tooltip.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/tooltip.js diff --git a/apache-tapestry/src/main/webapp/mybootstrap/js/transition.js b/web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/transition.js similarity index 100% rename from apache-tapestry/src/main/webapp/mybootstrap/js/transition.js rename to web-modules/apache-tapestry/src/main/webapp/mybootstrap/js/transition.js diff --git a/apache-tapestry/src/site/apt/index.apt b/web-modules/apache-tapestry/src/site/apt/index.apt similarity index 100% rename from apache-tapestry/src/site/apt/index.apt rename to web-modules/apache-tapestry/src/site/apt/index.apt diff --git a/apache-tapestry/src/site/site.xml b/web-modules/apache-tapestry/src/site/site.xml similarity index 100% rename from apache-tapestry/src/site/site.xml rename to web-modules/apache-tapestry/src/site/site.xml diff --git a/apache-tapestry/src/test/conf/testng.xml b/web-modules/apache-tapestry/src/test/conf/testng.xml similarity index 100% rename from apache-tapestry/src/test/conf/testng.xml rename to web-modules/apache-tapestry/src/test/conf/testng.xml diff --git a/apache-tapestry/src/test/conf/webdefault.xml b/web-modules/apache-tapestry/src/test/conf/webdefault.xml similarity index 100% rename from apache-tapestry/src/test/conf/webdefault.xml rename to web-modules/apache-tapestry/src/test/conf/webdefault.xml diff --git a/blade/README.md b/web-modules/blade/README.md similarity index 100% rename from blade/README.md rename to web-modules/blade/README.md diff --git a/blade/pom.xml b/web-modules/blade/pom.xml similarity index 97% rename from blade/pom.xml rename to web-modules/blade/pom.xml index 9c8638f0bc..0733556c20 100644 --- a/blade/pom.xml +++ b/web-modules/blade/pom.xml @@ -8,7 +8,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT @@ -109,7 +109,6 @@ 2.0.14.RELEASE 4.2.1 - 1.18.4 4.5.6 4.5.6 4.4.10 diff --git a/blade/src/main/java/com/baeldung/blade/sample/App.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/App.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/App.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/App.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/AttributesExampleController.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/AttributesExampleController.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/AttributesExampleController.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/AttributesExampleController.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/LogExampleController.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/LogExampleController.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/LogExampleController.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/LogExampleController.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/ParameterInjectionExampleController.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/ParameterInjectionExampleController.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/ParameterInjectionExampleController.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/ParameterInjectionExampleController.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/RouteExampleController.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/RouteExampleController.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/RouteExampleController.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/RouteExampleController.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/configuration/BaeldungException.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/BaeldungException.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/configuration/BaeldungException.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/BaeldungException.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/configuration/GlobalExceptionHandler.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/GlobalExceptionHandler.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/configuration/GlobalExceptionHandler.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/GlobalExceptionHandler.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/configuration/LoadConfig.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/LoadConfig.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/configuration/LoadConfig.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/LoadConfig.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/configuration/ScheduleExample.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/ScheduleExample.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/configuration/ScheduleExample.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/ScheduleExample.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungHook.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungHook.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungHook.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungHook.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungMiddleware.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungMiddleware.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungMiddleware.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungMiddleware.java diff --git a/blade/src/main/java/com/baeldung/blade/sample/vo/User.java b/web-modules/blade/src/main/java/com/baeldung/blade/sample/vo/User.java similarity index 100% rename from blade/src/main/java/com/baeldung/blade/sample/vo/User.java rename to web-modules/blade/src/main/java/com/baeldung/blade/sample/vo/User.java diff --git a/blade/src/main/resources/application.properties b/web-modules/blade/src/main/resources/application.properties similarity index 100% rename from blade/src/main/resources/application.properties rename to web-modules/blade/src/main/resources/application.properties diff --git a/blade/src/main/resources/custom-static/icon.png b/web-modules/blade/src/main/resources/custom-static/icon.png similarity index 100% rename from blade/src/main/resources/custom-static/icon.png rename to web-modules/blade/src/main/resources/custom-static/icon.png diff --git a/blade/src/main/resources/favicon.ico b/web-modules/blade/src/main/resources/favicon.ico similarity index 100% rename from blade/src/main/resources/favicon.ico rename to web-modules/blade/src/main/resources/favicon.ico diff --git a/blade/src/main/resources/static/app.css b/web-modules/blade/src/main/resources/static/app.css similarity index 100% rename from blade/src/main/resources/static/app.css rename to web-modules/blade/src/main/resources/static/app.css diff --git a/blade/src/main/resources/static/app.js b/web-modules/blade/src/main/resources/static/app.js similarity index 100% rename from blade/src/main/resources/static/app.js rename to web-modules/blade/src/main/resources/static/app.js diff --git a/blade/src/main/resources/static/file-upload.html b/web-modules/blade/src/main/resources/static/file-upload.html similarity index 100% rename from blade/src/main/resources/static/file-upload.html rename to web-modules/blade/src/main/resources/static/file-upload.html diff --git a/blade/src/main/resources/static/user-post.html b/web-modules/blade/src/main/resources/static/user-post.html similarity index 100% rename from blade/src/main/resources/static/user-post.html rename to web-modules/blade/src/main/resources/static/user-post.html diff --git a/blade/src/main/resources/templates/allmatch.html b/web-modules/blade/src/main/resources/templates/allmatch.html similarity index 100% rename from blade/src/main/resources/templates/allmatch.html rename to web-modules/blade/src/main/resources/templates/allmatch.html diff --git a/blade/src/main/resources/templates/delete.html b/web-modules/blade/src/main/resources/templates/delete.html similarity index 100% rename from blade/src/main/resources/templates/delete.html rename to web-modules/blade/src/main/resources/templates/delete.html diff --git a/blade/src/main/resources/templates/get.html b/web-modules/blade/src/main/resources/templates/get.html similarity index 100% rename from blade/src/main/resources/templates/get.html rename to web-modules/blade/src/main/resources/templates/get.html diff --git a/blade/src/main/resources/templates/index.html b/web-modules/blade/src/main/resources/templates/index.html similarity index 100% rename from blade/src/main/resources/templates/index.html rename to web-modules/blade/src/main/resources/templates/index.html diff --git a/blade/src/main/resources/templates/my-404.html b/web-modules/blade/src/main/resources/templates/my-404.html similarity index 100% rename from blade/src/main/resources/templates/my-404.html rename to web-modules/blade/src/main/resources/templates/my-404.html diff --git a/blade/src/main/resources/templates/my-500.html b/web-modules/blade/src/main/resources/templates/my-500.html similarity index 100% rename from blade/src/main/resources/templates/my-500.html rename to web-modules/blade/src/main/resources/templates/my-500.html diff --git a/blade/src/main/resources/templates/post.html b/web-modules/blade/src/main/resources/templates/post.html similarity index 100% rename from blade/src/main/resources/templates/post.html rename to web-modules/blade/src/main/resources/templates/post.html diff --git a/blade/src/main/resources/templates/put.html b/web-modules/blade/src/main/resources/templates/put.html similarity index 100% rename from blade/src/main/resources/templates/put.html rename to web-modules/blade/src/main/resources/templates/put.html diff --git a/blade/src/main/resources/templates/template-output-test.html b/web-modules/blade/src/main/resources/templates/template-output-test.html similarity index 100% rename from blade/src/main/resources/templates/template-output-test.html rename to web-modules/blade/src/main/resources/templates/template-output-test.html diff --git a/blade/src/test/java/com/baeldung/blade/sample/AppLiveTest.java b/web-modules/blade/src/test/java/com/baeldung/blade/sample/AppLiveTest.java similarity index 100% rename from blade/src/test/java/com/baeldung/blade/sample/AppLiveTest.java rename to web-modules/blade/src/test/java/com/baeldung/blade/sample/AppLiveTest.java diff --git a/blade/src/test/java/com/baeldung/blade/sample/AttributesExampleControllerLiveTest.java b/web-modules/blade/src/test/java/com/baeldung/blade/sample/AttributesExampleControllerLiveTest.java similarity index 100% rename from blade/src/test/java/com/baeldung/blade/sample/AttributesExampleControllerLiveTest.java rename to web-modules/blade/src/test/java/com/baeldung/blade/sample/AttributesExampleControllerLiveTest.java diff --git a/blade/src/test/java/com/baeldung/blade/sample/ParameterInjectionExampleControllerLiveTest.java b/web-modules/blade/src/test/java/com/baeldung/blade/sample/ParameterInjectionExampleControllerLiveTest.java similarity index 100% rename from blade/src/test/java/com/baeldung/blade/sample/ParameterInjectionExampleControllerLiveTest.java rename to web-modules/blade/src/test/java/com/baeldung/blade/sample/ParameterInjectionExampleControllerLiveTest.java diff --git a/blade/src/test/java/com/baeldung/blade/sample/RouteExampleControllerLiveTest.java b/web-modules/blade/src/test/java/com/baeldung/blade/sample/RouteExampleControllerLiveTest.java similarity index 100% rename from blade/src/test/java/com/baeldung/blade/sample/RouteExampleControllerLiveTest.java rename to web-modules/blade/src/test/java/com/baeldung/blade/sample/RouteExampleControllerLiveTest.java diff --git a/bootique/README.md b/web-modules/bootique/README.md similarity index 100% rename from bootique/README.md rename to web-modules/bootique/README.md diff --git a/bootique/config.yml b/web-modules/bootique/config.yml similarity index 100% rename from bootique/config.yml rename to web-modules/bootique/config.yml diff --git a/bootique/pom.xml b/web-modules/bootique/pom.xml similarity index 97% rename from bootique/pom.xml rename to web-modules/bootique/pom.xml index 34fc75a5c0..d06f835889 100644 --- a/bootique/pom.xml +++ b/web-modules/bootique/pom.xml @@ -12,7 +12,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/bootique/src/main/java/com/baeldung/bootique/App.java b/web-modules/bootique/src/main/java/com/baeldung/bootique/App.java similarity index 100% rename from bootique/src/main/java/com/baeldung/bootique/App.java rename to web-modules/bootique/src/main/java/com/baeldung/bootique/App.java diff --git a/bootique/src/main/java/com/baeldung/bootique/module/ModuleBinder.java b/web-modules/bootique/src/main/java/com/baeldung/bootique/module/ModuleBinder.java similarity index 100% rename from bootique/src/main/java/com/baeldung/bootique/module/ModuleBinder.java rename to web-modules/bootique/src/main/java/com/baeldung/bootique/module/ModuleBinder.java diff --git a/bootique/src/main/java/com/baeldung/bootique/module/ModuleProvider.java b/web-modules/bootique/src/main/java/com/baeldung/bootique/module/ModuleProvider.java similarity index 100% rename from bootique/src/main/java/com/baeldung/bootique/module/ModuleProvider.java rename to web-modules/bootique/src/main/java/com/baeldung/bootique/module/ModuleProvider.java diff --git a/bootique/src/main/java/com/baeldung/bootique/router/IndexController.java b/web-modules/bootique/src/main/java/com/baeldung/bootique/router/IndexController.java similarity index 100% rename from bootique/src/main/java/com/baeldung/bootique/router/IndexController.java rename to web-modules/bootique/src/main/java/com/baeldung/bootique/router/IndexController.java diff --git a/bootique/src/main/java/com/baeldung/bootique/router/SaveController.java b/web-modules/bootique/src/main/java/com/baeldung/bootique/router/SaveController.java similarity index 100% rename from bootique/src/main/java/com/baeldung/bootique/router/SaveController.java rename to web-modules/bootique/src/main/java/com/baeldung/bootique/router/SaveController.java diff --git a/bootique/src/main/java/com/baeldung/bootique/service/HelloService.java b/web-modules/bootique/src/main/java/com/baeldung/bootique/service/HelloService.java similarity index 100% rename from bootique/src/main/java/com/baeldung/bootique/service/HelloService.java rename to web-modules/bootique/src/main/java/com/baeldung/bootique/service/HelloService.java diff --git a/bootique/src/main/java/com/baeldung/bootique/service/impl/HelloServiceImpl.java b/web-modules/bootique/src/main/java/com/baeldung/bootique/service/impl/HelloServiceImpl.java similarity index 100% rename from bootique/src/main/java/com/baeldung/bootique/service/impl/HelloServiceImpl.java rename to web-modules/bootique/src/main/java/com/baeldung/bootique/service/impl/HelloServiceImpl.java diff --git a/bootique/src/main/resources/META-INF/services/io.bootique.BQModuleProvider b/web-modules/bootique/src/main/resources/META-INF/services/io.bootique.BQModuleProvider similarity index 100% rename from bootique/src/main/resources/META-INF/services/io.bootique.BQModuleProvider rename to web-modules/bootique/src/main/resources/META-INF/services/io.bootique.BQModuleProvider diff --git a/linkrest/src/main/resources/logback.xml b/web-modules/bootique/src/main/resources/logback.xml similarity index 100% rename from linkrest/src/main/resources/logback.xml rename to web-modules/bootique/src/main/resources/logback.xml diff --git a/bootique/src/test/java/com/baeldung/bootique/AppUnitTest.java b/web-modules/bootique/src/test/java/com/baeldung/bootique/AppUnitTest.java similarity index 100% rename from bootique/src/test/java/com/baeldung/bootique/AppUnitTest.java rename to web-modules/bootique/src/test/java/com/baeldung/bootique/AppUnitTest.java diff --git a/dropwizard/README.md b/web-modules/dropwizard/README.md similarity index 100% rename from dropwizard/README.md rename to web-modules/dropwizard/README.md diff --git a/dropwizard/pom.xml b/web-modules/dropwizard/pom.xml similarity index 98% rename from dropwizard/pom.xml rename to web-modules/dropwizard/pom.xml index 36f2ec43f0..999aa5c805 100644 --- a/dropwizard/pom.xml +++ b/web-modules/dropwizard/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/IntroductionApplication.java b/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/IntroductionApplication.java similarity index 100% rename from dropwizard/src/main/java/com/baeldung/dropwizard/introduction/IntroductionApplication.java rename to web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/IntroductionApplication.java diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/ApplicationHealthCheck.java b/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/ApplicationHealthCheck.java similarity index 100% rename from dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/ApplicationHealthCheck.java rename to web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/ApplicationHealthCheck.java diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/BasicConfiguration.java b/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/BasicConfiguration.java similarity index 100% rename from dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/BasicConfiguration.java rename to web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/BasicConfiguration.java diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/domain/Brand.java b/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/domain/Brand.java similarity index 100% rename from dropwizard/src/main/java/com/baeldung/dropwizard/introduction/domain/Brand.java rename to web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/domain/Brand.java diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/repository/BrandRepository.java b/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/repository/BrandRepository.java similarity index 100% rename from dropwizard/src/main/java/com/baeldung/dropwizard/introduction/repository/BrandRepository.java rename to web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/repository/BrandRepository.java diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/resource/BrandResource.java b/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/resource/BrandResource.java similarity index 100% rename from dropwizard/src/main/java/com/baeldung/dropwizard/introduction/resource/BrandResource.java rename to web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/resource/BrandResource.java diff --git a/dropwizard/src/main/resources/introduction-config.yml b/web-modules/dropwizard/src/main/resources/introduction-config.yml similarity index 100% rename from dropwizard/src/main/resources/introduction-config.yml rename to web-modules/dropwizard/src/main/resources/introduction-config.yml diff --git a/dropwizard/src/test/java/com/baeldung/dropwizard/introduction/repository/BrandRepositoryUnitTest.java b/web-modules/dropwizard/src/test/java/com/baeldung/dropwizard/introduction/repository/BrandRepositoryUnitTest.java similarity index 100% rename from dropwizard/src/test/java/com/baeldung/dropwizard/introduction/repository/BrandRepositoryUnitTest.java rename to web-modules/dropwizard/src/test/java/com/baeldung/dropwizard/introduction/repository/BrandRepositoryUnitTest.java diff --git a/google-web-toolkit/README.md b/web-modules/google-web-toolkit/README.md similarity index 100% rename from google-web-toolkit/README.md rename to web-modules/google-web-toolkit/README.md diff --git a/google-web-toolkit/pom.xml b/web-modules/google-web-toolkit/pom.xml similarity index 98% rename from google-web-toolkit/pom.xml rename to web-modules/google-web-toolkit/pom.xml index bcccc136a4..2d5a1fa324 100644 --- a/google-web-toolkit/pom.xml +++ b/web-modules/google-web-toolkit/pom.xml @@ -11,7 +11,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/google-web-toolkit/src/main/java/com/baeldung/Google_web_toolkit.gwt.xml b/web-modules/google-web-toolkit/src/main/java/com/baeldung/Google_web_toolkit.gwt.xml similarity index 100% rename from google-web-toolkit/src/main/java/com/baeldung/Google_web_toolkit.gwt.xml rename to web-modules/google-web-toolkit/src/main/java/com/baeldung/Google_web_toolkit.gwt.xml diff --git a/google-web-toolkit/src/main/java/com/baeldung/client/Google_web_toolkit.java b/web-modules/google-web-toolkit/src/main/java/com/baeldung/client/Google_web_toolkit.java similarity index 100% rename from google-web-toolkit/src/main/java/com/baeldung/client/Google_web_toolkit.java rename to web-modules/google-web-toolkit/src/main/java/com/baeldung/client/Google_web_toolkit.java diff --git a/google-web-toolkit/src/main/java/com/baeldung/server/MessageServiceImpl.java b/web-modules/google-web-toolkit/src/main/java/com/baeldung/server/MessageServiceImpl.java similarity index 100% rename from google-web-toolkit/src/main/java/com/baeldung/server/MessageServiceImpl.java rename to web-modules/google-web-toolkit/src/main/java/com/baeldung/server/MessageServiceImpl.java diff --git a/google-web-toolkit/src/main/java/com/baeldung/shared/MessageService.java b/web-modules/google-web-toolkit/src/main/java/com/baeldung/shared/MessageService.java similarity index 100% rename from google-web-toolkit/src/main/java/com/baeldung/shared/MessageService.java rename to web-modules/google-web-toolkit/src/main/java/com/baeldung/shared/MessageService.java diff --git a/google-web-toolkit/src/main/java/com/baeldung/shared/MessageServiceAsync.java b/web-modules/google-web-toolkit/src/main/java/com/baeldung/shared/MessageServiceAsync.java similarity index 100% rename from google-web-toolkit/src/main/java/com/baeldung/shared/MessageServiceAsync.java rename to web-modules/google-web-toolkit/src/main/java/com/baeldung/shared/MessageServiceAsync.java diff --git a/microprofile/src/main/resources/logback.xml b/web-modules/google-web-toolkit/src/main/resources/logback.xml similarity index 100% rename from microprofile/src/main/resources/logback.xml rename to web-modules/google-web-toolkit/src/main/resources/logback.xml diff --git a/google-web-toolkit/src/main/webapp/Google_web_toolkit.css b/web-modules/google-web-toolkit/src/main/webapp/Google_web_toolkit.css similarity index 100% rename from google-web-toolkit/src/main/webapp/Google_web_toolkit.css rename to web-modules/google-web-toolkit/src/main/webapp/Google_web_toolkit.css diff --git a/google-web-toolkit/src/main/webapp/Google_web_toolkit.html b/web-modules/google-web-toolkit/src/main/webapp/Google_web_toolkit.html similarity index 100% rename from google-web-toolkit/src/main/webapp/Google_web_toolkit.html rename to web-modules/google-web-toolkit/src/main/webapp/Google_web_toolkit.html diff --git a/google-web-toolkit/src/main/webapp/WEB-INF/web.xml b/web-modules/google-web-toolkit/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from google-web-toolkit/src/main/webapp/WEB-INF/web.xml rename to web-modules/google-web-toolkit/src/main/webapp/WEB-INF/web.xml diff --git a/google-web-toolkit/src/main/webapp/favicon.ico b/web-modules/google-web-toolkit/src/main/webapp/favicon.ico similarity index 100% rename from google-web-toolkit/src/main/webapp/favicon.ico rename to web-modules/google-web-toolkit/src/main/webapp/favicon.ico diff --git a/jakarta-ee/README.md b/web-modules/jakarta-ee/README.md similarity index 100% rename from jakarta-ee/README.md rename to web-modules/jakarta-ee/README.md diff --git a/jakarta-ee/pom.xml b/web-modules/jakarta-ee/pom.xml similarity index 100% rename from jakarta-ee/pom.xml rename to web-modules/jakarta-ee/pom.xml diff --git a/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/User.java b/web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/User.java similarity index 100% rename from jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/User.java rename to web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/User.java diff --git a/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserApplication.java b/web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserApplication.java similarity index 100% rename from jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserApplication.java rename to web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserApplication.java diff --git a/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserController.java b/web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserController.java similarity index 100% rename from jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserController.java rename to web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserController.java diff --git a/jakarta-ee/src/main/webapp/WEB-INF/beans.xml b/web-modules/jakarta-ee/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from jakarta-ee/src/main/webapp/WEB-INF/beans.xml rename to web-modules/jakarta-ee/src/main/webapp/WEB-INF/beans.xml diff --git a/jakarta-ee/src/main/webapp/WEB-INF/views/success.jsp b/web-modules/jakarta-ee/src/main/webapp/WEB-INF/views/success.jsp similarity index 100% rename from jakarta-ee/src/main/webapp/WEB-INF/views/success.jsp rename to web-modules/jakarta-ee/src/main/webapp/WEB-INF/views/success.jsp diff --git a/jakarta-ee/src/main/webapp/WEB-INF/views/user.jsp b/web-modules/jakarta-ee/src/main/webapp/WEB-INF/views/user.jsp similarity index 100% rename from jakarta-ee/src/main/webapp/WEB-INF/views/user.jsp rename to web-modules/jakarta-ee/src/main/webapp/WEB-INF/views/user.jsp diff --git a/jakarta-ee/src/main/webapp/styles.css b/web-modules/jakarta-ee/src/main/webapp/styles.css similarity index 100% rename from jakarta-ee/src/main/webapp/styles.css rename to web-modules/jakarta-ee/src/main/webapp/styles.css diff --git a/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/AppTest.java b/web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/AppTest.java similarity index 100% rename from jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/AppTest.java rename to web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/AppTest.java diff --git a/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/UserControllerUnitTest.java b/web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/UserControllerUnitTest.java similarity index 100% rename from jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/UserControllerUnitTest.java rename to web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/UserControllerUnitTest.java diff --git a/java-lite/README.md b/web-modules/java-lite/README.md similarity index 100% rename from java-lite/README.md rename to web-modules/java-lite/README.md diff --git a/java-lite/pom.xml b/web-modules/java-lite/pom.xml similarity index 98% rename from java-lite/pom.xml rename to web-modules/java-lite/pom.xml index 092063a110..0e44e72b09 100644 --- a/java-lite/pom.xml +++ b/web-modules/java-lite/pom.xml @@ -11,7 +11,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/java-lite/src/main/java/app/config/AppBootstrap.java b/web-modules/java-lite/src/main/java/app/config/AppBootstrap.java similarity index 100% rename from java-lite/src/main/java/app/config/AppBootstrap.java rename to web-modules/java-lite/src/main/java/app/config/AppBootstrap.java diff --git a/java-lite/src/main/java/app/config/AppControllerConfig.java b/web-modules/java-lite/src/main/java/app/config/AppControllerConfig.java similarity index 100% rename from java-lite/src/main/java/app/config/AppControllerConfig.java rename to web-modules/java-lite/src/main/java/app/config/AppControllerConfig.java diff --git a/java-lite/src/main/java/app/config/DbConfig.java b/web-modules/java-lite/src/main/java/app/config/DbConfig.java similarity index 100% rename from java-lite/src/main/java/app/config/DbConfig.java rename to web-modules/java-lite/src/main/java/app/config/DbConfig.java diff --git a/java-lite/src/main/java/app/controllers/ArticleController.java b/web-modules/java-lite/src/main/java/app/controllers/ArticleController.java old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/java/app/controllers/ArticleController.java rename to web-modules/java-lite/src/main/java/app/controllers/ArticleController.java diff --git a/java-lite/src/main/java/app/controllers/HomeController.java b/web-modules/java-lite/src/main/java/app/controllers/HomeController.java old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/java/app/controllers/HomeController.java rename to web-modules/java-lite/src/main/java/app/controllers/HomeController.java diff --git a/java-lite/src/main/java/app/controllers/ProductsController.java b/web-modules/java-lite/src/main/java/app/controllers/ProductsController.java similarity index 100% rename from java-lite/src/main/java/app/controllers/ProductsController.java rename to web-modules/java-lite/src/main/java/app/controllers/ProductsController.java diff --git a/java-lite/src/main/java/app/models/Article.java b/web-modules/java-lite/src/main/java/app/models/Article.java old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/java/app/models/Article.java rename to web-modules/java-lite/src/main/java/app/models/Article.java diff --git a/java-lite/src/main/java/app/models/Product.java b/web-modules/java-lite/src/main/java/app/models/Product.java similarity index 100% rename from java-lite/src/main/java/app/models/Product.java rename to web-modules/java-lite/src/main/java/app/models/Product.java diff --git a/java-lite/src/main/java/app/services/ArticleService.java b/web-modules/java-lite/src/main/java/app/services/ArticleService.java old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/java/app/services/ArticleService.java rename to web-modules/java-lite/src/main/java/app/services/ArticleService.java diff --git a/java-lite/src/main/java/app/services/ArticleServiceImpl.java b/web-modules/java-lite/src/main/java/app/services/ArticleServiceImpl.java old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/java/app/services/ArticleServiceImpl.java rename to web-modules/java-lite/src/main/java/app/services/ArticleServiceImpl.java diff --git a/java-lite/src/main/java/app/services/ArticleServiceModule.java b/web-modules/java-lite/src/main/java/app/services/ArticleServiceModule.java old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/java/app/services/ArticleServiceModule.java rename to web-modules/java-lite/src/main/java/app/services/ArticleServiceModule.java diff --git a/java-lite/src/main/resources/database.properties b/web-modules/java-lite/src/main/resources/database.properties similarity index 100% rename from java-lite/src/main/resources/database.properties rename to web-modules/java-lite/src/main/resources/database.properties diff --git a/msf4j/src/main/resources/logback.xml b/web-modules/java-lite/src/main/resources/logback.xml similarity index 100% rename from msf4j/src/main/resources/logback.xml rename to web-modules/java-lite/src/main/resources/logback.xml diff --git a/java-lite/src/main/webapp/WEB-INF/views/article/index.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/article/index.ftl old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/views/article/index.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/article/index.ftl diff --git a/java-lite/src/main/webapp/WEB-INF/views/article/search.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/article/search.ftl old mode 100755 new mode 100644 similarity index 95% rename from java-lite/src/main/webapp/WEB-INF/views/article/search.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/article/search.ftl index 45a73808ed..540bbaf857 --- a/java-lite/src/main/webapp/WEB-INF/views/article/search.ftl +++ b/web-modules/java-lite/src/main/webapp/WEB-INF/views/article/search.ftl @@ -1,17 +1,17 @@ -<@content for="title">Search - - - - - - - - - - - - - - - +<@content for="title">Search + +
TitleAuthorWords #Date Published
${article.title}${article.author}${article.words}${article.date}
+ + + + + + + + + + + + +
TitleAuthorWords #Date Published
${article.title}${article.author}${article.words}${article.date}
\ No newline at end of file diff --git a/java-lite/src/main/webapp/WEB-INF/views/common/error.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/common/error.ftl old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/views/common/error.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/common/error.ftl diff --git a/java-lite/src/main/webapp/WEB-INF/views/home/index.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/home/index.ftl old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/views/home/index.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/home/index.ftl diff --git a/java-lite/src/main/webapp/WEB-INF/views/layouts/default_layout.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/layouts/default_layout.ftl old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/views/layouts/default_layout.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/layouts/default_layout.ftl diff --git a/java-lite/src/main/webapp/WEB-INF/views/layouts/footer.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/layouts/footer.ftl old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/views/layouts/footer.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/layouts/footer.ftl diff --git a/java-lite/src/main/webapp/WEB-INF/views/layouts/header.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/layouts/header.ftl old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/views/layouts/header.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/layouts/header.ftl diff --git a/java-lite/src/main/webapp/WEB-INF/views/products/_comma.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/products/_comma.ftl similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/views/products/_comma.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/products/_comma.ftl diff --git a/java-lite/src/main/webapp/WEB-INF/views/products/_product.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/products/_product.ftl similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/views/products/_product.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/products/_product.ftl diff --git a/java-lite/src/main/webapp/WEB-INF/views/products/index.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/products/index.ftl similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/views/products/index.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/products/index.ftl diff --git a/java-lite/src/main/webapp/WEB-INF/views/products/message.ftl b/web-modules/java-lite/src/main/webapp/WEB-INF/views/products/message.ftl similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/views/products/message.ftl rename to web-modules/java-lite/src/main/webapp/WEB-INF/views/products/message.ftl diff --git a/java-lite/src/main/webapp/WEB-INF/web.xml b/web-modules/java-lite/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from java-lite/src/main/webapp/WEB-INF/web.xml rename to web-modules/java-lite/src/main/webapp/WEB-INF/web.xml diff --git a/java-lite/src/test/java/app/controllers/ArticleControllerSpec.java b/web-modules/java-lite/src/test/java/app/controllers/ArticleControllerSpec.java old mode 100755 new mode 100644 similarity index 100% rename from java-lite/src/test/java/app/controllers/ArticleControllerSpec.java rename to web-modules/java-lite/src/test/java/app/controllers/ArticleControllerSpec.java diff --git a/java-lite/src/test/java/app/models/ProductUnitTest.java b/web-modules/java-lite/src/test/java/app/models/ProductUnitTest.java similarity index 100% rename from java-lite/src/test/java/app/models/ProductUnitTest.java rename to web-modules/java-lite/src/test/java/app/models/ProductUnitTest.java diff --git a/javax-servlets-2/README.md b/web-modules/javax-servlets-2/README.md similarity index 100% rename from javax-servlets-2/README.md rename to web-modules/javax-servlets-2/README.md diff --git a/javax-servlets-2/pom.xml b/web-modules/javax-servlets-2/pom.xml similarity index 98% rename from javax-servlets-2/pom.xml rename to web-modules/javax-servlets-2/pom.xml index 5fa1e76e0b..1c008ceb9a 100644 --- a/javax-servlets-2/pom.xml +++ b/web-modules/javax-servlets-2/pom.xml @@ -11,7 +11,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/javax-servlets-2/src/main/java/com/baeldung/servlets/UserServlet.java b/web-modules/javax-servlets-2/src/main/java/com/baeldung/servlets/UserServlet.java similarity index 100% rename from javax-servlets-2/src/main/java/com/baeldung/servlets/UserServlet.java rename to web-modules/javax-servlets-2/src/main/java/com/baeldung/servlets/UserServlet.java diff --git a/javax-servlets-2/src/main/java/com/baeldung/user/check/User.java b/web-modules/javax-servlets-2/src/main/java/com/baeldung/user/check/User.java similarity index 100% rename from javax-servlets-2/src/main/java/com/baeldung/user/check/User.java rename to web-modules/javax-servlets-2/src/main/java/com/baeldung/user/check/User.java diff --git a/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckFilter.java b/web-modules/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckFilter.java similarity index 100% rename from javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckFilter.java rename to web-modules/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckFilter.java diff --git a/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckLoginServlet.java b/web-modules/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckLoginServlet.java similarity index 100% rename from javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckLoginServlet.java rename to web-modules/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckLoginServlet.java diff --git a/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckLogoutServlet.java b/web-modules/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckLogoutServlet.java similarity index 100% rename from javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckLogoutServlet.java rename to web-modules/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckLogoutServlet.java diff --git a/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckServlet.java b/web-modules/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckServlet.java similarity index 100% rename from javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckServlet.java rename to web-modules/javax-servlets-2/src/main/java/com/baeldung/user/check/UserCheckServlet.java diff --git a/ratpack/src/main/resources/logback.xml b/web-modules/javax-servlets-2/src/main/resources/logback.xml similarity index 100% rename from ratpack/src/main/resources/logback.xml rename to web-modules/javax-servlets-2/src/main/resources/logback.xml diff --git a/javax-servlets-2/src/main/webapp/WEB-INF/user.check/home.jsp b/web-modules/javax-servlets-2/src/main/webapp/WEB-INF/user.check/home.jsp similarity index 100% rename from javax-servlets-2/src/main/webapp/WEB-INF/user.check/home.jsp rename to web-modules/javax-servlets-2/src/main/webapp/WEB-INF/user.check/home.jsp diff --git a/javax-servlets-2/src/main/webapp/WEB-INF/user.check/login.jsp b/web-modules/javax-servlets-2/src/main/webapp/WEB-INF/user.check/login.jsp similarity index 100% rename from javax-servlets-2/src/main/webapp/WEB-INF/user.check/login.jsp rename to web-modules/javax-servlets-2/src/main/webapp/WEB-INF/user.check/login.jsp diff --git a/javax-servlets-2/src/test/java/com/baeldung/servlets/TestUtil.java b/web-modules/javax-servlets-2/src/test/java/com/baeldung/servlets/TestUtil.java similarity index 100% rename from javax-servlets-2/src/test/java/com/baeldung/servlets/TestUtil.java rename to web-modules/javax-servlets-2/src/test/java/com/baeldung/servlets/TestUtil.java diff --git a/javax-servlets-2/src/test/java/com/baeldung/servlets/UserServletUnitTest.java b/web-modules/javax-servlets-2/src/test/java/com/baeldung/servlets/UserServletUnitTest.java similarity index 100% rename from javax-servlets-2/src/test/java/com/baeldung/servlets/UserServletUnitTest.java rename to web-modules/javax-servlets-2/src/test/java/com/baeldung/servlets/UserServletUnitTest.java diff --git a/javax-servlets-2/src/test/java/com/baeldung/user/check/UserCheckServletLiveTest.java b/web-modules/javax-servlets-2/src/test/java/com/baeldung/user/check/UserCheckServletLiveTest.java similarity index 100% rename from javax-servlets-2/src/test/java/com/baeldung/user/check/UserCheckServletLiveTest.java rename to web-modules/javax-servlets-2/src/test/java/com/baeldung/user/check/UserCheckServletLiveTest.java diff --git a/javax-servlets/.gitignore b/web-modules/javax-servlets/.gitignore similarity index 100% rename from javax-servlets/.gitignore rename to web-modules/javax-servlets/.gitignore diff --git a/javax-servlets/README.md b/web-modules/javax-servlets/README.md similarity index 100% rename from javax-servlets/README.md rename to web-modules/javax-servlets/README.md diff --git a/javax-servlets/pom.xml b/web-modules/javax-servlets/pom.xml similarity index 97% rename from javax-servlets/pom.xml rename to web-modules/javax-servlets/pom.xml index 1dc58aa917..298c8562e4 100644 --- a/javax-servlets/pom.xml +++ b/web-modules/javax-servlets/pom.xml @@ -11,7 +11,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/javax-servlets/src/main/java/com/baeldung/Constants.java b/web-modules/javax-servlets/src/main/java/com/baeldung/Constants.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/Constants.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/Constants.java diff --git a/javax-servlets/src/main/java/com/baeldung/controller/StudentServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/controller/StudentServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/controller/StudentServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/controller/StudentServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/model/Employee.java b/web-modules/javax-servlets/src/main/java/com/baeldung/model/Employee.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/model/Employee.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/model/Employee.java diff --git a/javax-servlets/src/main/java/com/baeldung/model/Student.java b/web-modules/javax-servlets/src/main/java/com/baeldung/model/Student.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/model/Student.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/model/Student.java diff --git a/javax-servlets/src/main/java/com/baeldung/service/StudentService.java b/web-modules/javax-servlets/src/main/java/com/baeldung/service/StudentService.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/service/StudentService.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/service/StudentService.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/CookieReader.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/CookieReader.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/CookieReader.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/CookieReader.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/DownloadServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/DownloadServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/DownloadServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/DownloadServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/EmployeeServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/EmployeeServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/EmployeeServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/EmployeeServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/ErrorHandlerServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/ErrorHandlerServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/ErrorHandlerServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/ErrorHandlerServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/FormServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/FormServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/FormServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/FormServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/LoginServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/LoginServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/LoginServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/LoginServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/MainServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/MainServlet.java similarity index 96% rename from javax-servlets/src/main/java/com/baeldung/servlets/MainServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/MainServlet.java index 12c75444bb..198920cb23 100644 --- a/javax-servlets/src/main/java/com/baeldung/servlets/MainServlet.java +++ b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/MainServlet.java @@ -1,21 +1,21 @@ -package com.baeldung.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet("/main") -public class MainServlet extends HttpServlet { - - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - request.getRequestDispatcher("/WEB-INF/jsp/main.jsp").forward(request, response); - } - - - - -} +package com.baeldung.servlets; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet("/main") +public class MainServlet extends HttpServlet { + + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + request.getRequestDispatcher("/WEB-INF/jsp/main.jsp").forward(request, response); + } + + + + +} diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/MultipartServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/MultipartServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/MultipartServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/MultipartServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/MyHttpServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/MyHttpServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/MyHttpServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/MyHttpServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/RandomErrorServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/RandomErrorServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/RandomErrorServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/RandomErrorServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/UpdateServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UpdateServlet.java similarity index 96% rename from javax-servlets/src/main/java/com/baeldung/servlets/UpdateServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UpdateServlet.java index 721e3afe6b..8582a1ccef 100644 --- a/javax-servlets/src/main/java/com/baeldung/servlets/UpdateServlet.java +++ b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UpdateServlet.java @@ -1,31 +1,31 @@ -package com.baeldung.servlets; - -import java.io.IOException; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -@WebServlet("/update") -public class UpdateServlet extends HttpServlet { - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - HttpSession session = request.getSession(false); - - if (session != null) { - - session.setAttribute("userName", request.getParameter("userName")); - session.setAttribute("age", request.getParameter("age")); - - request.setAttribute("sessionData", session); - } - - request.getRequestDispatcher("/WEB-INF/jsp/update.jsp").forward(request, response); - } - -} +package com.baeldung.servlets; + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +@WebServlet("/update") +public class UpdateServlet extends HttpServlet { + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + HttpSession session = request.getSession(false); + + if (session != null) { + + session.setAttribute("userName", request.getParameter("userName")); + session.setAttribute("age", request.getParameter("age")); + + request.setAttribute("sessionData", session); + } + + request.getRequestDispatcher("/WEB-INF/jsp/update.jsp").forward(request, response); + } + +} diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/UploadServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UploadServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/UploadServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UploadServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/UploadWelcomeServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UploadWelcomeServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/UploadWelcomeServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UploadWelcomeServlet.java diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/UserLoginServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UserLoginServlet.java similarity index 96% rename from javax-servlets/src/main/java/com/baeldung/servlets/UserLoginServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UserLoginServlet.java index fd732ef89d..25ec6a8f59 100644 --- a/javax-servlets/src/main/java/com/baeldung/servlets/UserLoginServlet.java +++ b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UserLoginServlet.java @@ -1,28 +1,28 @@ -package com.baeldung.servlets; - - -import java.io.IOException; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -@WebServlet("/u_login") -public class UserLoginServlet extends HttpServlet { - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - HttpSession session = request.getSession(); - - session.setAttribute("userId", request.getParameter("userId")); - - request.setAttribute("id", session.getAttribute("userId")); - - request.getRequestDispatcher("/WEB-INF/jsp/userlogin.jsp").forward(request, response); - - } - -} +package com.baeldung.servlets; + + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +@WebServlet("/u_login") +public class UserLoginServlet extends HttpServlet { + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + HttpSession session = request.getSession(); + + session.setAttribute("userId", request.getParameter("userId")); + + request.setAttribute("id", session.getAttribute("userId")); + + request.getRequestDispatcher("/WEB-INF/jsp/userlogin.jsp").forward(request, response); + + } + +} diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/UserServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UserServlet.java similarity index 97% rename from javax-servlets/src/main/java/com/baeldung/servlets/UserServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UserServlet.java index 24f2500aa4..75977b0660 100644 --- a/javax-servlets/src/main/java/com/baeldung/servlets/UserServlet.java +++ b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/UserServlet.java @@ -1,49 +1,49 @@ -package com.baeldung.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebInitParam; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(name = "UserServlet", urlPatterns = "/userServlet", initParams={ - @WebInitParam(name="name", value="Not provided"), - @WebInitParam(name="email", value="Not provided")}) -public class UserServlet extends HttpServlet { - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - forwardRequest(request, response, "/WEB-INF/jsp/result.jsp"); - } - - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - } - - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - request.setAttribute("name", getRequestParameter(request, "name")); - request.setAttribute("email", getRequestParameter(request, "email")); - request.setAttribute("province", getContextParameter("province")); - request.setAttribute("country", getContextParameter("country")); - } - - protected String getRequestParameter(HttpServletRequest request, String name) { - String param = request.getParameter(name); - return !param.isEmpty() ? param : getInitParameter(name); - } - - protected String getContextParameter(String name) { - return getServletContext().getInitParameter(name); - } - - protected void forwardRequest(HttpServletRequest request, HttpServletResponse response, String path) - throws ServletException, IOException { - request.getRequestDispatcher(path).forward(request, response); - } +package com.baeldung.servlets; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebInitParam; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(name = "UserServlet", urlPatterns = "/userServlet", initParams={ + @WebInitParam(name="name", value="Not provided"), + @WebInitParam(name="email", value="Not provided")}) +public class UserServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + forwardRequest(request, response, "/WEB-INF/jsp/result.jsp"); + } + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + } + + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + request.setAttribute("name", getRequestParameter(request, "name")); + request.setAttribute("email", getRequestParameter(request, "email")); + request.setAttribute("province", getContextParameter("province")); + request.setAttribute("country", getContextParameter("country")); + } + + protected String getRequestParameter(HttpServletRequest request, String name) { + String param = request.getParameter(name); + return !param.isEmpty() ? param : getInitParameter(name); + } + + protected String getContextParameter(String name) { + return getServletContext().getInitParameter(name); + } + + protected void forwardRequest(HttpServletRequest request, HttpServletResponse response, String path) + throws ServletException, IOException { + request.getRequestDispatcher(path).forward(request, response); + } } \ No newline at end of file diff --git a/javax-servlets/src/main/java/com/baeldung/servlets/WelcomeServlet.java b/web-modules/javax-servlets/src/main/java/com/baeldung/servlets/WelcomeServlet.java similarity index 100% rename from javax-servlets/src/main/java/com/baeldung/servlets/WelcomeServlet.java rename to web-modules/javax-servlets/src/main/java/com/baeldung/servlets/WelcomeServlet.java diff --git a/resteasy/src/main/resources/logback.xml b/web-modules/javax-servlets/src/main/resources/logback.xml similarity index 100% rename from resteasy/src/main/resources/logback.xml rename to web-modules/javax-servlets/src/main/resources/logback.xml diff --git a/javax-servlets/src/main/webapp/WEB-INF/jsp/index.jsp b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/index.jsp similarity index 100% rename from javax-servlets/src/main/webapp/WEB-INF/jsp/index.jsp rename to web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/index.jsp diff --git a/javax-servlets/src/main/webapp/WEB-INF/jsp/login.jsp b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/login.jsp similarity index 100% rename from javax-servlets/src/main/webapp/WEB-INF/jsp/login.jsp rename to web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/login.jsp diff --git a/javax-servlets/src/main/webapp/WEB-INF/jsp/main.jsp b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/main.jsp similarity index 96% rename from javax-servlets/src/main/webapp/WEB-INF/jsp/main.jsp rename to web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/main.jsp index cbbb578770..313310a2a9 100644 --- a/javax-servlets/src/main/webapp/WEB-INF/jsp/main.jsp +++ b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/main.jsp @@ -1,15 +1,15 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - - - -
-

Enter your User Id and Password

- User ID:
- Password:
-
- +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + + + +
+

Enter your User Id and Password

+ User ID:
+ Password:
+
+ \ No newline at end of file diff --git a/javax-servlets/src/main/webapp/WEB-INF/jsp/result.jsp b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/result.jsp similarity index 100% rename from javax-servlets/src/main/webapp/WEB-INF/jsp/result.jsp rename to web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/result.jsp diff --git a/javax-servlets/src/main/webapp/WEB-INF/jsp/student-record.jsp b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/student-record.jsp similarity index 100% rename from javax-servlets/src/main/webapp/WEB-INF/jsp/student-record.jsp rename to web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/student-record.jsp diff --git a/javax-servlets/src/main/webapp/WEB-INF/jsp/update.jsp b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/update.jsp similarity index 96% rename from javax-servlets/src/main/webapp/WEB-INF/jsp/update.jsp rename to web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/update.jsp index 36ac2d277b..fae5ea2ac2 100644 --- a/javax-servlets/src/main/webapp/WEB-INF/jsp/update.jsp +++ b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/update.jsp @@ -1,17 +1,17 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - - - - - Hi, User : ${sessionData.getAttribute("userId")} - -
Your User Data has been updated as below : -
User Name: ${sessionData.getAttribute("userName")} -
Age : ${sessionData.getAttribute("age")} - - +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + + + + + Hi, User : ${sessionData.getAttribute("userId")} + +
Your User Data has been updated as below : +
User Name: ${sessionData.getAttribute("userName")} +
Age : ${sessionData.getAttribute("age")} + + \ No newline at end of file diff --git a/javax-servlets/src/main/webapp/WEB-INF/jsp/userlogin.jsp b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/userlogin.jsp similarity index 96% rename from javax-servlets/src/main/webapp/WEB-INF/jsp/userlogin.jsp rename to web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/userlogin.jsp index f181222f39..b2a550b811 100644 --- a/javax-servlets/src/main/webapp/WEB-INF/jsp/userlogin.jsp +++ b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/userlogin.jsp @@ -1,18 +1,18 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - - - -

Update your User Details:

- -
- User ID:
User Name: - Age:
-
- +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + + + +

Update your User Details:

+ +
+ User ID:
User Name: + Age:
+
+ \ No newline at end of file diff --git a/javax-servlets/src/main/webapp/WEB-INF/jsp/welcome.jsp b/web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/welcome.jsp similarity index 100% rename from javax-servlets/src/main/webapp/WEB-INF/jsp/welcome.jsp rename to web-modules/javax-servlets/src/main/webapp/WEB-INF/jsp/welcome.jsp diff --git a/javax-servlets/src/main/webapp/WEB-INF/sample.txt b/web-modules/javax-servlets/src/main/webapp/WEB-INF/sample.txt similarity index 100% rename from javax-servlets/src/main/webapp/WEB-INF/sample.txt rename to web-modules/javax-servlets/src/main/webapp/WEB-INF/sample.txt diff --git a/javax-servlets/src/main/webapp/WEB-INF/web.xml b/web-modules/javax-servlets/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from javax-servlets/src/main/webapp/WEB-INF/web.xml rename to web-modules/javax-servlets/src/main/webapp/WEB-INF/web.xml diff --git a/javax-servlets/src/main/webapp/error-404.html b/web-modules/javax-servlets/src/main/webapp/error-404.html similarity index 100% rename from javax-servlets/src/main/webapp/error-404.html rename to web-modules/javax-servlets/src/main/webapp/error-404.html diff --git a/javax-servlets/src/main/webapp/result.jsp b/web-modules/javax-servlets/src/main/webapp/result.jsp similarity index 100% rename from javax-servlets/src/main/webapp/result.jsp rename to web-modules/javax-servlets/src/main/webapp/result.jsp diff --git a/javax-servlets/src/main/webapp/upload.jsp b/web-modules/javax-servlets/src/main/webapp/upload.jsp similarity index 100% rename from javax-servlets/src/main/webapp/upload.jsp rename to web-modules/javax-servlets/src/main/webapp/upload.jsp diff --git a/javax-servlets/src/main/webapp/user.jsp b/web-modules/javax-servlets/src/main/webapp/user.jsp similarity index 100% rename from javax-servlets/src/main/webapp/user.jsp rename to web-modules/javax-servlets/src/main/webapp/user.jsp diff --git a/javax-servlets/src/test/java/com/baeldung/servlets/EmployeeServletIntegrationTest.java b/web-modules/javax-servlets/src/test/java/com/baeldung/servlets/EmployeeServletIntegrationTest.java similarity index 100% rename from javax-servlets/src/test/java/com/baeldung/servlets/EmployeeServletIntegrationTest.java rename to web-modules/javax-servlets/src/test/java/com/baeldung/servlets/EmployeeServletIntegrationTest.java diff --git a/javax-servlets/src/test/java/com/baeldung/test/FormServletLiveTest.java b/web-modules/javax-servlets/src/test/java/com/baeldung/test/FormServletLiveTest.java similarity index 100% rename from javax-servlets/src/test/java/com/baeldung/test/FormServletLiveTest.java rename to web-modules/javax-servlets/src/test/java/com/baeldung/test/FormServletLiveTest.java diff --git a/javax-servlets/src/test/java/com/baeldung/test/UserServletUnitTest.java b/web-modules/javax-servlets/src/test/java/com/baeldung/test/UserServletUnitTest.java similarity index 97% rename from javax-servlets/src/test/java/com/baeldung/test/UserServletUnitTest.java rename to web-modules/javax-servlets/src/test/java/com/baeldung/test/UserServletUnitTest.java index 6222e35f4b..ef3d877dd7 100644 --- a/javax-servlets/src/test/java/com/baeldung/test/UserServletUnitTest.java +++ b/web-modules/javax-servlets/src/test/java/com/baeldung/test/UserServletUnitTest.java @@ -1,52 +1,52 @@ -package com.baeldung.test; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class UserServletUnitTest { - - private static HttpServletRequest request; - private static HttpServletResponse response; - - - @BeforeClass - public static void setUpHttpServletRequestMockInstance() { - request = mock(HttpServletRequest.class); - } - - @BeforeClass - public static void setUpHttpServletResponsetMockInstance() { - response = mock(HttpServletResponse.class); - } - - @Test - public void givenHttpServletRequestMockInstance_whenCalledgetParameter_thenCalledAtLeastOnce() { - request.getParameter("name"); - verify(request, atLeast(1)).getParameter("name"); - } - - @Test - public void givenHttpServletRequestMockInstance_whenCalledgetParameter_thenOneAssertion() { - when(request.getParameter("name")).thenReturn("username"); - assertThat(request.getParameter("name")).isEqualTo("username"); - } - - @Test - public void givenHttpServletResponseMockInstance_whenCalledgetContentType_thenCalledAtLeastOnce() { - response.getContentType(); - verify(response, atLeast(1)).getContentType(); - } - - @Test - public void givenHttpServletResponseMockInstance_whenCalledgetContentType_thenOneAssertion() { - when(response.getContentType()).thenReturn("text/html"); - assertThat(response.getContentType()).isEqualTo("text/html"); - } +package com.baeldung.test; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class UserServletUnitTest { + + private static HttpServletRequest request; + private static HttpServletResponse response; + + + @BeforeClass + public static void setUpHttpServletRequestMockInstance() { + request = mock(HttpServletRequest.class); + } + + @BeforeClass + public static void setUpHttpServletResponsetMockInstance() { + response = mock(HttpServletResponse.class); + } + + @Test + public void givenHttpServletRequestMockInstance_whenCalledgetParameter_thenCalledAtLeastOnce() { + request.getParameter("name"); + verify(request, atLeast(1)).getParameter("name"); + } + + @Test + public void givenHttpServletRequestMockInstance_whenCalledgetParameter_thenOneAssertion() { + when(request.getParameter("name")).thenReturn("username"); + assertThat(request.getParameter("name")).isEqualTo("username"); + } + + @Test + public void givenHttpServletResponseMockInstance_whenCalledgetContentType_thenCalledAtLeastOnce() { + response.getContentType(); + verify(response, atLeast(1)).getContentType(); + } + + @Test + public void givenHttpServletResponseMockInstance_whenCalledgetContentType_thenOneAssertion() { + when(response.getContentType()).thenReturn("text/html"); + assertThat(response.getContentType()).isEqualTo("text/html"); + } } \ No newline at end of file diff --git a/jee-7/.gitignore b/web-modules/jee-7/.gitignore similarity index 100% rename from jee-7/.gitignore rename to web-modules/jee-7/.gitignore diff --git a/jee-7/README.md b/web-modules/jee-7/README.md similarity index 100% rename from jee-7/README.md rename to web-modules/jee-7/README.md diff --git a/jee-7/pom.xml b/web-modules/jee-7/pom.xml similarity index 99% rename from jee-7/pom.xml rename to web-modules/jee-7/pom.xml index eb23a3e150..08c8b2cc68 100644 --- a/jee-7/pom.xml +++ b/web-modules/jee-7/pom.xml @@ -11,7 +11,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/jee-7/src/main/java/com/baeldung/arquillian/CapsConvertor.java b/web-modules/jee-7/src/main/java/com/baeldung/arquillian/CapsConvertor.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/arquillian/CapsConvertor.java rename to web-modules/jee-7/src/main/java/com/baeldung/arquillian/CapsConvertor.java diff --git a/jee-7/src/main/java/com/baeldung/arquillian/CapsService.java b/web-modules/jee-7/src/main/java/com/baeldung/arquillian/CapsService.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/arquillian/CapsService.java rename to web-modules/jee-7/src/main/java/com/baeldung/arquillian/CapsService.java diff --git a/jee-7/src/main/java/com/baeldung/arquillian/Car.java b/web-modules/jee-7/src/main/java/com/baeldung/arquillian/Car.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/arquillian/Car.java rename to web-modules/jee-7/src/main/java/com/baeldung/arquillian/Car.java diff --git a/jee-7/src/main/java/com/baeldung/arquillian/CarEJB.java b/web-modules/jee-7/src/main/java/com/baeldung/arquillian/CarEJB.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/arquillian/CarEJB.java rename to web-modules/jee-7/src/main/java/com/baeldung/arquillian/CarEJB.java diff --git a/jee-7/src/main/java/com/baeldung/arquillian/Component.java b/web-modules/jee-7/src/main/java/com/baeldung/arquillian/Component.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/arquillian/Component.java rename to web-modules/jee-7/src/main/java/com/baeldung/arquillian/Component.java diff --git a/jee-7/src/main/java/com/baeldung/arquillian/ConvertToLowerCase.java b/web-modules/jee-7/src/main/java/com/baeldung/arquillian/ConvertToLowerCase.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/arquillian/ConvertToLowerCase.java rename to web-modules/jee-7/src/main/java/com/baeldung/arquillian/ConvertToLowerCase.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/ChunkExceptionSkipReadListener.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/ChunkExceptionSkipReadListener.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/ChunkExceptionSkipReadListener.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/ChunkExceptionSkipReadListener.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/CustomCheckPoint.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/CustomCheckPoint.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/CustomCheckPoint.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/CustomCheckPoint.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/DeciderJobSequence.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/DeciderJobSequence.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/DeciderJobSequence.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/DeciderJobSequence.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/InjectSimpleBatchLet.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/InjectSimpleBatchLet.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/InjectSimpleBatchLet.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/InjectSimpleBatchLet.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleBatchLet.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleBatchLet.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/SimpleBatchLet.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleBatchLet.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemProcessor.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemProcessor.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemProcessor.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemProcessor.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReader.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReader.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReader.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReader.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReaderError.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReaderError.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReaderError.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReaderError.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkWriter.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkWriter.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkWriter.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkWriter.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyInputRecord.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyInputRecord.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyInputRecord.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyInputRecord.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemProcessor.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemProcessor.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemProcessor.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemProcessor.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemReader.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemReader.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemReader.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemReader.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemWriter.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemWriter.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemWriter.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemWriter.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyOutputRecord.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyOutputRecord.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyOutputRecord.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyOutputRecord.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryProcessorListener.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryProcessorListener.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryProcessorListener.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryProcessorListener.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryReadListener.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryReadListener.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryReadListener.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryReadListener.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryWriteListener.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryWriteListener.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryWriteListener.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryWriteListener.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipProcessorListener.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipProcessorListener.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipProcessorListener.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipProcessorListener.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipReadListener.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipReadListener.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipReadListener.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipReadListener.java diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipWriteListener.java b/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipWriteListener.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipWriteListener.java rename to web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipWriteListener.java diff --git a/jee-7/src/main/java/com/baeldung/convListVal/ConvListVal.java b/web-modules/jee-7/src/main/java/com/baeldung/convListVal/ConvListVal.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/convListVal/ConvListVal.java rename to web-modules/jee-7/src/main/java/com/baeldung/convListVal/ConvListVal.java diff --git a/jee-7/src/main/java/com/baeldung/convListVal/MyListener.java b/web-modules/jee-7/src/main/java/com/baeldung/convListVal/MyListener.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/convListVal/MyListener.java rename to web-modules/jee-7/src/main/java/com/baeldung/convListVal/MyListener.java diff --git a/jee-7/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java b/web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java rename to web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java diff --git a/jee-7/src/main/java/com/baeldung/javaeeannotations/BankAppServletContextListener.java b/web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/BankAppServletContextListener.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/javaeeannotations/BankAppServletContextListener.java rename to web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/BankAppServletContextListener.java diff --git a/jee-7/src/main/java/com/baeldung/javaeeannotations/LogInFilter.java b/web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/LogInFilter.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/javaeeannotations/LogInFilter.java rename to web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/LogInFilter.java diff --git a/jee-7/src/main/java/com/baeldung/javaeeannotations/UploadCustomerDocumentsServlet.java b/web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/UploadCustomerDocumentsServlet.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/javaeeannotations/UploadCustomerDocumentsServlet.java rename to web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/UploadCustomerDocumentsServlet.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployee.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployee.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployee.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployee.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployeeResponse.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployeeResponse.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployeeResponse.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployeeResponse.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployees.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployees.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployees.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployees.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployeesResponse.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployeesResponse.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployeesResponse.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployeesResponse.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployee.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployee.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployee.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployee.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployeeResponse.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployeeResponse.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployeeResponse.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployeeResponse.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/Employee.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/Employee.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/Employee.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/Employee.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists_Exception.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists_Exception.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists_Exception.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists_Exception.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound_Exception.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound_Exception.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound_Exception.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound_Exception.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeServiceClient.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeServiceClient.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeServiceClient.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeServiceClient.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService_Service.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService_Service.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService_Service.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService_Service.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployees.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployees.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployees.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployees.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployeesResponse.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployeesResponse.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployeesResponse.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployeesResponse.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployee.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployee.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployee.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployee.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployeeResponse.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployeeResponse.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployeeResponse.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployeeResponse.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/ObjectFactory.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/ObjectFactory.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/ObjectFactory.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/ObjectFactory.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployee.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployee.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployee.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployee.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployeeResponse.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployeeResponse.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployeeResponse.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployeeResponse.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/client/package-info.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/package-info.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/client/package-info.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/package-info.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeService.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeService.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeService.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeService.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeServiceImpl.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeServiceImpl.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeServiceImpl.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeServiceImpl.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeAlreadyExists.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeAlreadyExists.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeAlreadyExists.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeAlreadyExists.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeNotFound.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeNotFound.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeNotFound.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeNotFound.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/model/Employee.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/model/Employee.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/model/Employee.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/model/Employee.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/config/EmployeeServicePublisher.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/config/EmployeeServicePublisher.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/config/EmployeeServicePublisher.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/config/EmployeeServicePublisher.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepository.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepository.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepository.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepository.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepositoryImpl.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepositoryImpl.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepositoryImpl.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepositoryImpl.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDownImpl.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDownImpl.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDownImpl.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDownImpl.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown_Service.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown_Service.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown_Service.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown_Service.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/ObjectFactory.java b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/ObjectFactory.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/server/topdown/ObjectFactory.java rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/ObjectFactory.java diff --git a/jee-7/src/main/java/com/baeldung/jaxws/wsdl/employeeservicetopdown.wsdl b/web-modules/jee-7/src/main/java/com/baeldung/jaxws/wsdl/employeeservicetopdown.wsdl similarity index 100% rename from jee-7/src/main/java/com/baeldung/jaxws/wsdl/employeeservicetopdown.wsdl rename to web-modules/jee-7/src/main/java/com/baeldung/jaxws/wsdl/employeeservicetopdown.wsdl diff --git a/jee-7/src/main/java/com/baeldung/json/Person.java b/web-modules/jee-7/src/main/java/com/baeldung/json/Person.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/json/Person.java rename to web-modules/jee-7/src/main/java/com/baeldung/json/Person.java diff --git a/jee-7/src/main/java/com/baeldung/json/PersonBuilder.java b/web-modules/jee-7/src/main/java/com/baeldung/json/PersonBuilder.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/json/PersonBuilder.java rename to web-modules/jee-7/src/main/java/com/baeldung/json/PersonBuilder.java diff --git a/jee-7/src/main/java/com/baeldung/json/PersonWriter.java b/web-modules/jee-7/src/main/java/com/baeldung/json/PersonWriter.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/json/PersonWriter.java rename to web-modules/jee-7/src/main/java/com/baeldung/json/PersonWriter.java diff --git a/jee-7/src/main/java/com/baeldung/singleton/Car.java b/web-modules/jee-7/src/main/java/com/baeldung/singleton/Car.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/singleton/Car.java rename to web-modules/jee-7/src/main/java/com/baeldung/singleton/Car.java diff --git a/jee-7/src/main/java/com/baeldung/singleton/CarServiceBean.java b/web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceBean.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/singleton/CarServiceBean.java rename to web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceBean.java diff --git a/jee-7/src/main/java/com/baeldung/singleton/CarServiceEjbSingleton.java b/web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceEjbSingleton.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/singleton/CarServiceEjbSingleton.java rename to web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceEjbSingleton.java diff --git a/jee-7/src/main/java/com/baeldung/singleton/CarServiceSingleton.java b/web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceSingleton.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/singleton/CarServiceSingleton.java rename to web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceSingleton.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Country.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Country.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Country.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Country.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/Country.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/Country.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/server/Country.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/Country.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryRepository.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryRepository.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/server/CountryRepository.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryRepository.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryService.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryService.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/server/CountryService.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryService.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServiceImpl.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServiceImpl.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServiceImpl.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServiceImpl.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServicePublisher.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServicePublisher.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServicePublisher.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServicePublisher.java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/Currency.java b/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/Currency.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/soap/ws/server/Currency.java rename to web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/Currency.java diff --git a/jee-7/src/main/java/com/baeldung/timer/AutomaticTimerBean.java b/web-modules/jee-7/src/main/java/com/baeldung/timer/AutomaticTimerBean.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/timer/AutomaticTimerBean.java rename to web-modules/jee-7/src/main/java/com/baeldung/timer/AutomaticTimerBean.java diff --git a/jee-7/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java b/web-modules/jee-7/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java rename to web-modules/jee-7/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java diff --git a/jee-7/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java b/web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java rename to web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java diff --git a/jee-7/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java b/web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java rename to web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java diff --git a/jee-7/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java b/web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java rename to web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java diff --git a/jee-7/src/main/java/com/baeldung/timer/ScheduleTimerBean.java b/web-modules/jee-7/src/main/java/com/baeldung/timer/ScheduleTimerBean.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/timer/ScheduleTimerBean.java rename to web-modules/jee-7/src/main/java/com/baeldung/timer/ScheduleTimerBean.java diff --git a/jee-7/src/main/java/com/baeldung/timer/TimerEvent.java b/web-modules/jee-7/src/main/java/com/baeldung/timer/TimerEvent.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/timer/TimerEvent.java rename to web-modules/jee-7/src/main/java/com/baeldung/timer/TimerEvent.java diff --git a/jee-7/src/main/java/com/baeldung/timer/TimerEventListener.java b/web-modules/jee-7/src/main/java/com/baeldung/timer/TimerEventListener.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/timer/TimerEventListener.java rename to web-modules/jee-7/src/main/java/com/baeldung/timer/TimerEventListener.java diff --git a/jee-7/src/main/java/com/baeldung/timer/WorkerBean.java b/web-modules/jee-7/src/main/java/com/baeldung/timer/WorkerBean.java similarity index 100% rename from jee-7/src/main/java/com/baeldung/timer/WorkerBean.java rename to web-modules/jee-7/src/main/java/com/baeldung/timer/WorkerBean.java diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/customCheckPoint.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/customCheckPoint.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/customCheckPoint.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/customCheckPoint.xml diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/decideJobSequence.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/decideJobSequence.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/decideJobSequence.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/decideJobSequence.xml diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/flowJobSequence.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/flowJobSequence.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/flowJobSequence.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/flowJobSequence.xml diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/injectionSimpleBatchLet.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/injectionSimpleBatchLet.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/injectionSimpleBatchLet.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/injectionSimpleBatchLet.xml diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/partitionSimpleBatchLet.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/partitionSimpleBatchLet.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/partitionSimpleBatchLet.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/partitionSimpleBatchLet.xml diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/simpleBatchLet.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/simpleBatchLet.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/simpleBatchLet.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/simpleBatchLet.xml diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/simpleChunk.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/simpleChunk.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/simpleChunk.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/simpleChunk.xml diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/simpleErrorChunk.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/simpleErrorChunk.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/simpleErrorChunk.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/simpleErrorChunk.xml diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/simpleErrorSkipChunk.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/simpleErrorSkipChunk.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/simpleErrorSkipChunk.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/simpleErrorSkipChunk.xml diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/simpleJobSequence.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/simpleJobSequence.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/simpleJobSequence.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/simpleJobSequence.xml diff --git a/jee-7/src/main/resources/META-INF/batch-jobs/splitJobSequence.xml b/web-modules/jee-7/src/main/resources/META-INF/batch-jobs/splitJobSequence.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/batch-jobs/splitJobSequence.xml rename to web-modules/jee-7/src/main/resources/META-INF/batch-jobs/splitJobSequence.xml diff --git a/jee-7/src/main/resources/META-INF/beans.xml b/web-modules/jee-7/src/main/resources/META-INF/beans.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/beans.xml rename to web-modules/jee-7/src/main/resources/META-INF/beans.xml diff --git a/jee-7/src/main/resources/META-INF/persistence.xml b/web-modules/jee-7/src/main/resources/META-INF/persistence.xml similarity index 100% rename from jee-7/src/main/resources/META-INF/persistence.xml rename to web-modules/jee-7/src/main/resources/META-INF/persistence.xml diff --git a/jee-7/src/main/resources/country.xsd b/web-modules/jee-7/src/main/resources/country.xsd similarity index 100% rename from jee-7/src/main/resources/country.xsd rename to web-modules/jee-7/src/main/resources/country.xsd diff --git a/jee-7/src/main/resources/logback.xml b/web-modules/jee-7/src/main/resources/logback.xml similarity index 100% rename from jee-7/src/main/resources/logback.xml rename to web-modules/jee-7/src/main/resources/logback.xml diff --git a/jee-7/src/main/webapp/ConvListVal.xhtml b/web-modules/jee-7/src/main/webapp/ConvListVal.xhtml similarity index 100% rename from jee-7/src/main/webapp/ConvListVal.xhtml rename to web-modules/jee-7/src/main/webapp/ConvListVal.xhtml diff --git a/jee-7/src/main/webapp/WEB-INF/beans.xml b/web-modules/jee-7/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from jee-7/src/main/webapp/WEB-INF/beans.xml rename to web-modules/jee-7/src/main/webapp/WEB-INF/beans.xml diff --git a/jee-7/src/main/webapp/WEB-INF/faces-config.xml b/web-modules/jee-7/src/main/webapp/WEB-INF/faces-config.xml similarity index 100% rename from jee-7/src/main/webapp/WEB-INF/faces-config.xml rename to web-modules/jee-7/src/main/webapp/WEB-INF/faces-config.xml diff --git a/jee-7/src/main/webapp/WEB-INF/web.xml b/web-modules/jee-7/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from jee-7/src/main/webapp/WEB-INF/web.xml rename to web-modules/jee-7/src/main/webapp/WEB-INF/web.xml diff --git a/jee-7/src/main/webapp/account.jsp b/web-modules/jee-7/src/main/webapp/account.jsp similarity index 100% rename from jee-7/src/main/webapp/account.jsp rename to web-modules/jee-7/src/main/webapp/account.jsp diff --git a/jee-7/src/main/webapp/upload.jsp b/web-modules/jee-7/src/main/webapp/upload.jsp similarity index 100% rename from jee-7/src/main/webapp/upload.jsp rename to web-modules/jee-7/src/main/webapp/upload.jsp diff --git a/jee-7/src/test/java/com/baeldug/json/JsonUnitTest.java b/web-modules/jee-7/src/test/java/com/baeldug/json/JsonUnitTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldug/json/JsonUnitTest.java rename to web-modules/jee-7/src/test/java/com/baeldug/json/JsonUnitTest.java diff --git a/jee-7/src/test/java/com/baeldung/arquillan/ArquillianLiveTest.java b/web-modules/jee-7/src/test/java/com/baeldung/arquillan/ArquillianLiveTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/arquillan/ArquillianLiveTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/arquillan/ArquillianLiveTest.java diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/BatchTestHelper.java b/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/BatchTestHelper.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/batch/understanding/BatchTestHelper.java rename to web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/BatchTestHelper.java diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointIntegrationTest.java b/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointIntegrationTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointIntegrationTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointIntegrationTest.java diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceIntegrationTest.java b/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceIntegrationTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceIntegrationTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceIntegrationTest.java diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetIntegrationTest.java b/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetIntegrationTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetIntegrationTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetIntegrationTest.java diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkIntegrationTest.java b/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkIntegrationTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkIntegrationTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkIntegrationTest.java diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkIntegrationTest.java b/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkIntegrationTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkIntegrationTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkIntegrationTest.java diff --git a/jee-7/src/test/java/com/baeldung/convListVal/ConvListValLiveTest.java b/web-modules/jee-7/src/test/java/com/baeldung/convListVal/ConvListValLiveTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/convListVal/ConvListValLiveTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/convListVal/ConvListValLiveTest.java diff --git a/jee-7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java b/web-modules/jee-7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java diff --git a/jee-7/src/test/java/com/baeldung/singleton/CarServiceIntegrationTest.java b/web-modules/jee-7/src/test/java/com/baeldung/singleton/CarServiceIntegrationTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/singleton/CarServiceIntegrationTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/singleton/CarServiceIntegrationTest.java diff --git a/jee-7/src/test/java/com/baeldung/soap/ws/client/CountryClientLiveTest.java b/web-modules/jee-7/src/test/java/com/baeldung/soap/ws/client/CountryClientLiveTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/soap/ws/client/CountryClientLiveTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/soap/ws/client/CountryClientLiveTest.java diff --git a/jee-7/src/test/java/com/baeldung/timer/AutomaticTimerBeanLiveTest.java b/web-modules/jee-7/src/test/java/com/baeldung/timer/AutomaticTimerBeanLiveTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/timer/AutomaticTimerBeanLiveTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/timer/AutomaticTimerBeanLiveTest.java diff --git a/jee-7/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanLiveTest.java b/web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanLiveTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanLiveTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanLiveTest.java diff --git a/jee-7/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanLiveTest.java b/web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanLiveTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanLiveTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanLiveTest.java diff --git a/jee-7/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanLiveTest.java b/web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanLiveTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanLiveTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanLiveTest.java diff --git a/jee-7/src/test/java/com/baeldung/timer/ScheduleTimerBeanLiveTest.java b/web-modules/jee-7/src/test/java/com/baeldung/timer/ScheduleTimerBeanLiveTest.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/timer/ScheduleTimerBeanLiveTest.java rename to web-modules/jee-7/src/test/java/com/baeldung/timer/ScheduleTimerBeanLiveTest.java diff --git a/jee-7/src/test/java/com/baeldung/timer/WithinWindowMatcher.java b/web-modules/jee-7/src/test/java/com/baeldung/timer/WithinWindowMatcher.java similarity index 100% rename from jee-7/src/test/java/com/baeldung/timer/WithinWindowMatcher.java rename to web-modules/jee-7/src/test/java/com/baeldung/timer/WithinWindowMatcher.java diff --git a/jee-7/src/test/resources/META-INF/persistence.xml b/web-modules/jee-7/src/test/resources/META-INF/persistence.xml similarity index 100% rename from jee-7/src/test/resources/META-INF/persistence.xml rename to web-modules/jee-7/src/test/resources/META-INF/persistence.xml diff --git a/jee-7/src/test/resources/arquillian.xml b/web-modules/jee-7/src/test/resources/arquillian.xml similarity index 100% rename from jee-7/src/test/resources/arquillian.xml rename to web-modules/jee-7/src/test/resources/arquillian.xml diff --git a/jee-7/src/test/resources/jberet.properties b/web-modules/jee-7/src/test/resources/jberet.properties similarity index 100% rename from jee-7/src/test/resources/jberet.properties rename to web-modules/jee-7/src/test/resources/jberet.properties diff --git a/jooby/README.md b/web-modules/jooby/README.md similarity index 100% rename from jooby/README.md rename to web-modules/jooby/README.md diff --git a/jooby/conf/application.conf b/web-modules/jooby/conf/application.conf similarity index 100% rename from jooby/conf/application.conf rename to web-modules/jooby/conf/application.conf diff --git a/jooby/conf/logback.xml b/web-modules/jooby/conf/logback.xml similarity index 100% rename from jooby/conf/logback.xml rename to web-modules/jooby/conf/logback.xml diff --git a/jooby/pom.xml b/web-modules/jooby/pom.xml similarity index 97% rename from jooby/pom.xml rename to web-modules/jooby/pom.xml index f972a22e9c..6c2ce3a5c5 100644 --- a/jooby/pom.xml +++ b/web-modules/jooby/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/jooby/public/form.html b/web-modules/jooby/public/form.html similarity index 100% rename from jooby/public/form.html rename to web-modules/jooby/public/form.html diff --git a/jooby/public/welcome.html b/web-modules/jooby/public/welcome.html similarity index 100% rename from jooby/public/welcome.html rename to web-modules/jooby/public/welcome.html diff --git a/jooby/src/etc/stork.yml b/web-modules/jooby/src/etc/stork.yml similarity index 100% rename from jooby/src/etc/stork.yml rename to web-modules/jooby/src/etc/stork.yml diff --git a/jooby/src/main/java/com/baeldung/jooby/App.java b/web-modules/jooby/src/main/java/com/baeldung/jooby/App.java similarity index 100% rename from jooby/src/main/java/com/baeldung/jooby/App.java rename to web-modules/jooby/src/main/java/com/baeldung/jooby/App.java diff --git a/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java b/web-modules/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java similarity index 100% rename from jooby/src/main/java/com/baeldung/jooby/bean/Employee.java rename to web-modules/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java diff --git a/jooby/src/main/java/com/baeldung/jooby/mvc/GetController.java b/web-modules/jooby/src/main/java/com/baeldung/jooby/mvc/GetController.java similarity index 100% rename from jooby/src/main/java/com/baeldung/jooby/mvc/GetController.java rename to web-modules/jooby/src/main/java/com/baeldung/jooby/mvc/GetController.java diff --git a/jooby/src/main/java/com/baeldung/jooby/mvc/PostController.java b/web-modules/jooby/src/main/java/com/baeldung/jooby/mvc/PostController.java similarity index 100% rename from jooby/src/main/java/com/baeldung/jooby/mvc/PostController.java rename to web-modules/jooby/src/main/java/com/baeldung/jooby/mvc/PostController.java diff --git a/software-security/sql-injection-samples/src/main/resources/logback.xml b/web-modules/jooby/src/main/resources/logback.xml similarity index 100% rename from software-security/sql-injection-samples/src/main/resources/logback.xml rename to web-modules/jooby/src/main/resources/logback.xml diff --git a/jooby/src/test/java/com/baeldung/jooby/AppLiveTest.java b/web-modules/jooby/src/test/java/com/baeldung/jooby/AppLiveTest.java similarity index 100% rename from jooby/src/test/java/com/baeldung/jooby/AppLiveTest.java rename to web-modules/jooby/src/test/java/com/baeldung/jooby/AppLiveTest.java diff --git a/jooby/src/test/java/com/baeldung/jooby/AppUnitTest.java b/web-modules/jooby/src/test/java/com/baeldung/jooby/AppUnitTest.java similarity index 100% rename from jooby/src/test/java/com/baeldung/jooby/AppUnitTest.java rename to web-modules/jooby/src/test/java/com/baeldung/jooby/AppUnitTest.java diff --git a/linkrest/README.md b/web-modules/linkrest/README.md similarity index 100% rename from linkrest/README.md rename to web-modules/linkrest/README.md diff --git a/linkrest/WebContent/META-INF/MANIFEST.MF b/web-modules/linkrest/WebContent/META-INF/MANIFEST.MF similarity index 100% rename from linkrest/WebContent/META-INF/MANIFEST.MF rename to web-modules/linkrest/WebContent/META-INF/MANIFEST.MF diff --git a/linkrest/WebContent/WEB-INF/web.xml b/web-modules/linkrest/WebContent/WEB-INF/web.xml similarity index 100% rename from linkrest/WebContent/WEB-INF/web.xml rename to web-modules/linkrest/WebContent/WEB-INF/web.xml diff --git a/linkrest/pom.xml b/web-modules/linkrest/pom.xml similarity index 98% rename from linkrest/pom.xml rename to web-modules/linkrest/pom.xml index e40efb3930..f43add6910 100644 --- a/linkrest/pom.xml +++ b/web-modules/linkrest/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/linkrest/src/main/java/com/baeldung/LinkRestApplication.java b/web-modules/linkrest/src/main/java/com/baeldung/LinkRestApplication.java similarity index 100% rename from linkrest/src/main/java/com/baeldung/LinkRestApplication.java rename to web-modules/linkrest/src/main/java/com/baeldung/LinkRestApplication.java diff --git a/linkrest/src/main/java/com/baeldung/cayenne/Department.java b/web-modules/linkrest/src/main/java/com/baeldung/cayenne/Department.java similarity index 100% rename from linkrest/src/main/java/com/baeldung/cayenne/Department.java rename to web-modules/linkrest/src/main/java/com/baeldung/cayenne/Department.java diff --git a/linkrest/src/main/java/com/baeldung/cayenne/Employee.java b/web-modules/linkrest/src/main/java/com/baeldung/cayenne/Employee.java similarity index 100% rename from linkrest/src/main/java/com/baeldung/cayenne/Employee.java rename to web-modules/linkrest/src/main/java/com/baeldung/cayenne/Employee.java diff --git a/linkrest/src/main/java/com/baeldung/cayenne/auto/_Department.java b/web-modules/linkrest/src/main/java/com/baeldung/cayenne/auto/_Department.java similarity index 100% rename from linkrest/src/main/java/com/baeldung/cayenne/auto/_Department.java rename to web-modules/linkrest/src/main/java/com/baeldung/cayenne/auto/_Department.java diff --git a/linkrest/src/main/java/com/baeldung/cayenne/auto/_Employee.java b/web-modules/linkrest/src/main/java/com/baeldung/cayenne/auto/_Employee.java similarity index 100% rename from linkrest/src/main/java/com/baeldung/cayenne/auto/_Employee.java rename to web-modules/linkrest/src/main/java/com/baeldung/cayenne/auto/_Employee.java diff --git a/linkrest/src/main/java/com/baeldung/linkrest/apis/DepartmentResource.java b/web-modules/linkrest/src/main/java/com/baeldung/linkrest/apis/DepartmentResource.java similarity index 100% rename from linkrest/src/main/java/com/baeldung/linkrest/apis/DepartmentResource.java rename to web-modules/linkrest/src/main/java/com/baeldung/linkrest/apis/DepartmentResource.java diff --git a/linkrest/src/main/java/com/baeldung/linkrest/apis/EmployeeSubResource.java b/web-modules/linkrest/src/main/java/com/baeldung/linkrest/apis/EmployeeSubResource.java similarity index 100% rename from linkrest/src/main/java/com/baeldung/linkrest/apis/EmployeeSubResource.java rename to web-modules/linkrest/src/main/java/com/baeldung/linkrest/apis/EmployeeSubResource.java diff --git a/linkrest/src/main/resources/cayenne-linkrest-project.xml b/web-modules/linkrest/src/main/resources/cayenne-linkrest-project.xml similarity index 100% rename from linkrest/src/main/resources/cayenne-linkrest-project.xml rename to web-modules/linkrest/src/main/resources/cayenne-linkrest-project.xml diff --git a/linkrest/src/main/resources/linkrest.map.xml b/web-modules/linkrest/src/main/resources/linkrest.map.xml similarity index 100% rename from linkrest/src/main/resources/linkrest.map.xml rename to web-modules/linkrest/src/main/resources/linkrest.map.xml diff --git a/spark-java/src/main/resources/logback.xml b/web-modules/linkrest/src/main/resources/logback.xml similarity index 100% rename from spark-java/src/main/resources/logback.xml rename to web-modules/linkrest/src/main/resources/logback.xml diff --git a/ninja/README.md b/web-modules/ninja/README.md similarity index 100% rename from ninja/README.md rename to web-modules/ninja/README.md diff --git a/ninja/pom.xml b/web-modules/ninja/pom.xml similarity index 100% rename from ninja/pom.xml rename to web-modules/ninja/pom.xml diff --git a/ninja/src/main/java/META-INF/persistence.xml b/web-modules/ninja/src/main/java/META-INF/persistence.xml similarity index 100% rename from ninja/src/main/java/META-INF/persistence.xml rename to web-modules/ninja/src/main/java/META-INF/persistence.xml diff --git a/ninja/src/main/java/assets/css/custom.css b/web-modules/ninja/src/main/java/assets/css/custom.css similarity index 100% rename from ninja/src/main/java/assets/css/custom.css rename to web-modules/ninja/src/main/java/assets/css/custom.css diff --git a/ninja/src/main/java/conf/Filters.java b/web-modules/ninja/src/main/java/conf/Filters.java similarity index 100% rename from ninja/src/main/java/conf/Filters.java rename to web-modules/ninja/src/main/java/conf/Filters.java diff --git a/ninja/src/main/java/conf/Module.java b/web-modules/ninja/src/main/java/conf/Module.java similarity index 100% rename from ninja/src/main/java/conf/Module.java rename to web-modules/ninja/src/main/java/conf/Module.java diff --git a/ninja/src/main/java/conf/Routes.java b/web-modules/ninja/src/main/java/conf/Routes.java similarity index 100% rename from ninja/src/main/java/conf/Routes.java rename to web-modules/ninja/src/main/java/conf/Routes.java diff --git a/ninja/src/main/java/conf/application.conf b/web-modules/ninja/src/main/java/conf/application.conf similarity index 100% rename from ninja/src/main/java/conf/application.conf rename to web-modules/ninja/src/main/java/conf/application.conf diff --git a/ninja/src/main/java/conf/messages.properties b/web-modules/ninja/src/main/java/conf/messages.properties similarity index 100% rename from ninja/src/main/java/conf/messages.properties rename to web-modules/ninja/src/main/java/conf/messages.properties diff --git a/ninja/src/main/java/conf/messages_fr.properties b/web-modules/ninja/src/main/java/conf/messages_fr.properties similarity index 100% rename from ninja/src/main/java/conf/messages_fr.properties rename to web-modules/ninja/src/main/java/conf/messages_fr.properties diff --git a/ninja/src/main/java/controllers/ApplicationController.java b/web-modules/ninja/src/main/java/controllers/ApplicationController.java similarity index 100% rename from ninja/src/main/java/controllers/ApplicationController.java rename to web-modules/ninja/src/main/java/controllers/ApplicationController.java diff --git a/ninja/src/main/java/ehcache.xml b/web-modules/ninja/src/main/java/ehcache.xml similarity index 100% rename from ninja/src/main/java/ehcache.xml rename to web-modules/ninja/src/main/java/ehcache.xml diff --git a/ninja/src/main/java/logback.xml b/web-modules/ninja/src/main/java/logback.xml similarity index 100% rename from ninja/src/main/java/logback.xml rename to web-modules/ninja/src/main/java/logback.xml diff --git a/ninja/src/main/java/models/User.java b/web-modules/ninja/src/main/java/models/User.java similarity index 100% rename from ninja/src/main/java/models/User.java rename to web-modules/ninja/src/main/java/models/User.java diff --git a/ninja/src/main/java/services/UserService.java b/web-modules/ninja/src/main/java/services/UserService.java similarity index 100% rename from ninja/src/main/java/services/UserService.java rename to web-modules/ninja/src/main/java/services/UserService.java diff --git a/ninja/src/main/java/services/UserServiceImpl.java b/web-modules/ninja/src/main/java/services/UserServiceImpl.java similarity index 100% rename from ninja/src/main/java/services/UserServiceImpl.java rename to web-modules/ninja/src/main/java/services/UserServiceImpl.java diff --git a/ninja/src/main/java/views/ApplicationController/createUser.ftl.html b/web-modules/ninja/src/main/java/views/ApplicationController/createUser.ftl.html similarity index 100% rename from ninja/src/main/java/views/ApplicationController/createUser.ftl.html rename to web-modules/ninja/src/main/java/views/ApplicationController/createUser.ftl.html diff --git a/ninja/src/main/java/views/ApplicationController/home.ftl.html b/web-modules/ninja/src/main/java/views/ApplicationController/home.ftl.html similarity index 100% rename from ninja/src/main/java/views/ApplicationController/home.ftl.html rename to web-modules/ninja/src/main/java/views/ApplicationController/home.ftl.html diff --git a/ninja/src/main/java/views/ApplicationController/index.ftl.html b/web-modules/ninja/src/main/java/views/ApplicationController/index.ftl.html similarity index 100% rename from ninja/src/main/java/views/ApplicationController/index.ftl.html rename to web-modules/ninja/src/main/java/views/ApplicationController/index.ftl.html diff --git a/ninja/src/main/java/views/layout/defaultLayout.ftl.html b/web-modules/ninja/src/main/java/views/layout/defaultLayout.ftl.html similarity index 100% rename from ninja/src/main/java/views/layout/defaultLayout.ftl.html rename to web-modules/ninja/src/main/java/views/layout/defaultLayout.ftl.html diff --git a/ninja/src/main/java/views/layout/footer.ftl.html b/web-modules/ninja/src/main/java/views/layout/footer.ftl.html similarity index 100% rename from ninja/src/main/java/views/layout/footer.ftl.html rename to web-modules/ninja/src/main/java/views/layout/footer.ftl.html diff --git a/ninja/src/main/java/views/layout/header.ftl.html b/web-modules/ninja/src/main/java/views/layout/header.ftl.html similarity index 100% rename from ninja/src/main/java/views/layout/header.ftl.html rename to web-modules/ninja/src/main/java/views/layout/header.ftl.html diff --git a/ninja/src/main/java/views/system/403forbidden.ftl.html b/web-modules/ninja/src/main/java/views/system/403forbidden.ftl.html similarity index 100% rename from ninja/src/main/java/views/system/403forbidden.ftl.html rename to web-modules/ninja/src/main/java/views/system/403forbidden.ftl.html diff --git a/ninja/src/main/java/views/system/404notFound.ftl.html b/web-modules/ninja/src/main/java/views/system/404notFound.ftl.html similarity index 100% rename from ninja/src/main/java/views/system/404notFound.ftl.html rename to web-modules/ninja/src/main/java/views/system/404notFound.ftl.html diff --git a/ninja/src/main/webapp/WEB-INF/web.xml b/web-modules/ninja/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from ninja/src/main/webapp/WEB-INF/web.xml rename to web-modules/ninja/src/main/webapp/WEB-INF/web.xml diff --git a/ninja/src/test/java/controllers/ApiControllerDocTesterTest.java b/web-modules/ninja/src/test/java/controllers/ApiControllerDocTesterTest.java similarity index 100% rename from ninja/src/test/java/controllers/ApiControllerDocTesterTest.java rename to web-modules/ninja/src/test/java/controllers/ApiControllerDocTesterTest.java diff --git a/ninja/src/test/java/controllers/ApiControllerMockUnitTest.java b/web-modules/ninja/src/test/java/controllers/ApiControllerMockUnitTest.java similarity index 100% rename from ninja/src/test/java/controllers/ApiControllerMockUnitTest.java rename to web-modules/ninja/src/test/java/controllers/ApiControllerMockUnitTest.java diff --git a/play-framework/README.md b/web-modules/play-framework/README.md similarity index 100% rename from play-framework/README.md rename to web-modules/play-framework/README.md diff --git a/play-framework/async-http/.g8/form/app/controllers/$model__Camel$Controller.java b/web-modules/play-framework/async-http/.g8/form/app/controllers/$model__Camel$Controller.java similarity index 100% rename from play-framework/async-http/.g8/form/app/controllers/$model__Camel$Controller.java rename to web-modules/play-framework/async-http/.g8/form/app/controllers/$model__Camel$Controller.java diff --git a/play-framework/async-http/.g8/form/app/controllers/$model__Camel$Data.java b/web-modules/play-framework/async-http/.g8/form/app/controllers/$model__Camel$Data.java similarity index 100% rename from play-framework/async-http/.g8/form/app/controllers/$model__Camel$Data.java rename to web-modules/play-framework/async-http/.g8/form/app/controllers/$model__Camel$Data.java diff --git a/play-framework/async-http/.g8/form/app/views/$model__camel$/form.scala.html b/web-modules/play-framework/async-http/.g8/form/app/views/$model__camel$/form.scala.html similarity index 100% rename from play-framework/async-http/.g8/form/app/views/$model__camel$/form.scala.html rename to web-modules/play-framework/async-http/.g8/form/app/views/$model__camel$/form.scala.html diff --git a/play-framework/async-http/.g8/form/default.properties b/web-modules/play-framework/async-http/.g8/form/default.properties similarity index 100% rename from play-framework/async-http/.g8/form/default.properties rename to web-modules/play-framework/async-http/.g8/form/default.properties diff --git a/play-framework/async-http/.g8/form/generated-test/README.md b/web-modules/play-framework/async-http/.g8/form/generated-test/README.md similarity index 100% rename from play-framework/async-http/.g8/form/generated-test/README.md rename to web-modules/play-framework/async-http/.g8/form/generated-test/README.md diff --git a/play-framework/async-http/.g8/form/generated-test/controllers/$model__Camel$ControllerTest.java b/web-modules/play-framework/async-http/.g8/form/generated-test/controllers/$model__Camel$ControllerTest.java similarity index 100% rename from play-framework/async-http/.g8/form/generated-test/controllers/$model__Camel$ControllerTest.java rename to web-modules/play-framework/async-http/.g8/form/generated-test/controllers/$model__Camel$ControllerTest.java diff --git a/play-framework/async-http/.gitignore b/web-modules/play-framework/async-http/.gitignore similarity index 100% rename from play-framework/async-http/.gitignore rename to web-modules/play-framework/async-http/.gitignore diff --git a/play-framework/async-http/README.md b/web-modules/play-framework/async-http/README.md similarity index 100% rename from play-framework/async-http/README.md rename to web-modules/play-framework/async-http/README.md diff --git a/play-framework/async-http/app/controllers/HomeController.java b/web-modules/play-framework/async-http/app/controllers/HomeController.java similarity index 100% rename from play-framework/async-http/app/controllers/HomeController.java rename to web-modules/play-framework/async-http/app/controllers/HomeController.java diff --git a/play-framework/async-http/app/views/index.scala.html b/web-modules/play-framework/async-http/app/views/index.scala.html similarity index 100% rename from play-framework/async-http/app/views/index.scala.html rename to web-modules/play-framework/async-http/app/views/index.scala.html diff --git a/play-framework/async-http/app/views/main.scala.html b/web-modules/play-framework/async-http/app/views/main.scala.html similarity index 100% rename from play-framework/async-http/app/views/main.scala.html rename to web-modules/play-framework/async-http/app/views/main.scala.html diff --git a/play-framework/async-http/build.sbt b/web-modules/play-framework/async-http/build.sbt similarity index 100% rename from play-framework/async-http/build.sbt rename to web-modules/play-framework/async-http/build.sbt diff --git a/play-framework/async-http/conf/application.conf b/web-modules/play-framework/async-http/conf/application.conf similarity index 100% rename from play-framework/async-http/conf/application.conf rename to web-modules/play-framework/async-http/conf/application.conf diff --git a/play-framework/async-http/conf/logback.xml b/web-modules/play-framework/async-http/conf/logback.xml similarity index 100% rename from play-framework/async-http/conf/logback.xml rename to web-modules/play-framework/async-http/conf/logback.xml diff --git a/play-framework/async-http/conf/routes b/web-modules/play-framework/async-http/conf/routes similarity index 100% rename from play-framework/async-http/conf/routes rename to web-modules/play-framework/async-http/conf/routes diff --git a/play-framework/async-http/project/build.properties b/web-modules/play-framework/async-http/project/build.properties similarity index 100% rename from play-framework/async-http/project/build.properties rename to web-modules/play-framework/async-http/project/build.properties diff --git a/play-framework/async-http/project/plugins.sbt b/web-modules/play-framework/async-http/project/plugins.sbt similarity index 100% rename from play-framework/async-http/project/plugins.sbt rename to web-modules/play-framework/async-http/project/plugins.sbt diff --git a/play-framework/async-http/public/images/favicon.png b/web-modules/play-framework/async-http/public/images/favicon.png similarity index 100% rename from play-framework/async-http/public/images/favicon.png rename to web-modules/play-framework/async-http/public/images/favicon.png diff --git a/play-framework/async-http/public/javascripts/main.js b/web-modules/play-framework/async-http/public/javascripts/main.js similarity index 100% rename from play-framework/async-http/public/javascripts/main.js rename to web-modules/play-framework/async-http/public/javascripts/main.js diff --git a/play-framework/async-http/public/stylesheets/main.css b/web-modules/play-framework/async-http/public/stylesheets/main.css similarity index 100% rename from play-framework/async-http/public/stylesheets/main.css rename to web-modules/play-framework/async-http/public/stylesheets/main.css diff --git a/play-framework/async-http/test/controllers/HomeControllerTest.java b/web-modules/play-framework/async-http/test/controllers/HomeControllerTest.java similarity index 100% rename from play-framework/async-http/test/controllers/HomeControllerTest.java rename to web-modules/play-framework/async-http/test/controllers/HomeControllerTest.java diff --git a/play-framework/introduction/.gitignore b/web-modules/play-framework/introduction/.gitignore similarity index 100% rename from play-framework/introduction/.gitignore rename to web-modules/play-framework/introduction/.gitignore diff --git a/play-framework/introduction/app/controllers/HomeController.java b/web-modules/play-framework/introduction/app/controllers/HomeController.java similarity index 100% rename from play-framework/introduction/app/controllers/HomeController.java rename to web-modules/play-framework/introduction/app/controllers/HomeController.java diff --git a/play-framework/introduction/app/views/index.scala.html b/web-modules/play-framework/introduction/app/views/index.scala.html similarity index 100% rename from play-framework/introduction/app/views/index.scala.html rename to web-modules/play-framework/introduction/app/views/index.scala.html diff --git a/play-framework/introduction/app/views/main.scala.html b/web-modules/play-framework/introduction/app/views/main.scala.html similarity index 100% rename from play-framework/introduction/app/views/main.scala.html rename to web-modules/play-framework/introduction/app/views/main.scala.html diff --git a/play-framework/introduction/build.sbt b/web-modules/play-framework/introduction/build.sbt similarity index 100% rename from play-framework/introduction/build.sbt rename to web-modules/play-framework/introduction/build.sbt diff --git a/play-framework/introduction/conf/application.conf b/web-modules/play-framework/introduction/conf/application.conf similarity index 100% rename from play-framework/introduction/conf/application.conf rename to web-modules/play-framework/introduction/conf/application.conf diff --git a/play-framework/introduction/conf/logback.xml b/web-modules/play-framework/introduction/conf/logback.xml similarity index 100% rename from play-framework/introduction/conf/logback.xml rename to web-modules/play-framework/introduction/conf/logback.xml diff --git a/play-framework/introduction/conf/routes b/web-modules/play-framework/introduction/conf/routes similarity index 100% rename from play-framework/introduction/conf/routes rename to web-modules/play-framework/introduction/conf/routes diff --git a/play-framework/introduction/project/build.properties b/web-modules/play-framework/introduction/project/build.properties similarity index 100% rename from play-framework/introduction/project/build.properties rename to web-modules/play-framework/introduction/project/build.properties diff --git a/play-framework/introduction/project/plugins.sbt b/web-modules/play-framework/introduction/project/plugins.sbt similarity index 100% rename from play-framework/introduction/project/plugins.sbt rename to web-modules/play-framework/introduction/project/plugins.sbt diff --git a/play-framework/introduction/public/images/favicon.png b/web-modules/play-framework/introduction/public/images/favicon.png similarity index 100% rename from play-framework/introduction/public/images/favicon.png rename to web-modules/play-framework/introduction/public/images/favicon.png diff --git a/play-framework/introduction/public/javascripts/main.js b/web-modules/play-framework/introduction/public/javascripts/main.js similarity index 100% rename from play-framework/introduction/public/javascripts/main.js rename to web-modules/play-framework/introduction/public/javascripts/main.js diff --git a/play-framework/introduction/public/stylesheets/main.css b/web-modules/play-framework/introduction/public/stylesheets/main.css similarity index 100% rename from play-framework/introduction/public/stylesheets/main.css rename to web-modules/play-framework/introduction/public/stylesheets/main.css diff --git a/play-framework/introduction/test/controllers/HomeControllerUnitTest.java b/web-modules/play-framework/introduction/test/controllers/HomeControllerUnitTest.java similarity index 100% rename from play-framework/introduction/test/controllers/HomeControllerUnitTest.java rename to web-modules/play-framework/introduction/test/controllers/HomeControllerUnitTest.java diff --git a/play-framework/routing-in-play/app/controllers/HomeController.java b/web-modules/play-framework/routing-in-play/app/controllers/HomeController.java similarity index 100% rename from play-framework/routing-in-play/app/controllers/HomeController.java rename to web-modules/play-framework/routing-in-play/app/controllers/HomeController.java diff --git a/play-framework/routing-in-play/app/views/index.scala.html b/web-modules/play-framework/routing-in-play/app/views/index.scala.html similarity index 100% rename from play-framework/routing-in-play/app/views/index.scala.html rename to web-modules/play-framework/routing-in-play/app/views/index.scala.html diff --git a/play-framework/routing-in-play/app/views/main.scala.html b/web-modules/play-framework/routing-in-play/app/views/main.scala.html similarity index 100% rename from play-framework/routing-in-play/app/views/main.scala.html rename to web-modules/play-framework/routing-in-play/app/views/main.scala.html diff --git a/play-framework/routing-in-play/build.sbt b/web-modules/play-framework/routing-in-play/build.sbt similarity index 100% rename from play-framework/routing-in-play/build.sbt rename to web-modules/play-framework/routing-in-play/build.sbt diff --git a/play-framework/routing-in-play/conf/application.conf b/web-modules/play-framework/routing-in-play/conf/application.conf similarity index 100% rename from play-framework/routing-in-play/conf/application.conf rename to web-modules/play-framework/routing-in-play/conf/application.conf diff --git a/play-framework/routing-in-play/conf/logback.xml b/web-modules/play-framework/routing-in-play/conf/logback.xml similarity index 100% rename from play-framework/routing-in-play/conf/logback.xml rename to web-modules/play-framework/routing-in-play/conf/logback.xml diff --git a/play-framework/routing-in-play/conf/routes b/web-modules/play-framework/routing-in-play/conf/routes similarity index 100% rename from play-framework/routing-in-play/conf/routes rename to web-modules/play-framework/routing-in-play/conf/routes diff --git a/play-framework/routing-in-play/project/build.properties b/web-modules/play-framework/routing-in-play/project/build.properties similarity index 100% rename from play-framework/routing-in-play/project/build.properties rename to web-modules/play-framework/routing-in-play/project/build.properties diff --git a/play-framework/routing-in-play/project/plugins.sbt b/web-modules/play-framework/routing-in-play/project/plugins.sbt similarity index 100% rename from play-framework/routing-in-play/project/plugins.sbt rename to web-modules/play-framework/routing-in-play/project/plugins.sbt diff --git a/play-framework/routing-in-play/public/images/favicon.png b/web-modules/play-framework/routing-in-play/public/images/favicon.png similarity index 100% rename from play-framework/routing-in-play/public/images/favicon.png rename to web-modules/play-framework/routing-in-play/public/images/favicon.png diff --git a/play-framework/routing-in-play/public/javascripts/main.js b/web-modules/play-framework/routing-in-play/public/javascripts/main.js similarity index 100% rename from play-framework/routing-in-play/public/javascripts/main.js rename to web-modules/play-framework/routing-in-play/public/javascripts/main.js diff --git a/play-framework/routing-in-play/public/stylesheets/main.css b/web-modules/play-framework/routing-in-play/public/stylesheets/main.css similarity index 100% rename from play-framework/routing-in-play/public/stylesheets/main.css rename to web-modules/play-framework/routing-in-play/public/stylesheets/main.css diff --git a/play-framework/routing-in-play/test/controllers/HomeControllerUnitTest.java b/web-modules/play-framework/routing-in-play/test/controllers/HomeControllerUnitTest.java similarity index 100% rename from play-framework/routing-in-play/test/controllers/HomeControllerUnitTest.java rename to web-modules/play-framework/routing-in-play/test/controllers/HomeControllerUnitTest.java diff --git a/play-framework/student-api/.gitignore b/web-modules/play-framework/student-api/.gitignore similarity index 100% rename from play-framework/student-api/.gitignore rename to web-modules/play-framework/student-api/.gitignore diff --git a/play-framework/student-api/app/controllers/StudentController.java b/web-modules/play-framework/student-api/app/controllers/StudentController.java similarity index 100% rename from play-framework/student-api/app/controllers/StudentController.java rename to web-modules/play-framework/student-api/app/controllers/StudentController.java diff --git a/play-framework/student-api/app/model/Student.java b/web-modules/play-framework/student-api/app/model/Student.java similarity index 100% rename from play-framework/student-api/app/model/Student.java rename to web-modules/play-framework/student-api/app/model/Student.java diff --git a/play-framework/student-api/app/store/StudentStore.java b/web-modules/play-framework/student-api/app/store/StudentStore.java similarity index 100% rename from play-framework/student-api/app/store/StudentStore.java rename to web-modules/play-framework/student-api/app/store/StudentStore.java diff --git a/play-framework/student-api/app/utils/Util.java b/web-modules/play-framework/student-api/app/utils/Util.java similarity index 100% rename from play-framework/student-api/app/utils/Util.java rename to web-modules/play-framework/student-api/app/utils/Util.java diff --git a/play-framework/student-api/build.sbt b/web-modules/play-framework/student-api/build.sbt similarity index 100% rename from play-framework/student-api/build.sbt rename to web-modules/play-framework/student-api/build.sbt diff --git a/play-framework/student-api/conf/application.conf b/web-modules/play-framework/student-api/conf/application.conf similarity index 100% rename from play-framework/student-api/conf/application.conf rename to web-modules/play-framework/student-api/conf/application.conf diff --git a/play-framework/student-api/conf/logback.xml b/web-modules/play-framework/student-api/conf/logback.xml similarity index 100% rename from play-framework/student-api/conf/logback.xml rename to web-modules/play-framework/student-api/conf/logback.xml diff --git a/play-framework/student-api/conf/routes b/web-modules/play-framework/student-api/conf/routes similarity index 100% rename from play-framework/student-api/conf/routes rename to web-modules/play-framework/student-api/conf/routes diff --git a/play-framework/student-api/project/build.properties b/web-modules/play-framework/student-api/project/build.properties similarity index 100% rename from play-framework/student-api/project/build.properties rename to web-modules/play-framework/student-api/project/build.properties diff --git a/play-framework/student-api/project/plugins.sbt b/web-modules/play-framework/student-api/project/plugins.sbt similarity index 100% rename from play-framework/student-api/project/plugins.sbt rename to web-modules/play-framework/student-api/project/plugins.sbt diff --git a/play-framework/student-api/test/controllers/StudentControllerUnitTest.java b/web-modules/play-framework/student-api/test/controllers/StudentControllerUnitTest.java similarity index 100% rename from play-framework/student-api/test/controllers/StudentControllerUnitTest.java rename to web-modules/play-framework/student-api/test/controllers/StudentControllerUnitTest.java diff --git a/play-framework/websockets/README.md b/web-modules/play-framework/websockets/README.md similarity index 100% rename from play-framework/websockets/README.md rename to web-modules/play-framework/websockets/README.md diff --git a/play-framework/websockets/app/actors/Messenger.java b/web-modules/play-framework/websockets/app/actors/Messenger.java similarity index 100% rename from play-framework/websockets/app/actors/Messenger.java rename to web-modules/play-framework/websockets/app/actors/Messenger.java diff --git a/play-framework/websockets/app/controllers/HomeController.java b/web-modules/play-framework/websockets/app/controllers/HomeController.java similarity index 100% rename from play-framework/websockets/app/controllers/HomeController.java rename to web-modules/play-framework/websockets/app/controllers/HomeController.java diff --git a/play-framework/websockets/app/dto/MessageDTO.java b/web-modules/play-framework/websockets/app/dto/MessageDTO.java similarity index 100% rename from play-framework/websockets/app/dto/MessageDTO.java rename to web-modules/play-framework/websockets/app/dto/MessageDTO.java diff --git a/play-framework/websockets/app/dto/RequestDTO.java b/web-modules/play-framework/websockets/app/dto/RequestDTO.java similarity index 100% rename from play-framework/websockets/app/dto/RequestDTO.java rename to web-modules/play-framework/websockets/app/dto/RequestDTO.java diff --git a/play-framework/websockets/app/utils/MessageConverter.java b/web-modules/play-framework/websockets/app/utils/MessageConverter.java similarity index 100% rename from play-framework/websockets/app/utils/MessageConverter.java rename to web-modules/play-framework/websockets/app/utils/MessageConverter.java diff --git a/play-framework/websockets/app/views/index.scala.html b/web-modules/play-framework/websockets/app/views/index.scala.html similarity index 100% rename from play-framework/websockets/app/views/index.scala.html rename to web-modules/play-framework/websockets/app/views/index.scala.html diff --git a/play-framework/websockets/app/views/main.scala.html b/web-modules/play-framework/websockets/app/views/main.scala.html similarity index 100% rename from play-framework/websockets/app/views/main.scala.html rename to web-modules/play-framework/websockets/app/views/main.scala.html diff --git a/play-framework/websockets/build.sbt b/web-modules/play-framework/websockets/build.sbt similarity index 100% rename from play-framework/websockets/build.sbt rename to web-modules/play-framework/websockets/build.sbt diff --git a/play-framework/websockets/conf/application.conf b/web-modules/play-framework/websockets/conf/application.conf similarity index 100% rename from play-framework/websockets/conf/application.conf rename to web-modules/play-framework/websockets/conf/application.conf diff --git a/play-framework/websockets/conf/logback.xml b/web-modules/play-framework/websockets/conf/logback.xml similarity index 100% rename from play-framework/websockets/conf/logback.xml rename to web-modules/play-framework/websockets/conf/logback.xml diff --git a/play-framework/websockets/conf/routes b/web-modules/play-framework/websockets/conf/routes similarity index 100% rename from play-framework/websockets/conf/routes rename to web-modules/play-framework/websockets/conf/routes diff --git a/play-framework/websockets/project/build.properties b/web-modules/play-framework/websockets/project/build.properties similarity index 100% rename from play-framework/websockets/project/build.properties rename to web-modules/play-framework/websockets/project/build.properties diff --git a/play-framework/websockets/project/plugins.sbt b/web-modules/play-framework/websockets/project/plugins.sbt similarity index 100% rename from play-framework/websockets/project/plugins.sbt rename to web-modules/play-framework/websockets/project/plugins.sbt diff --git a/play-framework/websockets/public/images/favicon.png b/web-modules/play-framework/websockets/public/images/favicon.png similarity index 100% rename from play-framework/websockets/public/images/favicon.png rename to web-modules/play-framework/websockets/public/images/favicon.png diff --git a/play-framework/websockets/public/javascripts/main.js b/web-modules/play-framework/websockets/public/javascripts/main.js similarity index 100% rename from play-framework/websockets/public/javascripts/main.js rename to web-modules/play-framework/websockets/public/javascripts/main.js diff --git a/play-framework/websockets/public/stylesheets/main.css b/web-modules/play-framework/websockets/public/stylesheets/main.css similarity index 100% rename from play-framework/websockets/public/stylesheets/main.css rename to web-modules/play-framework/websockets/public/stylesheets/main.css diff --git a/play-framework/websockets/test/controllers/HomeControllerTest.java b/web-modules/play-framework/websockets/test/controllers/HomeControllerTest.java similarity index 100% rename from play-framework/websockets/test/controllers/HomeControllerTest.java rename to web-modules/play-framework/websockets/test/controllers/HomeControllerTest.java diff --git a/web-modules/pom.xml b/web-modules/pom.xml new file mode 100644 index 0000000000..a6e13cbb2a --- /dev/null +++ b/web-modules/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + web-modules + web-modules + pom + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + apache-tapestry + blade + bootique + dropwizard + google-web-toolkit + jakarta-ee + java-lite + javax-servlets + javax-servlets-2 + jee-7 + jooby + linkrest + ninja + ratpack + resteasy + restx + spark-java + struts-2 + vraptor + wicket + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + \ No newline at end of file diff --git a/raml/README.md b/web-modules/raml/README.md similarity index 100% rename from raml/README.md rename to web-modules/raml/README.md diff --git a/raml/annotations/README.md b/web-modules/raml/annotations/README.md similarity index 100% rename from raml/annotations/README.md rename to web-modules/raml/annotations/README.md diff --git a/raml/annotations/api.raml b/web-modules/raml/annotations/api.raml similarity index 100% rename from raml/annotations/api.raml rename to web-modules/raml/annotations/api.raml diff --git a/raml/annotations/examples/Bar.json b/web-modules/raml/annotations/examples/Bar.json similarity index 100% rename from raml/annotations/examples/Bar.json rename to web-modules/raml/annotations/examples/Bar.json diff --git a/raml/annotations/examples/Bars.json b/web-modules/raml/annotations/examples/Bars.json similarity index 100% rename from raml/annotations/examples/Bars.json rename to web-modules/raml/annotations/examples/Bars.json diff --git a/raml/annotations/examples/Error.json b/web-modules/raml/annotations/examples/Error.json similarity index 100% rename from raml/annotations/examples/Error.json rename to web-modules/raml/annotations/examples/Error.json diff --git a/raml/annotations/examples/Foo.json b/web-modules/raml/annotations/examples/Foo.json similarity index 100% rename from raml/annotations/examples/Foo.json rename to web-modules/raml/annotations/examples/Foo.json diff --git a/raml/annotations/examples/Foos.json b/web-modules/raml/annotations/examples/Foos.json similarity index 100% rename from raml/annotations/examples/Foos.json rename to web-modules/raml/annotations/examples/Foos.json diff --git a/raml/annotations/extensions/en_US/additionalResources.raml b/web-modules/raml/annotations/extensions/en_US/additionalResources.raml similarity index 100% rename from raml/annotations/extensions/en_US/additionalResources.raml rename to web-modules/raml/annotations/extensions/en_US/additionalResources.raml diff --git a/raml/annotations/libraries/dataTypes.raml b/web-modules/raml/annotations/libraries/dataTypes.raml similarity index 100% rename from raml/annotations/libraries/dataTypes.raml rename to web-modules/raml/annotations/libraries/dataTypes.raml diff --git a/raml/annotations/libraries/resourceTypes.raml b/web-modules/raml/annotations/libraries/resourceTypes.raml similarity index 100% rename from raml/annotations/libraries/resourceTypes.raml rename to web-modules/raml/annotations/libraries/resourceTypes.raml diff --git a/raml/annotations/libraries/securitySchemes.raml b/web-modules/raml/annotations/libraries/securitySchemes.raml similarity index 100% rename from raml/annotations/libraries/securitySchemes.raml rename to web-modules/raml/annotations/libraries/securitySchemes.raml diff --git a/raml/annotations/libraries/traits.raml b/web-modules/raml/annotations/libraries/traits.raml similarity index 100% rename from raml/annotations/libraries/traits.raml rename to web-modules/raml/annotations/libraries/traits.raml diff --git a/raml/annotations/overlays/es_ES/additionalResources.raml b/web-modules/raml/annotations/overlays/es_ES/additionalResources.raml similarity index 100% rename from raml/annotations/overlays/es_ES/additionalResources.raml rename to web-modules/raml/annotations/overlays/es_ES/additionalResources.raml diff --git a/raml/annotations/overlays/es_ES/documentationItems.raml b/web-modules/raml/annotations/overlays/es_ES/documentationItems.raml similarity index 100% rename from raml/annotations/overlays/es_ES/documentationItems.raml rename to web-modules/raml/annotations/overlays/es_ES/documentationItems.raml diff --git a/raml/introduction/0.8/api.raml b/web-modules/raml/introduction/0.8/api.raml similarity index 100% rename from raml/introduction/0.8/api.raml rename to web-modules/raml/introduction/0.8/api.raml diff --git a/raml/introduction/0.8/error-example.json b/web-modules/raml/introduction/0.8/error-example.json similarity index 100% rename from raml/introduction/0.8/error-example.json rename to web-modules/raml/introduction/0.8/error-example.json diff --git a/raml/introduction/0.8/error.json b/web-modules/raml/introduction/0.8/error.json similarity index 100% rename from raml/introduction/0.8/error.json rename to web-modules/raml/introduction/0.8/error.json diff --git a/raml/introduction/0.8/foo-example.json b/web-modules/raml/introduction/0.8/foo-example.json similarity index 100% rename from raml/introduction/0.8/foo-example.json rename to web-modules/raml/introduction/0.8/foo-example.json diff --git a/raml/introduction/0.8/foo.json b/web-modules/raml/introduction/0.8/foo.json similarity index 100% rename from raml/introduction/0.8/foo.json rename to web-modules/raml/introduction/0.8/foo.json diff --git a/raml/introduction/0.8/foos-example.json b/web-modules/raml/introduction/0.8/foos-example.json similarity index 100% rename from raml/introduction/0.8/foos-example.json rename to web-modules/raml/introduction/0.8/foos-example.json diff --git a/raml/introduction/0.8/foos.json b/web-modules/raml/introduction/0.8/foos.json similarity index 100% rename from raml/introduction/0.8/foos.json rename to web-modules/raml/introduction/0.8/foos.json diff --git a/raml/introduction/1.0/api.raml b/web-modules/raml/introduction/1.0/api.raml similarity index 100% rename from raml/introduction/1.0/api.raml rename to web-modules/raml/introduction/1.0/api.raml diff --git a/raml/introduction/1.0/examples/Error.json b/web-modules/raml/introduction/1.0/examples/Error.json similarity index 100% rename from raml/introduction/1.0/examples/Error.json rename to web-modules/raml/introduction/1.0/examples/Error.json diff --git a/raml/introduction/1.0/examples/Foo.json b/web-modules/raml/introduction/1.0/examples/Foo.json similarity index 100% rename from raml/introduction/1.0/examples/Foo.json rename to web-modules/raml/introduction/1.0/examples/Foo.json diff --git a/raml/introduction/1.0/examples/Foos.json b/web-modules/raml/introduction/1.0/examples/Foos.json similarity index 100% rename from raml/introduction/1.0/examples/Foos.json rename to web-modules/raml/introduction/1.0/examples/Foos.json diff --git a/raml/introduction/1.0/types/Error.raml b/web-modules/raml/introduction/1.0/types/Error.raml similarity index 100% rename from raml/introduction/1.0/types/Error.raml rename to web-modules/raml/introduction/1.0/types/Error.raml diff --git a/raml/introduction/1.0/types/Foo.raml b/web-modules/raml/introduction/1.0/types/Foo.raml similarity index 100% rename from raml/introduction/1.0/types/Foo.raml rename to web-modules/raml/introduction/1.0/types/Foo.raml diff --git a/raml/modularization/README.md b/web-modules/raml/modularization/README.md similarity index 100% rename from raml/modularization/README.md rename to web-modules/raml/modularization/README.md diff --git a/raml/modularization/api-before-modularization.raml b/web-modules/raml/modularization/api-before-modularization.raml similarity index 100% rename from raml/modularization/api-before-modularization.raml rename to web-modules/raml/modularization/api-before-modularization.raml diff --git a/raml/modularization/api-with-libraries.raml b/web-modules/raml/modularization/api-with-libraries.raml similarity index 100% rename from raml/modularization/api-with-libraries.raml rename to web-modules/raml/modularization/api-with-libraries.raml diff --git a/raml/modularization/api-with-typed-fragments.raml b/web-modules/raml/modularization/api-with-typed-fragments.raml similarity index 100% rename from raml/modularization/api-with-typed-fragments.raml rename to web-modules/raml/modularization/api-with-typed-fragments.raml diff --git a/raml/modularization/api.raml b/web-modules/raml/modularization/api.raml similarity index 100% rename from raml/modularization/api.raml rename to web-modules/raml/modularization/api.raml diff --git a/raml/modularization/examples/Bar.json b/web-modules/raml/modularization/examples/Bar.json similarity index 100% rename from raml/modularization/examples/Bar.json rename to web-modules/raml/modularization/examples/Bar.json diff --git a/raml/modularization/examples/Bars.json b/web-modules/raml/modularization/examples/Bars.json similarity index 100% rename from raml/modularization/examples/Bars.json rename to web-modules/raml/modularization/examples/Bars.json diff --git a/raml/modularization/examples/Error.json b/web-modules/raml/modularization/examples/Error.json similarity index 100% rename from raml/modularization/examples/Error.json rename to web-modules/raml/modularization/examples/Error.json diff --git a/raml/modularization/examples/Foo.json b/web-modules/raml/modularization/examples/Foo.json similarity index 100% rename from raml/modularization/examples/Foo.json rename to web-modules/raml/modularization/examples/Foo.json diff --git a/raml/modularization/examples/Foos.json b/web-modules/raml/modularization/examples/Foos.json similarity index 100% rename from raml/modularization/examples/Foos.json rename to web-modules/raml/modularization/examples/Foos.json diff --git a/raml/modularization/extensions/en_US/additionalResources.raml b/web-modules/raml/modularization/extensions/en_US/additionalResources.raml similarity index 100% rename from raml/modularization/extensions/en_US/additionalResources.raml rename to web-modules/raml/modularization/extensions/en_US/additionalResources.raml diff --git a/raml/modularization/libraries/dataTypes.raml b/web-modules/raml/modularization/libraries/dataTypes.raml similarity index 100% rename from raml/modularization/libraries/dataTypes.raml rename to web-modules/raml/modularization/libraries/dataTypes.raml diff --git a/raml/modularization/libraries/resourceTypes.raml b/web-modules/raml/modularization/libraries/resourceTypes.raml similarity index 100% rename from raml/modularization/libraries/resourceTypes.raml rename to web-modules/raml/modularization/libraries/resourceTypes.raml diff --git a/raml/modularization/libraries/securitySchemes.raml b/web-modules/raml/modularization/libraries/securitySchemes.raml similarity index 100% rename from raml/modularization/libraries/securitySchemes.raml rename to web-modules/raml/modularization/libraries/securitySchemes.raml diff --git a/raml/modularization/libraries/traits.raml b/web-modules/raml/modularization/libraries/traits.raml similarity index 100% rename from raml/modularization/libraries/traits.raml rename to web-modules/raml/modularization/libraries/traits.raml diff --git a/raml/modularization/overlays/es_ES/additionalResources.raml b/web-modules/raml/modularization/overlays/es_ES/additionalResources.raml similarity index 100% rename from raml/modularization/overlays/es_ES/additionalResources.raml rename to web-modules/raml/modularization/overlays/es_ES/additionalResources.raml diff --git a/raml/modularization/overlays/es_ES/documentationItems.raml b/web-modules/raml/modularization/overlays/es_ES/documentationItems.raml similarity index 100% rename from raml/modularization/overlays/es_ES/documentationItems.raml rename to web-modules/raml/modularization/overlays/es_ES/documentationItems.raml diff --git a/raml/modularization/resourceTypes/collection.raml b/web-modules/raml/modularization/resourceTypes/collection.raml similarity index 100% rename from raml/modularization/resourceTypes/collection.raml rename to web-modules/raml/modularization/resourceTypes/collection.raml diff --git a/raml/modularization/resourceTypes/item.raml b/web-modules/raml/modularization/resourceTypes/item.raml similarity index 100% rename from raml/modularization/resourceTypes/item.raml rename to web-modules/raml/modularization/resourceTypes/item.raml diff --git a/raml/modularization/traits/hasNotFound.raml b/web-modules/raml/modularization/traits/hasNotFound.raml similarity index 100% rename from raml/modularization/traits/hasNotFound.raml rename to web-modules/raml/modularization/traits/hasNotFound.raml diff --git a/raml/modularization/traits/hasRequestItem.raml b/web-modules/raml/modularization/traits/hasRequestItem.raml similarity index 100% rename from raml/modularization/traits/hasRequestItem.raml rename to web-modules/raml/modularization/traits/hasRequestItem.raml diff --git a/raml/modularization/traits/hasResponseCollection.raml b/web-modules/raml/modularization/traits/hasResponseCollection.raml similarity index 100% rename from raml/modularization/traits/hasResponseCollection.raml rename to web-modules/raml/modularization/traits/hasResponseCollection.raml diff --git a/raml/modularization/traits/hasResponseItem.raml b/web-modules/raml/modularization/traits/hasResponseItem.raml similarity index 100% rename from raml/modularization/traits/hasResponseItem.raml rename to web-modules/raml/modularization/traits/hasResponseItem.raml diff --git a/raml/modularization/types/Bar.raml b/web-modules/raml/modularization/types/Bar.raml similarity index 100% rename from raml/modularization/types/Bar.raml rename to web-modules/raml/modularization/types/Bar.raml diff --git a/raml/modularization/types/Error.raml b/web-modules/raml/modularization/types/Error.raml similarity index 100% rename from raml/modularization/types/Error.raml rename to web-modules/raml/modularization/types/Error.raml diff --git a/raml/modularization/types/Foo.raml b/web-modules/raml/modularization/types/Foo.raml similarity index 100% rename from raml/modularization/types/Foo.raml rename to web-modules/raml/modularization/types/Foo.raml diff --git a/raml/resource-types-and-traits/README.md b/web-modules/raml/resource-types-and-traits/README.md similarity index 100% rename from raml/resource-types-and-traits/README.md rename to web-modules/raml/resource-types-and-traits/README.md diff --git a/raml/resource-types-and-traits/api-before-resource-types-and-traits.raml b/web-modules/raml/resource-types-and-traits/api-before-resource-types-and-traits.raml similarity index 100% rename from raml/resource-types-and-traits/api-before-resource-types-and-traits.raml rename to web-modules/raml/resource-types-and-traits/api-before-resource-types-and-traits.raml diff --git a/raml/resource-types-and-traits/api.raml b/web-modules/raml/resource-types-and-traits/api.raml similarity index 100% rename from raml/resource-types-and-traits/api.raml rename to web-modules/raml/resource-types-and-traits/api.raml diff --git a/raml/resource-types-and-traits/examples/Bar.json b/web-modules/raml/resource-types-and-traits/examples/Bar.json similarity index 100% rename from raml/resource-types-and-traits/examples/Bar.json rename to web-modules/raml/resource-types-and-traits/examples/Bar.json diff --git a/raml/resource-types-and-traits/examples/Bars.json b/web-modules/raml/resource-types-and-traits/examples/Bars.json similarity index 100% rename from raml/resource-types-and-traits/examples/Bars.json rename to web-modules/raml/resource-types-and-traits/examples/Bars.json diff --git a/raml/resource-types-and-traits/examples/Error.json b/web-modules/raml/resource-types-and-traits/examples/Error.json similarity index 100% rename from raml/resource-types-and-traits/examples/Error.json rename to web-modules/raml/resource-types-and-traits/examples/Error.json diff --git a/raml/resource-types-and-traits/examples/Foo.json b/web-modules/raml/resource-types-and-traits/examples/Foo.json similarity index 100% rename from raml/resource-types-and-traits/examples/Foo.json rename to web-modules/raml/resource-types-and-traits/examples/Foo.json diff --git a/raml/resource-types-and-traits/examples/Foos.json b/web-modules/raml/resource-types-and-traits/examples/Foos.json similarity index 100% rename from raml/resource-types-and-traits/examples/Foos.json rename to web-modules/raml/resource-types-and-traits/examples/Foos.json diff --git a/raml/resource-types-and-traits/types/Bar.raml b/web-modules/raml/resource-types-and-traits/types/Bar.raml similarity index 100% rename from raml/resource-types-and-traits/types/Bar.raml rename to web-modules/raml/resource-types-and-traits/types/Bar.raml diff --git a/raml/resource-types-and-traits/types/Error.raml b/web-modules/raml/resource-types-and-traits/types/Error.raml similarity index 100% rename from raml/resource-types-and-traits/types/Error.raml rename to web-modules/raml/resource-types-and-traits/types/Error.raml diff --git a/raml/resource-types-and-traits/types/Foo.raml b/web-modules/raml/resource-types-and-traits/types/Foo.raml similarity index 100% rename from raml/resource-types-and-traits/types/Foo.raml rename to web-modules/raml/resource-types-and-traits/types/Foo.raml diff --git a/ratpack/README.md b/web-modules/ratpack/README.md similarity index 100% rename from ratpack/README.md rename to web-modules/ratpack/README.md diff --git a/ratpack/build.gradle b/web-modules/ratpack/build.gradle similarity index 95% rename from ratpack/build.gradle rename to web-modules/ratpack/build.gradle index c997b4e697..f50c5b3800 100644 --- a/ratpack/build.gradle +++ b/web-modules/ratpack/build.gradle @@ -1,37 +1,37 @@ -buildscript { - repositories { - jcenter() - } - dependencies { - classpath "io.ratpack:ratpack-gradle:1.5.4" - classpath "com.h2database:h2:1.4.193" - } -} - -if (!JavaVersion.current().java8Compatible) { - throw new IllegalStateException("Must be built with Java 8 or higher") -} - -apply plugin: "io.ratpack.ratpack-java" -apply plugin: 'java' -apply plugin: 'groovy' -apply plugin: 'io.ratpack.ratpack-groovy' - -repositories { - jcenter() -} - -dependencies { - compile ratpack.dependency('hikari') - compile 'com.h2database:h2:1.4.193' - testCompile 'junit:junit:4.11' - runtime "org.slf4j:slf4j-simple:1.7.21" -} - -test { - testLogging { - events 'started', 'passed' - } -} - -mainClassName = "com.baeldung.Application" +buildscript { + repositories { + jcenter() + } + dependencies { + classpath "io.ratpack:ratpack-gradle:1.5.4" + classpath "com.h2database:h2:1.4.193" + } +} + +if (!JavaVersion.current().java8Compatible) { + throw new IllegalStateException("Must be built with Java 8 or higher") +} + +apply plugin: "io.ratpack.ratpack-java" +apply plugin: 'java' +apply plugin: 'groovy' +apply plugin: 'io.ratpack.ratpack-groovy' + +repositories { + jcenter() +} + +dependencies { + compile ratpack.dependency('hikari') + compile 'com.h2database:h2:1.4.193' + testCompile 'junit:junit:4.11' + runtime "org.slf4j:slf4j-simple:1.7.21" +} + +test { + testLogging { + events 'started', 'passed' + } +} + +mainClassName = "com.baeldung.Application" diff --git a/ratpack/pom.xml b/web-modules/ratpack/pom.xml similarity index 98% rename from ratpack/pom.xml rename to web-modules/ratpack/pom.xml index c57934d8b7..2a63b4118c 100644 --- a/ratpack/pom.xml +++ b/web-modules/ratpack/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/ratpack/src/main/groovy/com/baeldung/Ratpack.groovy b/web-modules/ratpack/src/main/groovy/com/baeldung/Ratpack.groovy similarity index 100% rename from ratpack/src/main/groovy/com/baeldung/Ratpack.groovy rename to web-modules/ratpack/src/main/groovy/com/baeldung/Ratpack.groovy diff --git a/ratpack/src/main/groovy/com/baeldung/RatpackGroovyApp.groovy b/web-modules/ratpack/src/main/groovy/com/baeldung/RatpackGroovyApp.groovy similarity index 100% rename from ratpack/src/main/groovy/com/baeldung/RatpackGroovyApp.groovy rename to web-modules/ratpack/src/main/groovy/com/baeldung/RatpackGroovyApp.groovy diff --git a/ratpack/src/main/groovy/com/baeldung/model/User.groovy b/web-modules/ratpack/src/main/groovy/com/baeldung/model/User.groovy similarity index 100% rename from ratpack/src/main/groovy/com/baeldung/model/User.groovy rename to web-modules/ratpack/src/main/groovy/com/baeldung/model/User.groovy diff --git a/ratpack/src/main/java/com/baeldung/Application.java b/web-modules/ratpack/src/main/java/com/baeldung/Application.java similarity index 97% rename from ratpack/src/main/java/com/baeldung/Application.java rename to web-modules/ratpack/src/main/java/com/baeldung/Application.java index 4a391d04a1..235a6f0068 100644 --- a/ratpack/src/main/java/com/baeldung/Application.java +++ b/web-modules/ratpack/src/main/java/com/baeldung/Application.java @@ -1,81 +1,81 @@ -package com.baeldung; - -import com.baeldung.filter.RequestValidatorFilter; -import com.baeldung.handler.EmployeeHandler; -import com.baeldung.handler.RedirectHandler; -import com.baeldung.model.Employee; -import com.baeldung.repository.EmployeeRepository; -import com.baeldung.repository.EmployeeRepositoryImpl; -import com.zaxxer.hikari.HikariConfig; -import io.netty.buffer.PooledByteBufAllocator; -import ratpack.func.Action; -import ratpack.func.Function; -import ratpack.guice.BindingsSpec; -import ratpack.guice.Guice; -import ratpack.handling.Chain; -import ratpack.hikari.HikariModule; -import ratpack.http.client.HttpClient; -import ratpack.jackson.Jackson; -import ratpack.registry.Registry; -import ratpack.server.RatpackServer; -import ratpack.server.RatpackServerSpec; -import ratpack.server.ServerConfig; - -import java.time.Duration; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.List; - -public class Application { - - public static void main(String[] args) throws Exception { - - final Action hikariConfigAction = hikariConfig -> { - hikariConfig.setDataSourceClassName("org.h2.jdbcx.JdbcDataSource"); - hikariConfig.addDataSourceProperty("URL", "jdbc:h2:mem:baeldung;INIT=RUNSCRIPT FROM 'classpath:/DDL.sql'"); - }; - - final Action bindingsSpecAction = bindings -> bindings.module(HikariModule.class, hikariConfigAction); - final HttpClient httpClient = HttpClient.of(httpClientSpec -> { - httpClientSpec.poolSize(10) - .connectTimeout(Duration.of(60, ChronoUnit.SECONDS)) - .maxContentLength(ServerConfig.DEFAULT_MAX_CONTENT_LENGTH) - .responseMaxChunkSize(16384) - .readTimeout(Duration.of(60, ChronoUnit.SECONDS)) - .byteBufAllocator(PooledByteBufAllocator.DEFAULT); - }); - final Function registryFunction = Guice.registry(bindingsSpecAction); - - final Action chainAction = chain -> chain.all(new RequestValidatorFilter()) - .get(ctx -> ctx.render("Welcome to baeldung ratpack!!!")) - .get("data/employees", ctx -> ctx.render(Jackson.json(createEmpList()))) - .get(":name", ctx -> ctx.render("Hello " + ctx.getPathTokens() - .get("name") + "!!!")) - .post(":amount", ctx -> ctx.render(" Amount $" + ctx.getPathTokens() - .get("amount") + " added successfully !!!")); - - final Action routerChainAction = routerChain -> { - routerChain.path("redirect", new RedirectHandler()) - .prefix("employee", empChain -> { - empChain.get(":id", new EmployeeHandler()); - }); - }; - final Action ratpackServerSpecAction = serverSpec -> serverSpec.registry(registryFunction) - .registryOf(registrySpec -> { - registrySpec.add(EmployeeRepository.class, new EmployeeRepositoryImpl()); - registrySpec.add(HttpClient.class, httpClient); - }) - .handlers(chain -> chain.insert(routerChainAction) - .insert(chainAction)); - - RatpackServer.start(ratpackServerSpecAction); - } - - private static List createEmpList() { - List employees = new ArrayList<>(); - employees.add(new Employee(1L, "Mr", "John Doe")); - employees.add(new Employee(2L, "Mr", "White Snow")); - return employees; - } - -} +package com.baeldung; + +import com.baeldung.filter.RequestValidatorFilter; +import com.baeldung.handler.EmployeeHandler; +import com.baeldung.handler.RedirectHandler; +import com.baeldung.model.Employee; +import com.baeldung.repository.EmployeeRepository; +import com.baeldung.repository.EmployeeRepositoryImpl; +import com.zaxxer.hikari.HikariConfig; +import io.netty.buffer.PooledByteBufAllocator; +import ratpack.func.Action; +import ratpack.func.Function; +import ratpack.guice.BindingsSpec; +import ratpack.guice.Guice; +import ratpack.handling.Chain; +import ratpack.hikari.HikariModule; +import ratpack.http.client.HttpClient; +import ratpack.jackson.Jackson; +import ratpack.registry.Registry; +import ratpack.server.RatpackServer; +import ratpack.server.RatpackServerSpec; +import ratpack.server.ServerConfig; + +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; + +public class Application { + + public static void main(String[] args) throws Exception { + + final Action hikariConfigAction = hikariConfig -> { + hikariConfig.setDataSourceClassName("org.h2.jdbcx.JdbcDataSource"); + hikariConfig.addDataSourceProperty("URL", "jdbc:h2:mem:baeldung;INIT=RUNSCRIPT FROM 'classpath:/DDL.sql'"); + }; + + final Action bindingsSpecAction = bindings -> bindings.module(HikariModule.class, hikariConfigAction); + final HttpClient httpClient = HttpClient.of(httpClientSpec -> { + httpClientSpec.poolSize(10) + .connectTimeout(Duration.of(60, ChronoUnit.SECONDS)) + .maxContentLength(ServerConfig.DEFAULT_MAX_CONTENT_LENGTH) + .responseMaxChunkSize(16384) + .readTimeout(Duration.of(60, ChronoUnit.SECONDS)) + .byteBufAllocator(PooledByteBufAllocator.DEFAULT); + }); + final Function registryFunction = Guice.registry(bindingsSpecAction); + + final Action chainAction = chain -> chain.all(new RequestValidatorFilter()) + .get(ctx -> ctx.render("Welcome to baeldung ratpack!!!")) + .get("data/employees", ctx -> ctx.render(Jackson.json(createEmpList()))) + .get(":name", ctx -> ctx.render("Hello " + ctx.getPathTokens() + .get("name") + "!!!")) + .post(":amount", ctx -> ctx.render(" Amount $" + ctx.getPathTokens() + .get("amount") + " added successfully !!!")); + + final Action routerChainAction = routerChain -> { + routerChain.path("redirect", new RedirectHandler()) + .prefix("employee", empChain -> { + empChain.get(":id", new EmployeeHandler()); + }); + }; + final Action ratpackServerSpecAction = serverSpec -> serverSpec.registry(registryFunction) + .registryOf(registrySpec -> { + registrySpec.add(EmployeeRepository.class, new EmployeeRepositoryImpl()); + registrySpec.add(HttpClient.class, httpClient); + }) + .handlers(chain -> chain.insert(routerChainAction) + .insert(chainAction)); + + RatpackServer.start(ratpackServerSpecAction); + } + + private static List createEmpList() { + List employees = new ArrayList<>(); + employees.add(new Employee(1L, "Mr", "John Doe")); + employees.add(new Employee(2L, "Mr", "White Snow")); + return employees; + } + +} diff --git a/ratpack/src/main/java/com/baeldung/filter/RequestValidatorFilter.java b/web-modules/ratpack/src/main/java/com/baeldung/filter/RequestValidatorFilter.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/filter/RequestValidatorFilter.java rename to web-modules/ratpack/src/main/java/com/baeldung/filter/RequestValidatorFilter.java diff --git a/ratpack/src/main/java/com/baeldung/guice/Application.java b/web-modules/ratpack/src/main/java/com/baeldung/guice/Application.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/guice/Application.java rename to web-modules/ratpack/src/main/java/com/baeldung/guice/Application.java diff --git a/ratpack/src/main/java/com/baeldung/guice/config/DependencyModule.java b/web-modules/ratpack/src/main/java/com/baeldung/guice/config/DependencyModule.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/guice/config/DependencyModule.java rename to web-modules/ratpack/src/main/java/com/baeldung/guice/config/DependencyModule.java diff --git a/ratpack/src/main/java/com/baeldung/guice/service/DataPumpService.java b/web-modules/ratpack/src/main/java/com/baeldung/guice/service/DataPumpService.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/guice/service/DataPumpService.java rename to web-modules/ratpack/src/main/java/com/baeldung/guice/service/DataPumpService.java diff --git a/ratpack/src/main/java/com/baeldung/guice/service/ServiceFactory.java b/web-modules/ratpack/src/main/java/com/baeldung/guice/service/ServiceFactory.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/guice/service/ServiceFactory.java rename to web-modules/ratpack/src/main/java/com/baeldung/guice/service/ServiceFactory.java diff --git a/ratpack/src/main/java/com/baeldung/guice/service/impl/DataPumpServiceImpl.java b/web-modules/ratpack/src/main/java/com/baeldung/guice/service/impl/DataPumpServiceImpl.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/guice/service/impl/DataPumpServiceImpl.java rename to web-modules/ratpack/src/main/java/com/baeldung/guice/service/impl/DataPumpServiceImpl.java diff --git a/ratpack/src/main/java/com/baeldung/handler/EmployeeHandler.java b/web-modules/ratpack/src/main/java/com/baeldung/handler/EmployeeHandler.java similarity index 97% rename from ratpack/src/main/java/com/baeldung/handler/EmployeeHandler.java rename to web-modules/ratpack/src/main/java/com/baeldung/handler/EmployeeHandler.java index 9a6b79259c..9144e68434 100644 --- a/ratpack/src/main/java/com/baeldung/handler/EmployeeHandler.java +++ b/web-modules/ratpack/src/main/java/com/baeldung/handler/EmployeeHandler.java @@ -1,20 +1,20 @@ -package com.baeldung.handler; - -import com.baeldung.repository.EmployeeRepository; -import com.baeldung.model.Employee; -import ratpack.exec.Promise; -import ratpack.handling.Context; -import ratpack.handling.Handler; - -public class EmployeeHandler implements Handler { - @Override - public void handle(Context ctx) throws Exception { - EmployeeRepository repository = ctx.get(EmployeeRepository.class); - Long id = Long.valueOf(ctx.getPathTokens() - .get("id")); - Promise employeePromise = repository.findEmployeeById(id); - employeePromise.map(employee -> employee.getName()) - .then(name -> ctx.getResponse() - .send(name)); - } -} +package com.baeldung.handler; + +import com.baeldung.repository.EmployeeRepository; +import com.baeldung.model.Employee; +import ratpack.exec.Promise; +import ratpack.handling.Context; +import ratpack.handling.Handler; + +public class EmployeeHandler implements Handler { + @Override + public void handle(Context ctx) throws Exception { + EmployeeRepository repository = ctx.get(EmployeeRepository.class); + Long id = Long.valueOf(ctx.getPathTokens() + .get("id")); + Promise employeePromise = repository.findEmployeeById(id); + employeePromise.map(employee -> employee.getName()) + .then(name -> ctx.getResponse() + .send(name)); + } +} diff --git a/ratpack/src/main/java/com/baeldung/handler/FooHandler.java b/web-modules/ratpack/src/main/java/com/baeldung/handler/FooHandler.java similarity index 95% rename from ratpack/src/main/java/com/baeldung/handler/FooHandler.java rename to web-modules/ratpack/src/main/java/com/baeldung/handler/FooHandler.java index d2c4dbdce5..c80d3a0654 100644 --- a/ratpack/src/main/java/com/baeldung/handler/FooHandler.java +++ b/web-modules/ratpack/src/main/java/com/baeldung/handler/FooHandler.java @@ -1,12 +1,12 @@ -package com.baeldung.handler; - -import ratpack.handling.Context; -import ratpack.handling.Handler; - -public class FooHandler implements Handler { - @Override - public void handle(Context ctx) throws Exception { - ctx.getResponse() - .send("Hello Foo!"); - } -} +package com.baeldung.handler; + +import ratpack.handling.Context; +import ratpack.handling.Handler; + +public class FooHandler implements Handler { + @Override + public void handle(Context ctx) throws Exception { + ctx.getResponse() + .send("Hello Foo!"); + } +} diff --git a/ratpack/src/main/java/com/baeldung/handler/RedirectHandler.java b/web-modules/ratpack/src/main/java/com/baeldung/handler/RedirectHandler.java similarity index 97% rename from ratpack/src/main/java/com/baeldung/handler/RedirectHandler.java rename to web-modules/ratpack/src/main/java/com/baeldung/handler/RedirectHandler.java index c95543a961..2ed4431ef2 100644 --- a/ratpack/src/main/java/com/baeldung/handler/RedirectHandler.java +++ b/web-modules/ratpack/src/main/java/com/baeldung/handler/RedirectHandler.java @@ -1,23 +1,23 @@ -package com.baeldung.handler; - -import ratpack.exec.Promise; -import ratpack.handling.Context; -import ratpack.handling.Handler; -import ratpack.http.client.HttpClient; -import ratpack.http.client.ReceivedResponse; - -import java.net.URI; - -public class RedirectHandler implements Handler { - @Override - public void handle(Context ctx) throws Exception { - HttpClient client = ctx.get(HttpClient.class); - URI uri = URI.create("http://localhost:5050/employee/1"); - Promise responsePromise = client.get(uri); - responsePromise.map(response -> response.getBody() - .getText() - .toUpperCase()) - .then(responseText -> ctx.getResponse() - .send(responseText)); - } +package com.baeldung.handler; + +import ratpack.exec.Promise; +import ratpack.handling.Context; +import ratpack.handling.Handler; +import ratpack.http.client.HttpClient; +import ratpack.http.client.ReceivedResponse; + +import java.net.URI; + +public class RedirectHandler implements Handler { + @Override + public void handle(Context ctx) throws Exception { + HttpClient client = ctx.get(HttpClient.class); + URI uri = URI.create("http://localhost:5050/employee/1"); + Promise responsePromise = client.get(uri); + responsePromise.map(response -> response.getBody() + .getText() + .toUpperCase()) + .then(responseText -> ctx.getResponse() + .send(responseText)); + } } \ No newline at end of file diff --git a/ratpack/src/main/java/com/baeldung/hystrix/HystrixAsyncHttpCommand.java b/web-modules/ratpack/src/main/java/com/baeldung/hystrix/HystrixAsyncHttpCommand.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/hystrix/HystrixAsyncHttpCommand.java rename to web-modules/ratpack/src/main/java/com/baeldung/hystrix/HystrixAsyncHttpCommand.java diff --git a/ratpack/src/main/java/com/baeldung/hystrix/HystrixReactiveHttpCommand.java b/web-modules/ratpack/src/main/java/com/baeldung/hystrix/HystrixReactiveHttpCommand.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/hystrix/HystrixReactiveHttpCommand.java rename to web-modules/ratpack/src/main/java/com/baeldung/hystrix/HystrixReactiveHttpCommand.java diff --git a/ratpack/src/main/java/com/baeldung/hystrix/HystrixSyncHttpCommand.java b/web-modules/ratpack/src/main/java/com/baeldung/hystrix/HystrixSyncHttpCommand.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/hystrix/HystrixSyncHttpCommand.java rename to web-modules/ratpack/src/main/java/com/baeldung/hystrix/HystrixSyncHttpCommand.java diff --git a/ratpack/src/main/java/com/baeldung/hystrix/RatpackHystrixApp.java b/web-modules/ratpack/src/main/java/com/baeldung/hystrix/RatpackHystrixApp.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/hystrix/RatpackHystrixApp.java rename to web-modules/ratpack/src/main/java/com/baeldung/hystrix/RatpackHystrixApp.java diff --git a/ratpack/src/main/java/com/baeldung/model/Employee.java b/web-modules/ratpack/src/main/java/com/baeldung/model/Employee.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/model/Employee.java rename to web-modules/ratpack/src/main/java/com/baeldung/model/Employee.java diff --git a/ratpack/src/main/java/com/baeldung/model/Movie.java b/web-modules/ratpack/src/main/java/com/baeldung/model/Movie.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/model/Movie.java rename to web-modules/ratpack/src/main/java/com/baeldung/model/Movie.java diff --git a/ratpack/src/main/java/com/baeldung/model/Quote.java b/web-modules/ratpack/src/main/java/com/baeldung/model/Quote.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/model/Quote.java rename to web-modules/ratpack/src/main/java/com/baeldung/model/Quote.java diff --git a/ratpack/src/main/java/com/baeldung/repository/EmployeeRepository.java b/web-modules/ratpack/src/main/java/com/baeldung/repository/EmployeeRepository.java similarity index 95% rename from ratpack/src/main/java/com/baeldung/repository/EmployeeRepository.java rename to web-modules/ratpack/src/main/java/com/baeldung/repository/EmployeeRepository.java index de04c23da5..2b23f91877 100644 --- a/ratpack/src/main/java/com/baeldung/repository/EmployeeRepository.java +++ b/web-modules/ratpack/src/main/java/com/baeldung/repository/EmployeeRepository.java @@ -1,10 +1,10 @@ -package com.baeldung.repository; - -import com.baeldung.model.Employee; -import ratpack.exec.Promise; - -public interface EmployeeRepository { - - Promise findEmployeeById(Long id) throws Exception; - -} +package com.baeldung.repository; + +import com.baeldung.model.Employee; +import ratpack.exec.Promise; + +public interface EmployeeRepository { + + Promise findEmployeeById(Long id) throws Exception; + +} diff --git a/ratpack/src/main/java/com/baeldung/repository/EmployeeRepositoryImpl.java b/web-modules/ratpack/src/main/java/com/baeldung/repository/EmployeeRepositoryImpl.java similarity index 96% rename from ratpack/src/main/java/com/baeldung/repository/EmployeeRepositoryImpl.java rename to web-modules/ratpack/src/main/java/com/baeldung/repository/EmployeeRepositoryImpl.java index 6d15012ccb..122e5206b1 100644 --- a/ratpack/src/main/java/com/baeldung/repository/EmployeeRepositoryImpl.java +++ b/web-modules/ratpack/src/main/java/com/baeldung/repository/EmployeeRepositoryImpl.java @@ -1,25 +1,25 @@ -package com.baeldung.repository; - -import com.baeldung.model.Employee; -import ratpack.exec.Promise; - -import java.util.HashMap; -import java.util.Map; - -public class EmployeeRepositoryImpl implements EmployeeRepository { - - private static final Map EMPLOYEE_MAP = new HashMap<>(); - - public EmployeeRepositoryImpl() { - EMPLOYEE_MAP.put(1L, new Employee(1L, "Ms", "Jane Doe")); - EMPLOYEE_MAP.put(2L, new Employee(2L, "Mr", "NY")); - } - - @Override - public Promise findEmployeeById(Long id) throws Exception { - return Promise.async(downstream -> { - Thread.sleep(500); - downstream.success(EMPLOYEE_MAP.get(id)); - }); - } -} +package com.baeldung.repository; + +import com.baeldung.model.Employee; +import ratpack.exec.Promise; + +import java.util.HashMap; +import java.util.Map; + +public class EmployeeRepositoryImpl implements EmployeeRepository { + + private static final Map EMPLOYEE_MAP = new HashMap<>(); + + public EmployeeRepositoryImpl() { + EMPLOYEE_MAP.put(1L, new Employee(1L, "Ms", "Jane Doe")); + EMPLOYEE_MAP.put(2L, new Employee(2L, "Mr", "NY")); + } + + @Override + public Promise findEmployeeById(Long id) throws Exception { + return Promise.async(downstream -> { + Thread.sleep(500); + downstream.success(EMPLOYEE_MAP.get(id)); + }); + } +} diff --git a/ratpack/src/main/java/com/baeldung/rxjava/RatpackErrorHandlingApp.java b/web-modules/ratpack/src/main/java/com/baeldung/rxjava/RatpackErrorHandlingApp.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/rxjava/RatpackErrorHandlingApp.java rename to web-modules/ratpack/src/main/java/com/baeldung/rxjava/RatpackErrorHandlingApp.java diff --git a/ratpack/src/main/java/com/baeldung/rxjava/RatpackObserveApp.java b/web-modules/ratpack/src/main/java/com/baeldung/rxjava/RatpackObserveApp.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/rxjava/RatpackObserveApp.java rename to web-modules/ratpack/src/main/java/com/baeldung/rxjava/RatpackObserveApp.java diff --git a/ratpack/src/main/java/com/baeldung/rxjava/RatpackParallelismApp.java b/web-modules/ratpack/src/main/java/com/baeldung/rxjava/RatpackParallelismApp.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/rxjava/RatpackParallelismApp.java rename to web-modules/ratpack/src/main/java/com/baeldung/rxjava/RatpackParallelismApp.java diff --git a/ratpack/src/main/java/com/baeldung/rxjava/RatpackPromiseApp.java b/web-modules/ratpack/src/main/java/com/baeldung/rxjava/RatpackPromiseApp.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/rxjava/RatpackPromiseApp.java rename to web-modules/ratpack/src/main/java/com/baeldung/rxjava/RatpackPromiseApp.java diff --git a/ratpack/src/main/java/com/baeldung/rxjava/service/MovieObservableService.java b/web-modules/ratpack/src/main/java/com/baeldung/rxjava/service/MovieObservableService.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/rxjava/service/MovieObservableService.java rename to web-modules/ratpack/src/main/java/com/baeldung/rxjava/service/MovieObservableService.java diff --git a/ratpack/src/main/java/com/baeldung/rxjava/service/MoviePromiseService.java b/web-modules/ratpack/src/main/java/com/baeldung/rxjava/service/MoviePromiseService.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/rxjava/service/MoviePromiseService.java rename to web-modules/ratpack/src/main/java/com/baeldung/rxjava/service/MoviePromiseService.java diff --git a/ratpack/src/main/java/com/baeldung/rxjava/service/QuotesService.java b/web-modules/ratpack/src/main/java/com/baeldung/rxjava/service/QuotesService.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/rxjava/service/QuotesService.java rename to web-modules/ratpack/src/main/java/com/baeldung/rxjava/service/QuotesService.java diff --git a/ratpack/src/main/java/com/baeldung/rxjava/service/impl/MovieObservableServiceImpl.java b/web-modules/ratpack/src/main/java/com/baeldung/rxjava/service/impl/MovieObservableServiceImpl.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/rxjava/service/impl/MovieObservableServiceImpl.java rename to web-modules/ratpack/src/main/java/com/baeldung/rxjava/service/impl/MovieObservableServiceImpl.java diff --git a/ratpack/src/main/java/com/baeldung/rxjava/service/impl/MoviePromiseServiceImpl.java b/web-modules/ratpack/src/main/java/com/baeldung/rxjava/service/impl/MoviePromiseServiceImpl.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/rxjava/service/impl/MoviePromiseServiceImpl.java rename to web-modules/ratpack/src/main/java/com/baeldung/rxjava/service/impl/MoviePromiseServiceImpl.java diff --git a/ratpack/src/main/java/com/baeldung/spring/ArticleList.java b/web-modules/ratpack/src/main/java/com/baeldung/spring/ArticleList.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/spring/ArticleList.java rename to web-modules/ratpack/src/main/java/com/baeldung/spring/ArticleList.java diff --git a/ratpack/src/main/java/com/baeldung/spring/Config.java b/web-modules/ratpack/src/main/java/com/baeldung/spring/Config.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/spring/Config.java rename to web-modules/ratpack/src/main/java/com/baeldung/spring/Config.java diff --git a/ratpack/src/main/java/com/baeldung/spring/Content.java b/web-modules/ratpack/src/main/java/com/baeldung/spring/Content.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/spring/Content.java rename to web-modules/ratpack/src/main/java/com/baeldung/spring/Content.java diff --git a/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackApp.java b/web-modules/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackApp.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/spring/EmbedRatpackApp.java rename to web-modules/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackApp.java diff --git a/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackStreamsApp.java b/web-modules/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackStreamsApp.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/spring/EmbedRatpackStreamsApp.java rename to web-modules/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackStreamsApp.java diff --git a/ratpack/src/main/java/com/baeldung/spring/EmbedSpringBootApp.java b/web-modules/ratpack/src/main/java/com/baeldung/spring/EmbedSpringBootApp.java similarity index 100% rename from ratpack/src/main/java/com/baeldung/spring/EmbedSpringBootApp.java rename to web-modules/ratpack/src/main/java/com/baeldung/spring/EmbedSpringBootApp.java diff --git a/ratpack/src/main/resources/DDL.sql b/web-modules/ratpack/src/main/resources/DDL.sql similarity index 100% rename from ratpack/src/main/resources/DDL.sql rename to web-modules/ratpack/src/main/resources/DDL.sql diff --git a/ratpack/src/main/resources/User.sql b/web-modules/ratpack/src/main/resources/User.sql similarity index 100% rename from ratpack/src/main/resources/User.sql rename to web-modules/ratpack/src/main/resources/User.sql diff --git a/spring-vertx/src/main/resources/logback.xml b/web-modules/ratpack/src/main/resources/logback.xml similarity index 100% rename from spring-vertx/src/main/resources/logback.xml rename to web-modules/ratpack/src/main/resources/logback.xml diff --git a/ratpack/src/main/resources/public/index.html b/web-modules/ratpack/src/main/resources/public/index.html similarity index 100% rename from ratpack/src/main/resources/public/index.html rename to web-modules/ratpack/src/main/resources/public/index.html diff --git a/ratpack/src/test/groovy/com/baeldung/RatpackGroovySpec.groovy b/web-modules/ratpack/src/test/groovy/com/baeldung/RatpackGroovySpec.groovy similarity index 100% rename from ratpack/src/test/groovy/com/baeldung/RatpackGroovySpec.groovy rename to web-modules/ratpack/src/test/groovy/com/baeldung/RatpackGroovySpec.groovy diff --git a/ratpack/src/test/java/com/baeldung/AppHttpUnitTest.java b/web-modules/ratpack/src/test/java/com/baeldung/AppHttpUnitTest.java similarity index 97% rename from ratpack/src/test/java/com/baeldung/AppHttpUnitTest.java rename to web-modules/ratpack/src/test/java/com/baeldung/AppHttpUnitTest.java index a97516dd74..74517d9a9b 100644 --- a/ratpack/src/test/java/com/baeldung/AppHttpUnitTest.java +++ b/web-modules/ratpack/src/test/java/com/baeldung/AppHttpUnitTest.java @@ -1,58 +1,58 @@ -package com.baeldung; - -import com.baeldung.model.Employee; -import org.junit.Test; -import ratpack.exec.Promise; -import ratpack.func.Action; -import ratpack.handling.Chain; -import ratpack.handling.Handler; -import ratpack.registry.Registry; -import ratpack.test.embed.EmbeddedApp; -import ratpack.test.exec.ExecHarness; - -import static org.junit.Assert.assertEquals; - -public class AppHttpUnitTest { - - @Test - public void givenAnyUri_GetEmployeeFromSameRegistry() throws Exception { - Handler allHandler = ctx -> { - Long id = Long.valueOf(ctx.getPathTokens() - .get("id")); - Employee employee = new Employee(id, "Mr", "NY"); - ctx.next(Registry.single(Employee.class, employee)); - }; - Handler empNameHandler = ctx -> { - Employee employee = ctx.get(Employee.class); - ctx.getResponse() - .send("Name of employee with ID " + employee.getId() + " is " + employee.getName()); - }; - Handler empTitleHandler = ctx -> { - Employee employee = ctx.get(Employee.class); - ctx.getResponse() - .send("Title of employee with ID " + employee.getId() + " is " + employee.getTitle()); - }; - - Action chainAction = chain -> chain.prefix("employee/:id", empChain -> { - empChain.all(allHandler) - .get("name", empNameHandler) - .get("title", empTitleHandler); - }); - EmbeddedApp.fromHandlers(chainAction) - .test(testHttpClient -> { - assertEquals("Name of employee with ID 1 is NY", testHttpClient.get("employee/1/name") - .getBody() - .getText()); - assertEquals("Title of employee with ID 1 is Mr", testHttpClient.get("employee/1/title") - .getBody() - .getText()); - }); - } - - @Test - public void givenSyncDataSource_GetDataFromPromise() throws Exception { - String value = ExecHarness.yieldSingle(execution -> Promise.sync(() -> "Foo")) - .getValueOrThrow(); - assertEquals("Foo", value); - } -} +package com.baeldung; + +import com.baeldung.model.Employee; +import org.junit.Test; +import ratpack.exec.Promise; +import ratpack.func.Action; +import ratpack.handling.Chain; +import ratpack.handling.Handler; +import ratpack.registry.Registry; +import ratpack.test.embed.EmbeddedApp; +import ratpack.test.exec.ExecHarness; + +import static org.junit.Assert.assertEquals; + +public class AppHttpUnitTest { + + @Test + public void givenAnyUri_GetEmployeeFromSameRegistry() throws Exception { + Handler allHandler = ctx -> { + Long id = Long.valueOf(ctx.getPathTokens() + .get("id")); + Employee employee = new Employee(id, "Mr", "NY"); + ctx.next(Registry.single(Employee.class, employee)); + }; + Handler empNameHandler = ctx -> { + Employee employee = ctx.get(Employee.class); + ctx.getResponse() + .send("Name of employee with ID " + employee.getId() + " is " + employee.getName()); + }; + Handler empTitleHandler = ctx -> { + Employee employee = ctx.get(Employee.class); + ctx.getResponse() + .send("Title of employee with ID " + employee.getId() + " is " + employee.getTitle()); + }; + + Action chainAction = chain -> chain.prefix("employee/:id", empChain -> { + empChain.all(allHandler) + .get("name", empNameHandler) + .get("title", empTitleHandler); + }); + EmbeddedApp.fromHandlers(chainAction) + .test(testHttpClient -> { + assertEquals("Name of employee with ID 1 is NY", testHttpClient.get("employee/1/name") + .getBody() + .getText()); + assertEquals("Title of employee with ID 1 is Mr", testHttpClient.get("employee/1/title") + .getBody() + .getText()); + }); + } + + @Test + public void givenSyncDataSource_GetDataFromPromise() throws Exception { + String value = ExecHarness.yieldSingle(execution -> Promise.sync(() -> "Foo")) + .getValueOrThrow(); + assertEquals("Foo", value); + } +} diff --git a/ratpack/src/test/java/com/baeldung/ApplicationIntegrationTest.java b/web-modules/ratpack/src/test/java/com/baeldung/ApplicationIntegrationTest.java similarity index 100% rename from ratpack/src/test/java/com/baeldung/ApplicationIntegrationTest.java rename to web-modules/ratpack/src/test/java/com/baeldung/ApplicationIntegrationTest.java diff --git a/ratpack/src/test/java/com/baeldung/hystrix/RatpackHystrixAppFallbackLiveTest.java b/web-modules/ratpack/src/test/java/com/baeldung/hystrix/RatpackHystrixAppFallbackLiveTest.java similarity index 100% rename from ratpack/src/test/java/com/baeldung/hystrix/RatpackHystrixAppFallbackLiveTest.java rename to web-modules/ratpack/src/test/java/com/baeldung/hystrix/RatpackHystrixAppFallbackLiveTest.java diff --git a/ratpack/src/test/java/com/baeldung/hystrix/RatpackHystrixAppLiveTest.java b/web-modules/ratpack/src/test/java/com/baeldung/hystrix/RatpackHystrixAppLiveTest.java similarity index 100% rename from ratpack/src/test/java/com/baeldung/hystrix/RatpackHystrixAppLiveTest.java rename to web-modules/ratpack/src/test/java/com/baeldung/hystrix/RatpackHystrixAppLiveTest.java diff --git a/ratpack/src/test/java/com/baeldung/ratpack/CompliantPublisher.java b/web-modules/ratpack/src/test/java/com/baeldung/ratpack/CompliantPublisher.java similarity index 100% rename from ratpack/src/test/java/com/baeldung/ratpack/CompliantPublisher.java rename to web-modules/ratpack/src/test/java/com/baeldung/ratpack/CompliantPublisher.java diff --git a/ratpack/src/test/java/com/baeldung/ratpack/LoggingSubscriber.java b/web-modules/ratpack/src/test/java/com/baeldung/ratpack/LoggingSubscriber.java similarity index 100% rename from ratpack/src/test/java/com/baeldung/ratpack/LoggingSubscriber.java rename to web-modules/ratpack/src/test/java/com/baeldung/ratpack/LoggingSubscriber.java diff --git a/ratpack/src/test/java/com/baeldung/ratpack/NonCompliantPublisher.java b/web-modules/ratpack/src/test/java/com/baeldung/ratpack/NonCompliantPublisher.java similarity index 100% rename from ratpack/src/test/java/com/baeldung/ratpack/NonCompliantPublisher.java rename to web-modules/ratpack/src/test/java/com/baeldung/ratpack/NonCompliantPublisher.java diff --git a/ratpack/src/test/java/com/baeldung/ratpack/RatpackStreamsUnitTest.java b/web-modules/ratpack/src/test/java/com/baeldung/ratpack/RatpackStreamsUnitTest.java similarity index 100% rename from ratpack/src/test/java/com/baeldung/ratpack/RatpackStreamsUnitTest.java rename to web-modules/ratpack/src/test/java/com/baeldung/ratpack/RatpackStreamsUnitTest.java diff --git a/ratpack/src/test/java/com/baeldung/spring/EmbedRatpackAppIntegrationTest.java b/web-modules/ratpack/src/test/java/com/baeldung/spring/EmbedRatpackAppIntegrationTest.java similarity index 100% rename from ratpack/src/test/java/com/baeldung/spring/EmbedRatpackAppIntegrationTest.java rename to web-modules/ratpack/src/test/java/com/baeldung/spring/EmbedRatpackAppIntegrationTest.java diff --git a/resteasy/README.md b/web-modules/resteasy/README.md similarity index 100% rename from resteasy/README.md rename to web-modules/resteasy/README.md diff --git a/resteasy/pom.xml b/web-modules/resteasy/pom.xml similarity index 99% rename from resteasy/pom.xml rename to web-modules/resteasy/pom.xml index b12576e583..355dcdb9b5 100644 --- a/resteasy/pom.xml +++ b/web-modules/resteasy/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/resteasy/src/main/java/com/baeldung/client/ServicesInterface.java b/web-modules/resteasy/src/main/java/com/baeldung/client/ServicesInterface.java similarity index 100% rename from resteasy/src/main/java/com/baeldung/client/ServicesInterface.java rename to web-modules/resteasy/src/main/java/com/baeldung/client/ServicesInterface.java diff --git a/resteasy/src/main/java/com/baeldung/filter/CORSFilter.java b/web-modules/resteasy/src/main/java/com/baeldung/filter/CORSFilter.java similarity index 100% rename from resteasy/src/main/java/com/baeldung/filter/CORSFilter.java rename to web-modules/resteasy/src/main/java/com/baeldung/filter/CORSFilter.java diff --git a/resteasy/src/main/java/com/baeldung/model/Movie.java b/web-modules/resteasy/src/main/java/com/baeldung/model/Movie.java similarity index 100% rename from resteasy/src/main/java/com/baeldung/model/Movie.java rename to web-modules/resteasy/src/main/java/com/baeldung/model/Movie.java diff --git a/resteasy/src/main/java/com/baeldung/server/MovieCrudService.java b/web-modules/resteasy/src/main/java/com/baeldung/server/MovieCrudService.java similarity index 100% rename from resteasy/src/main/java/com/baeldung/server/MovieCrudService.java rename to web-modules/resteasy/src/main/java/com/baeldung/server/MovieCrudService.java diff --git a/resteasy/src/main/java/com/baeldung/server/RestEasyServices.java b/web-modules/resteasy/src/main/java/com/baeldung/server/RestEasyServices.java similarity index 100% rename from resteasy/src/main/java/com/baeldung/server/RestEasyServices.java rename to web-modules/resteasy/src/main/java/com/baeldung/server/RestEasyServices.java diff --git a/struts-2/src/main/resources/logback.xml b/web-modules/resteasy/src/main/resources/logback.xml similarity index 100% rename from struts-2/src/main/resources/logback.xml rename to web-modules/resteasy/src/main/resources/logback.xml diff --git a/resteasy/src/main/webapp/WEB-INF/classes/logback.xml b/web-modules/resteasy/src/main/webapp/WEB-INF/classes/logback.xml similarity index 100% rename from resteasy/src/main/webapp/WEB-INF/classes/logback.xml rename to web-modules/resteasy/src/main/webapp/WEB-INF/classes/logback.xml diff --git a/resteasy/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/web-modules/resteasy/src/main/webapp/WEB-INF/jboss-deployment-structure.xml similarity index 100% rename from resteasy/src/main/webapp/WEB-INF/jboss-deployment-structure.xml rename to web-modules/resteasy/src/main/webapp/WEB-INF/jboss-deployment-structure.xml diff --git a/resteasy/src/main/webapp/WEB-INF/jboss-web.xml b/web-modules/resteasy/src/main/webapp/WEB-INF/jboss-web.xml similarity index 100% rename from resteasy/src/main/webapp/WEB-INF/jboss-web.xml rename to web-modules/resteasy/src/main/webapp/WEB-INF/jboss-web.xml diff --git a/resteasy/src/main/webapp/WEB-INF/web.xml b/web-modules/resteasy/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from resteasy/src/main/webapp/WEB-INF/web.xml rename to web-modules/resteasy/src/main/webapp/WEB-INF/web.xml diff --git a/resteasy/src/main/webapp/script.js b/web-modules/resteasy/src/main/webapp/script.js similarity index 100% rename from resteasy/src/main/webapp/script.js rename to web-modules/resteasy/src/main/webapp/script.js diff --git a/resteasy/src/test/java/com/baeldung/server/RestEasyClientLiveTest.java b/web-modules/resteasy/src/test/java/com/baeldung/server/RestEasyClientLiveTest.java similarity index 100% rename from resteasy/src/test/java/com/baeldung/server/RestEasyClientLiveTest.java rename to web-modules/resteasy/src/test/java/com/baeldung/server/RestEasyClientLiveTest.java diff --git a/resteasy/src/test/resources/com/baeldung/server/movies/batman.json b/web-modules/resteasy/src/test/resources/com/baeldung/server/movies/batman.json similarity index 100% rename from resteasy/src/test/resources/com/baeldung/server/movies/batman.json rename to web-modules/resteasy/src/test/resources/com/baeldung/server/movies/batman.json diff --git a/resteasy/src/test/resources/com/baeldung/server/movies/transformer.json b/web-modules/resteasy/src/test/resources/com/baeldung/server/movies/transformer.json similarity index 100% rename from resteasy/src/test/resources/com/baeldung/server/movies/transformer.json rename to web-modules/resteasy/src/test/resources/com/baeldung/server/movies/transformer.json diff --git a/restx/README.md b/web-modules/restx/README.md similarity index 100% rename from restx/README.md rename to web-modules/restx/README.md diff --git a/restx/data/credentials.json b/web-modules/restx/data/credentials.json similarity index 100% rename from restx/data/credentials.json rename to web-modules/restx/data/credentials.json diff --git a/restx/data/users.json b/web-modules/restx/data/users.json similarity index 100% rename from restx/data/users.json rename to web-modules/restx/data/users.json diff --git a/restx/md.restx.json b/web-modules/restx/md.restx.json similarity index 100% rename from restx/md.restx.json rename to web-modules/restx/md.restx.json diff --git a/restx/pom.xml b/web-modules/restx/pom.xml similarity index 99% rename from restx/pom.xml rename to web-modules/restx/pom.xml index 953b56e2f3..e48ee897e5 100644 --- a/restx/pom.xml +++ b/web-modules/restx/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/restx/src/main/java/restx/demo/AppModule.java b/web-modules/restx/src/main/java/restx/demo/AppModule.java similarity index 100% rename from restx/src/main/java/restx/demo/AppModule.java rename to web-modules/restx/src/main/java/restx/demo/AppModule.java diff --git a/restx/src/main/java/restx/demo/AppServer.java b/web-modules/restx/src/main/java/restx/demo/AppServer.java similarity index 100% rename from restx/src/main/java/restx/demo/AppServer.java rename to web-modules/restx/src/main/java/restx/demo/AppServer.java diff --git a/restx/src/main/java/restx/demo/Roles.java b/web-modules/restx/src/main/java/restx/demo/Roles.java similarity index 100% rename from restx/src/main/java/restx/demo/Roles.java rename to web-modules/restx/src/main/java/restx/demo/Roles.java diff --git a/restx/src/main/java/restx/demo/domain/Message.java b/web-modules/restx/src/main/java/restx/demo/domain/Message.java similarity index 100% rename from restx/src/main/java/restx/demo/domain/Message.java rename to web-modules/restx/src/main/java/restx/demo/domain/Message.java diff --git a/restx/src/main/java/restx/demo/rest/HelloResource.java b/web-modules/restx/src/main/java/restx/demo/rest/HelloResource.java similarity index 100% rename from restx/src/main/java/restx/demo/rest/HelloResource.java rename to web-modules/restx/src/main/java/restx/demo/rest/HelloResource.java diff --git a/restx/src/main/resources/logback.xml b/web-modules/restx/src/main/resources/logback.xml similarity index 100% rename from restx/src/main/resources/logback.xml rename to web-modules/restx/src/main/resources/logback.xml diff --git a/restx/src/main/resources/restx/demo/settings.properties b/web-modules/restx/src/main/resources/restx/demo/settings.properties similarity index 100% rename from restx/src/main/resources/restx/demo/settings.properties rename to web-modules/restx/src/main/resources/restx/demo/settings.properties diff --git a/restx/src/main/webapp/WEB-INF/web.xml b/web-modules/restx/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from restx/src/main/webapp/WEB-INF/web.xml rename to web-modules/restx/src/main/webapp/WEB-INF/web.xml diff --git a/restx/src/test/java/restx/demo/rest/HelloResourceSpecIntegrationTest.java b/web-modules/restx/src/test/java/restx/demo/rest/HelloResourceSpecIntegrationTest.java similarity index 100% rename from restx/src/test/java/restx/demo/rest/HelloResourceSpecIntegrationTest.java rename to web-modules/restx/src/test/java/restx/demo/rest/HelloResourceSpecIntegrationTest.java diff --git a/restx/src/test/resources/specs/hello/should_admin_say_hello.spec.yaml b/web-modules/restx/src/test/resources/specs/hello/should_admin_say_hello.spec.yaml similarity index 100% rename from restx/src/test/resources/specs/hello/should_admin_say_hello.spec.yaml rename to web-modules/restx/src/test/resources/specs/hello/should_admin_say_hello.spec.yaml diff --git a/restx/src/test/resources/specs/hello/should_anyone_say_hello.spec.yaml b/web-modules/restx/src/test/resources/specs/hello/should_anyone_say_hello.spec.yaml similarity index 100% rename from restx/src/test/resources/specs/hello/should_anyone_say_hello.spec.yaml rename to web-modules/restx/src/test/resources/specs/hello/should_anyone_say_hello.spec.yaml diff --git a/restx/src/test/resources/specs/hello/should_missing_value_triggers_validation_error.spec.yaml b/web-modules/restx/src/test/resources/specs/hello/should_missing_value_triggers_validation_error.spec.yaml similarity index 100% rename from restx/src/test/resources/specs/hello/should_missing_value_triggers_validation_error.spec.yaml rename to web-modules/restx/src/test/resources/specs/hello/should_missing_value_triggers_validation_error.spec.yaml diff --git a/restx/src/test/resources/specs/hello/should_user1_say_hello.spec.yaml b/web-modules/restx/src/test/resources/specs/hello/should_user1_say_hello.spec.yaml similarity index 100% rename from restx/src/test/resources/specs/hello/should_user1_say_hello.spec.yaml rename to web-modules/restx/src/test/resources/specs/hello/should_user1_say_hello.spec.yaml diff --git a/restx/src/test/resources/specs/hello/should_user2_not_say_hello.spec.yaml b/web-modules/restx/src/test/resources/specs/hello/should_user2_not_say_hello.spec.yaml similarity index 100% rename from restx/src/test/resources/specs/hello/should_user2_not_say_hello.spec.yaml rename to web-modules/restx/src/test/resources/specs/hello/should_user2_not_say_hello.spec.yaml diff --git a/spark-java/README.md b/web-modules/spark-java/README.md similarity index 100% rename from spark-java/README.md rename to web-modules/spark-java/README.md diff --git a/spark-java/pom.xml b/web-modules/spark-java/pom.xml similarity index 96% rename from spark-java/pom.xml rename to web-modules/spark-java/pom.xml index 0ecdd02f6a..da09467212 100644 --- a/spark-java/pom.xml +++ b/web-modules/spark-java/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/spark-java/src/main/java/com/baeldung/sparkjava/HelloWorldService.java b/web-modules/spark-java/src/main/java/com/baeldung/sparkjava/HelloWorldService.java similarity index 100% rename from spark-java/src/main/java/com/baeldung/sparkjava/HelloWorldService.java rename to web-modules/spark-java/src/main/java/com/baeldung/sparkjava/HelloWorldService.java diff --git a/spark-java/src/main/java/com/baeldung/sparkjava/SparkRestExample.java b/web-modules/spark-java/src/main/java/com/baeldung/sparkjava/SparkRestExample.java similarity index 100% rename from spark-java/src/main/java/com/baeldung/sparkjava/SparkRestExample.java rename to web-modules/spark-java/src/main/java/com/baeldung/sparkjava/SparkRestExample.java diff --git a/spark-java/src/main/java/com/baeldung/sparkjava/StandardResponse.java b/web-modules/spark-java/src/main/java/com/baeldung/sparkjava/StandardResponse.java similarity index 100% rename from spark-java/src/main/java/com/baeldung/sparkjava/StandardResponse.java rename to web-modules/spark-java/src/main/java/com/baeldung/sparkjava/StandardResponse.java diff --git a/spark-java/src/main/java/com/baeldung/sparkjava/StatusResponse.java b/web-modules/spark-java/src/main/java/com/baeldung/sparkjava/StatusResponse.java similarity index 100% rename from spark-java/src/main/java/com/baeldung/sparkjava/StatusResponse.java rename to web-modules/spark-java/src/main/java/com/baeldung/sparkjava/StatusResponse.java diff --git a/spark-java/src/main/java/com/baeldung/sparkjava/User.java b/web-modules/spark-java/src/main/java/com/baeldung/sparkjava/User.java similarity index 100% rename from spark-java/src/main/java/com/baeldung/sparkjava/User.java rename to web-modules/spark-java/src/main/java/com/baeldung/sparkjava/User.java diff --git a/spark-java/src/main/java/com/baeldung/sparkjava/UserException.java b/web-modules/spark-java/src/main/java/com/baeldung/sparkjava/UserException.java similarity index 100% rename from spark-java/src/main/java/com/baeldung/sparkjava/UserException.java rename to web-modules/spark-java/src/main/java/com/baeldung/sparkjava/UserException.java diff --git a/spark-java/src/main/java/com/baeldung/sparkjava/UserService.java b/web-modules/spark-java/src/main/java/com/baeldung/sparkjava/UserService.java similarity index 100% rename from spark-java/src/main/java/com/baeldung/sparkjava/UserService.java rename to web-modules/spark-java/src/main/java/com/baeldung/sparkjava/UserService.java diff --git a/spark-java/src/main/java/com/baeldung/sparkjava/UserServiceMapImpl.java b/web-modules/spark-java/src/main/java/com/baeldung/sparkjava/UserServiceMapImpl.java similarity index 100% rename from spark-java/src/main/java/com/baeldung/sparkjava/UserServiceMapImpl.java rename to web-modules/spark-java/src/main/java/com/baeldung/sparkjava/UserServiceMapImpl.java diff --git a/vavr/src/main/resources/logback.xml b/web-modules/spark-java/src/main/resources/logback.xml similarity index 100% rename from vavr/src/main/resources/logback.xml rename to web-modules/spark-java/src/main/resources/logback.xml diff --git a/struts-2/README.md b/web-modules/struts-2/README.md similarity index 100% rename from struts-2/README.md rename to web-modules/struts-2/README.md diff --git a/struts-2/WebContent/WEB-INF/web.xml b/web-modules/struts-2/WebContent/WEB-INF/web.xml similarity index 100% rename from struts-2/WebContent/WEB-INF/web.xml rename to web-modules/struts-2/WebContent/WEB-INF/web.xml diff --git a/struts-2/WebContent/input.jsp b/web-modules/struts-2/WebContent/input.jsp similarity index 97% rename from struts-2/WebContent/input.jsp rename to web-modules/struts-2/WebContent/input.jsp index 6d80aa3ffd..2d63c22fe3 100644 --- a/struts-2/WebContent/input.jsp +++ b/web-modules/struts-2/WebContent/input.jsp @@ -1,21 +1,21 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - -Baledung Struts - - -
-

Welcome to Baeldung Struts 2 app

-

Which car do you like !!

-

Please choose ferrari or bmw

- - -
- +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Baledung Struts + + +
+

Welcome to Baeldung Struts 2 app

+

Which car do you like !!

+

Please choose ferrari or bmw

+ + +
+ \ No newline at end of file diff --git a/struts-2/WebContent/result.jsp b/web-modules/struts-2/WebContent/result.jsp similarity index 95% rename from struts-2/WebContent/result.jsp rename to web-modules/struts-2/WebContent/result.jsp index 0fe9ea2d1d..d095a493ec 100644 --- a/struts-2/WebContent/result.jsp +++ b/web-modules/struts-2/WebContent/result.jsp @@ -1,11 +1,11 @@ -<%@ page contentType="text/html; charset=UTF-8" %> -<%@ taglib prefix="s" uri="/struts-tags" %> - - -Hello World - - -

Hello Baeldung User

-

You are a

- - +<%@ page contentType="text/html; charset=UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> + + +Hello World + + +

Hello Baeldung User

+

You are a

+ + diff --git a/struts-2/pom.xml b/web-modules/struts-2/pom.xml similarity index 93% rename from struts-2/pom.xml rename to web-modules/struts-2/pom.xml index 87663cf545..8b19bd530f 100644 --- a/struts-2/pom.xml +++ b/web-modules/struts-2/pom.xml @@ -1,76 +1,75 @@ - - - 4.0.0 - struts-2 - 0.0.1-SNAPSHOT - struts-2 - pom - - - com.baeldung - parent-spring-4 - 0.0.1-SNAPSHOT - ../parent-spring-4 - - - - - org.apache.struts - struts2-core - ${struts2.version} - - - org.apache.struts - struts2-junit-plugin - ${struts2.version} - - - org.apache.struts - struts2-convention-plugin - ${struts2-convention-plugin.version} - - - javax.servlet - javax.servlet-api - ${javax.servlet-api.version} - - - org.springframework - spring-core - ${spring.version} - - - commons-logging - commons-logging - - - - - - - src/main/java - - - src/main/resources - - - - - maven-war-plugin - ${maven-war-plugin.version} - - WebContent - - - - - - - 2.5.5 - 2.5.8 - 4.3.6.RELEASE - - + + + 4.0.0 + struts-2 + struts-2 + pom + + + com.baeldung + parent-spring-4 + 0.0.1-SNAPSHOT + ../../parent-spring-4 + + + + + org.apache.struts + struts2-core + ${struts2.version} + + + org.apache.struts + struts2-junit-plugin + ${struts2.version} + + + org.apache.struts + struts2-convention-plugin + ${struts2-convention-plugin.version} + + + javax.servlet + javax.servlet-api + ${javax.servlet-api.version} + + + org.springframework + spring-core + ${spring.version} + + + commons-logging + commons-logging + + + + + + + src/main/java + + + src/main/resources + + + + + maven-war-plugin + ${maven-war-plugin.version} + + WebContent + + + + + + + 2.5.5 + 2.5.8 + 4.3.6.RELEASE + + \ No newline at end of file diff --git a/struts-2/src/main/java/com/baeldung/struts/CarAction.java b/web-modules/struts-2/src/main/java/com/baeldung/struts/CarAction.java similarity index 96% rename from struts-2/src/main/java/com/baeldung/struts/CarAction.java rename to web-modules/struts-2/src/main/java/com/baeldung/struts/CarAction.java index 478f3b4cc2..b4eacb0fea 100644 --- a/struts-2/src/main/java/com/baeldung/struts/CarAction.java +++ b/web-modules/struts-2/src/main/java/com/baeldung/struts/CarAction.java @@ -1,37 +1,37 @@ -package com.baeldung.struts; - -import org.apache.struts2.convention.annotation.Action; -import org.apache.struts2.convention.annotation.Namespace; -import org.apache.struts2.convention.annotation.Result; - -@Namespace("/tutorial") -@Action("/car") -@Result(name = "success", location = "/result.jsp") -public class CarAction { - private String carName; - private String carMessage; - private CarMessageService carMessageService = new CarMessageService(); - - public String execute() { - System.out.println("inside execute(): carName is" + carName); - this.setCarMessage(this.carMessageService.getMessage(carName)); - return "success"; - } - - public String getCarName() { - return carName; - } - - public void setCarName(String carName) { - this.carName = carName; - } - - public String getCarMessage() { - return carMessage; - } - - public void setCarMessage(String carMessage) { - this.carMessage = carMessage; - } - -} +package com.baeldung.struts; + +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.Result; + +@Namespace("/tutorial") +@Action("/car") +@Result(name = "success", location = "/result.jsp") +public class CarAction { + private String carName; + private String carMessage; + private CarMessageService carMessageService = new CarMessageService(); + + public String execute() { + System.out.println("inside execute(): carName is" + carName); + this.setCarMessage(this.carMessageService.getMessage(carName)); + return "success"; + } + + public String getCarName() { + return carName; + } + + public void setCarName(String carName) { + this.carName = carName; + } + + public String getCarMessage() { + return carMessage; + } + + public void setCarMessage(String carMessage) { + this.carMessage = carMessage; + } + +} diff --git a/struts-2/src/main/java/com/baeldung/struts/CarMessageService.java b/web-modules/struts-2/src/main/java/com/baeldung/struts/CarMessageService.java similarity index 96% rename from struts-2/src/main/java/com/baeldung/struts/CarMessageService.java rename to web-modules/struts-2/src/main/java/com/baeldung/struts/CarMessageService.java index 34d3ca3d76..fb674de02e 100644 --- a/struts-2/src/main/java/com/baeldung/struts/CarMessageService.java +++ b/web-modules/struts-2/src/main/java/com/baeldung/struts/CarMessageService.java @@ -1,18 +1,18 @@ -package com.baeldung.struts; - -public class CarMessageService { - - public String getMessage(String carName) { - System.out.println("inside getMessage()" + carName); - if (carName.equalsIgnoreCase("ferrari")){ - return "Ferrari Fan!"; - } - else if (carName.equalsIgnoreCase("bmw")){ - return "BMW Fan!"; - } - else{ - return "please choose ferrari Or bmw"; - } - } - -} +package com.baeldung.struts; + +public class CarMessageService { + + public String getMessage(String carName) { + System.out.println("inside getMessage()" + carName); + if (carName.equalsIgnoreCase("ferrari")){ + return "Ferrari Fan!"; + } + else if (carName.equalsIgnoreCase("bmw")){ + return "BMW Fan!"; + } + else{ + return "please choose ferrari Or bmw"; + } + } + +} diff --git a/wicket/src/main/resources/logback.xml b/web-modules/struts-2/src/main/resources/logback.xml similarity index 100% rename from wicket/src/main/resources/logback.xml rename to web-modules/struts-2/src/main/resources/logback.xml diff --git a/struts-2/src/test/java/com/baeldung/struts/test/CarActionTest.java b/web-modules/struts-2/src/test/java/com/baeldung/struts/test/CarActionTest.java similarity index 97% rename from struts-2/src/test/java/com/baeldung/struts/test/CarActionTest.java rename to web-modules/struts-2/src/test/java/com/baeldung/struts/test/CarActionTest.java index 64b640edfb..41dc0a6ceb 100644 --- a/struts-2/src/test/java/com/baeldung/struts/test/CarActionTest.java +++ b/web-modules/struts-2/src/test/java/com/baeldung/struts/test/CarActionTest.java @@ -1,29 +1,29 @@ -//package com.baeldung.struts.test; -// -//import org.apache.struts2.StrutsTestCase; -//import org.junit.Test; -// -//import com.baeldung.struts.CarAction; -//import com.opensymphony.xwork2.ActionProxy; -// -//public class CarActionTest extends StrutsTestCase { -// -// public void testgivenCarOptions_WhenferrariSelected_ThenShowMessage() throws Exception { -// request.setParameter("carName", "ferrari"); -// ActionProxy proxy = getActionProxy("/tutorial/car.action"); -// CarAction carAction = (CarAction) proxy.getAction(); -// String result = proxy.execute(); -// assertEquals(result, "success"); -// assertEquals(carAction.getCarMessage(), "Ferrari Fan!"); -// } -// -// public void testgivenCarOptions_WhenbmwSelected_ThenShowMessage() throws Exception { -// request.setParameter("carName", "bmw"); -// ActionProxy proxy = getActionProxy("/tutorial/car.action"); -// CarAction carAction = (CarAction) proxy.getAction(); -// String result = proxy.execute(); -// assertEquals(result, "success"); -// assertEquals(carAction.getCarMessage(), "BMW Fan!"); -// } -// -//} +//package com.baeldung.struts.test; +// +//import org.apache.struts2.StrutsTestCase; +//import org.junit.Test; +// +//import com.baeldung.struts.CarAction; +//import com.opensymphony.xwork2.ActionProxy; +// +//public class CarActionTest extends StrutsTestCase { +// +// public void testgivenCarOptions_WhenferrariSelected_ThenShowMessage() throws Exception { +// request.setParameter("carName", "ferrari"); +// ActionProxy proxy = getActionProxy("/tutorial/car.action"); +// CarAction carAction = (CarAction) proxy.getAction(); +// String result = proxy.execute(); +// assertEquals(result, "success"); +// assertEquals(carAction.getCarMessage(), "Ferrari Fan!"); +// } +// +// public void testgivenCarOptions_WhenbmwSelected_ThenShowMessage() throws Exception { +// request.setParameter("carName", "bmw"); +// ActionProxy proxy = getActionProxy("/tutorial/car.action"); +// CarAction carAction = (CarAction) proxy.getAction(); +// String result = proxy.execute(); +// assertEquals(result, "success"); +// assertEquals(carAction.getCarMessage(), "BMW Fan!"); +// } +// +//} diff --git a/vraptor/.gitignore b/web-modules/vraptor/.gitignore similarity index 100% rename from vraptor/.gitignore rename to web-modules/vraptor/.gitignore diff --git a/vraptor/README.md b/web-modules/vraptor/README.md similarity index 100% rename from vraptor/README.md rename to web-modules/vraptor/README.md diff --git a/vraptor/pom.xml b/web-modules/vraptor/pom.xml similarity index 98% rename from vraptor/pom.xml rename to web-modules/vraptor/pom.xml index fad17e7aae..ecc6fe3313 100644 --- a/vraptor/pom.xml +++ b/web-modules/vraptor/pom.xml @@ -4,14 +4,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 vraptor - 1.0.0 vraptor war A demo project to start using VRaptor 4 com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/vraptor/src/main/java/com/baeldung/config/UserInfo.java b/web-modules/vraptor/src/main/java/com/baeldung/config/UserInfo.java similarity index 100% rename from vraptor/src/main/java/com/baeldung/config/UserInfo.java rename to web-modules/vraptor/src/main/java/com/baeldung/config/UserInfo.java diff --git a/vraptor/src/main/java/com/baeldung/controllers/AuthController.java b/web-modules/vraptor/src/main/java/com/baeldung/controllers/AuthController.java similarity index 100% rename from vraptor/src/main/java/com/baeldung/controllers/AuthController.java rename to web-modules/vraptor/src/main/java/com/baeldung/controllers/AuthController.java diff --git a/vraptor/src/main/java/com/baeldung/controllers/IndexController.java b/web-modules/vraptor/src/main/java/com/baeldung/controllers/IndexController.java similarity index 100% rename from vraptor/src/main/java/com/baeldung/controllers/IndexController.java rename to web-modules/vraptor/src/main/java/com/baeldung/controllers/IndexController.java diff --git a/vraptor/src/main/java/com/baeldung/controllers/PostController.java b/web-modules/vraptor/src/main/java/com/baeldung/controllers/PostController.java similarity index 100% rename from vraptor/src/main/java/com/baeldung/controllers/PostController.java rename to web-modules/vraptor/src/main/java/com/baeldung/controllers/PostController.java diff --git a/vraptor/src/main/java/com/baeldung/daos/PostDao.java b/web-modules/vraptor/src/main/java/com/baeldung/daos/PostDao.java similarity index 100% rename from vraptor/src/main/java/com/baeldung/daos/PostDao.java rename to web-modules/vraptor/src/main/java/com/baeldung/daos/PostDao.java diff --git a/vraptor/src/main/java/com/baeldung/daos/UserDao.java b/web-modules/vraptor/src/main/java/com/baeldung/daos/UserDao.java similarity index 100% rename from vraptor/src/main/java/com/baeldung/daos/UserDao.java rename to web-modules/vraptor/src/main/java/com/baeldung/daos/UserDao.java diff --git a/vraptor/src/main/java/com/baeldung/models/Post.java b/web-modules/vraptor/src/main/java/com/baeldung/models/Post.java similarity index 100% rename from vraptor/src/main/java/com/baeldung/models/Post.java rename to web-modules/vraptor/src/main/java/com/baeldung/models/Post.java diff --git a/vraptor/src/main/java/com/baeldung/models/User.java b/web-modules/vraptor/src/main/java/com/baeldung/models/User.java similarity index 100% rename from vraptor/src/main/java/com/baeldung/models/User.java rename to web-modules/vraptor/src/main/java/com/baeldung/models/User.java diff --git a/vraptor/src/main/resources/META-INF/beans.xml b/web-modules/vraptor/src/main/resources/META-INF/beans.xml similarity index 100% rename from vraptor/src/main/resources/META-INF/beans.xml rename to web-modules/vraptor/src/main/resources/META-INF/beans.xml diff --git a/vraptor/src/main/resources/database.sql b/web-modules/vraptor/src/main/resources/database.sql similarity index 100% rename from vraptor/src/main/resources/database.sql rename to web-modules/vraptor/src/main/resources/database.sql diff --git a/vraptor/src/main/resources/hibernate.cfg.xml b/web-modules/vraptor/src/main/resources/hibernate.cfg.xml similarity index 100% rename from vraptor/src/main/resources/hibernate.cfg.xml rename to web-modules/vraptor/src/main/resources/hibernate.cfg.xml diff --git a/vraptor/src/main/resources/log4j.xml b/web-modules/vraptor/src/main/resources/log4j.xml similarity index 100% rename from vraptor/src/main/resources/log4j.xml rename to web-modules/vraptor/src/main/resources/log4j.xml diff --git a/vraptor/src/main/resources/templates/auth/login.ftl b/web-modules/vraptor/src/main/resources/templates/auth/login.ftl similarity index 100% rename from vraptor/src/main/resources/templates/auth/login.ftl rename to web-modules/vraptor/src/main/resources/templates/auth/login.ftl diff --git a/vraptor/src/main/resources/templates/auth/register.ftl b/web-modules/vraptor/src/main/resources/templates/auth/register.ftl similarity index 100% rename from vraptor/src/main/resources/templates/auth/register.ftl rename to web-modules/vraptor/src/main/resources/templates/auth/register.ftl diff --git a/vraptor/src/main/resources/templates/index.ftl b/web-modules/vraptor/src/main/resources/templates/index.ftl similarity index 100% rename from vraptor/src/main/resources/templates/index.ftl rename to web-modules/vraptor/src/main/resources/templates/index.ftl diff --git a/vraptor/src/main/resources/templates/posts/add.ftl b/web-modules/vraptor/src/main/resources/templates/posts/add.ftl similarity index 100% rename from vraptor/src/main/resources/templates/posts/add.ftl rename to web-modules/vraptor/src/main/resources/templates/posts/add.ftl diff --git a/vraptor/src/main/resources/templates/view.ftl b/web-modules/vraptor/src/main/resources/templates/view.ftl similarity index 100% rename from vraptor/src/main/resources/templates/view.ftl rename to web-modules/vraptor/src/main/resources/templates/view.ftl diff --git a/vraptor/src/main/webapp/META-INF/MANIFEST.MF b/web-modules/vraptor/src/main/webapp/META-INF/MANIFEST.MF similarity index 100% rename from vraptor/src/main/webapp/META-INF/MANIFEST.MF rename to web-modules/vraptor/src/main/webapp/META-INF/MANIFEST.MF diff --git a/vraptor/src/main/webapp/WEB-INF/jsp/index/index.jsp b/web-modules/vraptor/src/main/webapp/WEB-INF/jsp/index/index.jsp similarity index 100% rename from vraptor/src/main/webapp/WEB-INF/jsp/index/index.jsp rename to web-modules/vraptor/src/main/webapp/WEB-INF/jsp/index/index.jsp diff --git a/vraptor/src/main/webapp/WEB-INF/web.xml b/web-modules/vraptor/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from vraptor/src/main/webapp/WEB-INF/web.xml rename to web-modules/vraptor/src/main/webapp/WEB-INF/web.xml diff --git a/vraptor/src/main/webapp/css/clean-blog.css b/web-modules/vraptor/src/main/webapp/css/clean-blog.css similarity index 100% rename from vraptor/src/main/webapp/css/clean-blog.css rename to web-modules/vraptor/src/main/webapp/css/clean-blog.css diff --git a/vraptor/src/main/webapp/css/clean-blog.min.css b/web-modules/vraptor/src/main/webapp/css/clean-blog.min.css similarity index 100% rename from vraptor/src/main/webapp/css/clean-blog.min.css rename to web-modules/vraptor/src/main/webapp/css/clean-blog.min.css diff --git a/vraptor/src/main/webapp/img/about-bg.jpg b/web-modules/vraptor/src/main/webapp/img/about-bg.jpg similarity index 100% rename from vraptor/src/main/webapp/img/about-bg.jpg rename to web-modules/vraptor/src/main/webapp/img/about-bg.jpg diff --git a/vraptor/src/main/webapp/img/contact-bg.jpg b/web-modules/vraptor/src/main/webapp/img/contact-bg.jpg similarity index 100% rename from vraptor/src/main/webapp/img/contact-bg.jpg rename to web-modules/vraptor/src/main/webapp/img/contact-bg.jpg diff --git a/vraptor/src/main/webapp/img/home-bg.jpg b/web-modules/vraptor/src/main/webapp/img/home-bg.jpg similarity index 100% rename from vraptor/src/main/webapp/img/home-bg.jpg rename to web-modules/vraptor/src/main/webapp/img/home-bg.jpg diff --git a/vraptor/src/main/webapp/img/post-bg.jpg b/web-modules/vraptor/src/main/webapp/img/post-bg.jpg similarity index 100% rename from vraptor/src/main/webapp/img/post-bg.jpg rename to web-modules/vraptor/src/main/webapp/img/post-bg.jpg diff --git a/vraptor/src/main/webapp/img/post-sample-image.jpg b/web-modules/vraptor/src/main/webapp/img/post-sample-image.jpg similarity index 100% rename from vraptor/src/main/webapp/img/post-sample-image.jpg rename to web-modules/vraptor/src/main/webapp/img/post-sample-image.jpg diff --git a/vraptor/src/main/webapp/js/clean-blog.js b/web-modules/vraptor/src/main/webapp/js/clean-blog.js similarity index 100% rename from vraptor/src/main/webapp/js/clean-blog.js rename to web-modules/vraptor/src/main/webapp/js/clean-blog.js diff --git a/vraptor/src/main/webapp/js/clean-blog.min.js b/web-modules/vraptor/src/main/webapp/js/clean-blog.min.js similarity index 100% rename from vraptor/src/main/webapp/js/clean-blog.min.js rename to web-modules/vraptor/src/main/webapp/js/clean-blog.min.js diff --git a/vraptor/src/main/webapp/js/contact_me.js b/web-modules/vraptor/src/main/webapp/js/contact_me.js similarity index 100% rename from vraptor/src/main/webapp/js/contact_me.js rename to web-modules/vraptor/src/main/webapp/js/contact_me.js diff --git a/vraptor/src/main/webapp/js/jqBootstrapValidation.js b/web-modules/vraptor/src/main/webapp/js/jqBootstrapValidation.js similarity index 100% rename from vraptor/src/main/webapp/js/jqBootstrapValidation.js rename to web-modules/vraptor/src/main/webapp/js/jqBootstrapValidation.js diff --git a/vraptor/src/main/webapp/vendor/bootstrap/css/bootstrap.css b/web-modules/vraptor/src/main/webapp/vendor/bootstrap/css/bootstrap.css similarity index 100% rename from vraptor/src/main/webapp/vendor/bootstrap/css/bootstrap.css rename to web-modules/vraptor/src/main/webapp/vendor/bootstrap/css/bootstrap.css diff --git a/vraptor/src/main/webapp/vendor/bootstrap/css/bootstrap.min.css b/web-modules/vraptor/src/main/webapp/vendor/bootstrap/css/bootstrap.min.css similarity index 100% rename from vraptor/src/main/webapp/vendor/bootstrap/css/bootstrap.min.css rename to web-modules/vraptor/src/main/webapp/vendor/bootstrap/css/bootstrap.min.css diff --git a/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot b/web-modules/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot rename to web-modules/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot diff --git a/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg b/web-modules/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg rename to web-modules/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg diff --git a/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf b/web-modules/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf rename to web-modules/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf diff --git a/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff b/web-modules/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff rename to web-modules/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff diff --git a/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff2 b/web-modules/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff2 similarity index 100% rename from vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff2 rename to web-modules/vraptor/src/main/webapp/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff2 diff --git a/vraptor/src/main/webapp/vendor/bootstrap/js/bootstrap.js b/web-modules/vraptor/src/main/webapp/vendor/bootstrap/js/bootstrap.js similarity index 100% rename from vraptor/src/main/webapp/vendor/bootstrap/js/bootstrap.js rename to web-modules/vraptor/src/main/webapp/vendor/bootstrap/js/bootstrap.js diff --git a/vraptor/src/main/webapp/vendor/bootstrap/js/bootstrap.min.js b/web-modules/vraptor/src/main/webapp/vendor/bootstrap/js/bootstrap.min.js similarity index 100% rename from vraptor/src/main/webapp/vendor/bootstrap/js/bootstrap.min.js rename to web-modules/vraptor/src/main/webapp/vendor/bootstrap/js/bootstrap.min.js diff --git a/vraptor/src/main/webapp/vendor/font-awesome/css/font-awesome.css b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/css/font-awesome.css similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/css/font-awesome.css rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/css/font-awesome.css diff --git a/vraptor/src/main/webapp/vendor/font-awesome/css/font-awesome.min.css b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/css/font-awesome.min.css similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/css/font-awesome.min.css rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/css/font-awesome.min.css diff --git a/vraptor/src/main/webapp/vendor/font-awesome/fonts/FontAwesome.otf b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/FontAwesome.otf similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/fonts/FontAwesome.otf rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/FontAwesome.otf diff --git a/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.eot b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.eot similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.eot rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.eot diff --git a/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.svg b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.svg similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.svg rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.svg diff --git a/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.ttf b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.ttf similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.ttf rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.ttf diff --git a/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.woff b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.woff similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.woff rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.woff diff --git a/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.woff2 b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.woff2 similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.woff2 rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/fonts/fontawesome-webfont.woff2 diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/animated.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/animated.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/animated.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/animated.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/bordered-pulled.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/bordered-pulled.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/bordered-pulled.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/bordered-pulled.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/core.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/core.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/core.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/core.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/fixed-width.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/fixed-width.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/fixed-width.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/fixed-width.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/font-awesome.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/font-awesome.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/font-awesome.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/font-awesome.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/icons.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/icons.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/icons.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/icons.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/larger.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/larger.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/larger.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/larger.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/list.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/list.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/list.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/list.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/mixins.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/mixins.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/mixins.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/mixins.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/path.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/path.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/path.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/path.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/rotated-flipped.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/rotated-flipped.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/rotated-flipped.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/rotated-flipped.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/screen-reader.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/screen-reader.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/screen-reader.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/screen-reader.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/stacked.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/stacked.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/stacked.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/stacked.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/less/variables.less b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/variables.less similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/less/variables.less rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/less/variables.less diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_animated.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_animated.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_animated.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_animated.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_bordered-pulled.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_bordered-pulled.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_bordered-pulled.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_bordered-pulled.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_core.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_core.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_core.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_core.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_fixed-width.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_fixed-width.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_fixed-width.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_fixed-width.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_icons.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_icons.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_icons.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_icons.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_larger.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_larger.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_larger.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_larger.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_list.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_list.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_list.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_list.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_mixins.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_mixins.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_mixins.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_mixins.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_path.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_path.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_path.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_path.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_rotated-flipped.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_rotated-flipped.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_rotated-flipped.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_rotated-flipped.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_screen-reader.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_screen-reader.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_screen-reader.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_screen-reader.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_stacked.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_stacked.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_stacked.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_stacked.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/_variables.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_variables.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/_variables.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/_variables.scss diff --git a/vraptor/src/main/webapp/vendor/font-awesome/scss/font-awesome.scss b/web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/font-awesome.scss similarity index 100% rename from vraptor/src/main/webapp/vendor/font-awesome/scss/font-awesome.scss rename to web-modules/vraptor/src/main/webapp/vendor/font-awesome/scss/font-awesome.scss diff --git a/vraptor/src/main/webapp/vendor/jquery/jquery.js b/web-modules/vraptor/src/main/webapp/vendor/jquery/jquery.js similarity index 100% rename from vraptor/src/main/webapp/vendor/jquery/jquery.js rename to web-modules/vraptor/src/main/webapp/vendor/jquery/jquery.js diff --git a/vraptor/src/main/webapp/vendor/jquery/jquery.min.js b/web-modules/vraptor/src/main/webapp/vendor/jquery/jquery.min.js similarity index 100% rename from vraptor/src/main/webapp/vendor/jquery/jquery.min.js rename to web-modules/vraptor/src/main/webapp/vendor/jquery/jquery.min.js diff --git a/wicket/README.md b/web-modules/wicket/README.md similarity index 100% rename from wicket/README.md rename to web-modules/wicket/README.md diff --git a/wicket/pom.xml b/web-modules/wicket/pom.xml similarity index 98% rename from wicket/pom.xml rename to web-modules/wicket/pom.xml index 55baf64032..c9dac11379 100644 --- a/wicket/pom.xml +++ b/web-modules/wicket/pom.xml @@ -11,7 +11,7 @@ com.baeldung - parent-modules + web-modules 1.0.0-SNAPSHOT diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.html b/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.html similarity index 100% rename from wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.html rename to web-modules/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.html diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.java b/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.java similarity index 100% rename from wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.java rename to web-modules/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.java diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java b/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java similarity index 100% rename from wicket/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java rename to web-modules/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html b/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html similarity index 100% rename from wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html rename to web-modules/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java b/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java similarity index 100% rename from wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java rename to web-modules/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html b/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html similarity index 100% rename from wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html rename to web-modules/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java b/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java similarity index 100% rename from wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java rename to web-modules/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java diff --git a/web-modules/wicket/src/main/resources/logback.xml b/web-modules/wicket/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/web-modules/wicket/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/wicket/src/main/test/java/com/baeldung/wicket/examples/HomePageIntegrationTest.java b/web-modules/wicket/src/main/test/java/com/baeldung/wicket/examples/HomePageIntegrationTest.java similarity index 100% rename from wicket/src/main/test/java/com/baeldung/wicket/examples/HomePageIntegrationTest.java rename to web-modules/wicket/src/main/test/java/com/baeldung/wicket/examples/HomePageIntegrationTest.java diff --git a/wicket/src/main/webapp/WEB-INF/web.xml b/web-modules/wicket/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from wicket/src/main/webapp/WEB-INF/web.xml rename to web-modules/wicket/src/main/webapp/WEB-INF/web.xml