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. Adds one or more race columns to a regatta - /api/v1/regattas/{regattaname}/removeracecolumn?racecolumn={racecolumnname} + /api/v1/regattas/{regattaname}/removeracecolumn Removes a race column from a regatta @@ -174,13 +174,21 @@ name to make sure you get to the event you're interested in. Gets the details of a competitor in the context of a leaderboard - /api/v1/leaderboards/{name}/marks?race_column={name}&fleet={name} + /api/v1/leaderboards/{name}/marks Gets the marks of a race (from the RaceLog and if possible the TrackedRace) - /api/v1/leaderboards/{name}/settrackingtimes?race_column={name}&fleet={name} + /api/v1/leaderboards/{name}/settrackingtimes Modifies the race's tracking interval + + /api/v1/leaderboards/{name}/starttracking + Starts tracking for a race log / smart phone-tracked race + + + /api/v1/leaderboards/{name}/stoptracking + Stops tracking for a race + /api/v1/leaderboards/{name}/marks/{id}/gps_fixes Pings the location of a mark via the RegattaLog diff --git a/java/com.sap.sailing.server.gateway/webservices/api/v1/leaderboardRaceSetTrackingTimes.html b/java/com.sap.sailing.server.gateway/webservices/api/v1/leaderboardRaceSetTrackingTimes.html index 4f241ab15ac..a4c9bcdd741 100755 --- a/java/com.sap.sailing.server.gateway/webservices/api/v1/leaderboardRaceSetTrackingTimes.html +++ b/java/com.sap.sailing.server.gateway/webservices/api/v1/leaderboardRaceSetTrackingTimes.html @@ -12,15 +12,7 @@

URL: /api/v1/leaderboards/{name}/settrackingtimes?race_column={name}&fleet={name}

Description: -

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,


@@ -55,10 +47,11 @@ set for the race and to which value. - diff --git a/java/com.sap.sailing.server.gateway/webservices/api/v1/leaderboardRaceStartTracking.html b/java/com.sap.sailing.server.gateway/webservices/api/v1/leaderboardRaceStartTracking.html new file mode 100755 index 00000000000..e7545a72d8d --- /dev/null +++ b/java/com.sap.sailing.server.gateway/webservices/api/v1/leaderboardRaceStartTracking.html @@ -0,0 +1,58 @@ + + + + + + + + SAP Sailing Analytics Webservices API Version 1.0 + + +

SAP Sailing Analytics Webservices API Version 1.0

+

URL: /api/v1/leaderboards/{name}/starttracking?race_column={name}&fleet={name}

+ +Description: +

Starts tracking the race identified by the race_column and fleet parameters. +If no smartphone tracking denotation exists yet for that race, one is added. +Wind tracking can be configured using optional request parameters.

+
+
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.
+
+Back to Web Service Overview + + diff --git a/java/com.sap.sailing.server.gateway/webservices/api/v1/leaderboardRaceStopTracking.html b/java/com.sap.sailing.server.gateway/webservices/api/v1/leaderboardRaceStopTracking.html new file mode 100755 index 00000000000..d9ba8f77578 --- /dev/null +++ b/java/com.sap.sailing.server.gateway/webservices/api/v1/leaderboardRaceStopTracking.html @@ -0,0 +1,50 @@ + + + + + + + + SAP Sailing Analytics Webservices API Version 1.0 + + +

SAP Sailing Analytics Webservices API Version 1.0

+

URL: /api/v1/leaderboards/{name}/stoptracking?race_column={name}&fleet={name}

+ +Description: +

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"}
+		
+
+Back to Web Service Overview + +