added documentation for createEvent; fixed baseURL inference

Change-Id: Ic70c49a64eeb8a7648ab41142997ee4f03752252
This commit is contained in:
Axel Uhl committed 2017-08-22 18:22:42 +02:00
1 parent 438d3a535c
commit f980a8f28f
12 files changed
+173 -79

No files matched your search

@@ -37,7 +37,7 @@ public abstract class AbstractJaxRsApiTest {
protected static SimpleDateFormat TIMEPOINT_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
public void setUp() {
public void setUp() throws Exception {
service = MongoDBConfiguration.getDefaultTestConfiguration().getService();
service.getDB().dropDatabase();
racingEventService = new RacingEventServiceImpl(/* clearPersistentCompetitorStore */ true,
@@ -44,7 +44,7 @@ public class CompetitorsResourceTeamImageTest extends AbstractJaxRsApiTest {
private FileStorageService storageService;
@Before
public void setUpSubClass() throws InvalidPropertiesException {
public void setUpSubClass() throws Exception {
super.setUp();
racingEventService = spy(racingEventService);
storageService = AmazonS3TestSupport.createService();
@@ -30,7 +30,7 @@ public class CompetitorsResourceTest extends AbstractJaxRsApiTest {
@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();
DynamicTeam team = new TeamImpl(null, Collections.singleton(new PersonImpl(null, new NationalityImpl(nationality), null, null)), null);
DynamicBoat boat = new BoatImpl(null, new BoatClassImpl(boatClassName, false), sailID);
@@ -3,12 +3,16 @@ package com.sap.sailing.server.gateway.test.jaxrs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.net.URI;
import java.text.ParseException;
import java.util.UUID;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang.RandomStringUtils;
import org.json.simple.JSONArray;
@@ -25,6 +29,7 @@ import com.sap.sailing.server.gateway.jaxrs.api.EventsResource;
import com.sap.sailing.server.gateway.jaxrs.api.LeaderboardGroupsResource;
import com.sap.sailing.server.gateway.jaxrs.api.LeaderboardsResource;
import com.sap.sailing.server.gateway.jaxrs.api.RegattasResource;
import com.sap.sse.InvalidDateException;
public class EventResourceTest extends AbstractJaxRsApiTest {
private EventsResource eventsResource;
@@ -32,10 +37,13 @@ public class EventResourceTest extends AbstractJaxRsApiTest {
private LeaderboardGroupsResource leaderboardGroupsResource;
private LeaderboardsResource leaderboardsResource;
private String randomName;
private UriInfo uriInfo;
@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();
uriInfo = mock(UriInfo.class);
when(uriInfo.getBaseUri()).thenReturn(new URI("http://127.0.0.1:8888/"));
eventsResource = createResource(new EventsResource(/* enforce security */ false));
regattasResource = createResource(new RegattasResource());
leaderboardGroupsResource = createResource(new LeaderboardGroupsResource());
@@ -109,33 +117,44 @@ public class EventResourceTest extends AbstractJaxRsApiTest {
assertTrue(containsObjectWithAttrbuteNameAndValue(arrLeaderboards, "name", strRegattaName));
}
private Response createEventWithLeaderboardGroup()
throws ParseException, NotFoundException, NumberFormatException, IOException, org.json.simple.parser.ParseException {
return eventsResource.createEvent(randomName, randomName, /* startDateParam */ null, /* endDateParam */ null, /* venueNameParam */ randomName,
/* venueLat */ null, /* venueLng */ null, /* isPublicParam */ null, /* officialWebsiteURLParam */ null, /* baseURLParam */ null,
/* leaderboardGroupIdsListParam */ null, /* createLeaderboardGroupParam */ "true", /* createRegattaParam */ "false",
/* boatClassNameParam */ null, /* numberOfRacesParam */ null);
}
private Response createEvent() throws ParseException, NotFoundException, NumberFormatException, IOException, org.json.simple.parser.ParseException {
return eventsResource.createEvent(randomName, randomName, /* startDateParam */ null, /* endDateParam */ null, /* venueNameParam */ randomName,
/* venueLat */ null, /* venueLng */ null, /* isPublicParam */ null, /* officialWebsiteURLParam */ null, /* baseURLParam */ null,
/* leaderboardGroupIdsListParam */ null, /* createLeaderboardGroupParam */ "false", /* createRegattaParam */ "false",
private Response createEventWithLeaderboardGroup() throws ParseException, NotFoundException, NumberFormatException,
IOException, org.json.simple.parser.ParseException, InvalidDateException {
return eventsResource.createEvent(uriInfo, randomName, randomName, /* startDateParam */ null,
/* startDateAsMillis */ null, /* endDateParam */ null, /* endDateAsMillis */ null,
/* venueNameParam */ randomName, /* venueLat */ null, /* venueLng */ null, /* isPublicParam */ null,
/* officialWebsiteURLParam */ null, /* baseURLParam */ null, /* leaderboardGroupIdsListParam */ null,
/* createLeaderboardGroupParam */ "true", /* createRegattaParam */ "false",
/* boatClassNameParam */ null, /* numberOfRacesParam */ null);
}
private Response createEventAtLocation(Position location) throws ParseException, NotFoundException, NumberFormatException, IOException, org.json.simple.parser.ParseException {
return eventsResource.createEvent(randomName, randomName, /* startDateParam */ null, /* endDateParam */ null, /* venueNameParam */ null,
/* venueLat */ ""+location.getLatDeg(), /* venueLng */ ""+location.getLngDeg(), /* isPublicParam */ null, /* officialWebsiteURLParam */ null, /* baseURLParam */ null,
/* leaderboardGroupIdsListParam */ null, /* createLeaderboardGroupParam */ "false", /* createRegattaParam */ "false",
private Response createEvent() throws ParseException, NotFoundException, NumberFormatException, IOException,
org.json.simple.parser.ParseException, InvalidDateException {
return eventsResource.createEvent(uriInfo, randomName, randomName, /* startDateParam */ null,
/* startDateAsMillis */ null, /* endDateParam */ null, /* endDateAsMillis */ null,
/* venueNameParam */ randomName, /* venueLat */ null, /* venueLng */ null, /* isPublicParam */ null,
/* officialWebsiteURLParam */ null, /* baseURLParam */ null, /* leaderboardGroupIdsListParam */ null,
/* createLeaderboardGroupParam */ "false", /* createRegattaParam */ "false",
/* boatClassNameParam */ null, /* numberOfRacesParam */ null);
}
private Response createEventWithLeaderboardGroupAndRegatta()
throws ParseException, NotFoundException, NumberFormatException, IOException, org.json.simple.parser.ParseException {
return eventsResource.createEvent(randomName, randomName, /* startDateParam */ null, /* endDateParam */ null, /* venueNameParam */ randomName,
/* venueLat */ null, /* venueLng */ null, /* isPublicParam */ null, /* officialWebsiteURLParam */ null, /* baseURLParam */ null,
/* leaderboardGroupIdsListParam */ null, /* createLeaderboardGroupParam */ "true", /* createRegattaParam */ "true",
private Response createEventAtLocation(Position location) throws ParseException, NotFoundException,
NumberFormatException, IOException, org.json.simple.parser.ParseException, InvalidDateException {
return eventsResource.createEvent(uriInfo, randomName, randomName, /* startDateParam */ null,
/* startDateAsMillis */ null, /* endDateParam */ null, /* endDateAsMillis */ null,
/* venueNameParam */ null, /* venueLat */ "" + location.getLatDeg(),
/* venueLng */ "" + location.getLngDeg(), /* isPublicParam */ null, /* officialWebsiteURLParam */ null,
/* baseURLParam */ null, /* leaderboardGroupIdsListParam */ null,
/* createLeaderboardGroupParam */ "false", /* createRegattaParam */ "false",
/* boatClassNameParam */ null, /* numberOfRacesParam */ null);
}
private Response createEventWithLeaderboardGroupAndRegatta() throws ParseException, NotFoundException,
NumberFormatException, IOException, org.json.simple.parser.ParseException, InvalidDateException {
return eventsResource.createEvent(uriInfo, randomName, randomName, /* startDateParam */ null,
/* startDateAsMillis */ null, /* endDateParam */ null, /* endDateAsMillis */ null,
/* venueNameParam */ randomName, /* venueLat */ null, /* venueLng */ null, /* isPublicParam */ null,
/* officialWebsiteURLParam */ null, /* baseURLParam */ null, /* leaderboardGroupIdsListParam */ null,
/* createLeaderboardGroupParam */ "true", /* createRegattaParam */ "true",
/* boatClassNameParam */ "A_CAT", /* numberOfRacesParam */ null);
}
@@ -39,7 +39,7 @@ public class LeaderboardGroupResourceTest extends AbstractJaxRsApiTest {
private String leaderboardGroupName = "TestLeaderboardGroup";
@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();
List<Series> series = new ArrayList<Series>();
List<Fleet> fleets = new ArrayList<Fleet>();
@@ -45,7 +45,7 @@ public class LeaderboardsResourceCheckinAndOutTest extends AbstractJaxRsApiTest
private RegattaLeaderboard leaderboard;
@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();
Competitor c = createCompetitors(1).get(0);
competitor = racingEventService.getBaseDomainFactory().getOrCreateCompetitor(c.getId(), c.getName(),
@@ -57,9 +57,8 @@ public class LeaderboardsResourcePingMarkTest extends AbstractJaxRsApiTest {
" }";
@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();
mark = racingEventService.getBaseDomainFactory().getOrCreateMark("id", "name");
Regatta regatta = new RegattaImpl("regatta", new BoatClassImpl("49er", false), MillisecondsTimePoint.now(),
MillisecondsTimePoint.now(), Collections.singleton(new SeriesImpl("series", false, /* isFleetsCanRunInParallel */ true, Collections
@@ -42,7 +42,7 @@ public class LeaderboardsResourceTest extends AbstractJaxRsApiTest {
private String regattaBaseName = "TestRegatta";
@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();
}
@@ -33,7 +33,7 @@ public class RegattasResourceTest extends AbstractJaxRsApiTest {
private String regattaName = "TestRegatta";
@Before
public void setUp() {
public void setUp() throws Exception {
super.setUp();
List<Series> series = new ArrayList<Series>();
List<Fleet> fleets = new ArrayList<Fleet>();
@@ -30,9 +30,11 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.shiro.SecurityUtils;
@@ -79,7 +81,9 @@ import com.sap.sailing.server.operationaltransformation.CreateEvent;
import com.sap.sailing.server.operationaltransformation.CreateRegattaLeaderboard;
import com.sap.sailing.server.operationaltransformation.UpdateLeaderboardGroup;
import com.sap.sailing.server.operationaltransformation.UpdateSeries;
import com.sap.sse.InvalidDateException;
import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.common.impl.MillisecondsDurationImpl;
@@ -92,7 +96,6 @@ import com.sap.sse.util.ServiceTrackerFactory;
@Path("/v1/events")
public class EventsResource extends AbstractSailingServerResource {
private static final SimpleDateFormat shortDateFormat = new SimpleDateFormat("dd-MM-yyyy");
private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm");
private final boolean enforceSecurityChecks;
@@ -112,29 +115,35 @@ public class EventsResource extends AbstractSailingServerResource {
@Path("/createEvent")
@Consumes("text/plain")
@Produces("text/plain")
public Response createEvent(@FormParam("eventName") String eventNameParam,
@FormParam("eventDescription") String eventDescriptionParam,
@FormParam("startDate") String startDateParam,
@FormParam("endDate") String endDateParam,
@FormParam("venueName") String venueNameParam, // takes precedence over lat/lng used for reverse geo-coding
@FormParam("venueLat") String venueLat,
@FormParam("venueLng") String venueLng,
@FormParam("isPublic") String isPublicParam,
@FormParam("officialWebsiteURL") String officialWebsiteURLParam,
@FormParam("baseURL")String baseURLParam,
@FormParam("leaderboardGroupIds") List<String> leaderboardGroupIdsListParam,
@FormParam("createLeaderboardGroup") String createLeaderboardGroupParam,
@FormParam("createRegatta") String createRegattaParam,
@FormParam("boatClassName") String boatClassNameParam,
@FormParam("numberOfRaces") String numberOfRacesParam)
throws ParseException, NotFoundException, NumberFormatException, IOException, org.json.simple.parser.ParseException {
public Response createEvent(
@Context UriInfo uriInfo,
@FormParam("eventName") String eventNameParam,
@FormParam("eventdescription") String eventDescriptionParam,
@FormParam("startdate") String startDateParam,
@FormParam("startdateasmillis") Long startDateAsMillis,
@FormParam("enddate") String endDateParam,
@FormParam("enddateasmillis") Long endDateAsMillis,
@FormParam("venuename") String venueNameParam, // takes precedence over lat/lng used for reverse geo-coding
@FormParam("venuelat") String venueLat,
@FormParam("venuelng") String venueLng,
@FormParam("ispublic") String isPublicParam,
@FormParam("officialwebsiteurl") String officialWebsiteURLParam,
@FormParam("baseurl") String baseURLParam,
@FormParam("leaderboardgroupids") List<String> leaderboardGroupIdsListParam,
@FormParam("createleaderboardgroup") String createLeaderboardGroupParam,
@FormParam("createregatta") String createRegattaParam,
@FormParam("boatclassname") String boatClassNameParam,
@FormParam("numberofraces") String numberOfRacesParam) throws ParseException, NotFoundException,
NumberFormatException, IOException, org.json.simple.parser.ParseException, InvalidDateException {
if (enforceSecurityChecks) {
SecurityUtils.getSubject().checkPermission(Permission.EVENT.getStringPermission(Mode.CREATE));
}
Event event = validateAndCreateEvent(eventNameParam, eventDescriptionParam, startDateParam, endDateParam, venueNameParam,
Event event = validateAndCreateEvent(uriInfo, eventNameParam, eventDescriptionParam, startDateParam,
startDateAsMillis, endDateParam, endDateAsMillis, venueNameParam,
/* venue latitude */ venueLat, /* venue longitude */ venueLng, isPublicParam, officialWebsiteURLParam,
baseURLParam, leaderboardGroupIdsListParam, createLeaderboardGroupParam, createRegattaParam, boatClassNameParam, numberOfRacesParam);
return ok(event.getId().toString(), MediaType.TEXT_PLAIN);
baseURLParam, leaderboardGroupIdsListParam, createLeaderboardGroupParam, createRegattaParam,
boatClassNameParam, numberOfRacesParam);
return ok(event.getId().toString(), MediaType.TEXT_PLAIN);
}
@POST
@@ -261,10 +270,9 @@ public class EventsResource extends AbstractSailingServerResource {
return response;
}
private RegattaLeaderboard validateAndCreateRegatta(String regattaNameParam, String boatClassNameParam, String startDateParam,
String endDateParam, String scoringSchemeParam, UUID courseAreaId, String buoyZoneRadiusInHullLengthsParam,
String useStartTimeInterferenceParam, String controlTrackingFromStartAndFinishTimesParam, String rankingMetricParam,
List<Integer> leaderboardDiscardThresholdsParam, String numberOfRacesParam)
private RegattaLeaderboard validateAndCreateRegatta(String regattaNameParam, String boatClassNameParam, String scoringSchemeParam,
UUID courseAreaId, String buoyZoneRadiusInHullLengthsParam, String useStartTimeInterferenceParam, String controlTrackingFromStartAndFinishTimesParam,
String rankingMetricParam, List<Integer> leaderboardDiscardThresholdsParam, String numberOfRacesParam)
throws ParseException, NotFoundException {
boolean controlTrackingFromStartAndFinishTimes = controlTrackingFromStartAndFinishTimesParam == null ? false : Boolean.parseBoolean(controlTrackingFromStartAndFinishTimesParam);
boolean useStartTimeInterference = useStartTimeInterferenceParam == null ? true : Boolean.parseBoolean(useStartTimeInterferenceParam);
@@ -277,8 +285,6 @@ public class EventsResource extends AbstractSailingServerResource {
}
String regattaName = regattaNameParam;
String boatClassName = boatClassNameParam;
MillisecondsTimePoint startDate = startDateParam == null ? null : toMillisecondsTimePoint(startDateParam);
MillisecondsTimePoint endDate = endDateParam == null ? null : toMillisecondsTimePoint(endDateParam) ;
ScoringScheme scoringScheme = scoringSchemeParam == null ? createScoringScheme("LOW_POINT") : createScoringScheme(scoringSchemeParam);
RankingMetrics rankingMetric = rankingMetricParam == null ? createRankingMetric("ONE_DESIGN") : createRankingMetric(rankingMetricParam);
int[] leaderboardDiscardThresholds = leaderboardDiscardThresholdsParam == null ? new int[0] : leaderboardDiscardThresholdsParam.stream().mapToInt(i -> i).toArray();
@@ -287,7 +293,7 @@ public class EventsResource extends AbstractSailingServerResource {
createDefaultSeriesCreationParameters(regattaName, numberOfRaces));
UUID regattaId = UUID.randomUUID();
addRegatta(regattaName, controlTrackingFromStartAndFinishTimes, useStartTimeInterference,
buoyZoneRadiusInHullLengths, courseAreaId, boatClassName, startDate, endDate, scoringScheme,
buoyZoneRadiusInHullLengths, courseAreaId, boatClassName, /* startDate */ null, /* endDate */ null, scoringScheme,
rankingMetric, regattaId, regattaCreationParametersDTO, leaderboardDiscardThresholds, numberOfRaces);
final RegattaLeaderboard leaderboard = addLeaderboard(regattaName, leaderboardDiscardThresholds);
SeriesCreationParametersDTO defaultSeries = regattaCreationParametersDTO.getSeriesCreationParameters().get("Default");
@@ -296,11 +302,11 @@ public class EventsResource extends AbstractSailingServerResource {
return leaderboard;
}
private Event validateAndCreateEvent(String eventNameParam, String eventDescriptionParam, String startDateParam,
String endDateParam, String venueNameParam, String venueLat, String venueLng, String isPublicParam,
String officialWebsiteURLParam, String baseURLParam, List<String> leaderboardGroupIdsListParam,
String createLeaderboardGroupParam, String createRegattaParam, String boatClassNameParam, String numberOfRacesParam)
throws ParseException, NotFoundException, NumberFormatException, IOException, org.json.simple.parser.ParseException {
private Event validateAndCreateEvent(UriInfo uriInfo, String eventNameParam, String eventDescriptionParam,
String startDateParam, Long startDateAsMillis, String endDateParam, Long endDateAsMillis, String venueNameParam,
String venueLat, String venueLng, String isPublicParam,
String officialWebsiteURLParam, String baseURLParam, List<String> leaderboardGroupIdsListParam, String createLeaderboardGroupParam, String createRegattaParam, String boatClassNameParam, String numberOfRacesParam)
throws ParseException, NotFoundException, NumberFormatException, IOException, org.json.simple.parser.ParseException, InvalidDateException {
boolean isPublic = isPublicParam == null ? false : Boolean.parseBoolean(isPublicParam);
boolean createRegatta = createRegattaParam == null ? true : Boolean.parseBoolean(createRegattaParam);
boolean createLeaderboardGroup = createLeaderboardGroupParam == null ? true : Boolean.parseBoolean(createLeaderboardGroupParam);
@@ -311,10 +317,10 @@ public class EventsResource extends AbstractSailingServerResource {
}
String boatClassName = boatClassNameParam == null ? null : getBoatClassDisplayName(boatClassNameParam);
String eventDescription = eventDescriptionParam == null ? eventName : eventDescriptionParam;
MillisecondsTimePoint startDate = startDateParam == null ? now() : toMillisecondsTimePoint(startDateParam);
MillisecondsTimePoint endDate = endDateParam == null ? new MillisecondsTimePoint(addOneWeek(startDate.asDate())): toMillisecondsTimePoint(endDateParam) ;
final TimePoint startDate = parseTimePoint(startDateParam, startDateAsMillis, now());
final TimePoint endDate = parseTimePoint(endDateParam, endDateAsMillis, new MillisecondsTimePoint(addOneWeek(startDate.asDate())));
URL officialWebsiteURL = officialWebsiteURLParam == null ? null : toURL(officialWebsiteURLParam);
URL baseURL = baseURLParam == null ? null : toURL(baseURLParam);
URL baseURL = baseURLParam == null ? uriInfo.getBaseUri().toURL() : toURL(baseURLParam);
List<UUID> leaderboardGroupIds = leaderboardGroupIdsListParam == null ? new ArrayList<UUID>() : toUUIDList(leaderboardGroupIdsListParam);
UUID eventId = UUID.randomUUID();
// ignoring sailorsInfoWebsiteURLs, images, videos
@@ -334,10 +340,10 @@ public class EventsResource extends AbstractSailingServerResource {
}
if (createRegatta) {
final RegattaLeaderboard leaderboard = validateAndCreateRegatta(event.getName(), boatClassName,
/* startDateParam */ null, /* endDateParam */ null, /* scoringSchemeParam */ null,
courseArea.getId(), /* buoyZoneRadiusInHullLengthsParam */ null,
/* scoringSchemeParam */ null, courseArea.getId(), /* buoyZoneRadiusInHullLengthsParam */ null,
/* useStartTimeInterferenceParam */ null, /* controlTrackingFromStartAndFinishTimesParam */ null,
/* rankingMetricParam */ null, /* leaderboardDiscardThresholdsParam */ null, numberOfRacesParam);
/* rankingMetricParam */ null, /* leaderboardDiscardThresholdsParam */ null,
numberOfRacesParam);
if (leaderboardGroup != null) {
getService().apply(new UpdateLeaderboardGroup(leaderboardGroup.getName(), leaderboardGroup.getName(), leaderboardGroup.getDescription(),
leaderboardGroup.getDisplayName(), Collections.singletonList(leaderboard.getName()),
@@ -421,7 +427,7 @@ public class EventsResource extends AbstractSailingServerResource {
}
private Event createEvent(String eventName, String eventDescription, String venueName, boolean isPublic,
MillisecondsTimePoint startDate, MillisecondsTimePoint endDate, URL officialWebsiteURL, URL baseURL,
TimePoint startDate, TimePoint endDate, URL officialWebsiteURL, URL baseURL,
List<UUID> leaderboardGroupIds, UUID eventId, Map<Locale, URL> sailorsInfoWebsiteURLs,
Iterable<ImageDescriptor> images, Iterable<VideoDescriptor> videos) {
if (enforceSecurityChecks) {
@@ -541,14 +547,6 @@ public class EventsResource extends AbstractSailingServerResource {
return c.getTime();
}
private MillisecondsTimePoint toMillisecondsTimePoint(String startDateParam) throws ParseException {
try {
return new MillisecondsTimePoint(shortDateFormat.parse(startDateParam));
} catch (ParseException e) {
throw new ParseException(ExceptionManager.invalidDateFormatMsg(startDateParam),0);
}
}
private URL toURL(String url) throws MalformedURLException{
try {
return new URL(url);
@@ -0,0 +1,74 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href='../../../../sailing-fontface-1.0.cache.css' media='screen' rel='stylesheet' title='Default stylesheet' type='text/css' />
<link href='../../../main.css' media='screen' rel='stylesheet' title='Default stylesheet' type='text/css' />
<link rel='icon' href='../../../../sap.ico' type='image/x-icon'>
<title>SAP Sailing Analytics Webservices API Version 1.0</title>
</head>
<body>
<h1>SAP Sailing Analytics Webservices API Version 1.0</h1>
<h2>URL: /api/v1/events/createEvent</h2>
<b>Description:</b>
<p>Creates a new event. Optional parameters control how "deep" the structure is to be created, regarding
a default regatta, leaderboard and leaderboard group. Furthermore, optional parameters control some of
the most important attributes of the objects created. Reasonable defaults are supposed to make the
consumption of this service simple.</p>
<br/>
<table>
<tr>
<td>Webservice Type:</td>
<td>POST</td>
</tr>
<tr>
<td>Output format:</td>
<td>{event-id}</td>
</tr>
<tr>
<td>Mandatory parameters:</td>
<td>None</td>
</tr>
<tr>
<td>Optional parameters:</td>
<td>
<div>eventname name of the event; defaults to a name constructed from the user name
and a timestamp</div>
<div>eventdescription the event description text; defaults to the event name</div>
<div>startdate the event start date in ISO format (e.g., 2017-08-17T10:00:00+0200)</div>
<div>startdateasmillis (alternative to startdate) the event start date in milliseconds since the epoch (Unix time)</div>
<div>enddate the event end date in ISO format (e.g., 2017-08-19T20:00:00+0200)</div>
<div>enddateasmillis (alternative to enddate) the event end date in milliseconds since the epoch (Unix time)</div>
<div>venuename the name of the venue; if not provided, venuelat and venuelng can be used, and the name of
the town nearest to the coordinates will be used as a venue name then</div>
<div>venuelat decimal degrees; can be provided instead of a venuename, together with venuelng encoding the location of the event</div>
<div>venuelng decimal degrees; can be provided instead of a venuename, together with venuelat encoding the location of the event</div>
<div>ispublic a booleann value, true/false, telling whether the event shall be public</div>
<div>officialwebsiteurl URL of the official web site</div>
<div>baseurl event base URL; will be used in e-mails sent out, e.g., for registration; defaults to the base URL of this request</div>
<div>leaderboardgroupids IDs of the leaderboard groups to add to the new event</div>
<div>createleaderboardgroup boolean; if true, a new leaderboard group will be created, named and described like the
event; the new leaderboard group will be added to the event</div>
<div>createregatta boolean; if true, a new regatta will be created, named like the event; in this case, providing
a value for boatclassname becomes mandatory; the regatta will have a "Default" series with a single "Default"
fleet; a regatta leaderboard is created, and if a leaderboard group
was also created, the regatta leaderboard will automatically be added to the new leaderboard group</div>
<div>boatclassname must be provided if createretatta=true; can be the display name or an alias name of a boat class to
use for the new regatta</div>
<div>numberofraces tells how many races shall be created in the default series; by default the series remains empty</div>
</td>
</tr>
<tr>
<td>Request method:</td>
<td>POST</td>
</tr>
<tr>
<td>Example:</td>
<td>curl -X POST -H "Authorization: Bearer w9YSIfr/Zf6a127SZDddkhdAtQuuv0Jm1PSXlo1Yvd0=" "http://dev.sapsailing.com/sailingserver/api/v1/events/createEvent"</td>
</tr>
</table>
<div style="height: 1em;"></div>
<a href="index.html">Back to Web Service Overview</a>
</body>
</html>
@@ -32,6 +32,10 @@ name to make sure you get to the event you're interested in.
</tr>
</thead>
<tbody>
<tr>
<td><a href="eventsCreateEvent.html">/api/v1/events/createEvent</a></td>
<td>Creates a new event</td>
</tr>
<tr>
<td><a href="eventsGetDoc.html">/api/v1/events</a></td>
<td>Gets all events</td>