bug5442: simplified the check for deviceUuid present for creating the device mapping

This commit is contained in:
Axel Uhl committed 2020-11-27 20:16:15 +01:00
1 parent b0b129ce7f
commit 8735ad84ff
1 file changed
+2 -3
@@ -575,7 +575,6 @@ public class RegattasResource extends AbstractSailingServerResource {
if (!getSecurityService().hasCurrentUserUpdatePermission(regatta) && (!skipPermissionChecksBasedOnCorrectRegattaSecretProvided || !regatta.getCompetitorRegistrationType().isOpen())) {
return getBadRegattaRegistrationTypeErrorResponse(regattaName);
}
boolean checkInCompetitor = false; // whether to create a RegattaLogDeviceCompetitorMappingEvent in the RegattaLog; requires non-null deviceUuid to be provided
String eCompetitorName = null, eCompetitorShortName = null, eCompetitorEmail = null;
if (competitorName == null && user == null) {
return getBadRegattaRegistrationValidationErrorResponse("No competitor name specified and no user authenticated; can't derive competitor name");
@@ -586,7 +585,7 @@ public class RegattasResource extends AbstractSailingServerResource {
eCompetitorEmail = competitorEmail == null ? user != null ? user.getEmail() : null : competitorEmail;
// Check regattalog if device has been already registered to this regatta
boolean duplicateDeviceId = false;
if (checkInCompetitor) {
if (deviceUuid != null) {
final RegattaLog regattaLog = regatta.getRegattaLog();
regattaLog.lockForRead();
try {
@@ -673,7 +672,7 @@ public class RegattasResource extends AbstractSailingServerResource {
regatta.registerCompetitor(competitor);
response = Response.ok(streamingOutput(CompetitorJsonSerializer.create().serialize(competitor)))
.header("Content-Type", MediaType.APPLICATION_JSON + ";charset=UTF-8").build();
if (checkInCompetitor) {
if (deviceUuid != null) {
final DeviceIdentifier device = new SmartphoneUUIDIdentifierImpl(UUID.fromString(deviceUuid));
final TimePoint now = MillisecondsTimePoint.now();
RegattaLogDeviceMappingEventImpl<Competitor> event = new RegattaLogDeviceCompetitorMappingEventImpl(now,