├── .mvn └── wrapper │ ├── maven-wrapper.jar │ ├── maven-wrapper.properties │ └── MavenWrapperDownloader.java ├── src ├── main │ ├── resources │ │ └── application.properties │ └── java │ │ └── com │ │ └── vic │ │ └── io │ │ └── covidvaccination │ │ ├── Btly │ │ ├── ShortenResponse.java │ │ ├── ShortenRequest.java │ │ └── BitlyHelper.java │ │ ├── Model │ │ ├── VaccineFee.java │ │ ├── Response.java │ │ ├── SessionList.java │ │ ├── Centers.java │ │ └── User.java │ │ ├── Repository │ │ └── userRepo.java │ │ ├── Notification │ │ ├── TwilioConfig.java │ │ ├── twilioInit.java │ │ └── Notify.java │ │ ├── CovidvaccinationApplication.java │ │ ├── Filter │ │ └── CustomCorsFilter.java │ │ ├── ErrorHandler │ │ └── RestTemplateResponseErrorHandler.java │ │ ├── Controllers │ │ └── userController.java │ │ └── Service │ │ ├── UserService.java │ │ ├── getData.java │ │ ├── CenterCheck.java │ │ ├── Scheduler.java │ │ └── GetAvailability.java └── test │ └── java │ └── com │ └── vic │ └── io │ └── covidvaccination │ └── CovidvaccinationApplicationTest.java ├── .gitignore ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ ├── master_potato1.yml │ └── codeql-analysis.yml ├── README.md ├── LICENSE ├── pom.xml ├── mvnw.cmd ├── mvnw └── checkstyle.xml /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vic7z/CovidVaccineNotifier/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | azure.keyvault.client-id=${client} 2 | azure.keyvault.client-key=${key} 3 | azure.keyvault.tenant-id=${tenant} 4 | azure.keyvault.uri=${keyvault} 5 | azure.keyvault.enabled=true -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Btly/ShortenResponse.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Btly; 2 | 3 | class ShortenResponse { 4 | 5 | private String link; 6 | 7 | public String getLink() { 8 | return link; 9 | } 10 | 11 | public void setLink(String link) { 12 | this.link = link; 13 | } 14 | } -------------------------------------------------------------------------------- /src/test/java/com/vic/io/covidvaccination/CovidvaccinationApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class CovidvaccinationApplicationTest { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | } -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Model/VaccineFee.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | import lombok.ToString; 8 | 9 | @Getter 10 | @Setter 11 | @NoArgsConstructor 12 | @ToString 13 | @JsonIgnoreProperties(ignoreUnknown = true) 14 | public class VaccineFee { 15 | 16 | private String vaccine; 17 | private String fee; 18 | } 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Model/Response.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import java.util.List; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | 10 | 11 | @Getter 12 | @Setter 13 | @NoArgsConstructor 14 | @JsonIgnoreProperties(ignoreUnknown = true) 15 | public class Response { 16 | 17 | @JsonProperty("centers") 18 | List centers; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Repository/userRepo.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Repository; 2 | 3 | import com.vic.io.covidvaccination.Model.User; 4 | import java.util.Optional; 5 | import org.springframework.data.mongodb.repository.MongoRepository; 6 | import org.springframework.data.mongodb.repository.Query; 7 | import org.springframework.stereotype.Repository; 8 | 9 | @Repository 10 | public interface userRepo extends MongoRepository { 11 | 12 | @Query("{ 'phoneNo' : ?0 }") 13 | Optional findByPhoneNo(String phoneNo); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Btly/ShortenRequest.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Btly; 2 | 3 | class ShortenRequest { 4 | 5 | private String domain = "bit.ly"; 6 | private String long_url; 7 | 8 | public ShortenRequest(String long_url) { 9 | this.long_url = long_url; 10 | } 11 | 12 | public String getDomain() { 13 | return domain; 14 | } 15 | 16 | public void setDomain(String domain) { 17 | this.domain = domain; 18 | } 19 | 20 | public String getLong_url() { 21 | return long_url; 22 | } 23 | 24 | public void setLong_url(String long_url) { 25 | this.long_url = long_url; 26 | } 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Notification/TwilioConfig.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Notification; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | @Configuration 11 | @ConfigurationProperties(prefix = "twilio") 12 | @Getter 13 | @Setter 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class TwilioConfig { 17 | 18 | private String myNumber; 19 | private String AuthToken; 20 | private String AccountSid; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Notification/twilioInit.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Notification; 2 | 3 | import com.twilio.Twilio; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | @Configuration 10 | public class twilioInit { 11 | 12 | private static final Logger logger = LoggerFactory.getLogger(twilioInit.class); 13 | 14 | 15 | @Autowired 16 | public twilioInit(TwilioConfig configuration) { 17 | Twilio.init( 18 | configuration.getAccountSid(), 19 | configuration.getAuthToken() 20 | ); 21 | logger.info("Twilio init"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Model/SessionList.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | import lombok.ToString; 10 | 11 | @Getter 12 | @Setter 13 | @NoArgsConstructor 14 | @ToString 15 | @JsonIgnoreProperties(ignoreUnknown = true) 16 | public class SessionList { 17 | 18 | private String session_id; 19 | private String date; 20 | private int available_capacity; 21 | private int min_age_limit; 22 | private String vaccine; 23 | private List slots = new ArrayList<>(); 24 | private int available_capacity_dose1; 25 | private int available_capacity_dose2; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/CovidvaccinationApplication.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.web.client.RestTemplateBuilder; 7 | import org.springframework.cache.annotation.EnableCaching; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.scheduling.annotation.EnableScheduling; 10 | 11 | 12 | @SpringBootApplication 13 | 14 | @EnableScheduling 15 | //@EnableCaching 16 | public class CovidvaccinationApplication { 17 | 18 | @Bean 19 | public RestTemplateBuilder getRestTemplateBuilder() { 20 | return new RestTemplateBuilder(); 21 | } 22 | 23 | 24 | public static void main(String[] args) { 25 | SpringApplication.run(CovidvaccinationApplication.class, args); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Model/Centers.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.Setter; 10 | import lombok.ToString; 11 | 12 | @Getter 13 | @Setter 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @ToString 17 | @JsonIgnoreProperties(ignoreUnknown = true) 18 | public class Centers { 19 | 20 | private int center_id; 21 | private String name; 22 | private String address; 23 | private String block_name; 24 | private int pincode; 25 | private String from; 26 | private String to; 27 | private String fee_type; 28 | private List sessions = new ArrayList<>(); 29 | private List vaccine_fees = new ArrayList<>(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About 2 | [![CodeQL](https://github.com/vic7z/CovidVaccineNotifier/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/vic7z/CovidVaccineNotifier/actions/workflows/codeql-analysis.yml) 3 | 4 | 5 | 6 | A simple spring boot application that can track vaccine availability and automatically sends a SMS alert with the avilable centers 7 | 8 | Features 9 | * Dose type selection 10 | * age group selection 11 | * Vaccine type selection 12 | * Paid/Free selection 13 | 14 | You can register [here](https://notifier1.azurewebsites.net/) 15 | 16 | **Comply with checkstyle** 17 | 18 | This repository follows the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). 19 | Feel free to download formatting presets for your IDE from Google's GitHub repository. 20 | We have set up [checkstyle](https://github.com/vic7z/CovidVaccineNotifier/blob/master/checkstyle.xml) 21 | to enforce them throughout this project. 22 | You can check locally if your changes comply with these guidelines by executing the maven goal `compile`. 23 | 24 | Project no longer maintained 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Model/User.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | import org.springframework.data.annotation.Id; 10 | import org.springframework.data.mongodb.core.mapping.Document; 11 | 12 | 13 | @Getter 14 | @Setter 15 | @ToString 16 | @NoArgsConstructor 17 | @Document(collection = "UserDetails") 18 | public class User { 19 | 20 | @Id 21 | private String id; 22 | private String userName; 23 | private String phoneNo; 24 | private String district_id; 25 | private String Fee; 26 | private int age; 27 | private int dosageType; 28 | private String vaccine; 29 | private int Pincode; 30 | private List AvailableCenters; 31 | private boolean enable; 32 | private String from; 33 | private String to; 34 | 35 | public User(String userName, String phoneNo, String district_id, String fee, int age, 36 | int dosageType, String vaccine, int pincode) { 37 | this.userName = userName; 38 | this.phoneNo = phoneNo; 39 | this.district_id = district_id; 40 | this.Fee = fee; 41 | this.age = age; 42 | this.dosageType = dosageType; 43 | this.vaccine = vaccine; 44 | this.Pincode = pincode; 45 | this.AvailableCenters = new ArrayList<>(); 46 | this.enable = true; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Filter/CustomCorsFilter.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Filter; 2 | 3 | 4 | import java.io.IOException; 5 | import javax.servlet.FilterChain; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | import lombok.extern.log4j.Log4j2; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.web.cors.CorsConfigurationSource; 12 | import org.springframework.web.filter.CorsFilter; 13 | 14 | @Configuration 15 | @Log4j2 16 | public class CustomCorsFilter extends CorsFilter { 17 | 18 | public CustomCorsFilter(CorsConfigurationSource configSource) { 19 | super(configSource); 20 | log.info("CORSFilter init"); 21 | } 22 | 23 | @Override 24 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, 25 | FilterChain filterChain) 26 | throws ServletException, IOException { 27 | 28 | response.addHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); 29 | response.addHeader("Access-Control-Allow-Credentials", "true"); 30 | response.addHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); 31 | response.addHeader("Access-Control-Max-Age", "3600"); 32 | response.addHeader("Access-Control-Allow-Headers", 33 | "Content-Type, Accept, X-Requested-With, remember-me,observe"); 34 | 35 | filterChain.doFilter(request, response); 36 | } 37 | 38 | @Override 39 | public void destroy() { 40 | } 41 | 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/ErrorHandler/RestTemplateResponseErrorHandler.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.ErrorHandler; 2 | 3 | import static org.springframework.http.HttpStatus.Series.CLIENT_ERROR; 4 | import static org.springframework.http.HttpStatus.Series.SERVER_ERROR; 5 | 6 | import java.io.IOException; 7 | import lombok.extern.log4j.Log4j2; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.client.ClientHttpResponse; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.web.client.ResponseErrorHandler; 12 | import org.springframework.web.server.ResponseStatusException; 13 | 14 | 15 | @Component 16 | @Log4j2 17 | public class RestTemplateResponseErrorHandler 18 | implements ResponseErrorHandler { 19 | 20 | @Override 21 | public boolean hasError(ClientHttpResponse httpResponse) 22 | throws IOException { 23 | 24 | return ( 25 | httpResponse.getStatusCode().series() == CLIENT_ERROR 26 | || httpResponse.getStatusCode().series() == SERVER_ERROR); 27 | } 28 | 29 | @Override 30 | public void handleError(ClientHttpResponse httpResponse) 31 | throws IOException { 32 | 33 | if (httpResponse.getStatusCode().series() == SERVER_ERROR) { 34 | log.info("server error"); 35 | } else if (httpResponse.getStatusCode().series() == CLIENT_ERROR) { 36 | log.info("client error"); 37 | if (httpResponse.getStatusCode() == HttpStatus.NOT_FOUND) { 38 | throw new ResponseStatusException( 39 | HttpStatus.NOT_FOUND, "entity not found" 40 | ); 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /.github/workflows/master_potato1.yml: -------------------------------------------------------------------------------- 1 | # Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy 2 | # More GitHub Actions for Azure: https://github.com/Azure/actions 3 | 4 | name: Build and deploy JAR app to Azure Web App - potato1 5 | 6 | on: 7 | push: 8 | branches: 9 | - master 10 | workflow_dispatch: 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | 19 | - name: Set up Java version 20 | uses: actions/setup-java@v1 21 | with: 22 | java-version: '11' 23 | 24 | - name: Build with Maven 25 | run: mvn clean install 26 | env: 27 | client: ${{secrets.CLIENT}} 28 | key: ${{secrets.KEY}} 29 | Keyvault: ${{secrets.KEYVAULT}} 30 | tenant: ${{secrets.TENANT}} 31 | 32 | - name: Upload artifact for deployment job 33 | uses: actions/upload-artifact@v2 34 | with: 35 | name: java-app 36 | path: '${{ github.workspace }}/target/*.jar' 37 | 38 | deploy: 39 | runs-on: ubuntu-latest 40 | needs: build 41 | environment: 42 | name: 'production' 43 | url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} 44 | 45 | steps: 46 | - name: Download artifact from build job 47 | uses: actions/download-artifact@v2 48 | with: 49 | name: java-app 50 | 51 | - name: Deploy to Azure Web App 52 | id: deploy-to-webapp 53 | uses: azure/webapps-deploy@v2 54 | with: 55 | app-name: 'potato1' 56 | slot-name: 'production' 57 | publish-profile: ${{ secrets.AzureAppService_PublishProfile_e38790d7b27b4ed8b70ccb9564a8a83f }} 58 | package: '*.jar' 59 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Controllers/userController.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Controllers; 2 | 3 | 4 | import com.vic.io.covidvaccination.Model.Centers; 5 | import com.vic.io.covidvaccination.Model.User; 6 | import com.vic.io.covidvaccination.Service.UserService; 7 | import java.util.List; 8 | import lombok.extern.log4j.Log4j2; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.data.repository.query.Param; 11 | import org.springframework.http.MediaType; 12 | import org.springframework.http.ResponseEntity; 13 | import org.springframework.web.bind.annotation.DeleteMapping; 14 | import org.springframework.web.bind.annotation.GetMapping; 15 | import org.springframework.web.bind.annotation.PostMapping; 16 | import org.springframework.web.bind.annotation.RequestBody; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | @Log4j2 21 | @RestController 22 | @RequestMapping("/user") 23 | public class userController { 24 | 25 | private final UserService userService; 26 | 27 | 28 | @Autowired 29 | public userController(UserService userService) { 30 | this.userService = userService; 31 | } 32 | 33 | @PostMapping("/add") 34 | public ResponseEntity addUser(@RequestBody User user) { 35 | return userService.setUser(user); 36 | } 37 | 38 | @GetMapping(value = "/get-center", produces = MediaType.APPLICATION_JSON_VALUE) 39 | public ResponseEntity> getCenters(@Param(value = "id") String id) { 40 | return this.userService.getCenter(id); 41 | } 42 | 43 | @DeleteMapping("/delete") 44 | public ResponseEntity deleteUser(@Param(value = "id") String id) { 45 | return this.userService.deleteByID(id); 46 | 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Btly/BitlyHelper.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Btly; 2 | 3 | 4 | import com.vic.io.covidvaccination.ErrorHandler.RestTemplateResponseErrorHandler; 5 | import java.util.Collections; 6 | import java.util.Objects; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.boot.web.client.RestTemplateBuilder; 10 | import org.springframework.http.HttpEntity; 11 | import org.springframework.http.HttpHeaders; 12 | import org.springframework.http.HttpMethod; 13 | import org.springframework.http.MediaType; 14 | import org.springframework.http.ResponseEntity; 15 | import org.springframework.stereotype.Service; 16 | import org.springframework.web.client.RestTemplate; 17 | 18 | @Service 19 | public class BitlyHelper { 20 | 21 | private final RestTemplate restTemplate; 22 | 23 | @Value("${btly}") 24 | private String bitlyToken; 25 | 26 | private static final String endpoint = "https://api-ssl.bitly.com/v4/shorten"; 27 | 28 | @Autowired 29 | public BitlyHelper(RestTemplateBuilder restTemplateBuilder) { 30 | this.restTemplate = restTemplateBuilder 31 | .errorHandler(new RestTemplateResponseErrorHandler()) 32 | .build(); 33 | } 34 | 35 | public String shorten(String longUrl) { 36 | HttpHeaders headers = new HttpHeaders(); 37 | headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); 38 | headers.setContentType(MediaType.APPLICATION_JSON); 39 | headers.add("Authorization", String.format("Bearer %s", bitlyToken)); 40 | 41 | ShortenRequest request = new ShortenRequest(longUrl); 42 | HttpEntity entity = new HttpEntity<>(request, headers); 43 | 44 | ResponseEntity bitlyResponse = restTemplate 45 | .exchange(endpoint, HttpMethod.POST, entity, ShortenResponse.class); 46 | return Objects.requireNonNull(bitlyResponse.getBody()).getLink(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Service; 2 | 3 | 4 | import com.vic.io.covidvaccination.Model.Centers; 5 | import com.vic.io.covidvaccination.Model.User; 6 | import com.vic.io.covidvaccination.Notification.Notify; 7 | import com.vic.io.covidvaccination.Repository.userRepo; 8 | import java.util.List; 9 | import java.util.Optional; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.http.HttpStatus; 12 | import org.springframework.http.ResponseEntity; 13 | import org.springframework.stereotype.Service; 14 | 15 | @Service 16 | public class UserService { 17 | 18 | private final userRepo userRepo; 19 | private final CenterCheck centerCheck; 20 | private final Notify notify; 21 | 22 | 23 | @Autowired 24 | public UserService(userRepo userRepo, CenterCheck centerCheck, Notify notify) { 25 | this.userRepo = userRepo; 26 | this.centerCheck = centerCheck; 27 | this.notify = notify; 28 | } 29 | 30 | public ResponseEntity setUser(User newUser) { 31 | Optional user = userRepo.findByPhoneNo(newUser.getPhoneNo()); 32 | 33 | if (user.isPresent()) { 34 | User user1 = centerCheck.setData(newUser); 35 | userRepo.save(user1); 36 | notify.sendSms(user1); 37 | 38 | return ResponseEntity.ok(newUser); 39 | } else { 40 | return ResponseEntity.status(HttpStatus.BAD_REQUEST).build(); 41 | } 42 | 43 | } 44 | 45 | public ResponseEntity> getCenter(String id) { 46 | Optional user = userRepo.findById(id); 47 | return user.map(value -> ResponseEntity.ok(value.getAvailableCenters())) 48 | .orElseGet(() -> ResponseEntity.status(HttpStatus.BAD_REQUEST).build()); 49 | 50 | } 51 | 52 | // public ResponseEntity deleteByPhone(String s) { 53 | // User user=userRepo.findByPhoneNo(s).orElse(null); 54 | // if (user!=null) { 55 | // userRepo.delete(user); 56 | // return ResponseEntity.ok().build(); 57 | // }else { 58 | // return ResponseEntity.status(HttpStatus.BAD_REQUEST).build(); 59 | // } 60 | // } 61 | public ResponseEntity deleteByID(String id) { 62 | if (userRepo.findById(id).isPresent()) { 63 | userRepo.deleteById(id); 64 | return ResponseEntity.ok().build(); 65 | } else { 66 | return ResponseEntity.status(HttpStatus.BAD_REQUEST).build(); 67 | } 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '26 2 * * 2' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'java' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 37 | # Learn more: 38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 39 | 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v2 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v1 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v1 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v1 72 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Service/getData.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Service; 2 | 3 | 4 | import com.vic.io.covidvaccination.ErrorHandler.RestTemplateResponseErrorHandler; 5 | import com.vic.io.covidvaccination.Model.Centers; 6 | import com.vic.io.covidvaccination.Model.Response; 7 | import com.vic.io.covidvaccination.Model.SessionList; 8 | import java.time.ZoneId; 9 | import java.time.ZonedDateTime; 10 | import java.time.format.DateTimeFormatter; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import java.util.stream.Collectors; 14 | import lombok.extern.log4j.Log4j2; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.boot.web.client.RestTemplateBuilder; 17 | import org.springframework.stereotype.Service; 18 | import org.springframework.web.client.RestTemplate; 19 | import org.springframework.web.util.UriComponentsBuilder; 20 | 21 | @Service 22 | @Log4j2 23 | public class getData { 24 | 25 | private final RestTemplate restTemplate; 26 | 27 | 28 | DateTimeFormatter dataFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); 29 | 30 | 31 | @Autowired 32 | public getData(RestTemplateBuilder restTemplateBuilder) { 33 | this.restTemplate = restTemplateBuilder 34 | .errorHandler(new RestTemplateResponseErrorHandler()) 35 | .build(); 36 | } 37 | 38 | // FIXME: 17/06/21 Null Pointer Exception 39 | 40 | // @Cacheable("centers") 41 | public List getDetails(String district_id) { 42 | 43 | ZonedDateTime date = ZonedDateTime.now(ZoneId.of("Asia/Kolkata")); 44 | String getByDistrict = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict"; 45 | UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(getByDistrict) 46 | .queryParam("district_id", district_id) 47 | .queryParam("date", date.format(dataFormatter)); 48 | return restTemplate.getForObject(builder.toUriString(), Response.class).getCenters(); 49 | } 50 | 51 | //check for available centers 52 | 53 | public List getAvailability(String district_id) { 54 | List centers = getDetails(district_id); 55 | List centersList1 = new ArrayList<>(); 56 | if (centers != null) { 57 | for (Centers centers1 : centers) { 58 | List sessionLists = centers1.getSessions(); 59 | List collect = sessionLists.stream() 60 | .filter(sessionList -> sessionList.getAvailable_capacity() >= 1) 61 | .collect(Collectors.toList()); 62 | 63 | if (!collect.isEmpty()) { 64 | centers1.setSessions(collect); 65 | centersList1.add(centers1); 66 | } 67 | } 68 | 69 | } 70 | return centersList1; 71 | } 72 | 73 | 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Service/CenterCheck.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Service; 2 | 3 | 4 | // TODO: 18/06/21 fix issues 5 | // TODO: 23/06/21 lot of clean up 6 | // TODO: 26/06/21 cache the repo 7 | 8 | import com.vic.io.covidvaccination.Model.Centers; 9 | import com.vic.io.covidvaccination.Model.SessionList; 10 | import com.vic.io.covidvaccination.Model.User; 11 | import java.time.ZoneId; 12 | import java.time.ZonedDateTime; 13 | import java.time.format.DateTimeFormatter; 14 | import java.util.ArrayList; 15 | import java.util.Comparator; 16 | import java.util.List; 17 | import java.util.stream.Collectors; 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.stereotype.Service; 22 | 23 | @Service 24 | public class CenterCheck { 25 | 26 | private final GetAvailability getAvailability; 27 | 28 | DateTimeFormatter dataFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); 29 | 30 | private static final Logger log = LoggerFactory.getLogger(CenterCheck.class); 31 | 32 | @Autowired 33 | public CenterCheck(GetAvailability getAvailability) { 34 | this.getAvailability = getAvailability; 35 | } 36 | 37 | 38 | public List setDate(User user) { 39 | List dates = new ArrayList<>(); 40 | for (Centers centers1 : user.getAvailableCenters()) { 41 | for (SessionList sessionList : centers1.getSessions()) { 42 | dates.add(sessionList.getDate()); 43 | } 44 | } 45 | System.out.println( 46 | dates.stream().distinct().sorted(Comparator.reverseOrder()).collect(Collectors.toList())); 47 | return (dates.stream().distinct().sorted(Comparator.reverseOrder()) 48 | .collect(Collectors.toList())); 49 | 50 | } 51 | 52 | public List extractName(List centers) { 53 | List centreNames = new ArrayList<>(); 54 | for (Centers centers1 : centers) { 55 | centreNames.add(centers1.getName()); 56 | } 57 | return centreNames; 58 | } 59 | 60 | public User setData(User user) { 61 | log.info(user.getUserName()); 62 | 63 | if (!this.getAvailability.getCenters(user).isEmpty()) { 64 | user.setAvailableCenters(this.getAvailability.getCenters(user)); 65 | List date = setDate(user); 66 | 67 | user.setFrom(date.get(date.size() - 1)); 68 | user.setTo(date.get(0)); 69 | user.setEnable(true); 70 | } else { 71 | ZonedDateTime date = ZonedDateTime.now(ZoneId.of("Asia/Kolkata")); 72 | log.info(user.getUserName() + " has no available centers"); 73 | user.setAvailableCenters(new ArrayList<>()); 74 | user.setFrom(date.format(dataFormatter)); 75 | user.setTo(date.format(dataFormatter)); 76 | } 77 | return user; 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Service/Scheduler.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Service; 2 | 3 | 4 | import com.vic.io.covidvaccination.Model.User; 5 | import com.vic.io.covidvaccination.Notification.Notify; 6 | import com.vic.io.covidvaccination.Repository.userRepo; 7 | import java.time.LocalDate; 8 | import java.time.ZoneId; 9 | import java.time.ZonedDateTime; 10 | import java.time.format.DateTimeFormatter; 11 | import java.util.List; 12 | import lombok.extern.log4j.Log4j2; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.scheduling.annotation.Scheduled; 15 | import org.springframework.stereotype.Service; 16 | 17 | @Log4j2 18 | @Service 19 | public class Scheduler { 20 | 21 | private final GetAvailability getData; 22 | private final userRepo userRepo; 23 | private final CenterCheck centerCheck; 24 | private final Notify notify; 25 | 26 | DateTimeFormatter dataFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); 27 | 28 | @Autowired 29 | public Scheduler(GetAvailability getData, userRepo userRepo, CenterCheck centerCheck, 30 | Notify notify) { 31 | this.getData = getData; 32 | this.userRepo = userRepo; 33 | this.centerCheck = centerCheck; 34 | this.notify = notify; 35 | } 36 | 37 | 38 | @Scheduled(cron = "0 0/5 * * * ?") 39 | // @Scheduled(fixedRate = 5000) 40 | public void check() { 41 | ZonedDateTime date = ZonedDateTime.now(ZoneId.of("Asia/Kolkata")); 42 | log.info(date.format(dataFormatter)); 43 | List userList = userRepo.findAll(); 44 | for (User user : userList) { 45 | 46 | if (user.getAvailableCenters().isEmpty()) { 47 | 48 | if (this.getData.getCenters(user).isEmpty()) { 49 | log.info(user.getUserName() + ": center empty"); 50 | user.setEnable(false); 51 | } else { 52 | user.setAvailableCenters(this.getData.getCenters(user)); 53 | log.info(user.getUserName() + ": updated center "); 54 | snd(user); 55 | 56 | } 57 | // userRepo.save(user); 58 | 59 | } else { 60 | if (user.isEnable() && LocalDate.parse(user.getTo(), dataFormatter) 61 | .isBefore(date.toLocalDate()) && !getData.getCenters(user).isEmpty()) { 62 | snd(user); 63 | } else if (!this.centerCheck.extractName(user.getAvailableCenters()) 64 | .equals(this.centerCheck.extractName(getData.getCenters(user))) && !getData 65 | .getCenters(user).isEmpty()) { 66 | user.setAvailableCenters(this.getData.getCenters(user)); 67 | userRepo.save(user); 68 | } 69 | } 70 | 71 | } 72 | } 73 | 74 | private void snd(User user) { 75 | log.info(user.getUserName() + " sending msg"); 76 | user.setAvailableCenters(this.getData.getCenters(user)); 77 | List date = this.centerCheck.setDate(user); 78 | user.setFrom(date.get(date.size() - 1)); 79 | user.setTo(date.get(0)); 80 | user.setEnable(true); 81 | userRepo.save(user); 82 | this.notify.sendSms(user); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Notification/Notify.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Notification; 2 | 3 | import com.twilio.exception.ApiException; 4 | import com.twilio.rest.api.v2010.account.Message; 5 | import com.twilio.type.PhoneNumber; 6 | import com.vic.io.covidvaccination.Btly.BitlyHelper; 7 | import com.vic.io.covidvaccination.Model.SessionList; 8 | import com.vic.io.covidvaccination.Model.User; 9 | import com.vic.io.covidvaccination.Repository.userRepo; 10 | import lombok.extern.log4j.Log4j2; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | import org.springframework.web.util.UriComponentsBuilder; 14 | 15 | // FIXME: 17/06/21 list null value check 16 | // TODO: 18/06/21 implement twilio api 17 | 18 | @Service 19 | @Log4j2 20 | public class Notify { 21 | 22 | private final TwilioConfig twilioConfig; 23 | private final userRepo userRepo; 24 | private final BitlyHelper btly; 25 | 26 | @Autowired 27 | public Notify(TwilioConfig twilioConfig, com.vic.io.covidvaccination.Repository.userRepo userRepo, 28 | BitlyHelper btly) { 29 | this.twilioConfig = twilioConfig; 30 | this.userRepo = userRepo; 31 | this.btly = btly; 32 | } 33 | 34 | public void sendSms(User user) { 35 | 36 | if (!user.getAvailableCenters().isEmpty()) { 37 | String message = "Hi " + user.getUserName() + ". \r\n" + user.getAvailableCenters().size() 38 | + " vaccination centers available for " + 39 | (user.getDosageType() == 1 ? "1st" : "2nd") + " dose\r\n" + 40 | "more details @ " + this.getUri(user); 41 | user.setEnable(false); 42 | sndMessage(user, message); 43 | log.info(message); 44 | } else { 45 | String message = 46 | "hi " + user.getUserName() + "\n" + "we couldn't find any available centers for you." + 47 | "\nyou will get notified once an available center is found" + 48 | "more details @ " + this.getUri(user); 49 | sndMessage(user, message); 50 | log.info("no centers where found"); 51 | 52 | } 53 | } 54 | 55 | private void sndMessage(User user, String message) { 56 | System.out.println("msg snd"); 57 | try { 58 | Message.creator( 59 | new PhoneNumber(user.getPhoneNo()), 60 | new PhoneNumber(twilioConfig.getMyNumber()), message) 61 | .create(); 62 | 63 | } catch (final ApiException e) { 64 | log.warn(e); 65 | } 66 | } 67 | 68 | // private String centerDetails(User user){ 69 | // return "Name: "+user.getAvailableCenters().get(0).getName() 70 | // +",Address :"+user.getAvailableCenters().get(0).getAddress() 71 | // +" ,Pincode :"+user.getAvailableCenters().get(0).getPincode() 72 | // +" available dosage "+getDosage(user); 73 | // } 74 | 75 | private int getDosage(User user) { 76 | int sum; 77 | if (user.getDosageType() == 1) { 78 | sum = user.getAvailableCenters().get(0).getSessions().stream() 79 | .mapToInt(SessionList::getAvailable_capacity_dose1).sum(); 80 | } else { 81 | sum = user.getAvailableCenters().get(0).getSessions().stream() 82 | .mapToInt(SessionList::getAvailable_capacity_dose2).sum(); 83 | } 84 | return sum; 85 | } 86 | 87 | public String getUri(User user) { 88 | User user1 = user; 89 | if (user.getId() == null) { 90 | user1 = userRepo.findByPhoneNo(user1.getPhoneNo()).get(); 91 | } 92 | 93 | String uri = "https://notifier1.azurewebsites.net/data"; 94 | UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(uri) 95 | .queryParam("id", user1.getId()); 96 | 97 | return btly.shorten(builder.toUriString()); 98 | 99 | 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/vic/io/covidvaccination/Service/GetAvailability.java: -------------------------------------------------------------------------------- 1 | package com.vic.io.covidvaccination.Service; 2 | 3 | 4 | // FIXME: 16/06/21 please send help 5 | 6 | // FIXME: 23/06/21 API already exist for this things :/ 7 | 8 | import com.vic.io.covidvaccination.Model.Centers; 9 | import com.vic.io.covidvaccination.Model.SessionList; 10 | import com.vic.io.covidvaccination.Model.User; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import java.util.stream.Collectors; 14 | import lombok.extern.log4j.Log4j2; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Service; 17 | 18 | @Service 19 | @Log4j2 20 | public class GetAvailability { 21 | 22 | private final getData getData; 23 | 24 | @Autowired 25 | public GetAvailability(getData getData) { 26 | this.getData = getData; 27 | } 28 | 29 | // return the centers based on the given data 30 | // works most of the time ig 31 | 32 | public List getCenters(User user) { 33 | List centers; 34 | List centersList; 35 | List centersList1; 36 | 37 | if (!getData.getAvailability(user.getDistrict_id()).isEmpty()) { 38 | centers = getData.getAvailability(user.getDistrict_id()); 39 | 40 | if (user.getFee().equals("Paid")) { 41 | centersList = centers; 42 | 43 | } else { 44 | centersList = centers.stream() 45 | .parallel() 46 | .filter(centers1 -> centers1.getFee_type().equals("Free")) 47 | .collect(Collectors.toList()); 48 | } 49 | 50 | //log.info(user.getUserName() +" "+centersList); 51 | 52 | if (centersList.isEmpty() && !centers.isEmpty()) { 53 | centersList1 = filterCenter(centers, user); 54 | } else { 55 | centersList1 = filterCenter(centersList, user); 56 | } 57 | 58 | //please dont judge 59 | List centersList2 = centersList1.stream() 60 | .filter(centers1 -> centers1.getPincode() == user.getPincode()) 61 | .collect(Collectors.toList()); 62 | if (centersList2.isEmpty()) { 63 | return centersList1; 64 | } else { 65 | return centersList2; 66 | } 67 | } 68 | return new ArrayList<>(); 69 | 70 | } 71 | 72 | private List filterCenter(List centersList, User user) { 73 | List centersList1 = new ArrayList<>(); 74 | List collect; 75 | for (Centers centers1 : centersList) { 76 | if (!user.getVaccine().equalsIgnoreCase("any")) { 77 | collect = centers1.getSessions() 78 | .stream() 79 | .parallel() 80 | .filter(sessionList -> sessionList.getMin_age_limit() <= user.getAge()) 81 | .filter(sessionList -> sessionList.getVaccine().equalsIgnoreCase(user.getVaccine())) 82 | //.filter(sessionList -> sessionList.getAvailable_capacity_dose2()>=1) 83 | .collect(Collectors.toList()); 84 | } else { 85 | collect = centers1.getSessions() 86 | .stream() 87 | .parallel() 88 | .filter(sessionList -> sessionList.getMin_age_limit() <= user.getAge()) 89 | // .filter(sessionList -> sessionList.getVaccine().equalsIgnoreCase(user.getVaccine())) 90 | .collect(Collectors.toList()); 91 | } 92 | if (user.getDosageType() == 1) { 93 | collect = collect.stream() 94 | .filter(sessionList -> sessionList.getAvailable_capacity_dose1() != 0) 95 | .collect(Collectors.toList()); 96 | } else { 97 | collect = collect.stream() 98 | .filter(sessionList -> sessionList.getAvailable_capacity_dose2() != 0) 99 | .collect(Collectors.toList()); 100 | } 101 | 102 | if (!collect.isEmpty()) { 103 | centers1.setSessions(collect); 104 | centersList1.add(centers1); 105 | } 106 | } 107 | 108 | return centersList1; 109 | 110 | } 111 | } 112 | 113 | -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.4.8-SNAPSHOT 9 | 10 | 11 | com.vic.io 12 | Covidvaccination 13 | 0.0.1-SNAPSHOT 14 | Covidvaccination 15 | Demo project for Spring Boot 16 | 17 | 11 18 | 3.5.0 19 | 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-data-mongodb 26 | 27 | 28 | 29 | com.twilio.sdk 30 | twilio 31 | 8.3.0 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-configuration-processor 42 | 2.1.6.RELEASE 43 | true 44 | 45 | 46 | 47 | com.azure.spring 48 | azure-spring-boot-starter-keyvault-secrets 49 | 50 | 51 | 52 | org.projectlombok 53 | lombok 54 | true 55 | 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-test 60 | test 61 | 62 | 63 | 64 | com.google.guava 65 | guava 66 | 30.1.1-jre 67 | 68 | 69 | org.springframework 70 | spring-context-support 71 | 4.0.0.RELEASE 72 | 73 | 74 | org.springframework.boot 75 | spring-boot-starter-cache 76 | 77 | 78 | 79 | 80 | 81 | com.azure.spring 82 | azure-spring-boot-bom 83 | ${azure.version} 84 | pom 85 | import 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | org.springframework.boot 94 | spring-boot-maven-plugin 95 | 96 | 97 | 98 | org.projectlombok 99 | lombok 100 | 101 | 102 | 103 | 104 | 105 | org.apache.maven.plugins 106 | maven-checkstyle-plugin 107 | 3.1.2 108 | 109 | checkstyle.xml 110 | UTF-8 111 | true 112 | true 113 | false 114 | 115 | 116 | 117 | validate 118 | validate 119 | 120 | check 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | spring-milestones 130 | Spring Milestones 131 | https://repo.spring.io/milestone 132 | 133 | false 134 | 135 | 136 | 137 | spring-snapshots 138 | Spring Snapshots 139 | https://repo.spring.io/snapshot 140 | 141 | false 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | spring-milestones 154 | Spring Milestones 155 | https://repo.spring.io/milestone 156 | 157 | false 158 | 159 | 160 | 161 | spring-snapshots 162 | Spring Snapshots 163 | https://repo.spring.io/snapshot 164 | 165 | false 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /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 Maven 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 keystroke 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 by 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.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /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 | # Maven 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*) 57 | darwin=true 58 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 59 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 60 | if [ -z "$JAVA_HOME" ]; then 61 | if [ -x "/usr/libexec/java_home" ]; then 62 | export JAVA_HOME="$(/usr/libexec/java_home)" 63 | else 64 | export JAVA_HOME="/Library/Java/Home" 65 | fi 66 | fi 67 | ;; 68 | esac 69 | 70 | if [ -z "$JAVA_HOME" ]; then 71 | if [ -r /etc/gentoo-release ]; then 72 | JAVA_HOME=$(java-config --jre-home) 73 | fi 74 | fi 75 | 76 | if [ -z "$M2_HOME" ]; then 77 | ## resolve links - $0 may be a link to maven's home 78 | PRG="$0" 79 | 80 | # need this for relative symlinks 81 | while [ -h "$PRG" ]; do 82 | ls=$(ls -ld "$PRG") 83 | link=$(expr "$ls" : '.*-> \(.*\)$') 84 | if expr "$link" : '/.*' >/dev/null; then 85 | PRG="$link" 86 | else 87 | PRG="$(dirname "$PRG")/$link" 88 | fi 89 | done 90 | 91 | saveddir=$(pwd) 92 | 93 | M2_HOME=$(dirname "$PRG")/.. 94 | 95 | # make it fully qualified 96 | M2_HOME=$(cd "$M2_HOME" && pwd) 97 | 98 | cd "$saveddir" 99 | # echo Using m2 at $M2_HOME 100 | fi 101 | 102 | # For Cygwin, ensure paths are in UNIX format before anything is touched 103 | if $cygwin; then 104 | [ -n "$M2_HOME" ] && 105 | M2_HOME=$(cygpath --unix "$M2_HOME") 106 | [ -n "$JAVA_HOME" ] && 107 | JAVA_HOME=$(cygpath --unix "$JAVA_HOME") 108 | [ -n "$CLASSPATH" ] && 109 | CLASSPATH=$(cygpath --path --unix "$CLASSPATH") 110 | fi 111 | 112 | # For Mingw, ensure paths are in UNIX format before anything is touched 113 | if $mingw; then 114 | [ -n "$M2_HOME" ] && 115 | M2_HOME="$( ( 116 | cd "$M2_HOME" 117 | pwd 118 | ))" 119 | [ -n "$JAVA_HOME" ] && 120 | JAVA_HOME="$( ( 121 | cd "$JAVA_HOME" 122 | pwd 123 | ))" 124 | fi 125 | 126 | if [ -z "$JAVA_HOME" ]; then 127 | javaExecutable="$(which javac)" 128 | if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then 129 | # readlink(1) is not available as standard on Solaris 10. 130 | readLink=$(which readlink) 131 | if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then 132 | if $darwin; then 133 | javaHome="$(dirname \"$javaExecutable\")" 134 | javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac" 135 | else 136 | javaExecutable="$(readlink -f \"$javaExecutable\")" 137 | fi 138 | javaHome="$(dirname \"$javaExecutable\")" 139 | javaHome=$(expr "$javaHome" : '\(.*\)/bin') 140 | JAVA_HOME="$javaHome" 141 | export JAVA_HOME 142 | fi 143 | fi 144 | fi 145 | 146 | if [ -z "$JAVACMD" ]; then 147 | if [ -n "$JAVA_HOME" ]; then 148 | if [ -x "$JAVA_HOME/jre/sh/java" ]; then 149 | # IBM's JDK on AIX uses strange locations for the executables 150 | JAVACMD="$JAVA_HOME/jre/sh/java" 151 | else 152 | JAVACMD="$JAVA_HOME/bin/java" 153 | fi 154 | else 155 | JAVACMD="$(which java)" 156 | fi 157 | fi 158 | 159 | if [ ! -x "$JAVACMD" ]; then 160 | echo "Error: JAVA_HOME is not defined correctly." >&2 161 | echo " We cannot execute $JAVACMD" >&2 162 | exit 1 163 | fi 164 | 165 | if [ -z "$JAVA_HOME" ]; then 166 | echo "Warning: JAVA_HOME environment variable is not set." 167 | fi 168 | 169 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 170 | 171 | # traverses directory structure from process work directory to filesystem root 172 | # first directory with .mvn subdirectory is considered project base directory 173 | find_maven_basedir() { 174 | 175 | if [ -z "$1" ]; then 176 | echo "Path not specified to find_maven_basedir" 177 | return 1 178 | fi 179 | 180 | basedir="$1" 181 | wdir="$1" 182 | while [ "$wdir" != '/' ]; do 183 | if [ -d "$wdir"/.mvn ]; then 184 | basedir=$wdir 185 | break 186 | fi 187 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 188 | if [ -d "${wdir}" ]; then 189 | wdir=$( 190 | cd "$wdir/.." 191 | pwd 192 | ) 193 | fi 194 | # end of workaround 195 | done 196 | echo "${basedir}" 197 | } 198 | 199 | # concatenates all lines of a file 200 | concat_lines() { 201 | if [ -f "$1" ]; then 202 | echo "$(tr -s '\n' ' ' <"$1")" 203 | fi 204 | } 205 | 206 | BASE_DIR=$(find_maven_basedir "$(pwd)") 207 | if [ -z "$BASE_DIR" ]; then 208 | exit 1 209 | fi 210 | 211 | ########################################################################################## 212 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 213 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 214 | ########################################################################################## 215 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 216 | if [ "$MVNW_VERBOSE" = true ]; then 217 | echo "Found .mvn/wrapper/maven-wrapper.jar" 218 | fi 219 | else 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 222 | fi 223 | if [ -n "$MVNW_REPOURL" ]; then 224 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 225 | else 226 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 227 | fi 228 | while IFS="=" read key value; do 229 | case "$key" in wrapperUrl) 230 | jarUrl="$value" 231 | break 232 | ;; 233 | esac 234 | done <"$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 235 | if [ "$MVNW_VERBOSE" = true ]; then 236 | echo "Downloading from: $jarUrl" 237 | fi 238 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 239 | if $cygwin; then 240 | wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") 241 | fi 242 | 243 | if command -v wget >/dev/null; then 244 | if [ "$MVNW_VERBOSE" = true ]; then 245 | echo "Found wget ... using wget" 246 | fi 247 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 248 | wget "$jarUrl" -O "$wrapperJarPath" 249 | else 250 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 251 | fi 252 | elif command -v curl >/dev/null; then 253 | if [ "$MVNW_VERBOSE" = true ]; then 254 | echo "Found curl ... using curl" 255 | fi 256 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 257 | curl -o "$wrapperJarPath" "$jarUrl" -f 258 | else 259 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 260 | fi 261 | 262 | else 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo "Falling back to using Java to download" 265 | fi 266 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 267 | # For Cygwin, switch paths to Windows format before running javac 268 | if $cygwin; then 269 | javaClass=$(cygpath --path --windows "$javaClass") 270 | fi 271 | if [ -e "$javaClass" ]; then 272 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 273 | if [ "$MVNW_VERBOSE" = true ]; then 274 | echo " - Compiling MavenWrapperDownloader.java ..." 275 | fi 276 | # Compiling the Java class 277 | ("$JAVA_HOME/bin/javac" "$javaClass") 278 | fi 279 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 280 | # Running the downloader 281 | if [ "$MVNW_VERBOSE" = true ]; then 282 | echo " - Running MavenWrapperDownloader.java ..." 283 | fi 284 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 285 | fi 286 | fi 287 | fi 288 | fi 289 | ########################################################################################## 290 | # End of extension 291 | ########################################################################################## 292 | 293 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 294 | if [ "$MVNW_VERBOSE" = true ]; then 295 | echo $MAVEN_PROJECTBASEDIR 296 | fi 297 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 298 | 299 | # For Cygwin, switch paths to Windows format before running java 300 | if $cygwin; then 301 | [ -n "$M2_HOME" ] && 302 | M2_HOME=$(cygpath --path --windows "$M2_HOME") 303 | [ -n "$JAVA_HOME" ] && 304 | JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") 305 | [ -n "$CLASSPATH" ] && 306 | CLASSPATH=$(cygpath --path --windows "$CLASSPATH") 307 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 308 | MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") 309 | fi 310 | 311 | # Provide a "standardized" way to retrieve the CLI args that will 312 | # work with both Windows and non-Windows executions. 313 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 314 | export MAVEN_CMD_LINE_ARGS 315 | 316 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 317 | 318 | exec "$JAVACMD" \ 319 | $MAVEN_OPTS \ 320 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 321 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 322 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 323 | -------------------------------------------------------------------------------- /checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 48 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 83 | 84 | 85 | 86 | 87 | 90 | 91 | 92 | 93 | 94 | 96 | 97 | 98 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 116 | 118 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 187 | 188 | 189 | 192 | 193 | 194 | 195 | 200 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 243 | 244 | 245 | 246 | --------------------------------------------------------------------------------