diff options
author | Abyss777 <abyss@fox5.ru> | 2017-03-02 12:16:17 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-03-02 12:16:17 +0500 |
commit | 5a964d4adf67d2f49b58f0b14d4388d7aa2353d2 (patch) | |
tree | 54a3ddde7b08557ed2aa5bb0dfd35385b1242908 /src/org/traccar/api/resource | |
parent | 5012663d8688fa521fa7de02116f42ddbb57e7fb (diff) | |
download | trackermap-server-5a964d4adf67d2f49b58f0b14d4388d7aa2353d2.tar.gz trackermap-server-5a964d4adf67d2f49b58f0b14d4388d7aa2353d2.tar.bz2 trackermap-server-5a964d4adf67d2f49b58f0b14d4388d7aa2353d2.zip |
Implement sms commands
Diffstat (limited to 'src/org/traccar/api/resource')
-rw-r--r-- | src/org/traccar/api/resource/CommandResource.java | 12 | ||||
-rw-r--r-- | src/org/traccar/api/resource/CommandTypeResource.java | 6 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/org/traccar/api/resource/CommandResource.java b/src/org/traccar/api/resource/CommandResource.java index 41b263bf9..e5468b5f5 100644 --- a/src/org/traccar/api/resource/CommandResource.java +++ b/src/org/traccar/api/resource/CommandResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,11 @@ import org.traccar.Context; import org.traccar.api.BaseResource; import org.traccar.model.Command; +import com.cloudhopper.smpp.type.RecoverablePduException; +import com.cloudhopper.smpp.type.SmppChannelException; +import com.cloudhopper.smpp.type.SmppTimeoutException; +import com.cloudhopper.smpp.type.UnrecoverablePduException; + import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -32,10 +37,11 @@ import javax.ws.rs.core.Response; public class CommandResource extends BaseResource { @POST - public Response add(Command entity) { + public Response add(Command entity) throws RecoverablePduException, UnrecoverablePduException, + SmppTimeoutException, SmppChannelException, InterruptedException { Context.getPermissionsManager().checkReadonly(getUserId()); Context.getPermissionsManager().checkDevice(getUserId(), entity.getDeviceId()); - Context.getConnectionManager().getActiveDevice(entity.getDeviceId()).sendCommand(entity); + Context.getDeviceManager().sendCommand(entity); return Response.ok(entity).build(); } diff --git a/src/org/traccar/api/resource/CommandTypeResource.java b/src/org/traccar/api/resource/CommandTypeResource.java index ce27f5241..3ee773fbf 100644 --- a/src/org/traccar/api/resource/CommandTypeResource.java +++ b/src/org/traccar/api/resource/CommandTypeResource.java @@ -1,5 +1,6 @@ /* * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) + * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; -import java.sql.SQLException; import java.util.Collection; @Path("commandtypes") @@ -34,9 +34,9 @@ import java.util.Collection; public class CommandTypeResource extends BaseResource { @GET - public Collection<CommandType> get(@QueryParam("deviceId") long deviceId) throws SQLException { + public Collection<CommandType> get(@QueryParam("deviceId") long deviceId, @QueryParam("sms") boolean sms) { Context.getPermissionsManager().checkDevice(getUserId(), deviceId); - return Context.getConnectionManager().getActiveDevice(deviceId).getCommandTypes(); + return Context.getDeviceManager().getCommandTypes(deviceId, sms); } } |