add a registrationSecret, if none is given in the creationCall, also do

return the used secret in the response, adjusted doc accordingly
This commit is contained in:
Kai Börnert committed 2019-02-07 11:17:56 +01:00
1 parent 4c173f5221
commit a604bb9d87
2 files changed
+17 -2

No files matched your search

@@ -18,6 +18,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Spliterator;
import java.util.UUID;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
@@ -104,6 +105,7 @@ import com.sap.sse.shared.media.VideoDescriptor;
@Path("/v1/events")
public class EventsResource extends AbstractSailingServerResource {
private static final Logger logger = Logger.getLogger(EventsResource.class.getName());
private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -170,6 +172,8 @@ public class EventsResource extends AbstractSailingServerResource {
}
if (eventAndLeaderboardGroupAndLeaderboard.getC() != null) {
jsonResponse.put("regatta", eventAndLeaderboardGroupAndLeaderboard.getC().getRegatta().getName());
jsonResponse.put("registrationSecret",
eventAndLeaderboardGroupAndLeaderboard.getC().getRegatta().getRegistrationLinkSecret());
jsonResponse.put("leaderboard", eventAndLeaderboardGroupAndLeaderboard.getC().getName());
}
response = ok(jsonResponse.toJSONString(), MediaType.APPLICATION_JSON);
@@ -354,6 +358,9 @@ public class EventsResource extends AbstractSailingServerResource {
if (regattaNameParam == null) {
throw new IllegalArgumentException(ExceptionManager.parameterRequiredMsg("regattaName"));
}
if (competitorRegistrationSecret == null) {
throw new IllegalArgumentException(ExceptionManager.parameterRequiredMsg("competitorRegistrationSecret"));
}
if (boatClassNameParam == null) {
throw new IllegalArgumentException(ExceptionManager.parameterRequiredMsg("boatClassName"));
}
@@ -458,11 +465,18 @@ public class EventsResource extends AbstractSailingServerResource {
}
final RegattaLeaderboard leaderboard;
if (createRegatta) {
String localCompetitorRegistrationSecret = competitorRegistrationSecret;
if (localCompetitorRegistrationSecret == null) {
localCompetitorRegistrationSecret = UUID.randomUUID().toString();
logger.warning(
"Got request that created a new Regatta without a registrationSecret, generated a new one");
}
leaderboard = validateAndCreateRegatta(event.getName(), boatClassName,
/* scoringSchemeParam */ null, courseArea.getId(), /* buoyZoneRadiusInHullLengthsParam */ null,
/* useStartTimeInterferenceParam */ null, /* controlTrackingFromStartAndFinishTimesParam */ null,
/* rankingMetricParam */ null, /* leaderboardDiscardThresholdsParam */ null,
numberOfRacesParam, canBoatsOfCompetitorsChangePerRace, competitorRegistrationType, competitorRegistrationSecret);
numberOfRacesParam, canBoatsOfCompetitorsChangePerRace, competitorRegistrationType,
localCompetitorRegistrationSecret);
if (leaderboardGroup != null) {
getService().apply(new UpdateLeaderboardGroup(leaderboardGroup.getName(), leaderboardGroup.getName(),
leaderboardGroup.getDescription(), leaderboardGroup.getDisplayName(),
@@ -60,7 +60,7 @@ consumption of this service simple.</p>
<div>numberofraces tells how many races shall be created in the default series; by default the series remains empty</div>
<div>canBoatsOfCompetitorsChangePerRace If true, boats and competitors can change per race, also it is necessary to register them in this case for each race!</div>
<div>competitorRegistrationType defines the registration type for competitor self registration to the regatta. Allowed values are CLOSED (no self registration) or OPEN_UNMODERATED (self registration for competitors is allowed)</div>
<div>secret a string that is used to verify competitor self registrations</div>
<div>secret a string that is used to verify competitor self registrations, if not given the server will generate one</div>
</td>
</tr>
<tr>
@@ -79,6 +79,7 @@ consumption of this service simple.</p>
"leaderboardgroupid":99859e24-2fe0-4c4e-bcbb-2df272a26c2c,
"regatta":"Session admin 24-08-2017 16:46:40",
"leaderboard":"Session admin 24-08-2017 16:46:40"
"secret":"123456789-fd82-45f6-a0a3-2920eb3307cb",
}
</pre></td>
</tr>