From be0040a7c18f5c165f1aaa27a194a189f50b1510 Mon Sep 17 00:00:00 2001 From: Gabor Somogyi Date: Thu, 5 May 2016 15:36:56 +0200 Subject: Backend side model put back --- src/org/traccar/ServerManager.java | 10 +++++--- .../api/resource/SupportedCommandResource.java | 3 ++- src/org/traccar/model/SupportedCommand.java | 29 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/org/traccar/model/SupportedCommand.java (limited to 'src/org/traccar') diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index 59bb88829..f79d543ff 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -15,6 +15,8 @@ */ package org.traccar; +import org.traccar.model.SupportedCommand; + import java.io.File; import java.net.URI; import java.net.URL; @@ -96,13 +98,15 @@ public class ServerManager { } } - public Collection getProtocolSuppportedCommands(String protocol) { - List result = new ArrayList<>(); + public Collection getProtocolSuppportedCommands(String protocol) { + List result = new ArrayList<>(); if (protocol != null) { BaseProtocol baseProtocol = protocols.get(protocol); for (String commandKey : baseProtocol.getSupportedCommands()) { - result.add(commandKey); + SupportedCommand supportedCommand = new SupportedCommand(); + supportedCommand.setKey(commandKey); + result.add(supportedCommand); } } diff --git a/src/org/traccar/api/resource/SupportedCommandResource.java b/src/org/traccar/api/resource/SupportedCommandResource.java index 393588d9b..1d5ce8595 100644 --- a/src/org/traccar/api/resource/SupportedCommandResource.java +++ b/src/org/traccar/api/resource/SupportedCommandResource.java @@ -18,6 +18,7 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; import org.traccar.model.Position; +import org.traccar.model.SupportedCommand; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -35,7 +36,7 @@ import java.util.Collections; public class SupportedCommandResource extends BaseResource { @GET - public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { + public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { Context.getPermissionsManager().checkDevice(getUserId(), deviceId); Position lastPosition = Context.getConnectionManager().getLastPosition(deviceId); if (lastPosition != null) { diff --git a/src/org/traccar/model/SupportedCommand.java b/src/org/traccar/model/SupportedCommand.java new file mode 100644 index 000000000..59a24d033 --- /dev/null +++ b/src/org/traccar/model/SupportedCommand.java @@ -0,0 +1,29 @@ +/* + * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.model; + +public class SupportedCommand { + + private String key; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } +} -- cgit v1.2.3