-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from MathieuSoysal/12-convertor-logement-objec…
…t-json 12 convertor logement object json
- Loading branch information
Showing
12 changed files
with
285 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name: Deploy Javadoc | |
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
|
||
jobs: | ||
publish: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.github.mathieusoysal; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.exc.StreamReadException; | ||
import com.fasterxml.jackson.databind.DatabindException; | ||
import com.github.forax.beautifullogger.Logger; | ||
|
||
import io.github.mathieusoysal.exceptions.ApiRequestFailedException; | ||
import io.github.mathieusoysal.exceptions.PropertiesNotFoundRuntimeException; | ||
import io.github.mathieusoysal.logement.data.DataCollector; | ||
import io.github.mathieusoysal.logement.data.DataSaver; | ||
|
||
public class App { | ||
private static final Logger LOGGER = Logger.getLogger(); | ||
private static final String MAIL_PROPERTIES_NAME = "MAIL"; | ||
private static final String PASSWORD_PROPERTIES_NAME = "PASSWORD"; | ||
|
||
public static void main(String[] args) | ||
throws StreamReadException, DatabindException, ApiRequestFailedException, IOException, | ||
InterruptedException { | ||
LOGGER.info(() -> "Starting application"); | ||
var logements = DataCollector.getAvailableLogementsWithConnection(getEmail(), getPassword()); | ||
DataSaver.createArchiveLogements(logements); | ||
LOGGER.info(() -> "Application finished"); | ||
} | ||
|
||
private static String getEmail() { | ||
LOGGER.info(() -> "Getting email from environment variables"); | ||
String email = System.getenv(MAIL_PROPERTIES_NAME); | ||
if (email == null) | ||
{ | ||
LOGGER.error(() -> "Email not found in environment variables"); | ||
throw new PropertiesNotFoundRuntimeException(MAIL_PROPERTIES_NAME); | ||
} | ||
return email; | ||
} | ||
|
||
private static String getPassword() { | ||
LOGGER.info(() -> "Getting password from environment variables"); | ||
String password = System.getenv(PASSWORD_PROPERTIES_NAME); | ||
if (password == null) | ||
{ | ||
LOGGER.error(() -> "Password not found in environment variables"); | ||
throw new PropertiesNotFoundRuntimeException(PASSWORD_PROPERTIES_NAME); | ||
} | ||
return password; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/io/github/mathieusoysal/exceptions/PropertiesNotFoundRuntimeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.github.mathieusoysal.exceptions; | ||
|
||
public class PropertiesNotFoundRuntimeException extends RuntimeException { | ||
|
||
public PropertiesNotFoundRuntimeException(String propertiesName) { | ||
super("Properties value " + propertiesName + " not found in environment variables"); | ||
} | ||
|
||
public PropertiesNotFoundRuntimeException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.