aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Martinez <ivanfmartinez@users.noreply.github.com>2018-06-01 10:43:16 -0300
committerIvan Martinez <ivanfmartinez@users.noreply.github.com>2018-06-01 10:43:16 -0300
commit294c399e5b260313a2d49a0fed1516116a23fbd5 (patch)
tree24207d763ec5ef5bee09975a3c7e4745854a0779
parent4fc750b585dd6b2953b16408dd57a8ef93fdeee9 (diff)
downloadtrackermap-server-294c399e5b260313a2d49a0fed1516116a23fbd5.tar.gz
trackermap-server-294c399e5b260313a2d49a0fed1516116a23fbd5.tar.bz2
trackermap-server-294c399e5b260313a2d49a0fed1516116a23fbd5.zip
update api to support notificators
-rw-r--r--src/org/traccar/api/resource/NotificationResource.java21
-rw-r--r--src/org/traccar/notification/NotificatorManager.java8
2 files changed, 22 insertions, 7 deletions
diff --git a/src/org/traccar/api/resource/NotificationResource.java b/src/org/traccar/api/resource/NotificationResource.java
index 830e34fc0..2347b43fa 100644
--- a/src/org/traccar/api/resource/NotificationResource.java
+++ b/src/org/traccar/api/resource/NotificationResource.java
@@ -21,6 +21,7 @@ import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -51,9 +52,25 @@ public class NotificationResource extends ExtendedObjectResource<Notification> {
@POST
@Path("test")
public Response testMessage() throws NotificationException, InterruptedException {
- Context.getNotificatorManager().getMail().sendSync(getUserId(), new Event("test", 0), null);
- Context.getNotificatorManager().getSms().sendSync(getUserId(), new Event("test", 0), null);
+ for (String method : Context.getNotificatorManager().getNotificatorTypes()) {
+ Context.getNotificatorManager().getNotificator(method).sendSync(getUserId(), new Event("test", 0), null);
+ }
return Response.noContent().build();
}
+ @POST
+ @Path("test/{method}")
+ public Response testMessage(@PathParam("method") String method) throws NotificationException, InterruptedException {
+ Context.getNotificatorManager().getNotificator(method).sendSync(getUserId(), new Event("test", 0), null);
+ return Response.noContent().build();
+ }
+
+
+ @GET
+ @Path("notificators")
+ public Collection<String> getNotificators() {
+ return Context.getNotificatorManager().getNotificatorTypes();
+ }
+
+
}
diff --git a/src/org/traccar/notification/NotificatorManager.java b/src/org/traccar/notification/NotificatorManager.java
index c58149847..20c7749d2 100644
--- a/src/org/traccar/notification/NotificatorManager.java
+++ b/src/org/traccar/notification/NotificatorManager.java
@@ -20,6 +20,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import org.traccar.Context;
import org.traccar.helper.Log;
@@ -60,12 +61,9 @@ public final class NotificatorManager {
return n;
}
- public Notificator getSms() {
- return getNotificator("sms");
- }
- public Notificator getMail() {
- return getNotificator("mail");
+ public Set<String> getNotificatorTypes() {
+ return notificators.keySet();
}