-
Notifications
You must be signed in to change notification settings - Fork 5
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 #56 from RADAR-base/release-0.2.1
Release 0.2.1
- Loading branch information
Showing
14 changed files
with
187 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,6 @@ smtp.env | |
|
||
/out/ | ||
/libs/ | ||
|
||
# Distribution | ||
/radar-backend-* |
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
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,41 @@ | ||
package org.radarcns.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.List; | ||
|
||
|
||
/** | ||
* POJO to store each email Notification configuration. | ||
*/ | ||
public class NotifyConfig { | ||
@JsonProperty("project_id") | ||
private String projectId; | ||
|
||
@JsonProperty("email_address") | ||
private List<String> emailAddress; | ||
|
||
@JsonCreator | ||
public NotifyConfig(@JsonProperty("project_id") String projectId, | ||
@JsonProperty("email_address") List<String> emailAddress) { | ||
this.projectId = projectId; | ||
this.emailAddress = emailAddress; | ||
} | ||
|
||
public String getProjectId() { | ||
return projectId; | ||
} | ||
|
||
public void setProjectId(String projectId) { | ||
this.projectId = projectId; | ||
} | ||
|
||
public List<String> getEmailAddress() { | ||
return emailAddress; | ||
} | ||
|
||
public void setEmailAddress(List<String> emailAddress) { | ||
this.emailAddress = emailAddress; | ||
} | ||
} |
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,48 @@ | ||
package org.radarcns.util; | ||
|
||
import org.radarcns.config.MonitorConfig; | ||
import org.radarcns.config.NotifyConfig; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
|
||
/** | ||
* Class to store {@link EmailSender} associated with each project. | ||
*/ | ||
public class EmailSenders { | ||
|
||
private final Map<String,EmailSender> emailSenderMap; | ||
|
||
public EmailSenders(Map<String, EmailSender> map) { | ||
this.emailSenderMap = map; | ||
} | ||
|
||
/** | ||
* | ||
* Parses the {@link MonitorConfig} to map the corresponding | ||
* {@link EmailSender} to each project. A project can have a list of | ||
* associated email addresses. | ||
* | ||
* @param config Configuration of the Monitor containing project | ||
* and email address mapping | ||
* @throws IOException | ||
*/ | ||
|
||
public static EmailSenders parseConfig(MonitorConfig config) throws IOException{ | ||
Map<String, EmailSender> map = new HashMap<>(); | ||
for(NotifyConfig notifyConfig : config.getNotifyConfig()) { | ||
map.put(notifyConfig.getProjectId(), | ||
new EmailSender(config.getEmailHost(), config.getEmailPort(), | ||
config.getEmailUser(), notifyConfig.getEmailAddress())); | ||
} | ||
|
||
return new EmailSenders(map); | ||
} | ||
|
||
public EmailSender getEmailSenderForProject(String projectId) { | ||
return emailSenderMap.get(projectId); | ||
} | ||
|
||
} |
Oops, something went wrong.