aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorSubodh Ranadive <subodh.ranadive@ekzero.com>2021-03-07 09:58:11 +0530
committerSubodh Ranadive <subodh.ranadive@ekzero.com>2021-03-24 15:30:31 +0530
commitd2dc1f983a9b5fc579b24c406587260e726dc35d (patch)
tree6674984c84d9877fdf38b19ff83ce556c9e47992 /src/main
parentb01ac16f670861b1fb5ffe8747674d0c298d1f81 (diff)
downloadtrackermap-server-d2dc1f983a9b5fc579b24c406587260e726dc35d.tar.gz
trackermap-server-d2dc1f983a9b5fc579b24c406587260e726dc35d.tar.bz2
trackermap-server-d2dc1f983a9b5fc579b24c406587260e726dc35d.zip
Minor fixes
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/Context.java2
-rw-r--r--src/main/java/org/traccar/config/Keys.java8
-rw-r--r--src/main/java/org/traccar/sms/SnsSmsClient.java23
3 files changed, 13 insertions, 20 deletions
diff --git a/src/main/java/org/traccar/Context.java b/src/main/java/org/traccar/Context.java
index 40340b1f0..934006347 100644
--- a/src/main/java/org/traccar/Context.java
+++ b/src/main/java/org/traccar/Context.java
@@ -318,7 +318,7 @@ public final class Context {
if (config.hasKey(Keys.SMS_HTTP_URL)) {
smsManager = new HttpSmsClient();
- } else if (config.hasKey(Keys.AWS_SNS_ENABLED)) {
+ } else if (config.hasKey(Keys.AWS_REGION)) {
smsManager = new SnsSmsClient();
}
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index ac105b99c..c3dce88c4 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -702,14 +702,6 @@ public final class Keys {
Collections.singletonList(KeyType.GLOBAL));
/**
- * SNS Enable switch.
- * Use 'enable' to send message with SNS or 'disable' to stop using SNS
- */
- public static final ConfigKey<String> AWS_SNS_ENABLED = new ConfigKey<>(
- "sms.sns.enabled",
- Collections.singletonList(KeyType.GLOBAL));
-
- /**
* AWS Region for SNS service.
* Make sure to use regions that are supported for messaging.
*/
diff --git a/src/main/java/org/traccar/sms/SnsSmsClient.java b/src/main/java/org/traccar/sms/SnsSmsClient.java
index d79079f7a..81114e5f5 100644
--- a/src/main/java/org/traccar/sms/SnsSmsClient.java
+++ b/src/main/java/org/traccar/sms/SnsSmsClient.java
@@ -37,10 +37,9 @@ public class SnsSmsClient implements SmsManager {
private final AmazonSNS snsClient;
public SnsSmsClient() {
- if (!Context.getConfig().getString(Keys.AWS_SNS_ENABLED).equals("true")
+ if (Context.getConfig().getString(Keys.AWS_REGION) == null
|| Context.getConfig().getString(Keys.AWS_ACCESS_KEY) == null
- || Context.getConfig().getString(Keys.AWS_SECRET_KEY) == null
- || Context.getConfig().getString(Keys.AWS_REGION) == null) {
+ || Context.getConfig().getString(Keys.AWS_SECRET_KEY) == null) {
throw new RuntimeException("SNS Not Configured Properly. Please provide valid config.");
}
snsClient = awsSNSClient();
@@ -53,7 +52,9 @@ public class SnsSmsClient implements SmsManager {
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).build();
}
- public void sendSNSMessage(String message, String destAddress) {
+ @Override
+ public void sendMessageSync(String destAddress, String message, boolean command)
+ throws InterruptedException, MessageException {
Map<String, MessageAttributeValue> smsAttributes = new HashMap<>();
smsAttributes.put("AWS.SNS.SMS.SenderID",
new MessageAttributeValue().withStringValue("SNS").withDataType("String"));
@@ -64,13 +65,13 @@ public class SnsSmsClient implements SmsManager {
}
@Override
- public void sendMessageSync(String destAddress, String message, boolean command)
- throws InterruptedException, MessageException {
- sendSNSMessage(message, destAddress);
- }
-
- @Override
public void sendMessageAsync(String destAddress, String message, boolean command) {
- sendSNSMessage(message, destAddress);
+ try {
+ sendMessageSync(destAddress, message, command);
+ } catch (InterruptedException interruptedException) {
+ LOGGER.warn("SMS send failed", interruptedException.getMessage());
+ } catch (MessageException messageException) {
+ LOGGER.warn("SMS send failed", messageException.getMessage());
+ }
}
}