├── crazy-hotels-service ├── .attach_pid26734 ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── maf │ │ │ ├── crazyhotel │ │ │ └── domain │ │ │ │ └── model │ │ │ │ ├── IATACode.java │ │ │ │ └── CrazyHotel.java │ │ │ └── crazyhotels │ │ │ ├── service │ │ │ ├── CrazyHotelService.java │ │ │ └── impl │ │ │ │ └── CrazyHotelServiceImpl.java │ │ │ ├── exception │ │ │ └── BadRequest.java │ │ │ ├── response │ │ │ └── CustomResponse.java │ │ │ ├── app │ │ │ └── CrazyHotelsServiceApplication.java │ │ │ ├── controller │ │ │ └── CrazyHotelsController.java │ │ │ └── repository │ │ │ └── CrazyHotelsRepository.java │ └── test │ │ └── java │ │ └── com │ │ └── maf │ │ └── app │ │ ├── CrazyHotelControllerIntegrationTest.java │ │ ├── CrazyHotelsServiceTests.java │ │ ├── CrazyHotelRepositoryTest.java │ │ └── CrazyHotelControllerUnitTest.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── MicroServices (1).png ├── available-hotels-service ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── maf │ │ │ ├── hotels │ │ │ ├── constants │ │ │ │ ├── IATACode.java │ │ │ │ ├── ResponseStatus.java │ │ │ │ ├── Constant.java │ │ │ │ └── ResponseCode.java │ │ │ ├── service │ │ │ │ ├── AvailableHotelsService.java │ │ │ │ └── impl │ │ │ │ │ └── AvailableHotelsServiceImpl.java │ │ │ ├── responses │ │ │ │ ├── ExceptionResponse.java │ │ │ │ ├── AvailableHotels.java │ │ │ │ ├── ListResponse.java │ │ │ │ └── BaseResponse.java │ │ │ ├── client │ │ │ │ ├── HotelServiceClientFallBack.java │ │ │ │ └── HotelsServiceClient.java │ │ │ ├── app │ │ │ │ └── HotelsServiceApplication.java │ │ │ ├── config │ │ │ │ └── Swagger2Config.java │ │ │ └── controller │ │ │ │ └── HotelsController.java │ │ │ └── hotel │ │ │ └── exceptions │ │ │ ├── BadRequestException.java │ │ │ └── CustomizedExceptionHandler.java │ │ └── resources │ │ └── application.properties ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── requestModel │ └── HotelsRequestModel.java ├── pom.xml ├── mvnw.cmd └── mvnw ├── best-hotels-service ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── maf │ │ │ │ └── besthotels │ │ │ │ ├── repository │ │ │ │ ├── IATACode.java │ │ │ │ └── BestHotelsRepository.java │ │ │ │ ├── service │ │ │ │ ├── BestHotelsService.java │ │ │ │ └── impl │ │ │ │ │ └── BestHotelsServiceImpl.java │ │ │ │ ├── dto │ │ │ │ └── BestHotelDTO.java │ │ │ │ ├── domain │ │ │ │ └── model │ │ │ │ │ └── BestHotel.java │ │ │ │ ├── exceptions │ │ │ │ └── BadRequest.java │ │ │ │ ├── response │ │ │ │ └── CustomResponse.java │ │ │ │ ├── util │ │ │ │ └── NumberUtil.java │ │ │ │ ├── app │ │ │ │ └── BestHotelsServiceApplication.java │ │ │ │ └── controller │ │ │ │ └── BestHotelsController.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── maf │ │ └── app │ │ ├── BestHotelsServiceControllerTests.java │ │ ├── BestHotelServiceTest.java │ │ └── BestHotelRepositoryTest.java ├── resources │ └── application.properties ├── .gitignore ├── java │ └── com │ │ └── maf │ │ └── hotels │ │ └── HotelsServiceApplicationTests.java ├── pom.xml ├── mvnw.cmd └── mvnw ├── eureka-naming-server ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── maf │ │ │ └── eurekanamingserver │ │ │ └── EurekaNamingServerApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── maf │ │ └── eurekanamingserver │ │ └── EurekaNamingServerApplicationTests.java ├── pom.xml ├── mvnw.cmd └── mvnw ├── hotels-aggregator-service ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ ├── maven-wrapper.jar │ │ └── MavenWrapperDownloader.java ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── maf │ │ │ │ └── aggregator │ │ │ │ ├── constant │ │ │ │ └── IATACode.java │ │ │ │ ├── response │ │ │ │ ├── BestHotelResponse.java │ │ │ │ ├── HotelCustomResponse.java │ │ │ │ └── CrazyHotelResponse.java │ │ │ │ ├── service │ │ │ │ ├── HotelServiceProvidersIntegration.java │ │ │ │ └── Imp │ │ │ │ │ └── HoterServiceProvidersIntegrationImpl.java │ │ │ │ ├── mapper │ │ │ │ ├── CrazyHotelToCustomHotelMapper.java │ │ │ │ └── BestHotelToCustomHotelMapper.java │ │ │ │ ├── client │ │ │ │ ├── CrazyHotelClientFallBack.java │ │ │ │ ├── BestHotelClientFallBack.java │ │ │ │ ├── CrazyHotelClient.java │ │ │ │ └── BestHotelsClient.java │ │ │ │ ├── app │ │ │ │ └── HotelsAggregatorServiceApplication.java │ │ │ │ ├── controller │ │ │ │ └── AggregatorController.java │ │ │ │ └── util │ │ │ │ └── DiscoveryUtil.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── maf │ │ └── aggregator │ │ └── app │ │ └── HotelsAggregatorServiceApplicationTests.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw └── README.md /crazy-hotels-service/.attach_pid26734: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MicroServices (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlaaMezian/spring-boot-microservices/HEAD/MicroServices (1).png -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/constants/IATACode.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.constants; 2 | 3 | public enum IATACode { 4 | AUH,AUJ,AUE; 5 | } 6 | -------------------------------------------------------------------------------- /best-hotels-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlaaMezian/spring-boot-microservices/HEAD/best-hotels-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /best-hotels-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /crazy-hotels-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlaaMezian/spring-boot-microservices/HEAD/crazy-hotels-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /crazy-hotels-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /eureka-naming-server/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlaaMezian/spring-boot-microservices/HEAD/eureka-naming-server/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /eureka-naming-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /available-hotels-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlaaMezian/spring-boot-microservices/HEAD/available-hotels-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /available-hotels-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/repository/IATACode.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.repository; 2 | 3 | public enum IATACode { 4 | AUH,AUJ,AUE; 5 | 6 | } 7 | -------------------------------------------------------------------------------- /hotels-aggregator-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/constant/IATACode.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.constant; 2 | 3 | public enum IATACode { 4 | AUH,AUJ,AUE; 5 | 6 | } 7 | -------------------------------------------------------------------------------- /hotels-aggregator-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlaaMezian/spring-boot-microservices/HEAD/hotels-aggregator-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /crazy-hotels-service/src/main/java/com/maf/crazyhotel/domain/model/IATACode.java: -------------------------------------------------------------------------------- 1 | package com.maf.crazyhotel.domain.model; 2 | 3 | public enum IATACode { 4 | 5 | AUH,AUJ,AUE; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /best-hotels-service/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = crazy-hotels-service 2 | 3 | server.port = 8080 4 | 5 | eureka.client.service-url.defaultZone=http://localhost:8761/eureka 6 | 7 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = best-hotels-service 2 | 3 | server.port = 8081 4 | 5 | eureka.client.service-url.defaultZone=http://localhost:8761/eureka 6 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = available-hotels-service 2 | server.port = 8082 3 | feign.hystrix.enabled= true 4 | 5 | eureka.client.service-url.defaultZone=http://localhost:8761/eureka 6 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = hotels-aggregator-service 2 | feign.hystrix.enabled= true 3 | server.port = 8090 4 | 5 | eureka.client.service-url.defaultZone=http://localhost:8761/eureka 6 | 7 | 8 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/constants/ResponseStatus.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.constants; 2 | 3 | public class ResponseStatus { 4 | 5 | public final static String RESPONSE_STATUS_SUCCESS = "Success"; 6 | public final static String RESPONSE_STATUS_FAILED = "Failed"; 7 | } 8 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/service/BestHotelsService.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.service; 2 | 3 | import java.util.Collection; 4 | 5 | import com.maf.besthotels.domain.model.BestHotel; 6 | import com.maf.besthotels.dto.BestHotelDTO; 7 | 8 | public interface BestHotelsService { 9 | 10 | public Collection retriveBestHotels(BestHotelDTO bestHotelDto); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/response/BestHotelResponse.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.response; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Setter 7 | @Getter 8 | public class BestHotelResponse { 9 | 10 | private Integer hotelId; 11 | private String hotelName; 12 | private Double hotelRate; 13 | private Double hotelFare; 14 | private String roomAmenitites; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/service/AvailableHotelsService.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.service; 2 | 3 | import java.time.LocalDate; 4 | 5 | import com.maf.hotels.constants.IATACode; 6 | import com.maf.hotels.responses.BaseResponse; 7 | 8 | public interface AvailableHotelsService { 9 | 10 | BaseResponse retriveAllAvailableHotels(LocalDate fromDate, LocalDate toDate, IATACode city, Integer numberOfAdults); 11 | } 12 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/response/HotelCustomResponse.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.response; 2 | 3 | import java.util.List; 4 | 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | public class HotelCustomResponse { 11 | 12 | private String provider; 13 | private String hotelName; 14 | private Double fare; 15 | private Double rate; 16 | private List aminities; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /best-hotels-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /crazy-hotels-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /eureka-naming-server/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /available-hotels-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /hotels-aggregator-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /best-hotels-service/java/com/maf/hotels/HotelsServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class HotelsServiceApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/response/CrazyHotelResponse.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.response; 2 | 3 | import java.util.List; 4 | 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | @Setter 9 | @Getter 10 | public class CrazyHotelResponse { 11 | 12 | private Integer crazyHotelId; 13 | private String hotelName; 14 | private String rate; 15 | private Double price; 16 | private String discount; 17 | private List amenitites; 18 | } 19 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/main/java/com/maf/crazyhotels/service/CrazyHotelService.java: -------------------------------------------------------------------------------- 1 | package com.maf.crazyhotels.service; 2 | 3 | import java.time.Instant; 4 | import java.util.Collection; 5 | 6 | import com.maf.crazyhotel.domain.model.CrazyHotel; 7 | import com.maf.crazyhotel.domain.model.IATACode; 8 | 9 | public interface CrazyHotelService { 10 | 11 | public Collection retriveAllCrazyHotels(Instant fromDate, Instant to, IATACode city, Integer AdultsCount ); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /eureka-naming-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = eureka-naming-server 2 | server.port = 8761 3 | 4 | 5 | ## Do not register yourself with the registration center eureka.client.register-with-eureka=false 6 | eureka.client.register-with-eureka= false 7 | 8 | ## means not to retrieve other services, because the service registry itself is responsible for maintaining the service instance, it does not need to retrieve other services 9 | eureka.client.fetch-registry= false 10 | 11 | -------------------------------------------------------------------------------- /eureka-naming-server/src/test/java/com/maf/eurekanamingserver/EurekaNamingServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.maf.eurekanamingserver; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaNamingServerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/dto/BestHotelDTO.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.dto; 2 | 3 | import java.time.LocalDate; 4 | 5 | import com.maf.besthotels.repository.IATACode; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | 11 | @Setter 12 | @Getter 13 | @AllArgsConstructor 14 | public class BestHotelDTO { 15 | 16 | private LocalDate fromDate; 17 | private LocalDate to; 18 | private IATACode city; 19 | private Integer numberOfAdults; 20 | } 21 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/service/HotelServiceProvidersIntegration.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.service; 2 | 3 | import java.time.LocalDate; 4 | import java.util.List; 5 | 6 | import com.maf.aggregator.constant.IATACode; 7 | import com.maf.aggregator.response.HotelCustomResponse; 8 | 9 | 10 | public interface HotelServiceProvidersIntegration { 11 | 12 | List retriveHotelsFromProviders(LocalDate fromDate, LocalDate to, IATACode city, Integer numberOfAdults); 13 | } 14 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/test/java/com/maf/aggregator/app/HotelsAggregatorServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.app; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class HotelsAggregatorServiceApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/domain/model/BestHotel.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.domain.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | @Setter 9 | @Getter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class BestHotel { 13 | 14 | private Integer hotelId; 15 | private String hotelName; 16 | private Double hotelRate; 17 | private Double hotelFare; 18 | private String roomAmenitites; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /available-hotels-service/requestModel/HotelsRequestModel.java: -------------------------------------------------------------------------------- 1 | package com.maf.requestModel; 2 | 3 | import java.util.Date; 4 | 5 | import com.fasterxml.jackson.annotation.JsonAlias; 6 | import com.maf.constants.IATACode; 7 | 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | 11 | @Setter 12 | @Getter 13 | public class HotelsRequestModel { 14 | 15 | @JsonAlias({ "fromDate", "from" }) 16 | private Date fromDate; 17 | private Date toDate; 18 | private IATACode city; 19 | @JsonAlias({ "numberOfAdults", "adultsCount" }) 20 | private Integer numberOfAdults; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /eureka-naming-server/src/main/java/com/maf/eurekanamingserver/EurekaNamingServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.maf.eurekanamingserver; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaNamingServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaNamingServerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/main/java/com/maf/crazyhotel/domain/model/CrazyHotel.java: -------------------------------------------------------------------------------- 1 | package com.maf.crazyhotel.domain.model; 2 | 3 | import java.util.List; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | 10 | @Setter 11 | @Getter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class CrazyHotel { 15 | 16 | private Integer crazyHotelId; 17 | private String hotelName; 18 | private String rate; 19 | private Double price; 20 | private String discount; 21 | private List amenitites; 22 | } 23 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/exceptions/BadRequest.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.BAD_REQUEST) 7 | public class BadRequest extends RuntimeException { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public BadRequest() { 12 | super(); 13 | } 14 | 15 | public BadRequest(Throwable cause) { 16 | super(cause); 17 | } 18 | 19 | public BadRequest(String exception) { 20 | 21 | super(exception); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/main/java/com/maf/crazyhotels/exception/BadRequest.java: -------------------------------------------------------------------------------- 1 | package com.maf.crazyhotels.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.BAD_REQUEST) 7 | public class BadRequest extends RuntimeException { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public BadRequest() { 12 | super(); 13 | } 14 | 15 | public BadRequest(Throwable cause) { 16 | super(cause); 17 | } 18 | 19 | public BadRequest(String exception) { 20 | 21 | super(exception); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/constants/Constant.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.constants; 2 | 3 | public final class Constant { 4 | 5 | private Constant() { 6 | // restrict instantiation 7 | } 8 | 9 | public static final String BLANK = ""; 10 | public static final String COLON = " : "; 11 | public static final String DASH = " - "; 12 | 13 | public static final String DEFAULT_LOCALE = "en"; 14 | 15 | public static final String SORT_ASC = "ASC"; 16 | public static final String SORT_DESC = "DESC"; 17 | 18 | public static boolean hasError = false; 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotel/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotel.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.BAD_REQUEST) 7 | public class BadRequestException extends RuntimeException { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public BadRequestException() { 12 | super(); 13 | } 14 | 15 | public BadRequestException(Throwable cause) { 16 | super(cause); 17 | } 18 | 19 | public BadRequestException(String exception) { 20 | 21 | super(exception); 22 | } 23 | } -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/response/CustomResponse.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.response; 2 | 3 | import lombok.Data; 4 | 5 | 6 | @Data 7 | public class CustomResponse { 8 | 9 | private final boolean success = true; 10 | 11 | private final Object code; 12 | 13 | private String message; 14 | 15 | private Object data; 16 | 17 | public CustomResponse(Object code, String message, Object data) { 18 | this.message = message; 19 | this.code = code.toString(); 20 | this.data = data; 21 | } 22 | 23 | public CustomResponse(Object code, String message) { 24 | this.message = message; 25 | this.code = code.toString(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/main/java/com/maf/crazyhotels/response/CustomResponse.java: -------------------------------------------------------------------------------- 1 | package com.maf.crazyhotels.response; 2 | 3 | 4 | import lombok.Data; 5 | 6 | @Data 7 | public class CustomResponse { 8 | 9 | private final boolean success = true; 10 | 11 | private final Object code; 12 | 13 | private String message; 14 | 15 | private Object data; 16 | 17 | public CustomResponse(Object code, String message, Object data) { 18 | this.message = message; 19 | this.code = code.toString(); 20 | this.data = data; 21 | } 22 | 23 | public CustomResponse(Object code, String message) { 24 | this.message = message; 25 | this.code = code.toString(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/responses/ExceptionResponse.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.responses; 2 | 3 | import java.util.Date; 4 | 5 | public class ExceptionResponse { 6 | private Date timestamp; 7 | private String message; 8 | private String details; 9 | 10 | public ExceptionResponse(Date timestamp, String message,String details) { 11 | super(); 12 | this.timestamp = timestamp; 13 | this.message = message; 14 | this.details = details; 15 | } 16 | 17 | public Date getTimestamp() { 18 | return timestamp; 19 | } 20 | 21 | public String getMessage() { 22 | return message; 23 | } 24 | 25 | public String getDetails() { 26 | return details; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/responses/AvailableHotels.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.responses; 2 | 3 | import java.util.List; 4 | 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | @Getter 10 | @Setter 11 | public class AvailableHotels { 12 | 13 | @ApiModelProperty(notes = "The name of the hotel service provider") 14 | private String provider; 15 | 16 | @ApiModelProperty(notes = "The name of the hotel") 17 | private String hotelName; 18 | 19 | @ApiModelProperty(notes = "The cost of hotel per night") 20 | private Double fare; 21 | 22 | @ApiModelProperty(notes = "List of aminitiest ") 23 | private List aminities; 24 | } 25 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/client/HotelServiceClientFallBack.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.client; 2 | 3 | import java.time.LocalDate; 4 | import java.util.Collection; 5 | import java.util.Collections; 6 | 7 | import org.springframework.stereotype.Component; 8 | 9 | import com.maf.hotels.constants.IATACode; 10 | import com.maf.hotels.responses.AvailableHotels; 11 | 12 | @Component 13 | public class HotelServiceClientFallBack implements HotelsServiceClient { 14 | 15 | @Override 16 | public Collection retriveBestHotels(LocalDate from, LocalDate toDate, IATACode city, 17 | Integer numberOfAdults) { 18 | 19 | Collection collection = Collections.emptyList(); 20 | return collection; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/util/NumberUtil.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.util; 2 | 3 | import java.math.BigDecimal; 4 | import java.math.RoundingMode; 5 | 6 | 7 | public class NumberUtil { 8 | 9 | /** 10 | * @author Ala'a Mezian 11 | * @param value:double ,value that need to be rounded 12 | * @param places :integer , number of digits that the value should be rounded to 13 | * @return the value of the number rounded to the desired decimal points 14 | */ 15 | public static double round(double value, int places) { 16 | if (places < 0) throw new IllegalArgumentException(); 17 | 18 | BigDecimal bd = new BigDecimal(Double.toString(value)); 19 | bd = bd.setScale(places, RoundingMode.HALF_UP); 20 | return bd.doubleValue(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/app/BestHotelsServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.app; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | @SpringBootApplication 9 | @ComponentScan( 10 | basePackages = { 11 | "com.maf.besthotels.controller" , 12 | "com.maf.besthotels.service", 13 | "com.maf.besthotels.repository" 14 | } 15 | ) 16 | @EnableDiscoveryClient 17 | public class BestHotelsServiceApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(BestHotelsServiceApplication.class, args); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/main/java/com/maf/crazyhotels/app/CrazyHotelsServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.maf.crazyhotels.app; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | @ComponentScan( 11 | basePackages = { 12 | "com.maf.crazyhotels.controller" , 13 | "com.maf.crazyhotels.service", 14 | "com.maf.crazyhotels.repository" 15 | } 16 | ) 17 | public class CrazyHotelsServiceApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(CrazyHotelsServiceApplication.class, args); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/mapper/CrazyHotelToCustomHotelMapper.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.mapper; 2 | 3 | import com.maf.aggregator.response.CrazyHotelResponse; 4 | import com.maf.aggregator.response.HotelCustomResponse; 5 | 6 | public class CrazyHotelToCustomHotelMapper { 7 | 8 | public static HotelCustomResponse map(CrazyHotelResponse crazyHotel) { 9 | 10 | HotelCustomResponse hotelCustomResponse = new HotelCustomResponse(); 11 | hotelCustomResponse.setProvider("Crazy Hotels"); 12 | hotelCustomResponse.setHotelName(crazyHotel.getHotelName()); 13 | hotelCustomResponse.setFare(crazyHotel.getPrice()); 14 | hotelCustomResponse.setAminities(crazyHotel.getAmenitites()); 15 | hotelCustomResponse.setRate((double) crazyHotel.getRate().length()); 16 | return hotelCustomResponse; 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/constants/ResponseCode.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.constants; 2 | 3 | public class ResponseCode { 4 | 5 | public final static String SUCCESS_RESPONSE_CODE = "200" ; 6 | public final static String SUCCESS_CREATE_CODE = "201"; 7 | public final static String FAILED_RESPONSE_CODE = "400" ; 8 | public final static String FAILED_GET_CODE = "404" ; 9 | public final static String FAILED_AUTH_CODE = "401"; 10 | public final static String NO_CONTENT = "204"; 11 | 12 | public final static String RESPONSE_CODE_SUCCESS = "200" ; 13 | public final static String RESPONSE_CODE_CREATED = "201"; 14 | public final static String RESPONSE_CODE_BAD_REQUEST = "400" ; 15 | public final static String RESPONSE_CODE_NOT_FOUND = "404" ; 16 | public final static String RESPONSE_CODE_UNAUTHORIZED = "401"; 17 | public final static String RESPONSE_CODE_FORBIDDEN = "403"; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/client/CrazyHotelClientFallBack.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.client; 2 | 3 | import java.time.Instant; 4 | import java.util.Collection; 5 | import java.util.Collections; 6 | 7 | import org.springframework.stereotype.Component; 8 | 9 | import com.maf.aggregator.constant.IATACode; 10 | import com.maf.aggregator.response.CrazyHotelResponse; 11 | 12 | @Component 13 | public class CrazyHotelClientFallBack implements CrazyHotelClient{ 14 | 15 | /** 16 | * @author Ala'a Mezian 17 | * @return emptyList if the crazyHotels microservice fails for some reason or its down 18 | */ 19 | @Override 20 | public Collection retriveCrazyHotels(Instant from, Instant toDate, IATACode city, 21 | Integer adultsCount) { 22 | System.out.println(" Warning : Using fallback method for Crazy Hotel Service------->"); 23 | Collection collection = Collections.emptyList(); 24 | return collection; } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/service/impl/BestHotelsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.service.impl; 2 | 3 | import java.util.Collection; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.maf.besthotels.domain.model.BestHotel; 9 | import com.maf.besthotels.dto.BestHotelDTO; 10 | import com.maf.besthotels.exceptions.BadRequest; 11 | import com.maf.besthotels.repository.BestHotelsRepository; 12 | import com.maf.besthotels.service.BestHotelsService; 13 | 14 | @Service 15 | public class BestHotelsServiceImpl implements BestHotelsService { 16 | 17 | @Autowired 18 | private BestHotelsRepository bestHotelRepo; 19 | 20 | public Collection retriveBestHotels(BestHotelDTO bestHotelDto) { 21 | if(bestHotelDto.getTo().isBefore(bestHotelDto.getFromDate())) { 22 | throw new BadRequest("invalid from-to period"); 23 | } 24 | return bestHotelRepo.findAll(); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/client/BestHotelClientFallBack.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.client; 2 | 3 | import java.time.LocalDate; 4 | import java.util.Collection; 5 | import java.util.Collections; 6 | 7 | import org.springframework.stereotype.Component; 8 | 9 | import com.maf.aggregator.constant.IATACode; 10 | import com.maf.aggregator.response.BestHotelResponse; 11 | 12 | @Component 13 | public class BestHotelClientFallBack implements BestHotelsClient{ 14 | 15 | /** 16 | * @author Ala'a Mezian 17 | * @return emptyList if the bestHotels microservice fails for some reason or its down 18 | */ 19 | @Override 20 | public Collection retriveBestHotels(LocalDate from, LocalDate toDate, IATACode city, 21 | Integer numberOfAdults) { 22 | 23 | System.out.println(" Warning : Using fallback method for Best Hotel Service------->"); 24 | Collection collection = Collections.emptyList(); 25 | return collection; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/client/CrazyHotelClient.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.client; 2 | 3 | import java.time.Instant; 4 | import java.util.Collection; 5 | 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestMethod; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | 11 | import com.maf.aggregator.constant.IATACode; 12 | import com.maf.aggregator.response.CrazyHotelResponse; 13 | 14 | @FeignClient(name = "crazy-hotels-service" , fallback = CrazyHotelClientFallBack.class) 15 | public interface CrazyHotelClient { 16 | 17 | @RequestMapping(method = RequestMethod.GET, value = "/CrazyHotels") 18 | public Collection retriveCrazyHotels(@RequestParam("from") Instant from, 19 | @RequestParam("to") Instant toDate, @RequestParam("city") IATACode city, 20 | @RequestParam("adultsCount") Integer adultsCount); 21 | } 22 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/main/java/com/maf/crazyhotels/service/impl/CrazyHotelServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.maf.crazyhotels.service.impl; 2 | 3 | import java.time.Instant; 4 | import java.util.Collection; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.maf.crazyhotel.domain.model.CrazyHotel; 10 | import com.maf.crazyhotel.domain.model.IATACode; 11 | import com.maf.crazyhotels.exception.BadRequest; 12 | import com.maf.crazyhotels.repository.CrazyHotelsRepository; 13 | import com.maf.crazyhotels.service.CrazyHotelService; 14 | 15 | @Service 16 | public class CrazyHotelServiceImpl implements CrazyHotelService{ 17 | 18 | @Autowired 19 | private CrazyHotelsRepository crazyHotelsRepository; 20 | 21 | @Override 22 | public Collection retriveAllCrazyHotels(Instant fromDate, Instant to, IATACode city, Integer AdultsCount) { 23 | if(to.isAfter(fromDate)) { 24 | throw new BadRequest(); 25 | } 26 | return crazyHotelsRepository.findAll(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/app/HotelsServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.app; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | import org.springframework.context.annotation.ComponentScan; 9 | 10 | @SpringBootApplication 11 | @EnableDiscoveryClient 12 | @EnableFeignClients(basePackages = {"com.maf.hotels.client"}) 13 | @ComponentScan( 14 | basePackages = { 15 | "com.maf.hotels.controller" , 16 | "com.maf.hotels.service", 17 | "com.maf.hotels.repository", 18 | "com.maf.hotels.client", 19 | "com.maf.hotels.config" 20 | } 21 | ) 22 | @EnableCircuitBreaker 23 | public class HotelsServiceApplication { 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(HotelsServiceApplication.class, args); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotel/exceptions/CustomizedExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotel.exceptions; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.ControllerAdvice; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.context.request.WebRequest; 10 | import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; 11 | 12 | import com.maf.hotels.responses.ExceptionResponse; 13 | 14 | @ControllerAdvice 15 | public class CustomizedExceptionHandler extends ResponseEntityExceptionHandler { 16 | 17 | @ExceptionHandler(BadRequestException.class) 18 | public final ResponseEntity handleBadRequestException(BadRequestException ex, 19 | WebRequest request) { 20 | ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), ex.getMessage(),request.getDescription(false)); 21 | return new ResponseEntity<>(exceptionResponse, HttpStatus.BAD_REQUEST); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/client/HotelsServiceClient.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.client; 2 | 3 | import java.time.LocalDate; 4 | import java.util.Collection; 5 | 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | 12 | import com.maf.hotels.constants.IATACode; 13 | import com.maf.hotels.responses.AvailableHotels; 14 | 15 | 16 | @FeignClient(name = "hotels-aggregator-service" , fallback = HotelServiceClientFallBack.class) 17 | public interface HotelsServiceClient { 18 | 19 | 20 | @RequestMapping(method = RequestMethod.GET, value="/hotels" ) 21 | public Collection retriveBestHotels(@RequestParam("fromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate from, 22 | @RequestParam("toDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate, 23 | @RequestParam("city") IATACode city, @RequestParam("numberOfAdults") Integer numberOfAdults); 24 | } 25 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/client/BestHotelsClient.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.client; 2 | 3 | import java.time.LocalDate; 4 | import java.util.Collection; 5 | 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | 12 | import com.maf.aggregator.constant.IATACode; 13 | import com.maf.aggregator.response.BestHotelResponse; 14 | 15 | @FeignClient(name = "best-hotels-service" , fallback = BestHotelClientFallBack.class) 16 | public interface BestHotelsClient { 17 | 18 | 19 | @RequestMapping(method = RequestMethod.GET, value = "/BestHotels" ) 20 | public Collection retriveBestHotels(@RequestParam("fromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromaDate, 21 | @RequestParam("toDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate, 22 | @RequestParam("city") IATACode city, @RequestParam("numberOfAdults") Integer numberOfAdults); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/mapper/BestHotelToCustomHotelMapper.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.mapper; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | 7 | import com.maf.aggregator.response.BestHotelResponse; 8 | import com.maf.aggregator.response.HotelCustomResponse; 9 | 10 | public class BestHotelToCustomHotelMapper { 11 | 12 | public static HotelCustomResponse map(BestHotelResponse bestHotelRes) { 13 | 14 | HotelCustomResponse hotelCustomResponse = new HotelCustomResponse(); 15 | hotelCustomResponse.setProvider("Best Hotels"); 16 | hotelCustomResponse.setHotelName(bestHotelRes.getHotelName()); 17 | hotelCustomResponse.setFare(bestHotelRes.getHotelFare()); 18 | if (!bestHotelRes.getRoomAmenitites().equals(null) && bestHotelRes.getRoomAmenitites() instanceof String) { 19 | String[] bestHotelAminities = bestHotelRes.getRoomAmenitites().split(","); 20 | List aminities = new ArrayList<>(); 21 | aminities = Arrays.asList(bestHotelAminities); 22 | hotelCustomResponse.setAminities(aminities); 23 | } 24 | hotelCustomResponse.setRate(bestHotelRes.getHotelRate()); 25 | return hotelCustomResponse; 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/app/HotelsAggregatorServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.app; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 8 | import org.springframework.cloud.openfeign.EnableFeignClients; 9 | import org.springframework.context.annotation.ComponentScan; 10 | 11 | @SpringBootApplication 12 | @EnableDiscoveryClient 13 | @ComponentScan( 14 | basePackages = { 15 | "com.maf.aggregator.controller" , 16 | "com.maf.aggregator.service", 17 | "com.maf.aggregator.repository", 18 | "com.maf.aggregator.client" 19 | } 20 | ) 21 | @EnableCircuitBreaker 22 | @EnableHystrixDashboard 23 | @EnableFeignClients(basePackages = {"com.maf.aggregator.client"}) 24 | public class HotelsAggregatorServiceApplication { 25 | 26 | public static void main(String[] args) { 27 | SpringApplication.run(HotelsAggregatorServiceApplication.class, args); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/service/impl/AvailableHotelsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.service.impl; 2 | 3 | import java.time.LocalDate; 4 | import java.util.Collection; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.maf.hotel.exceptions.BadRequestException; 10 | import com.maf.hotels.client.HotelsServiceClient; 11 | import com.maf.hotels.constants.IATACode; 12 | import com.maf.hotels.responses.AvailableHotels; 13 | import com.maf.hotels.responses.BaseResponse; 14 | import com.maf.hotels.responses.ListResponse; 15 | import com.maf.hotels.service.AvailableHotelsService; 16 | 17 | @Service 18 | public class AvailableHotelsServiceImpl implements AvailableHotelsService { 19 | 20 | @Autowired 21 | private HotelsServiceClient hotelServiceClient; 22 | 23 | @Override 24 | public BaseResponse retriveAllAvailableHotels(LocalDate fromDate, LocalDate toDate, IATACode city, 25 | Integer numberOfAdults) { 26 | if (fromDate.isAfter(toDate)) { 27 | throw new BadRequestException("please enter a valid from - to period"); 28 | } 29 | if (numberOfAdults <= 0) { 30 | throw new BadRequestException("number of adults should be more than zero "); 31 | } 32 | Collection availableHotels = hotelServiceClient.retriveBestHotels(fromDate, toDate, city, 33 | numberOfAdults); 34 | return ListResponse.found(availableHotels); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/controller/AggregatorController.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.controller; 2 | 3 | import java.time.LocalDate; 4 | import java.util.Collection; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import com.maf.aggregator.constant.IATACode; 14 | import com.maf.aggregator.response.HotelCustomResponse; 15 | import com.maf.aggregator.service.HotelServiceProvidersIntegration; 16 | 17 | @RestController 18 | public class AggregatorController { 19 | 20 | @Autowired 21 | private HotelServiceProvidersIntegration hotelProvidersService; 22 | 23 | @RequestMapping(value = "/hotels", method = RequestMethod.GET) 24 | public Collection retriveHotelsFromProviders( 25 | @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate, 26 | @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate, @RequestParam IATACode city, 27 | @RequestParam Integer numberOfAdults) { 28 | Collection hotels = hotelProvidersService.retriveHotelsFromProviders(fromDate, toDate, 29 | city, numberOfAdults); 30 | return hotels; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/config/Swagger2Config.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.service.ApiInfo; 10 | import springfox.documentation.service.Contact; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 14 | 15 | @Configuration 16 | @EnableSwagger2 17 | public class Swagger2Config { 18 | 19 | @Bean 20 | public Docket api() { 21 | return new Docket(DocumentationType.SWAGGER_2).select() 22 | .apis(RequestHandlerSelectors 23 | .basePackage("com.maf.hotels.controller")) 24 | .paths(PathSelectors.regex("/.*")) 25 | .build().apiInfo(apiEndPointsInfo()); 26 | } 27 | private ApiInfo apiEndPointsInfo() { 28 | return new ApiInfoBuilder().title("Spring Boot REST API") 29 | .description("Available Hotel Service") 30 | .contact(new Contact("Ala'a Mezian", "https://www.linkedin.com/in/alaamezian/", "alaa.mezian.mail@gmail.com")) 31 | .license("Apache 2.0") 32 | .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") 33 | .version("1.0.0") 34 | .build(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/main/java/com/maf/crazyhotels/controller/CrazyHotelsController.java: -------------------------------------------------------------------------------- 1 | package com.maf.crazyhotels.controller; 2 | 3 | import java.time.Instant; 4 | import java.util.Collection; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import com.maf.crazyhotel.domain.model.CrazyHotel; 14 | import com.maf.crazyhotel.domain.model.IATACode; 15 | import com.maf.crazyhotels.service.CrazyHotelService; 16 | 17 | @RestController 18 | public class CrazyHotelsController { 19 | 20 | @Autowired 21 | private CrazyHotelService crazyHotelsService; 22 | 23 | /** 24 | * @author Ala'a.mezian 25 | * @description Crazy Hotels API Provider 26 | * @param from : Date 27 | * @param to : Date 28 | * @param adultsCount : integer 29 | * @param IATACode : Enum representing airports code in each city therefore 30 | * it represent the city which contain the hotel 31 | * @return collection of crazy hotels 32 | */ 33 | @RequestMapping(value = "/CrazyHotels", method = RequestMethod.GET) 34 | public Collection retriveCrazyHotels(@RequestParam @DateTimeFormat Instant from, 35 | @RequestParam Instant to, @RequestParam IATACode city, @RequestParam Integer adultsCount) { 36 | Collection crazyHotels = crazyHotelsService.retriveAllCrazyHotels(from, to, city, adultsCount); 37 | return crazyHotels; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/controller/BestHotelsController.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.controller; 2 | 3 | import java.time.LocalDate; 4 | import java.util.Collection; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import com.maf.besthotels.domain.model.BestHotel; 14 | import com.maf.besthotels.dto.BestHotelDTO; 15 | import com.maf.besthotels.repository.IATACode; 16 | import com.maf.besthotels.service.BestHotelsService; 17 | 18 | @RestController 19 | public class BestHotelsController { 20 | 21 | @Autowired 22 | private BestHotelsService bestHotelService; 23 | 24 | /** 25 | * @author Ala'a.mezian 26 | * @description Best Hotels API Provider 27 | * @param hotelRequest consist of the following params: 28 | * from : Date 29 | * to : Date 30 | * numberOfAdults : integer 31 | * IATACode : Enum representing airports code in each city therefore it represent the city which contain the hotel 32 | * @return Collection of best hotels 33 | */ 34 | @RequestMapping(value = "/BestHotels", method = RequestMethod.GET) 35 | public Collection retriveBestHotels(@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate , 36 | @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate , @RequestParam IATACode city , @RequestParam Integer numberOfAdults) { 37 | BestHotelDTO bestHotelDTO = new BestHotelDTO(fromDate,toDate,city,numberOfAdults); 38 | Collection bestHotels = bestHotelService.retriveBestHotels(bestHotelDTO); 39 | return bestHotels; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/controller/HotelsController.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.controller; 2 | 3 | import java.time.LocalDate; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.format.annotation.DateTimeFormat; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestMethod; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import com.maf.hotels.constants.IATACode; 13 | import com.maf.hotels.responses.AvailableHotels; 14 | import com.maf.hotels.responses.BaseResponse; 15 | import com.maf.hotels.service.AvailableHotelsService; 16 | 17 | import io.swagger.annotations.ApiOperation; 18 | import io.swagger.annotations.ApiParam; 19 | import io.swagger.annotations.ApiResponse; 20 | import io.swagger.annotations.ApiResponses; 21 | 22 | @RestController 23 | @RequestMapping("/api/v1") 24 | public class HotelsController { 25 | 26 | @Autowired 27 | private AvailableHotelsService availableHotelService; 28 | 29 | @RequestMapping(value = "/AvailableHotel", method = RequestMethod.GET) 30 | @ApiOperation(value = "View a list of available events in the system ordered by hotel rate", response = AvailableHotels.class) 31 | @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully retrieved list"), 32 | @ApiResponse(code = 500, message = "internal server error,the server might be down") }) 33 | BaseResponse retriveAvailableHotels(@ApiParam(value="2008-09-15") @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate, 34 | @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate, @RequestParam IATACode city, 35 | @RequestParam Integer numberOfAdults) { 36 | 37 | return availableHotelService.retriveAllAvailableHotels(fromDate, toDate, city, numberOfAdults); 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /eureka-naming-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.0.0.RELEASE 9 | 10 | 11 | com.maf 12 | eureka-naming-server 13 | 0.0.1-SNAPSHOT 14 | eureka-naming-server 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | Finchley.M8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-actuator 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-netflix-eureka-server 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-devtools 35 | runtime 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-test 40 | test 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-dependencies 49 | ${spring-cloud.version} 50 | pom 51 | import 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | org.springframework.boot 60 | spring-boot-maven-plugin 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/util/DiscoveryUtil.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.util; 2 | 3 | import java.net.URI; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.cloud.client.ServiceInstance; 8 | import org.springframework.cloud.client.discovery.DiscoveryClient; 9 | import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * 14 | * @author Ala'a Mezian 15 | * @note this class can be used with Rest Template to determine URLs for services and services name 16 | * i didn't use this class because i used feign client which integrate with Eruka naming server 17 | * so it determine the URL of the service automatically based on service name , 18 | * and require less code to write 19 | * 20 | */ 21 | @Component 22 | public class DiscoveryUtil { 23 | 24 | @Autowired 25 | private LoadBalancerClient loadBalancer; 26 | 27 | @Autowired 28 | private DiscoveryClient discoveryClient; 29 | 30 | /** 31 | * @author Ala'a Mezian 32 | * @param serviceId the name of the service you want to discover it base URI 33 | * @param fallbackUri in case the service is down for some reason 34 | * @return the Base URI for service provider based on service name 35 | */ 36 | private URI getServiceUrl(String serviceId, String fallbackUri) { 37 | URI uri = null; 38 | try { 39 | ServiceInstance instance = loadBalancer.choose(serviceId); 40 | uri = instance.getUri(); 41 | 42 | System.out.println("Resolved serviceId '{}' to URL '{}'." + serviceId + " " + uri); 43 | 44 | } catch (RuntimeException e) { 45 | // Eureka not available, use fallback 46 | uri = URI.create(fallbackUri); 47 | System.out.println("Failed to resolve serviceId '{}'. Fallback to URL '{}'." + serviceId + " " + uri); 48 | } 49 | 50 | return uri; 51 | } 52 | 53 | /** 54 | * @author Ala'a Mezian 55 | * @return the names of all service providers names registered with in the Eureka 56 | * naming server 57 | */ 58 | List discoverProvidersNames() { 59 | List applications = discoveryClient.getServices(); 60 | return applications; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/responses/ListResponse.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.responses; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.maf.hotels.constants.ResponseCode; 7 | import com.maf.hotels.constants.ResponseStatus; 8 | 9 | public class ListResponse extends BaseResponse { 10 | 11 | private int size; 12 | private List data; 13 | 14 | public ListResponse(String status, String code, String message , List data) { 15 | super(status, code, message); 16 | this.setData(data); 17 | this.setSize(data.size()); 18 | } 19 | 20 | private ListResponse(Builder builder) { 21 | super(builder); 22 | this.size = builder.size; 23 | this.data = builder.data; 24 | } 25 | 26 | public void setData(List data) { 27 | this.data = data; 28 | } 29 | 30 | public void setSize(int size) { 31 | this.size = size; 32 | } 33 | 34 | public int getSize() { 35 | return size; 36 | } 37 | 38 | public List getData() { 39 | return data; 40 | } 41 | 42 | public static Builder builder(){ 43 | return new Builder(); 44 | } 45 | 46 | private static class Builder extends BaseBuilder>{ 47 | private List data; 48 | private int size; 49 | 50 | public Builder data(Iterable data) { 51 | 52 | List list = new ArrayList<>(); 53 | for (T datum : data) { 54 | list.add(datum); 55 | } 56 | 57 | this.data = list; 58 | size = this.data.size(); 59 | return this; 60 | } 61 | 62 | public Builder fromPrototype(ListResponse prototype) { 63 | super.fromPrototype(prototype); 64 | data = prototype.data; 65 | return this; 66 | } 67 | 68 | public ListResponse build() { 69 | return new ListResponse(this); 70 | } 71 | 72 | @Override 73 | protected Builder getInstance() { 74 | return this; 75 | } 76 | } 77 | 78 | public static ListResponse found(Iterable data){ 79 | return (ListResponse) new Builder() 80 | .data(data) 81 | .code(ResponseCode.RESPONSE_CODE_SUCCESS) 82 | .status(ResponseStatus.RESPONSE_STATUS_SUCCESS) 83 | .message("Successfully retrieved list") 84 | .build(); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /best-hotels-service/src/test/java/com/maf/app/BestHotelsServiceControllerTests.java: -------------------------------------------------------------------------------- 1 | package com.maf.app; 2 | 3 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 4 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 5 | 6 | import java.time.Duration; 7 | import java.time.Instant; 8 | import java.time.LocalDate; 9 | 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | import org.mockito.MockitoAnnotations; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 16 | import org.springframework.boot.test.context.SpringBootTest; 17 | import org.springframework.test.context.junit4.SpringRunner; 18 | import org.springframework.test.web.servlet.MockMvc; 19 | 20 | import com.maf.besthotels.app.BestHotelsServiceApplication; 21 | import com.maf.besthotels.repository.IATACode; 22 | 23 | @RunWith(SpringRunner.class) 24 | @SpringBootTest(classes = BestHotelsServiceApplication.class) 25 | @AutoConfigureMockMvc 26 | public class BestHotelsServiceControllerTests { 27 | 28 | @Autowired 29 | private MockMvc mvc; 30 | 31 | @Before 32 | public void beforeRunningTests() { 33 | MockitoAnnotations.initMocks(this); 34 | } 35 | 36 | @Test 37 | public void testBestHotelsEndPointWhenFromAndToIsValid_thenReturn200() throws Exception { 38 | 39 | mvc.perform(get("/BestHotels") 40 | .param("fromDate", LocalDate.of(2014, 02, 20).toString()) 41 | .param("toDate", LocalDate.of(2018, 02, 20).toString()) 42 | .param("city",IATACode.AUE.toString()) 43 | .param("numberOfAdults",new Integer(3).toString()).contentType("application/json")).andExpect(status().isOk()); 44 | } 45 | 46 | @Test 47 | public void testBestHotelsEndPointWhenFromAndToIsNotValid_thenReturn400() { 48 | 49 | try { 50 | mvc.perform(get("/BestHotels") 51 | .param("fromDate", LocalDate.of(2018, 02, 20).toString()) 52 | .param("toDate", LocalDate.of(2014, 02, 20).toString()) 53 | .param("city",IATACode.AUE.toString()) 54 | .param("numberOfAdults",new Integer(3).toString()).contentType("application/json")).andExpect(status().isBadRequest()); 55 | } catch (Exception e) { 56 | e.printStackTrace(); 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/test/java/com/maf/app/CrazyHotelControllerIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.maf.app; 2 | 3 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 4 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 5 | 6 | import java.time.Duration; 7 | import java.time.Instant; 8 | 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.mockito.MockitoAnnotations; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 15 | import org.springframework.boot.test.context.SpringBootTest; 16 | import org.springframework.test.context.junit4.SpringRunner; 17 | import org.springframework.test.web.servlet.MockMvc; 18 | 19 | import com.maf.crazyhotel.domain.model.IATACode; 20 | import com.maf.crazyhotels.app.CrazyHotelsServiceApplication; 21 | 22 | /* 23 | * Note that the class is called integration test because it test the integration 24 | * of the controller with the http component 25 | */ 26 | @RunWith(SpringRunner.class) 27 | @SpringBootTest(classes = CrazyHotelsServiceApplication.class) 28 | @AutoConfigureMockMvc 29 | public class CrazyHotelControllerIntegrationTest { 30 | 31 | @Autowired 32 | private MockMvc mvc; 33 | 34 | @Before 35 | public void beforeRunningTests() { 36 | MockitoAnnotations.initMocks(this); 37 | } 38 | 39 | @Test 40 | public void testCrazyHotelsEndPointWhenFromAndToIsValid_thenReturn200() throws Exception { 41 | 42 | mvc.perform(get("/CrazyHotels") 43 | .param("from", Instant.now().toString()) 44 | .param("to", Instant.now().minus(Duration.ofHours(5)).toString()) 45 | .param("city",IATACode.AUE.toString()) 46 | .param("adultsCount",new Integer(3).toString()).contentType("application/json")).andExpect(status().isOk()); 47 | } 48 | 49 | @Test 50 | public void testCrazyHotelsEndPointWhenFromAndToIsNotValid_thenReturn400() { 51 | 52 | try { 53 | mvc.perform(get("/CrazyHotels") 54 | .param("from", Instant.now().toString()) 55 | .param("to", Instant.now().plus(Duration.ofHours(5)).toString()) 56 | .param("city",IATACode.AUE.toString()) 57 | .param("adultsCount",new Integer(3).toString()).contentType("application/json")).andExpect(status().isBadRequest()); 58 | } catch (Exception e) { 59 | e.printStackTrace(); 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /best-hotels-service/src/test/java/com/maf/app/BestHotelServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.maf.app; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.mockito.Mockito.when; 5 | 6 | import java.time.LocalDate; 7 | import java.util.Collection; 8 | import java.util.HashMap; 9 | 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | import org.mockito.InjectMocks; 14 | import org.mockito.Mock; 15 | import org.mockito.MockitoAnnotations; 16 | import org.springframework.boot.test.context.SpringBootTest; 17 | import org.springframework.test.context.junit4.SpringRunner; 18 | 19 | import com.maf.besthotels.app.BestHotelsServiceApplication; 20 | import com.maf.besthotels.domain.model.BestHotel; 21 | import com.maf.besthotels.dto.BestHotelDTO; 22 | import com.maf.besthotels.exceptions.BadRequest; 23 | import com.maf.besthotels.repository.BestHotelsRepository; 24 | import com.maf.besthotels.repository.IATACode; 25 | import com.maf.besthotels.service.BestHotelsService; 26 | import com.maf.besthotels.service.impl.BestHotelsServiceImpl; 27 | 28 | @RunWith(SpringRunner.class) 29 | @SpringBootTest(classes = BestHotelsServiceApplication.class) 30 | public class BestHotelServiceTest { 31 | 32 | @Mock 33 | BestHotelsRepository bestHotelRepo; 34 | 35 | @InjectMocks 36 | BestHotelsService bestHotelServiceImpl = new BestHotelsServiceImpl(); 37 | 38 | @Before 39 | public void test() { 40 | MockitoAnnotations.initMocks(this); 41 | } 42 | 43 | @Test 44 | public void testRetriveAllBestHotels() { 45 | Collection hotels = new HashMap() { 46 | { 47 | put(1, new BestHotel(1, "Hitlon", 4.0, 25.66, "Swna, Bean Bags , Double Size Bed")); 48 | put(2, new BestHotel(2, "Four Seasons", 4.5, 36.2023, "Table Lamp, Envelopes")); 49 | } 50 | }.values(); 51 | when(bestHotelRepo.findAll()).thenReturn(hotels); 52 | BestHotelDTO bestHotelTest = new BestHotelDTO(LocalDate.of(2014, 02, 20), LocalDate.of(2018, 02, 20), IATACode.AUE, 53 | new Integer(3)); 54 | assertThat(bestHotelServiceImpl 55 | .retriveBestHotels(bestHotelTest) 56 | .containsAll(hotels)); 57 | } 58 | 59 | @Test(expected = BadRequest.class) 60 | public void testInvalidDate() { 61 | BestHotelDTO bestHotelTest = new BestHotelDTO(LocalDate.of(2018, 02, 20), LocalDate.of(2014, 02, 20), IATACode.AUE, 62 | new Integer(3)); 63 | bestHotelServiceImpl.retriveBestHotels(bestHotelTest); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /crazy-hotels-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.4.RELEASE 9 | 10 | 11 | com.maf 12 | CrazyHotels 13 | 0.0.1-SNAPSHOT 14 | crazy-hotels-service 15 | crazy hotels service provider 16 | 17 | 18 | 1.8 19 | Greenwich.SR1 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-actuator 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-web 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-netflix-eureka-client 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-devtools 39 | runtime 40 | 41 | 42 | org.projectlombok 43 | lombok 44 | true 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-test 49 | test 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-dependencies 58 | ${spring-cloud.version} 59 | pom 60 | import 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-maven-plugin 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /best-hotels-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.4.RELEASE 9 | 10 | 11 | com.maf 12 | BestHotel 13 | 0.0.1-SNAPSHOT 14 | best-hotels-service 15 | a service provider 16 | 17 | 18 | 1.8 19 | Greenwich.SR1 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-actuator 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-web 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-starter-netflix-eureka-client 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-devtools 41 | runtime 42 | 43 | 44 | org.projectlombok 45 | lombok 46 | true 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-test 51 | test 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | org.springframework.cloud 60 | spring-cloud-dependencies 61 | ${spring-cloud.version} 62 | pom 63 | import 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-maven-plugin 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/test/java/com/maf/app/CrazyHotelsServiceTests.java: -------------------------------------------------------------------------------- 1 | package com.maf.app; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.mockito.Mockito.when; 5 | 6 | import java.time.Duration; 7 | import java.time.Instant; 8 | import java.util.Arrays; 9 | import java.util.Collection; 10 | import java.util.HashMap; 11 | 12 | import org.junit.Before; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | import org.mockito.InjectMocks; 16 | import org.mockito.Mock; 17 | import org.mockito.MockitoAnnotations; 18 | import org.springframework.boot.test.context.SpringBootTest; 19 | import org.springframework.test.context.junit4.SpringRunner; 20 | 21 | import com.maf.crazyhotel.domain.model.CrazyHotel; 22 | import com.maf.crazyhotel.domain.model.IATACode; 23 | import com.maf.crazyhotels.app.CrazyHotelsServiceApplication; 24 | import com.maf.crazyhotels.exception.BadRequest; 25 | import com.maf.crazyhotels.repository.CrazyHotelsRepository; 26 | import com.maf.crazyhotels.service.CrazyHotelService; 27 | import com.maf.crazyhotels.service.impl.CrazyHotelServiceImpl; 28 | 29 | @RunWith(SpringRunner.class) 30 | @SpringBootTest(classes = CrazyHotelsServiceApplication.class) 31 | public class CrazyHotelsServiceTests { 32 | 33 | @Mock 34 | CrazyHotelsRepository hotelRepo; 35 | 36 | @InjectMocks 37 | CrazyHotelService crazyHotelServiceImpl = new CrazyHotelServiceImpl(); 38 | 39 | @Before 40 | public void test() { 41 | MockitoAnnotations.initMocks(this); 42 | } 43 | 44 | @Test 45 | public void testRetriveAllCrazyHotels() { 46 | Collection hotels = new HashMap() { 47 | { 48 | put(1, new CrazyHotel(1, "Starwood", "***", 150.469, "10%", 49 | Arrays.asList("Jackozi", "Envelopes", "LED Monitor"))); 50 | put(2, new CrazyHotel(2, "Marriott", "****", 250.605, "0%", 51 | Arrays.asList("Table Lamp", "King Size Bed"))); 52 | put(3, new CrazyHotel(3, "Lime Wood", "**", 180.0, "0%", 53 | Arrays.asList("Large Swimming pool", "Air Conditions"))); 54 | } 55 | }.values(); 56 | when(hotelRepo.findAll()).thenReturn(hotels); 57 | assertThat(crazyHotelServiceImpl.retriveAllCrazyHotels(Instant.now(), 58 | Instant.now().minus(Duration.ofHours(5).plusMinutes(4)), IATACode.AUE, 3).containsAll(hotels)); 59 | } 60 | 61 | @Test(expected = BadRequest.class) 62 | public void testInvalidDate() { 63 | crazyHotelServiceImpl.retriveAllCrazyHotels(Instant.now(), 64 | Instant.now().plus(Duration.ofHours(5).plusMinutes(4)), IATACode.AUE, 3); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /best-hotels-service/src/test/java/com/maf/app/BestHotelRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.maf.app; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.mockito.Mockito.when; 5 | 6 | import java.util.Collection; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | import java.util.stream.Stream; 10 | 11 | import org.junit.Before; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import org.mockito.MockitoAnnotations; 15 | import org.springframework.boot.test.context.SpringBootTest; 16 | import org.springframework.boot.test.mock.mockito.MockBean; 17 | import org.springframework.test.context.junit4.SpringRunner; 18 | 19 | import com.maf.besthotels.app.BestHotelsServiceApplication; 20 | import com.maf.besthotels.domain.model.BestHotel; 21 | import com.maf.besthotels.repository.BestHotelsRepository; 22 | 23 | @RunWith(SpringRunner.class) 24 | @SpringBootTest(classes = BestHotelsServiceApplication.class) 25 | public class BestHotelRepositoryTest { 26 | 27 | @MockBean 28 | BestHotelsRepository bestHotelRepo; 29 | 30 | Map HotelRepository; 31 | 32 | @Before 33 | public void before() { 34 | MockitoAnnotations.initMocks(this); 35 | Stream hotelsStream = Stream.of("1-Hitlon-4-25.659-Swna, Bean Bags , Double Size Bed", 36 | "2-Four Seasons-4.5-36.2023-Table Lamp, Envelopes"); 37 | HotelRepository = BestHotelsRepository.createBestHotels(hotelsStream); 38 | } 39 | 40 | @Test 41 | public void givenValidInputStreamAsBestHotels_ThenGetHotelById() { 42 | 43 | BestHotel testHotel = new BestHotel(1, "Hitlon", 4.0, 25.66, "Swna, Bean Bags , Double Size Bed"); 44 | when(bestHotelRepo.findById(1L)).thenReturn(testHotel); 45 | 46 | assertThat(HotelRepository.get(1)).isEqualToComparingFieldByField(bestHotelRepo.findById(1L)); 47 | } 48 | 49 | @Test 50 | public void givenValidInputStreamAsBestHotels_ThenCreateBestHotels() { 51 | BestHotel testHotel = new BestHotel(1, "Hitlon", 4.0, 25.66, "Swna, Bean Bags , Double Size Bed"); 52 | assertThat(HotelRepository.get(1)).isEqualToComparingFieldByField(testHotel); 53 | } 54 | 55 | @Test 56 | public void givenValidInputStreamAsBestHotels_ThenFindAllBestHotels() { 57 | Collection hotels = new HashMap() { 58 | { 59 | put(1, new BestHotel(1, "Hitlon", 4.0, 25.659, "Swna, Bean Bags , Double Size Bed")); 60 | put(2, new BestHotel(2, "Four Seasons", 4.5, 36.2023, "Table Lamp, Envelopes")); 61 | } 62 | }.values(); 63 | 64 | when(bestHotelRepo.findAll()).thenReturn(hotels); 65 | assertThat(HotelRepository.values().containsAll(hotels)); 66 | 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /best-hotels-service/src/main/java/com/maf/besthotels/repository/BestHotelsRepository.java: -------------------------------------------------------------------------------- 1 | package com.maf.besthotels.repository; 2 | 3 | import static com.maf.besthotels.util.NumberUtil.round; 4 | 5 | import java.util.Collection; 6 | import java.util.Map; 7 | import java.util.stream.Collectors; 8 | import java.util.stream.Stream; 9 | 10 | import org.springframework.beans.factory.annotation.Value; 11 | import org.springframework.stereotype.Repository; 12 | 13 | import com.maf.besthotels.domain.model.BestHotel; 14 | 15 | @Repository 16 | public class BestHotelsRepository { 17 | 18 | 19 | /** 20 | * Note the map is acting as a temporary data base 21 | **/ 22 | private static Map HotelRepsitory = null; 23 | 24 | static { 25 | /** 26 | * Note the stream is acting as a data source for the map 27 | **/ 28 | Stream hotelsStream = Stream.of("1-Hitlon-4-25.659-Swna, Bean Bags , Double Size Bed", 29 | "2-Four Seasons-4.5-36.2023-Table Lamp, Envelopes"); 30 | HotelRepsitory = createBestHotels(hotelsStream); 31 | } 32 | 33 | public static Map createBestHotels(Stream hotelsStream){ 34 | return hotelsStream.map(hotel -> { 35 | String[] info = hotel.split("-"); 36 | return createBestHotel(new Integer(info[0]), info[1], new Double(info[2]), new Double(info[3]), info[4]); 37 | }).collect(Collectors.toMap(BestHotel::getHotelId, bHotel -> bHotel)); 38 | } 39 | 40 | /** 41 | * @author Ala'a Mezian 42 | * @param id:integer ,the identifier of the besthotel object you want to 43 | * create 44 | * @param name :string , name of the hotel 45 | * @param hotelRate :double , the rate of the hotel number from 1-5 46 | * @param hotelFare : double , Total price rounded to 2 decimals 47 | * @param roomAmenities: String of amenities separated by comma 48 | * @return inserted best hotel object 49 | */ 50 | private static BestHotel createBestHotel(Integer id, String name, Double hotelRate, Double hotelFare, 51 | String roomAminities) { 52 | BestHotel bestHotel = new BestHotel(); 53 | bestHotel.setHotelId(id); 54 | bestHotel.setHotelName(name); 55 | bestHotel.setHotelRate(hotelRate); 56 | bestHotel.setHotelFare(round(hotelFare, 2)); 57 | bestHotel.setRoomAmenitites(roomAminities); 58 | return bestHotel; 59 | } 60 | 61 | /** 62 | * @author Ala'a Mezian 63 | * @param id:long ,the identifier of the desired hotel to be retrieved 64 | * @return BestHotel object by id 65 | */ 66 | public BestHotel findById(Long id) { 67 | return HotelRepsitory.get(id); 68 | } 69 | 70 | /** 71 | * @author Ala'a Mezian 72 | * @return a collection of all hotels in the besthotel provider 73 | */ 74 | public Collection findAll() { 75 | return HotelRepsitory.values(); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spring Boot MicroService Bridge Solution 2 | 3 | This is a solution based on micro-service architecture to easily add / remove services providers without effecting other providers and without effecting the main services consumer. 4 | 5 | In this solution i used spring boot and spring cloud to implement microservice archtiture here are some of the modules used in the solution: 6 | - Service Discovery (Eureka Naming Server) 7 | - Feign Rest Client 8 | - Hystrix for fault tolerance 9 | - Rest Controllers 10 | - Swagger for api documentation 11 | 12 | # Archticture 13 | In this paragraph i will explain the archticture ,our solution contains five component , four core microservices, bestHotel, crazyHotel ,available hotel which act as a consumer for other services and aggregateHotels, the aggregate hotel micro service act as bridge or as some other people call front door to other underlying micro service ,finally eruka naming server which will register and ease the communication between services. 14 | 15 | The purpose of the aggregate service is to be the main portal to microservices leaving each microservice sperate independent from other services,so adding or removing microservice will be maintained only in the aggregate service code, the aggregate service is the key for this structure to because it will calls each relevant microservice collects the data, apply business logic to it, and further publish it is as a REST Endpoint. 16 | 17 | 18 | Implementating hystrix applied defensive programming strategy is essential, if besthotel service provider went down , our main service consumer won't go down and will not recive an error but instead hystrix will call a FallBack Command which will handle besthotel microservice fauiler. 19 | 20 | 21 | ![alt text](https://github.com/AlaaMezian/Maf-Task/blob/master/MicroServices%20(1).png) 22 | 23 | 24 | To run and test the project please run the following respectively 25 | - Eruka Naming Server (must be first) 26 | - Best Hotel Serivce 27 | - Crazy Hotel Service 28 | - Aggregate Hotel Serivce 29 | - Available Hotel Service (Consumer Service) 30 | 31 | After luanching the projects ,testing the main consumer service available hotel can be done through swagger at: 32 | http://localhost:8082/swagger-ui.html#/ 33 | 34 | Please note that Shutting down any of the provider service won't effect the overwhole process ,as if crazy hotel service provider shut down ,the following will happen: 35 | - hystrix fall back will be triggered 36 | - aggregate service will collect data from alive providers in our case besthotels service 37 | - our consumer will still gets the data of best hotels after all. 38 | 39 | # Future Improvements : 40 | :heavy_check_mark: cover the solution with unit testing using JUnit added junit 41 | for both best hotel and crazy hotel micro service 42 | - add Load Balancing Ribbons to microservice . 43 | 44 | Please feel free to :star: happy programming :v: 45 | -------------------------------------------------------------------------------- /hotels-aggregator-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.1.4.RELEASE 10 | 11 | 12 | com.maf 13 | hotels-aggregator-service 14 | 0.0.1-SNAPSHOT 15 | hotels-aggregator-service 16 | The user makes a single call to the Aggregator, and the aggregator then calls each relevant microservice and collects the data, apply business logic to it, and further publish is as a REST Endpoint 17 | 18 | 19 | 1.8 20 | Greenwich.SR1 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-web 32 | 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-netflix-eureka-client 37 | 38 | 39 | 40 | org.springframework.cloud 41 | spring-cloud-starter-netflix-hystrix 42 | 43 | 44 | 45 | org.springframework.cloud 46 | spring-cloud-starter-netflix-hystrix-dashboard 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-devtools 52 | runtime 53 | 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-starter-openfeign 58 | 59 | 60 | 61 | org.projectlombok 62 | lombok 63 | true 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-starter-test 68 | test 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.springframework.cloud 76 | spring-cloud-dependencies 77 | ${spring-cloud.version} 78 | pom 79 | import 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | org.springframework.boot 88 | spring-boot-maven-plugin 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/test/java/com/maf/app/CrazyHotelRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.maf.app; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.junit.Assert.assertThat; 5 | import static org.mockito.Mockito.when; 6 | 7 | import java.util.Arrays; 8 | import java.util.Collection; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | import java.util.stream.Stream; 12 | 13 | import org.hamcrest.collection.IsMapContaining; 14 | import org.junit.Before; 15 | import org.junit.Test; 16 | import org.junit.runner.RunWith; 17 | import org.mockito.MockitoAnnotations; 18 | import org.springframework.boot.test.context.SpringBootTest; 19 | import org.springframework.boot.test.mock.mockito.MockBean; 20 | import org.springframework.test.context.junit4.SpringRunner; 21 | 22 | import com.maf.crazyhotel.domain.model.CrazyHotel; 23 | import com.maf.crazyhotels.app.CrazyHotelsServiceApplication; 24 | import com.maf.crazyhotels.repository.CrazyHotelsRepository; 25 | 26 | @RunWith(SpringRunner.class) 27 | @SpringBootTest(classes = CrazyHotelsServiceApplication.class) 28 | public class CrazyHotelRepositoryTest { 29 | 30 | @MockBean 31 | CrazyHotelsRepository crazyHotelRepo; 32 | 33 | Map HotelRepository; 34 | 35 | @Before 36 | public void before() { 37 | MockitoAnnotations.initMocks(this); 38 | Stream hotelsStream = Stream.of("1-Starwood-***-150.469-10%-Table Lamp,Envelopes,LED Monitor", 39 | "2-Marriott-****-250.605-0-Jackozi,King Size Bed", 40 | "3-Lime Wood-**-180-0-Large Swimming pool,Air Conditions"); 41 | HotelRepository = CrazyHotelsRepository.createCrazyHotels(hotelsStream); 42 | } 43 | 44 | @Test 45 | public void givenValidInputStreamAsCrazyHotel_ThenGetHotelById() { 46 | 47 | CrazyHotel testHotel = new CrazyHotel(1, "Starwood", "***", 150.469, "10%", 48 | Arrays.asList("Table Lamp", "Envelopes", "LED Monitor")); 49 | when(crazyHotelRepo.findById(1L)).thenReturn(testHotel); 50 | 51 | assertThat(HotelRepository.get(1)).isEqualToComparingFieldByField(crazyHotelRepo.findById(1L)); 52 | } 53 | 54 | @Test 55 | public void givenValidInputStream_ThenTestFindAll() { 56 | Collection hotels = new HashMap() { 57 | { 58 | put(1, new CrazyHotel(1, "Starwood", "***", 150.469, "10%", 59 | Arrays.asList("Jackozi", "Envelopes", "LED Monitor"))); 60 | put(2, new CrazyHotel(2, "Marriott", "****", 250.605, "0%", 61 | Arrays.asList("Table Lamp", "King Size Bed"))); 62 | put(3, new CrazyHotel(3, "Lime Wood", "**", 180.0, "0%", 63 | Arrays.asList("Large Swimming pool", "Air Conditions"))); 64 | } 65 | }.values(); 66 | when(crazyHotelRepo.findAll()).thenReturn(hotels); 67 | assertThat(HotelRepository.values().containsAll(hotels)); 68 | assertThat(HotelRepository,IsMapContaining.hasKey(1)); 69 | assertThat(HotelRepository,IsMapContaining.hasKey(2)); 70 | assertThat(HotelRepository,IsMapContaining.hasKey(3)); 71 | 72 | } 73 | 74 | @Test 75 | public void givenValidInputStreamAsCrazyHotels_ThenCreateCrazyHotels() { 76 | 77 | CrazyHotel testHotel = new CrazyHotel(1, "Starwood", "***", 150.469, "10%", 78 | Arrays.asList("Table Lamp", "Envelopes", "LED Monitor")); 79 | assertThat(HotelRepository.get(1)).isEqualToComparingFieldByField(testHotel); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /available-hotels-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.1.4.RELEASE 10 | 11 | 12 | com.maf 13 | HotelsService 14 | 0.0.1-SNAPSHOT 15 | HotelsService 16 | Demo Project for Hotel service 17 | 18 | 19 | 1.8 20 | Greenwich.SR1 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-starter-netflix-hystrix 36 | 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-netflix-eureka-client 41 | 42 | 43 | 44 | org.springframework.cloud 45 | spring-cloud-starter-openfeign 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-devtools 51 | runtime 52 | 53 | 54 | 55 | org.projectlombok 56 | lombok 57 | true 58 | 59 | 60 | 61 | io.springfox 62 | springfox-swagger2 63 | 2.8.0 64 | 65 | 66 | 67 | io.springfox 68 | springfox-swagger-ui 69 | 2.10.0 70 | 71 | 72 | 73 | org.springframework.boot 74 | spring-boot-starter-test 75 | test 76 | 77 | 78 | 79 | 80 | 81 | 82 | org.springframework.cloud 83 | spring-cloud-dependencies 84 | ${spring-cloud.version} 85 | pom 86 | import 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | org.springframework.boot 95 | spring-boot-maven-plugin 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/main/java/com/maf/crazyhotels/repository/CrazyHotelsRepository.java: -------------------------------------------------------------------------------- 1 | package com.maf.crazyhotels.repository; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.Collection; 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.stream.Collectors; 9 | import java.util.stream.Stream; 10 | 11 | import org.springframework.stereotype.Repository; 12 | 13 | import com.maf.crazyhotel.domain.model.CrazyHotel; 14 | 15 | @Repository 16 | public class CrazyHotelsRepository { 17 | 18 | /** 19 | * Note the map is acting as a temporary data base 20 | **/ 21 | private static Map HotelRepsitory = null; 22 | 23 | static { 24 | /** 25 | * Note the stream is acting as a data source for the map 26 | **/ 27 | Stream hotelsStream = Stream.of("1-Starwood-***-150.469-10%-Table Lamp, Envelopes,LED Monitor", 28 | "2-Marriott-****-250.605-0-Jackozi, King Size Bed", 29 | "3-Lime Wood-**-180-0-Large Swimming pool, Air Conditions"); 30 | HotelRepsitory = createCrazyHotels(hotelsStream); 31 | } 32 | 33 | /** 34 | * @author Ala'a Mezian 35 | * @param hotelsStream :stream,act as the data source of the repository 36 | * @return inserted crazy hotel object into the hash map 37 | */ 38 | public static Map createCrazyHotels(Stream hotelsStream) { 39 | return hotelsStream.map(hotel -> { 40 | String[] info = hotel.split("-"); 41 | return createCrazyHotel(new Integer(info[0]), info[1], info[2], new Double(info[3]), info[4], info[5]); 42 | }).collect(Collectors.toMap(CrazyHotel::getCrazyHotelId, cHotel -> cHotel)); 43 | } 44 | 45 | /** 46 | * @author Ala'a Mezian 47 | * @param id :integer , the identifier of the best hotels object you 48 | * want to create 49 | * @param name :string , name of the hotel 50 | * @param hotelRate :double , the rate of the hotel number from 1-5 51 | * @param hotelprice: double , hotel room price per night 52 | * @param roomAmenities: String of amenities separated by comma 53 | * @return inserted crazy hotel object 54 | */ 55 | public static CrazyHotel createCrazyHotel(Integer id, String name, String hotelRate, Double hotelFare, 56 | String discount, String roomAminities) { 57 | CrazyHotel crazyHotel = new CrazyHotel(); 58 | crazyHotel.setCrazyHotelId(id); 59 | crazyHotel.setHotelName(name); 60 | crazyHotel.setRate(hotelRate); 61 | crazyHotel.setPrice(hotelFare); 62 | if (!discount.equals("0")) { 63 | crazyHotel.setDiscount(discount); 64 | } 65 | if (!roomAminities.equals(null)) { 66 | List amenitites = new ArrayList<>(); 67 | String[] roomAmenitiesArr = roomAminities.split(","); 68 | if (roomAmenitiesArr.length == 1) { 69 | amenitites.add(roomAmenitiesArr[0]); 70 | } else { 71 | amenitites = Arrays.asList(roomAmenitiesArr); 72 | } 73 | crazyHotel.setAmenitites(amenitites); 74 | } 75 | return crazyHotel; 76 | } 77 | 78 | public CrazyHotel findById(Long id) { 79 | return HotelRepsitory.get(id); 80 | } 81 | 82 | /** 83 | * @author Ala'a Mezian 84 | * @return a collection of all hotels in the crazy hotels provider 85 | */ 86 | public Collection findAll() { 87 | return HotelRepsitory.values(); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /crazy-hotels-service/src/test/java/com/maf/app/CrazyHotelControllerUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.maf.app; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.mockito.BDDMockito.given; 5 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 6 | 7 | import java.time.Duration; 8 | import java.time.Instant; 9 | import java.util.Arrays; 10 | import java.util.HashMap; 11 | 12 | import org.junit.Before; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | import org.mockito.InjectMocks; 16 | import org.mockito.MockitoAnnotations; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 19 | import org.springframework.boot.test.context.SpringBootTest; 20 | import org.springframework.boot.test.mock.mockito.MockBean; 21 | import org.springframework.http.HttpStatus; 22 | import org.springframework.mock.web.MockHttpServletResponse; 23 | import org.springframework.test.context.junit4.SpringRunner; 24 | import org.springframework.test.web.servlet.MockMvc; 25 | 26 | import com.fasterxml.jackson.databind.ObjectMapper; 27 | import com.maf.crazyhotel.domain.model.CrazyHotel; 28 | import com.maf.crazyhotel.domain.model.IATACode; 29 | import com.maf.crazyhotels.app.CrazyHotelsServiceApplication; 30 | import com.maf.crazyhotels.controller.CrazyHotelsController; 31 | import com.maf.crazyhotels.service.CrazyHotelService; 32 | 33 | @RunWith(SpringRunner.class) 34 | @SpringBootTest(classes = CrazyHotelsServiceApplication.class) 35 | @AutoConfigureMockMvc 36 | public class CrazyHotelControllerUnitTest { 37 | 38 | @Autowired 39 | private MockMvc mvc; 40 | 41 | @MockBean 42 | private CrazyHotelService crazyHotelService; 43 | 44 | @InjectMocks 45 | private CrazyHotelsController crazyHotelServiceController; 46 | 47 | /* 48 | * the object mapper is needed if we want to serialize and send data with the 49 | * request 50 | */ 51 | @Autowired 52 | private ObjectMapper objectMapper; 53 | 54 | @Before 55 | public void beforeRunningTests() { 56 | MockitoAnnotations.initMocks(this); 57 | } 58 | 59 | @Test 60 | public void testCrazyHotelEndPointGivenValidParams_ThenReturnDataFromService() throws Exception { 61 | 62 | given(crazyHotelService.retriveAllCrazyHotels(Instant.now(), Instant.now().minus(Duration.ofHours(5)), 63 | IATACode.AUE, new Integer(3))).willReturn(new HashMap() { 64 | { 65 | put(1, new CrazyHotel(1, "Starwood", "***", 150.469, "10%", 66 | Arrays.asList("Jackozi", "Envelopes", "LED Monitor"))); 67 | put(2, new CrazyHotel(2, "Marriott", "****", 250.605, "0%", 68 | Arrays.asList("Table Lamp", "King Size Bed"))); 69 | put(3, new CrazyHotel(3, "Lime Wood", "**", 180.0, "0%", 70 | Arrays.asList("Large Swimming pool", "Air Conditions"))); 71 | } 72 | }.values()); 73 | 74 | MockHttpServletResponse response= mvc.perform(get("/CrazyHotels").param("from", Instant.now().toString()) 75 | .param("to", Instant.now().minus(Duration.ofHours(5)).toString()).param("city", IATACode.AUE.toString()) 76 | .param("adultsCount", new Integer(3).toString()).contentType("application/json")) 77 | .andReturn().getResponse(); 78 | ; 79 | assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value()); 80 | assertThat(response.getContentAsString()). 81 | isEqualTo(crazyHotelService.retriveAllCrazyHotels( 82 | Instant.now(), Instant.now().minus(Duration.ofHours(5)) 83 | ,IATACode.AUE, new Integer(3)).toString()); 84 | 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /available-hotels-service/src/main/java/com/maf/hotels/responses/BaseResponse.java: -------------------------------------------------------------------------------- 1 | package com.maf.hotels.responses; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | import com.maf.hotels.constants.ResponseCode; 6 | import com.maf.hotels.constants.ResponseStatus; 7 | 8 | 9 | 10 | public class BaseResponse { 11 | 12 | protected String status; 13 | protected String code; 14 | protected String message; 15 | 16 | 17 | 18 | public BaseResponse(String status, String code, String message ) { 19 | this.setStatus(status); 20 | this.setCode(code); 21 | this.setMessage(message); 22 | } 23 | 24 | protected BaseResponse(BaseBuilder builder) { 25 | this.status = builder.status; 26 | this.code = builder.code; 27 | this.message = builder.message; 28 | } 29 | 30 | 31 | public void setStatus(String status) { 32 | this.status = status; 33 | } 34 | 35 | 36 | public void setCode(String code) { 37 | this.code = code; 38 | } 39 | 40 | 41 | public void setMessage(String message) { 42 | this.message = message; 43 | } 44 | 45 | public String getStatus() { 46 | return status; 47 | } 48 | 49 | public String getCode() { 50 | return code; 51 | } 52 | 53 | public String getMessage() { 54 | return message; 55 | } 56 | 57 | 58 | 59 | public static abstract class BaseBuilder { 60 | public String status; 61 | public String code; 62 | public String message; 63 | 64 | public T status(String status) { 65 | this.status = status; 66 | return getInstance(); 67 | } 68 | 69 | public T code(String code) { 70 | this.code = code; 71 | return getInstance(); 72 | } 73 | 74 | public T message(String message) { 75 | this.message = message; 76 | return getInstance(); } 77 | 78 | public T fromPrototype(BaseResponse prototype) { 79 | status = prototype.status; 80 | code = prototype.code; 81 | message = prototype.message; 82 | return getInstance(); 83 | } 84 | 85 | protected abstract T getInstance(); 86 | 87 | public BaseResponse baseBuild() { 88 | return new BaseResponse(this); 89 | } 90 | 91 | } 92 | 93 | public static BaseResponse unAuthorized(){ 94 | return new BaseResponse(ResponseStatus.RESPONSE_STATUS_FAILED, ResponseCode.RESPONSE_CODE_UNAUTHORIZED, 95 | "sorry you are not authorized"); 96 | } 97 | 98 | public static BaseResponse unAuthorized(String msg){ 99 | return new BaseResponse(ResponseStatus.RESPONSE_STATUS_FAILED, ResponseCode.RESPONSE_CODE_UNAUTHORIZED,msg); 100 | } 101 | 102 | public static BaseResponse forbidden(){ 103 | return new BaseResponse(ResponseStatus.RESPONSE_STATUS_FAILED, ResponseCode.RESPONSE_CODE_FORBIDDEN, 104 | "forbidden"); 105 | } 106 | 107 | public static BaseResponse notFound(){ 108 | return new BaseResponse(ResponseStatus.RESPONSE_STATUS_FAILED,ResponseCode.RESPONSE_CODE_NOT_FOUND, 109 | "Not Found !"); 110 | } 111 | 112 | public static BaseResponse notFound(String fieldName){ 113 | return new BaseResponse(ResponseStatus.RESPONSE_STATUS_FAILED,ResponseCode.RESPONSE_CODE_NOT_FOUND, 114 | fieldName); 115 | } 116 | 117 | public static BaseResponse noContent() { 118 | return new BaseResponse(HttpStatus.NO_CONTENT.name(),ResponseCode.NO_CONTENT, 119 | "no content"); 120 | } 121 | 122 | public static BaseResponse alreadyRegistered(){ 123 | return new BaseResponse(ResponseStatus.RESPONSE_STATUS_FAILED,ResponseCode.RESPONSE_CODE_BAD_REQUEST, 124 | "already registered"); 125 | } 126 | public static BaseResponse alreadyLoggedIn(){ 127 | return new BaseResponse(ResponseStatus.RESPONSE_STATUS_FAILED,ResponseCode.RESPONSE_CODE_BAD_REQUEST, 128 | "you are already logged in"); 129 | } 130 | 131 | public static BaseResponse failed(String message){ 132 | return new BaseResponse(ResponseStatus.RESPONSE_STATUS_FAILED,ResponseCode.RESPONSE_CODE_BAD_REQUEST,message); 133 | } 134 | public static BaseResponse success(String message){ 135 | return new BaseResponse(ResponseStatus.RESPONSE_STATUS_SUCCESS,ResponseCode.RESPONSE_CODE_SUCCESS,message); 136 | } 137 | public static BaseResponse created(String message){ 138 | return new BaseResponse(ResponseStatus.RESPONSE_STATUS_SUCCESS,ResponseCode.RESPONSE_CODE_CREATED,message); 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /best-hotels-service/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | https://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.net.URL; 25 | import java.nio.channels.Channels; 26 | import java.nio.channels.ReadableByteChannel; 27 | import java.util.Properties; 28 | 29 | public class MavenWrapperDownloader { 30 | 31 | /** 32 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 33 | */ 34 | private static final String DEFAULT_DOWNLOAD_URL = 35 | "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; 36 | 37 | /** 38 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 39 | * use instead of the default one. 40 | */ 41 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 42 | ".mvn/wrapper/maven-wrapper.properties"; 43 | 44 | /** 45 | * Path where the maven-wrapper.jar will be saved to. 46 | */ 47 | private static final String MAVEN_WRAPPER_JAR_PATH = 48 | ".mvn/wrapper/maven-wrapper.jar"; 49 | 50 | /** 51 | * Name of the property which should be used to override the default download url for the wrapper. 52 | */ 53 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 54 | 55 | public static void main(String args[]) { 56 | System.out.println("- Downloader started"); 57 | File baseDirectory = new File(args[0]); 58 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 59 | 60 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 61 | // wrapperUrl parameter. 62 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 63 | String url = DEFAULT_DOWNLOAD_URL; 64 | if(mavenWrapperPropertyFile.exists()) { 65 | FileInputStream mavenWrapperPropertyFileInputStream = null; 66 | try { 67 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 68 | Properties mavenWrapperProperties = new Properties(); 69 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 70 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 71 | } catch (IOException e) { 72 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 73 | } finally { 74 | try { 75 | if(mavenWrapperPropertyFileInputStream != null) { 76 | mavenWrapperPropertyFileInputStream.close(); 77 | } 78 | } catch (IOException e) { 79 | // Ignore ... 80 | } 81 | } 82 | } 83 | System.out.println("- Downloading from: : " + url); 84 | 85 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 86 | if(!outputFile.getParentFile().exists()) { 87 | if(!outputFile.getParentFile().mkdirs()) { 88 | System.out.println( 89 | "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 90 | } 91 | } 92 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 93 | try { 94 | downloadFileFromURL(url, outputFile); 95 | System.out.println("Done"); 96 | System.exit(0); 97 | } catch (Throwable e) { 98 | System.out.println("- Error downloading"); 99 | e.printStackTrace(); 100 | System.exit(1); 101 | } 102 | } 103 | 104 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 105 | URL website = new URL(urlString); 106 | ReadableByteChannel rbc; 107 | rbc = Channels.newChannel(website.openStream()); 108 | FileOutputStream fos = new FileOutputStream(destination); 109 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 110 | fos.close(); 111 | rbc.close(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /crazy-hotels-service/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | https://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.net.URL; 25 | import java.nio.channels.Channels; 26 | import java.nio.channels.ReadableByteChannel; 27 | import java.util.Properties; 28 | 29 | public class MavenWrapperDownloader { 30 | 31 | /** 32 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 33 | */ 34 | private static final String DEFAULT_DOWNLOAD_URL = 35 | "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; 36 | 37 | /** 38 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 39 | * use instead of the default one. 40 | */ 41 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 42 | ".mvn/wrapper/maven-wrapper.properties"; 43 | 44 | /** 45 | * Path where the maven-wrapper.jar will be saved to. 46 | */ 47 | private static final String MAVEN_WRAPPER_JAR_PATH = 48 | ".mvn/wrapper/maven-wrapper.jar"; 49 | 50 | /** 51 | * Name of the property which should be used to override the default download url for the wrapper. 52 | */ 53 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 54 | 55 | public static void main(String args[]) { 56 | System.out.println("- Downloader started"); 57 | File baseDirectory = new File(args[0]); 58 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 59 | 60 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 61 | // wrapperUrl parameter. 62 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 63 | String url = DEFAULT_DOWNLOAD_URL; 64 | if(mavenWrapperPropertyFile.exists()) { 65 | FileInputStream mavenWrapperPropertyFileInputStream = null; 66 | try { 67 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 68 | Properties mavenWrapperProperties = new Properties(); 69 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 70 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 71 | } catch (IOException e) { 72 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 73 | } finally { 74 | try { 75 | if(mavenWrapperPropertyFileInputStream != null) { 76 | mavenWrapperPropertyFileInputStream.close(); 77 | } 78 | } catch (IOException e) { 79 | // Ignore ... 80 | } 81 | } 82 | } 83 | System.out.println("- Downloading from: : " + url); 84 | 85 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 86 | if(!outputFile.getParentFile().exists()) { 87 | if(!outputFile.getParentFile().mkdirs()) { 88 | System.out.println( 89 | "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 90 | } 91 | } 92 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 93 | try { 94 | downloadFileFromURL(url, outputFile); 95 | System.out.println("Done"); 96 | System.exit(0); 97 | } catch (Throwable e) { 98 | System.out.println("- Error downloading"); 99 | e.printStackTrace(); 100 | System.exit(1); 101 | } 102 | } 103 | 104 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 105 | URL website = new URL(urlString); 106 | ReadableByteChannel rbc; 107 | rbc = Channels.newChannel(website.openStream()); 108 | FileOutputStream fos = new FileOutputStream(destination); 109 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 110 | fos.close(); 111 | rbc.close(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /eureka-naming-server/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | https://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.net.URL; 25 | import java.nio.channels.Channels; 26 | import java.nio.channels.ReadableByteChannel; 27 | import java.util.Properties; 28 | 29 | public class MavenWrapperDownloader { 30 | 31 | /** 32 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 33 | */ 34 | private static final String DEFAULT_DOWNLOAD_URL = 35 | "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; 36 | 37 | /** 38 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 39 | * use instead of the default one. 40 | */ 41 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 42 | ".mvn/wrapper/maven-wrapper.properties"; 43 | 44 | /** 45 | * Path where the maven-wrapper.jar will be saved to. 46 | */ 47 | private static final String MAVEN_WRAPPER_JAR_PATH = 48 | ".mvn/wrapper/maven-wrapper.jar"; 49 | 50 | /** 51 | * Name of the property which should be used to override the default download url for the wrapper. 52 | */ 53 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 54 | 55 | public static void main(String args[]) { 56 | System.out.println("- Downloader started"); 57 | File baseDirectory = new File(args[0]); 58 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 59 | 60 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 61 | // wrapperUrl parameter. 62 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 63 | String url = DEFAULT_DOWNLOAD_URL; 64 | if(mavenWrapperPropertyFile.exists()) { 65 | FileInputStream mavenWrapperPropertyFileInputStream = null; 66 | try { 67 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 68 | Properties mavenWrapperProperties = new Properties(); 69 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 70 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 71 | } catch (IOException e) { 72 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 73 | } finally { 74 | try { 75 | if(mavenWrapperPropertyFileInputStream != null) { 76 | mavenWrapperPropertyFileInputStream.close(); 77 | } 78 | } catch (IOException e) { 79 | // Ignore ... 80 | } 81 | } 82 | } 83 | System.out.println("- Downloading from: : " + url); 84 | 85 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 86 | if(!outputFile.getParentFile().exists()) { 87 | if(!outputFile.getParentFile().mkdirs()) { 88 | System.out.println( 89 | "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 90 | } 91 | } 92 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 93 | try { 94 | downloadFileFromURL(url, outputFile); 95 | System.out.println("Done"); 96 | System.exit(0); 97 | } catch (Throwable e) { 98 | System.out.println("- Error downloading"); 99 | e.printStackTrace(); 100 | System.exit(1); 101 | } 102 | } 103 | 104 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 105 | URL website = new URL(urlString); 106 | ReadableByteChannel rbc; 107 | rbc = Channels.newChannel(website.openStream()); 108 | FileOutputStream fos = new FileOutputStream(destination); 109 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 110 | fos.close(); 111 | rbc.close(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /available-hotels-service/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | https://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.net.URL; 25 | import java.nio.channels.Channels; 26 | import java.nio.channels.ReadableByteChannel; 27 | import java.util.Properties; 28 | 29 | public class MavenWrapperDownloader { 30 | 31 | /** 32 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 33 | */ 34 | private static final String DEFAULT_DOWNLOAD_URL = 35 | "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; 36 | 37 | /** 38 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 39 | * use instead of the default one. 40 | */ 41 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 42 | ".mvn/wrapper/maven-wrapper.properties"; 43 | 44 | /** 45 | * Path where the maven-wrapper.jar will be saved to. 46 | */ 47 | private static final String MAVEN_WRAPPER_JAR_PATH = 48 | ".mvn/wrapper/maven-wrapper.jar"; 49 | 50 | /** 51 | * Name of the property which should be used to override the default download url for the wrapper. 52 | */ 53 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 54 | 55 | public static void main(String args[]) { 56 | System.out.println("- Downloader started"); 57 | File baseDirectory = new File(args[0]); 58 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 59 | 60 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 61 | // wrapperUrl parameter. 62 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 63 | String url = DEFAULT_DOWNLOAD_URL; 64 | if(mavenWrapperPropertyFile.exists()) { 65 | FileInputStream mavenWrapperPropertyFileInputStream = null; 66 | try { 67 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 68 | Properties mavenWrapperProperties = new Properties(); 69 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 70 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 71 | } catch (IOException e) { 72 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 73 | } finally { 74 | try { 75 | if(mavenWrapperPropertyFileInputStream != null) { 76 | mavenWrapperPropertyFileInputStream.close(); 77 | } 78 | } catch (IOException e) { 79 | // Ignore ... 80 | } 81 | } 82 | } 83 | System.out.println("- Downloading from: : " + url); 84 | 85 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 86 | if(!outputFile.getParentFile().exists()) { 87 | if(!outputFile.getParentFile().mkdirs()) { 88 | System.out.println( 89 | "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 90 | } 91 | } 92 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 93 | try { 94 | downloadFileFromURL(url, outputFile); 95 | System.out.println("Done"); 96 | System.exit(0); 97 | } catch (Throwable e) { 98 | System.out.println("- Error downloading"); 99 | e.printStackTrace(); 100 | System.exit(1); 101 | } 102 | } 103 | 104 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 105 | URL website = new URL(urlString); 106 | ReadableByteChannel rbc; 107 | rbc = Channels.newChannel(website.openStream()); 108 | FileOutputStream fos = new FileOutputStream(destination); 109 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 110 | fos.close(); 111 | rbc.close(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /hotels-aggregator-service/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | https://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.net.URL; 25 | import java.nio.channels.Channels; 26 | import java.nio.channels.ReadableByteChannel; 27 | import java.util.Properties; 28 | 29 | public class MavenWrapperDownloader { 30 | 31 | /** 32 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 33 | */ 34 | private static final String DEFAULT_DOWNLOAD_URL = 35 | "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; 36 | 37 | /** 38 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 39 | * use instead of the default one. 40 | */ 41 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 42 | ".mvn/wrapper/maven-wrapper.properties"; 43 | 44 | /** 45 | * Path where the maven-wrapper.jar will be saved to. 46 | */ 47 | private static final String MAVEN_WRAPPER_JAR_PATH = 48 | ".mvn/wrapper/maven-wrapper.jar"; 49 | 50 | /** 51 | * Name of the property which should be used to override the default download url for the wrapper. 52 | */ 53 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 54 | 55 | public static void main(String args[]) { 56 | System.out.println("- Downloader started"); 57 | File baseDirectory = new File(args[0]); 58 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 59 | 60 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 61 | // wrapperUrl parameter. 62 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 63 | String url = DEFAULT_DOWNLOAD_URL; 64 | if(mavenWrapperPropertyFile.exists()) { 65 | FileInputStream mavenWrapperPropertyFileInputStream = null; 66 | try { 67 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 68 | Properties mavenWrapperProperties = new Properties(); 69 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 70 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 71 | } catch (IOException e) { 72 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 73 | } finally { 74 | try { 75 | if(mavenWrapperPropertyFileInputStream != null) { 76 | mavenWrapperPropertyFileInputStream.close(); 77 | } 78 | } catch (IOException e) { 79 | // Ignore ... 80 | } 81 | } 82 | } 83 | System.out.println("- Downloading from: : " + url); 84 | 85 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 86 | if(!outputFile.getParentFile().exists()) { 87 | if(!outputFile.getParentFile().mkdirs()) { 88 | System.out.println( 89 | "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 90 | } 91 | } 92 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 93 | try { 94 | downloadFileFromURL(url, outputFile); 95 | System.out.println("Done"); 96 | System.exit(0); 97 | } catch (Throwable e) { 98 | System.out.println("- Error downloading"); 99 | e.printStackTrace(); 100 | System.exit(1); 101 | } 102 | } 103 | 104 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 105 | URL website = new URL(urlString); 106 | ReadableByteChannel rbc; 107 | rbc = Channels.newChannel(website.openStream()); 108 | FileOutputStream fos = new FileOutputStream(destination); 109 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 110 | fos.close(); 111 | rbc.close(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /hotels-aggregator-service/src/main/java/com/maf/aggregator/service/Imp/HoterServiceProvidersIntegrationImpl.java: -------------------------------------------------------------------------------- 1 | package com.maf.aggregator.service.Imp; 2 | 3 | import java.time.Instant; 4 | import java.time.LocalDate; 5 | import java.time.ZoneOffset; 6 | import java.util.ArrayList; 7 | import java.util.Collection; 8 | import java.util.List; 9 | import java.util.stream.Collectors; 10 | import java.util.stream.Stream; 11 | 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | 15 | import com.maf.aggregator.client.BestHotelsClient; 16 | import com.maf.aggregator.client.CrazyHotelClient; 17 | import com.maf.aggregator.constant.IATACode; 18 | import com.maf.aggregator.mapper.BestHotelToCustomHotelMapper; 19 | import com.maf.aggregator.mapper.CrazyHotelToCustomHotelMapper; 20 | import com.maf.aggregator.response.BestHotelResponse; 21 | import com.maf.aggregator.response.CrazyHotelResponse; 22 | import com.maf.aggregator.response.HotelCustomResponse; 23 | import com.maf.aggregator.service.HotelServiceProvidersIntegration; 24 | 25 | @Service 26 | public class HoterServiceProvidersIntegrationImpl implements HotelServiceProvidersIntegration { 27 | 28 | @Autowired 29 | private BestHotelsClient bestHotelClient; 30 | 31 | @Autowired 32 | private CrazyHotelClient crazyHotelClient; 33 | 34 | /** 35 | * @author Ala'a Mezian 36 | * @param fromDate :Date 37 | * @param to :Date 38 | * @param city :IATACode 39 | * @param numberOfAdults :Integer 40 | * @return this function return a list of hotels from all providers ,if a new 41 | * provider is added this function is the only one that should be 42 | * changed 43 | */ 44 | @Override 45 | public List retriveHotelsFromProviders(LocalDate fromDate, LocalDate to, IATACode city, 46 | Integer numberOfAdults) { 47 | Collection hotelsFromBestHotelProvider = callBestHotelProvider(fromDate, to, city, 48 | numberOfAdults); 49 | 50 | Collection hotelsFromCrazyHotelProvider = callCrazyHotelProvider(fromDate, to, city, 51 | numberOfAdults); 52 | 53 | ArrayList availableHtoels = Stream 54 | .of(hotelsFromBestHotelProvider, hotelsFromCrazyHotelProvider).flatMap(x -> x.stream()) 55 | .sorted((h1, h2)->h2.getRate().compareTo(h1.getRate())) 56 | .collect(Collectors.toCollection(ArrayList::new)); 57 | return availableHtoels; 58 | } 59 | 60 | public Collection callCrazyHotelProvider(LocalDate fromDate, LocalDate to, IATACode city, 61 | Integer adultsCount) { 62 | Instant from = fromDate.atStartOfDay().toInstant(ZoneOffset.UTC); 63 | Instant toDate = to.atStartOfDay().toInstant(ZoneOffset.UTC); 64 | Collection crazyHotelsResponses = crazyHotelClient.retriveCrazyHotels(from, toDate, city, 65 | adultsCount); 66 | 67 | return convertCrazyHotelsToHotelCustomResponse(crazyHotelsResponses); 68 | } 69 | 70 | /** 71 | * @author Ala'a Mezian 72 | * @param crazyHotelResponses :represent the collection received from the crazy 73 | * hotel provider 74 | * @return hotelCustomResponses : represent a collection of hotels converted 75 | * into another JSON Format(available hotel format) 76 | */ 77 | private Collection convertCrazyHotelsToHotelCustomResponse( 78 | Collection crazyHotelResponses) { 79 | Collection hotelCustomResponses = new ArrayList(crazyHotelResponses.size()); 80 | for (CrazyHotelResponse crazyHotel : crazyHotelResponses) { 81 | hotelCustomResponses.add(CrazyHotelToCustomHotelMapper.map(crazyHotel)); 82 | } 83 | return hotelCustomResponses; 84 | } 85 | 86 | /** 87 | * @author Ala'a Mezian 88 | * @param from:Local_ISO_FORMAT 89 | * @param to:Local_ISO_FORMAT 90 | * @param city:IATACode 91 | * @param numberOfAdults:Integer 92 | * @return hotelCustomResponses : represent a collection of hotels converted 93 | * into another JSON Format 94 | */ 95 | public Collection callBestHotelProvider(LocalDate fromDate, LocalDate to, IATACode city, 96 | Integer numberOfAdults) { 97 | Collection bestHotelResponses = bestHotelClient.retriveBestHotels(fromDate, to, city, 98 | numberOfAdults); 99 | 100 | return convertBestHotelToHotelCustomResponse(bestHotelResponses); 101 | } 102 | 103 | /** 104 | * @author Ala'a Mezian 105 | * @param bestHotelResponses :represent the collection received from the best 106 | * hotel provider 107 | * @return hotelCustomResponses : represent a collection of hotels converted 108 | * into another JSON Format(hotel custom response) 109 | */ 110 | private Collection convertBestHotelToHotelCustomResponse( 111 | Collection bestHotelsResposes) { 112 | Collection hotelCustomResponses = new ArrayList(bestHotelsResposes.size()); 113 | for (BestHotelResponse bestHotel : bestHotelsResposes) { 114 | hotelCustomResponses.add(BestHotelToCustomHotelMapper.map(bestHotel)); 115 | } 116 | return hotelCustomResponses; 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /best-hotels-service/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /crazy-hotels-service/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /eureka-naming-server/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /available-hotels-service/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /hotels-aggregator-service/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /best-hotels-service/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /crazy-hotels-service/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /eureka-naming-server/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /available-hotels-service/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /hotels-aggregator-service/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | --------------------------------------------------------------------------------