Skip to content

Commit

Permalink
Merged in bugfix/SHIBUI-999 (pull request #235)
Browse files Browse the repository at this point in the history
[SHIBUI-999]
  • Loading branch information
Bill Smith authored and Jonathan Johnson committed Nov 14, 2018
2 parents 9b51a67 + f849c91 commit 04949ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,21 @@ class RelyingPartyOverridesJsonSchemaValidatingControllerAdvice extends RequestB
}

@Override
Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
def relyingPartyOverrides = EntityDescriptorRepresentation.cast(body).relyingPartyOverrides
def relyingPartyOverridesJson = Json.make([relyingPartyOverrides: relyingPartyOverrides])
HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter,
Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
throws IOException {
def bytes = inputMessage.body.bytes
def schema = Json.schema(this.jsonSchemaLocation.uri)
def validationResult = schema.validate(relyingPartyOverridesJson)

def stream = new ByteArrayInputStream(bytes)
def validationResult = schema.validate(Json.read(stream.getText()))
if (!validationResult.at('ok')) {
throw new JsonSchemaValidationFailedException(validationResult.at('errors').asList())
}
body
return [
getBody: { new ByteArrayInputStream(bytes) },
getHeaders: { inputMessage.headers }
] as HttpInputMessage
}

@ExceptionHandler(JsonSchemaValidationFailedException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,21 @@ public List<Attribute> getAttributeListFromRelyingPartyOverridesRepresentation(M
switch (ModelRepresentationConversions.AttributeTypes.valueOf(overrideProperty.getDisplayType().toUpperCase())) {
case BOOLEAN:
if (overrideProperty.getPersistType() != null &&
!overrideProperty.getPersistType().equalsIgnoreCase("boolean")) {
!overrideProperty.getPersistType().equalsIgnoreCase("boolean") &&
((entry.getValue() instanceof Boolean && (Boolean)entry.getValue()) || Boolean.valueOf((String)entry.getValue()))) {
list.add(attributeUtility.createAttributeWithStringValues(overrideProperty.getAttributeName(),
overrideProperty.getAttributeFriendlyName(),
(String) entry.getValue()));
overrideProperty.getPersistValue()));
} else {
list.add(attributeUtility.createAttributeWithBooleanValue(overrideProperty.getAttributeName(),
overrideProperty.getAttributeFriendlyName(),
(Boolean) entry.getValue()));
if (entry.getValue() instanceof String) {
list.add(attributeUtility.createAttributeWithBooleanValue(overrideProperty.getAttributeName(),
overrideProperty.getAttributeFriendlyName(),
Boolean.valueOf((String) entry.getValue())));
} else {
list.add(attributeUtility.createAttributeWithBooleanValue(overrideProperty.getAttributeName(),
overrideProperty.getAttributeFriendlyName(),
(Boolean) entry.getValue()));
}
}
break;
case INTEGER:
Expand Down

0 comments on commit 04949ba

Please sign in to comment.