fix cache bug within ClientConnection request / more tests
This commit is contained in:
parent
eb71c4bcc4
commit
bffdcc07e3
10 changed files with 141 additions and 29 deletions
|
@ -69,7 +69,7 @@ public class ClientConnectionData {
|
||||||
while (i1.hasNext()) {
|
while (i1.hasNext()) {
|
||||||
final IndicatorValue iv1 = i1.next();
|
final IndicatorValue iv1 = i1.next();
|
||||||
final IndicatorValue iv2 = i2.next();
|
final IndicatorValue iv2 = i2.next();
|
||||||
if (iv1.getType() != iv2.getType() || Math.round(iv1.getValue() - iv2.getValue()) < .0001) {
|
if (iv1.getType() != iv2.getType() || iv1.getValue() != iv2.getValue()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,6 +165,27 @@ public class AttributeMapping {
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
final StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("AttributeMapping [templateId=");
|
||||||
|
builder.append(this.templateId);
|
||||||
|
builder.append(", attributeIdMapping=");
|
||||||
|
builder.append(this.attributeIdMapping);
|
||||||
|
builder.append(", attributeNameIdMapping=");
|
||||||
|
builder.append(this.attributeNameIdMapping);
|
||||||
|
builder.append(", orientationAttributeMapping=");
|
||||||
|
builder.append(this.orientationAttributeMapping);
|
||||||
|
builder.append(", orientationAttributeNameMapping=");
|
||||||
|
builder.append(this.orientationAttributeNameMapping);
|
||||||
|
builder.append(", childAttributeMapping=");
|
||||||
|
builder.append(this.childAttributeMapping);
|
||||||
|
builder.append(", attributeGroupMapping=");
|
||||||
|
builder.append(this.attributeGroupMapping);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
private List<ConfigurationAttribute> getChildAttributes(final ConfigurationAttribute attribute) {
|
private List<ConfigurationAttribute> getChildAttributes(final ConfigurationAttribute attribute) {
|
||||||
return this.attributeIdMapping
|
return this.attributeIdMapping
|
||||||
.values()
|
.values()
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
|
||||||
private final InputFieldBuilderSupplier inputFieldBuilderSupplier;
|
private final InputFieldBuilderSupplier inputFieldBuilderSupplier;
|
||||||
private final Collection<ValueChangeRule> valueChangeRules;
|
private final Collection<ValueChangeRule> valueChangeRules;
|
||||||
|
|
||||||
protected ExamConfigurationServiceImpl(
|
public ExamConfigurationServiceImpl(
|
||||||
final RestService restService,
|
final RestService restService,
|
||||||
final JSONMapper jsonMapper,
|
final JSONMapper jsonMapper,
|
||||||
final WidgetFactory widgetFactory,
|
final WidgetFactory widgetFactory,
|
||||||
|
@ -109,7 +109,7 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
|
||||||
.getBuilder(GetOrientations.class)
|
.getBuilder(GetOrientations.class)
|
||||||
.withQueryParam(Orientation.FILTER_ATTR_TEMPLATE_ID, String.valueOf(templateId))
|
.withQueryParam(Orientation.FILTER_ATTR_TEMPLATE_ID, String.valueOf(templateId))
|
||||||
.call()
|
.call()
|
||||||
.onError(t -> log.error("Failed to get all Orientation of template {}", templateId))
|
.onError(t -> log.error("Failed to get all Orientation of template {}", templateId, t))
|
||||||
.getOrThrow());
|
.getOrThrow());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,10 @@ public interface ClientConnectionDAO extends EntityDAO<ClientConnection, ClientC
|
||||||
@CacheEvict(cacheNames = CONNECTION_TOKENS_CACHE, allEntries = true)
|
@CacheEvict(cacheNames = CONNECTION_TOKENS_CACHE, allEntries = true)
|
||||||
Result<ClientConnection> createNew(ClientConnection data);
|
Result<ClientConnection> createNew(ClientConnection data);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CacheEvict(cacheNames = CONNECTION_TOKENS_CACHE, allEntries = true)
|
||||||
|
Result<ClientConnection> save(ClientConnection data);
|
||||||
|
|
||||||
/** Deletes the given ClientConnection data.
|
/** Deletes the given ClientConnection data.
|
||||||
*
|
*
|
||||||
* This evicts all entries from the CONNECTION_TOKENS_CACHE.
|
* This evicts all entries from the CONNECTION_TOKENS_CACHE.
|
||||||
|
|
|
@ -134,15 +134,12 @@ final class MockupLmsAPITemplate implements LmsAPITemplate {
|
||||||
if (StringUtils.isNoneBlank(externalAddressAlias)) {
|
if (StringUtils.isNoneBlank(externalAddressAlias)) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Found external address alias: {}", externalAddressAlias);
|
|
||||||
}
|
|
||||||
|
|
||||||
final String _externalStartURI =
|
final String _externalStartURI =
|
||||||
this.webserviceInfo.getHttpScheme() +
|
this.webserviceInfo.getHttpScheme() +
|
||||||
"://" + externalAddressAlias + "/api/";
|
"://" + externalAddressAlias + "/api/";
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
log.info("Use external address for course access: {}", _externalStartURI);
|
log.debug("Use external address for course access: {}", _externalStartURI);
|
||||||
|
}
|
||||||
|
|
||||||
return new QuizData(
|
return new QuizData(
|
||||||
quizData.id, quizData.institutionId, quizData.lmsSetupId, quizData.lmsType,
|
quizData.id, quizData.institutionId, quizData.lmsSetupId, quizData.lmsType,
|
||||||
|
|
|
@ -259,11 +259,6 @@ final class OpenEdxLmsAPITemplate implements LmsAPITemplate {
|
||||||
String _externalStartURI = lmsSetup.lmsApiUrl + OPEN_EDX_DEFAULT_COURSE_START_URL_PREFIX;
|
String _externalStartURI = lmsSetup.lmsApiUrl + OPEN_EDX_DEFAULT_COURSE_START_URL_PREFIX;
|
||||||
if (StringUtils.isNoneBlank(externalAddressAlias)) {
|
if (StringUtils.isNoneBlank(externalAddressAlias)) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Found external address alias: {}", externalAddressAlias);
|
|
||||||
}
|
|
||||||
|
|
||||||
final URL url = new URL(lmsSetup.lmsApiUrl);
|
final URL url = new URL(lmsSetup.lmsApiUrl);
|
||||||
final int port = url.getPort();
|
final int port = url.getPort();
|
||||||
_externalStartURI = this.webserviceInfo.getHttpScheme() +
|
_externalStartURI = this.webserviceInfo.getHttpScheme() +
|
||||||
|
@ -273,7 +268,9 @@ final class OpenEdxLmsAPITemplate implements LmsAPITemplate {
|
||||||
: StringUtils.EMPTY)
|
: StringUtils.EMPTY)
|
||||||
+ Constants.URL_PATH_SEPARATOR;
|
+ Constants.URL_PATH_SEPARATOR;
|
||||||
|
|
||||||
log.info("Use external address for course access: {}", _externalStartURI);
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Use external address for course access: {}", _externalStartURI);
|
||||||
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log.error("Failed to create external address from alias: ", e);
|
log.error("Failed to create external address from alias: ", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
|
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
|
||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
@ -50,7 +51,12 @@ public class APIExceptionHandler extends ResponseEntityExceptionHandler {
|
||||||
final HttpStatus status,
|
final HttpStatus status,
|
||||||
final WebRequest request) {
|
final WebRequest request) {
|
||||||
|
|
||||||
log.error("Unexpected generic error catched at the API endpoint: ", ex);
|
if (ex instanceof AccessDeniedException) {
|
||||||
|
log.warn("Access denied: ", ex);
|
||||||
|
} else {
|
||||||
|
log.error("Unexpected generic error catched at the API endpoint: ", ex);
|
||||||
|
}
|
||||||
|
|
||||||
final List<APIMessage> errors = Arrays.asList(APIMessage.ErrorMessage.GENERIC.of(ex.getMessage()));
|
final List<APIMessage> errors = Arrays.asList(APIMessage.ErrorMessage.GENERIC.of(ex.getMessage()));
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
errors,
|
errors,
|
||||||
|
@ -145,6 +151,16 @@ public class APIExceptionHandler extends ResponseEntityExceptionHandler {
|
||||||
.createErrorResponse(ex.getMessage());
|
.createErrorResponse(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(AccessDeniedException.class)
|
||||||
|
public ResponseEntity<Object> handleUnexpected(
|
||||||
|
final AccessDeniedException ex,
|
||||||
|
final WebRequest request) {
|
||||||
|
|
||||||
|
log.warn("Access denied: ", ex);
|
||||||
|
return APIMessage.ErrorMessage.FORBIDDEN
|
||||||
|
.createErrorResponse(ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionHandler(Exception.class)
|
@ExceptionHandler(Exception.class)
|
||||||
public ResponseEntity<Object> handleUnexpected(
|
public ResponseEntity<Object> handleUnexpected(
|
||||||
final Exception ex,
|
final Exception ex,
|
||||||
|
|
|
@ -251,7 +251,6 @@ public class ExamAPI_V1_Controller {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Updated connection: {}", connection);
|
log.debug("Updated connection: {}", connection);
|
||||||
}
|
}
|
||||||
//handshakeUpdate(connectionToken, Long.valueOf(examId), null, principal, request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final ServletOutputStream outputStream = response.getOutputStream();
|
final ServletOutputStream outputStream = response.getOutputStream();
|
||||||
|
|
|
@ -78,8 +78,8 @@ public class HTTPClientBot {
|
||||||
|
|
||||||
public HTTPClientBot(final Map<String, String> args) {
|
public HTTPClientBot(final Map<String, String> args) {
|
||||||
|
|
||||||
this.webserviceAddress = args.getOrDefault("webserviceAddress", "http://ralph.ethz.ch:8080");
|
//this.webserviceAddress = args.getOrDefault("webserviceAddress", "http://ralph.ethz.ch:8080");
|
||||||
//this.webserviceAddress = args.getOrDefault("webserviceAddress", "http://localhost:8080");
|
this.webserviceAddress = args.getOrDefault("webserviceAddress", "http://localhost:8080");
|
||||||
|
|
||||||
this.accessTokenEndpoint = args.getOrDefault("accessTokenEndpoint", "/oauth/token");
|
this.accessTokenEndpoint = args.getOrDefault("accessTokenEndpoint", "/oauth/token");
|
||||||
this.clientId = args.getOrDefault("clientId", "TO_SET");
|
this.clientId = args.getOrDefault("clientId", "TO_SET");
|
||||||
|
@ -147,11 +147,12 @@ public class HTTPClientBot {
|
||||||
headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
||||||
this.connectBody = new HttpEntity<>(API.PARAM_INSTITUTION_ID +
|
this.connectBody = new HttpEntity<>(API.PARAM_INSTITUTION_ID +
|
||||||
Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR +
|
Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR +
|
||||||
HTTPClientBot.this.institutionId +
|
HTTPClientBot.this.institutionId
|
||||||
Constants.FORM_URL_ENCODED_SEPARATOR +
|
// + Constants.FORM_URL_ENCODED_SEPARATOR
|
||||||
API.EXAM_API_PARAM_EXAM_ID +
|
// + API.EXAM_API_PARAM_EXAM_ID
|
||||||
Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR +
|
// + Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR
|
||||||
HTTPClientBot.this.examId,
|
// + HTTPClientBot.this.examId
|
||||||
|
,
|
||||||
headers);
|
headers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue