fixes and ping preformance
This commit is contained in:
parent
b15ee062cf
commit
a360bfffc8
4 changed files with 72 additions and 21 deletions
|
@ -134,22 +134,10 @@ public final class MultiSelectionCombo extends Composite implements Selection {
|
||||||
|
|
||||||
Arrays.asList(StringUtils.split(keys, Constants.LIST_SEPARATOR))
|
Arrays.asList(StringUtils.split(keys, Constants.LIST_SEPARATOR))
|
||||||
.stream()
|
.stream()
|
||||||
.map(this::itemForName)
|
.map(this::itemForId)
|
||||||
.forEach(this::addSelection);
|
.forEach(this::addSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tuple<String> itemForName(final String name) {
|
|
||||||
final Optional<Tuple<String>> findFirst = this.availableValues
|
|
||||||
.stream()
|
|
||||||
.filter(it -> it._2 != null && it._2.equals(name))
|
|
||||||
.findFirst();
|
|
||||||
if (findFirst.isPresent()) {
|
|
||||||
return findFirst.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSelectionValue() {
|
public String getSelectionValue() {
|
||||||
if (this.selectedValues.isEmpty()) {
|
if (this.selectedValues.isEmpty()) {
|
||||||
|
@ -237,4 +225,28 @@ public final class MultiSelectionCombo extends Composite implements Selection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Tuple<String> itemForName(final String name) {
|
||||||
|
final Optional<Tuple<String>> findFirst = this.availableValues
|
||||||
|
.stream()
|
||||||
|
.filter(it -> it._2 != null && it._2.equals(name))
|
||||||
|
.findFirst();
|
||||||
|
if (findFirst.isPresent()) {
|
||||||
|
return findFirst.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Tuple<String> itemForId(final String id) {
|
||||||
|
final Optional<Tuple<String>> findFirst = this.availableValues
|
||||||
|
.stream()
|
||||||
|
.filter(it -> it._1 != null && it._1.equals(id))
|
||||||
|
.findFirst();
|
||||||
|
if (findFirst.isPresent()) {
|
||||||
|
return findFirst.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,8 @@ public class SebInstructionServiceImpl implements SebInstructionService {
|
||||||
|
|
||||||
loadInstruction()
|
loadInstruction()
|
||||||
.onError(
|
.onError(
|
||||||
error -> log.error("Failed to initialize and load persistent storage SEB client instructions: ",
|
error -> log.error(
|
||||||
|
"Failed to initialize and load persistent storage SEB client instructions: ",
|
||||||
error));
|
error));
|
||||||
|
|
||||||
if (this.instructions.size() > 0) {
|
if (this.instructions.size() > 0) {
|
||||||
|
@ -116,6 +117,9 @@ public class SebInstructionServiceImpl implements SebInstructionService {
|
||||||
@Override
|
@Override
|
||||||
public String getInstructionJSON(final String connectionToken) {
|
public String getInstructionJSON(final String connectionToken) {
|
||||||
refreshCache();
|
refreshCache();
|
||||||
|
if (this.instructions.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final ClientInstructionRecord clientInstruction = this.instructions.remove(connectionToken);
|
final ClientInstructionRecord clientInstruction = this.instructions.remove(connectionToken);
|
||||||
if (clientInstruction != null) {
|
if (clientInstruction != null) {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import java.security.Principal;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -26,6 +25,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
@ -129,7 +129,8 @@ public class ExamAPI_V1_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
log.warn("There are no currently running exams for institution: {}. SEB connection creation denied", institutionId);
|
log.warn("There are no currently running exams for institution: {}. SEB connection creation denied",
|
||||||
|
institutionId);
|
||||||
throw new IllegalStateException("There are no currently running exams");
|
throw new IllegalStateException("There are no currently running exams");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,22 +307,48 @@ public class ExamAPI_V1_Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final ResponseEntity<String> EMPTY_PING_RESPONSE = ResponseEntity
|
||||||
|
.ok()
|
||||||
|
.build();
|
||||||
|
|
||||||
@RequestMapping(
|
@RequestMapping(
|
||||||
path = API.EXAM_API_PING_ENDPOINT,
|
path = API.EXAM_API_PING_ENDPOINT,
|
||||||
method = RequestMethod.POST,
|
method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
|
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
|
||||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public CompletableFuture<String> ping(
|
public ResponseEntity<String> ping(
|
||||||
@RequestHeader(name = API.EXAM_API_SEB_CONNECTION_TOKEN, required = true) final String connectionToken,
|
@RequestHeader(name = API.EXAM_API_SEB_CONNECTION_TOKEN, required = true) final String connectionToken,
|
||||||
@RequestParam(name = API.EXAM_API_PING_TIMESTAMP, required = true) final long timestamp,
|
@RequestParam(name = API.EXAM_API_PING_TIMESTAMP, required = true) final long timestamp,
|
||||||
@RequestParam(name = API.EXAM_API_PING_NUMBER, required = false) final int pingNumber) {
|
@RequestParam(name = API.EXAM_API_PING_NUMBER, required = false) final int pingNumber) {
|
||||||
|
|
||||||
return CompletableFuture.supplyAsync(
|
final String notifyPing = this.sebClientConnectionService
|
||||||
() -> this.sebClientConnectionService
|
.notifyPing(connectionToken, timestamp, pingNumber);
|
||||||
.notifyPing(connectionToken, timestamp, pingNumber),
|
|
||||||
this.executor);
|
if (notifyPing == null) {
|
||||||
|
return EMPTY_PING_RESPONSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity
|
||||||
|
.ok()
|
||||||
|
.body(notifyPing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @RequestMapping(
|
||||||
|
// path = API.EXAM_API_PING_ENDPOINT,
|
||||||
|
// method = RequestMethod.POST,
|
||||||
|
// consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
|
||||||
|
// produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
|
// public CompletableFuture<String> ping(
|
||||||
|
// @RequestHeader(name = API.EXAM_API_SEB_CONNECTION_TOKEN, required = true) final String connectionToken,
|
||||||
|
// @RequestParam(name = API.EXAM_API_PING_TIMESTAMP, required = true) final long timestamp,
|
||||||
|
// @RequestParam(name = API.EXAM_API_PING_NUMBER, required = false) final int pingNumber) {
|
||||||
|
//
|
||||||
|
// return CompletableFuture.supplyAsync(
|
||||||
|
// () -> this.sebClientConnectionService
|
||||||
|
// .notifyPing(connectionToken, timestamp, pingNumber),
|
||||||
|
// this.executor);
|
||||||
|
// }
|
||||||
|
|
||||||
@RequestMapping(
|
@RequestMapping(
|
||||||
path = API.EXAM_API_EVENT_ENDPOINT,
|
path = API.EXAM_API_EVENT_ENDPOINT,
|
||||||
method = RequestMethod.POST,
|
method = RequestMethod.POST,
|
||||||
|
|
|
@ -339,6 +339,14 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
.flatMap(this.examAdminService::applyAdditionalSEBRestrictions);
|
.flatMap(this.examAdminService::applyAdditionalSEBRestrictions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Result<Exam> notifySaved(final Exam entity) {
|
||||||
|
return Result.tryCatch(() -> {
|
||||||
|
this.examSessionService.flushCache(entity);
|
||||||
|
return entity;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Result<Exam> validForCreate(final Exam entity) {
|
protected Result<Exam> validForCreate(final Exam entity) {
|
||||||
return super.validForCreate(entity)
|
return super.validForCreate(entity)
|
||||||
|
|
Loading…
Reference in a new issue