diff --git a/java/com.sap.sailing.server.gateway/resources/shiro.ini b/java/com.sap.sailing.server.gateway/resources/shiro.ini index d964408a2dc..c2fc798c10c 100755 --- a/java/com.sap.sailing.server.gateway/resources/shiro.ini +++ b/java/com.sap.sailing.server.gateway/resources/shiro.ini @@ -70,6 +70,7 @@ bearerToken = com.sap.sailing.server.security.BearerTokenOrBasicOrFormAuthentica /api/v1/leaderboards/*/racecolumnfactors/** = bearerToken /api/v1/leaderboards/*/settrackingtimes/** = bearerToken /api/v1/leaderboards/*/starttracking/** = bearerToken +/api/v1/leaderboards/*/stoptracking/** = bearerToken /api/v1/regattas/*/addracecolumns/** = bearerToken /api/v1/regattas/*/removeracecolumn = bearerToken /api/v1/regattas/*/competitors/*/add = bearerToken diff --git a/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/LeaderboardsResource.java b/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/LeaderboardsResource.java index 892a84a680b..f51961805ee 100644 --- a/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/LeaderboardsResource.java +++ b/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/LeaderboardsResource.java @@ -3,6 +3,7 @@ package com.sap.sailing.server.gateway.jaxrs.api; import java.io.IOException; import java.io.Serializable; import java.io.StringWriter; +import java.net.MalformedURLException; import java.util.Collections; import java.util.Date; import java.util.HashSet; @@ -52,6 +53,8 @@ import com.sap.sailing.domain.base.Fleet; import com.sap.sailing.domain.base.Mark; import com.sap.sailing.domain.base.Nationality; import com.sap.sailing.domain.base.RaceColumn; +import com.sap.sailing.domain.base.RaceDefinition; +import com.sap.sailing.domain.base.Regatta; import com.sap.sailing.domain.base.Waypoint; import com.sap.sailing.domain.common.MaxPointsReason; import com.sap.sailing.domain.common.NoWindException; @@ -700,6 +703,34 @@ public class LeaderboardsResource extends AbstractSailingServerResource { return result; } + @POST + @Produces(MediaType.APPLICATION_JSON) + @Path("{leaderboardName}/stoptracking") + public Response stopTracking(@PathParam("leaderboardName") String leaderboardName, + @QueryParam(RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME) String raceColumnName, + @QueryParam(RaceLogServletConstants.PARAMS_RACE_FLEET_NAME) String fleetName) throws MalformedURLException, IOException, InterruptedException { + SecurityUtils.getSubject().checkPermission(Permission.LEADERBOARD.getStringPermissionForObjects(Mode.UPDATE, leaderboardName)); + final LeaderboardAndRaceColumnAndFleetAndResponse leaderboardAndRaceColumnAndFleetAndResponse = getLeaderboardAndRaceColumnAndFleet(leaderboardName, raceColumnName, fleetName); + final Response result; + if (leaderboardAndRaceColumnAndFleetAndResponse.getFleet() != null) { + JSONObject jsonResult = new JSONObject(); + final TrackedRace trackedRace = leaderboardAndRaceColumnAndFleetAndResponse.getRaceColumn().getTrackedRace(leaderboardAndRaceColumnAndFleetAndResponse.getFleet()); + if (trackedRace == null) { + result = Response.status(Status.PRECONDITION_FAILED).entity("no tracked race").build(); + } else { + final Regatta regatta = trackedRace.getTrackedRegatta().getRegatta(); + final RaceDefinition race = trackedRace.getRace(); + getService().stopTracking(regatta, race); + jsonResult.put("regatta", regatta.getName()); + jsonResult.put("race", race.getName()); + result = Response.ok(jsonResult.toJSONString()).build(); + } + } else { + result = leaderboardAndRaceColumnAndFleetAndResponse.getResponse(); + } + return result; + } + @GET @Produces(MediaType.APPLICATION_JSON) @Path("{leaderboardName}/marks") diff --git a/java/com.sap.sailing.server.gateway/webservices/api/v1/index.html b/java/com.sap.sailing.server.gateway/webservices/api/v1/index.html index 63ead97ef9f..92087a9dd77 100644 --- a/java/com.sap.sailing.server.gateway/webservices/api/v1/index.html +++ b/java/com.sap.sailing.server.gateway/webservices/api/v1/index.html @@ -122,7 +122,7 @@ name to make sure you get to the event you're interested in.
Modifies the tracking start/finish times for a race. If nothing is specified about the start -of tracking time (none of the parameters startoftracking and startoftrackingasmillis present), -no modification will be applied to the tracking start time, and no race log entry will be created -for it. If one of the two parameters is provided but with an empty value, the tracking start time -will be set to null explicitly.
-Likewise, the same holds for endoftracking and endoftrackingmillis, accordingly. -
-The resulting JSON document tells which of the startoftracking and endoftracking times have been -set for the race and to which value. +
Starts tracking for a race. By default, wind tracking is activated,
| Example: | -http://127.0.0.1:8888/sailingserver/api/v1/leaderboards/TracTrac%20Virtual%20Course%20Marks%20Test/settrackingtimes?race_column=R1&fleet=Default&startoftracking=2007-01-03T13:05:00Z + | http://127.0.0.1:8888/sailingserver/api/v1/leaderboards/TracTrac%20Virtual%20Course%20Marks%20Test/starttracking?race_column=R1&fleet=Default delivers
{
- "startoftracking": 1167829500000
+ "addeddenotation": true
+ "regatta": "TracTrac Virtual Course Marks Test"
}
|
| Webservice Type: | +REST | +
| Output format: | +Json | +
| Mandatory parameters: | +race_column, fleet | +
| Optional parameters: | +
+ trackWind a boolean value, defaulting to true; tells whether to start receiving live wind data for the tracked race
+ correctWindDirectionByMagneticDeclination a boolean value, defaulting to true; if trackWind is true,
+ this parameter controls whether the wind directions received are to be corrected by the magnetic
+ declination
+ |
+
| Request method: | +POST | +
| Example: | +http://127.0.0.1:8888/sailingserver/api/v1/leaderboards/TracTrac%20Virtual%20Course%20Marks%20Test/settrackingtimes?race_column=R1&fleet=Default&startoftracking=2007-01-03T13:05:00Z + delivers
+ {"addeddenotation":false, "regatta":"TracTrac Virtual Course Marks Test"}
+
+ where the addeddenotation field tells whether an annotation for smartphone tracking had to be added
+ in order to be able to track the race. |
+
Stops tracking the race identified by the race_column and fleet parameters. +
+| Webservice Type: | +REST | +
| Output format: | +Json | +
| Mandatory parameters: | +race_column, fleet | +
| Optional parameters: | +None | +
| Request method: | +POST | +
| Example: | +curl -X POST -H "Authorization: Bearer w9YSIfr/Zf6a127SZDddkhdAtQuuv0Jm1PSXlo1Yvd0=" "http://127.0.0.1:8888/sailingserver/api/v1/leaderboards/Smartphone%20Tracking%20Test%2022.06/stoptracking?race_column=K1&fleet=Blue" + delivers the regatta and race name of the race whose tracking got stopped:
+ {"regatta":"Smartphone Tracking Test 22.06","race":"Smartphone Tracking Test 22.06 K1 Blue"}
+ |
+