You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Konrad Windszus (JIRA)" <ji...@apache.org> on 2017/02/20 14:25:44 UTC

[jira] [Comment Edited] (SLING-6531) Do not always throw exceptions to propagate information about failed validations

    [ https://issues.apache.org/jira/browse/SLING-6531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15874594#comment-15874594 ] 

Konrad Windszus edited comment on SLING-6531 at 2/20/17 2:25 PM:
-----------------------------------------------------------------

The question is, how can the information about the validation be propagated without leveraging an exception, without having a request at hand and without leveraging a ThreadLocal (compare with http://apache-sling.73963.n3.nabble.com/RTC-ThreadLocal-for-getting-current-request-in-sling-td4042387.html). My proposal is:
Attach the {{ValidationResult}} to the {{Resource}} by leveraging the {{Resource.getResourceMetadata().put("sling.validation", validationResult)}}. Then make the {{ValidationResult}} accessible by registering an {{AdapterFactory}} for adaptations from {{Resource}} to {{ValidationResult}} which will expose that object again (by looking it up in the Resources metadata).
  


was (Author: kwin):
The question is, how can the information about the validation be propagated without leveraging an exception and without having a request/thread at hand (compare with http://apache-sling.73963.n3.nabble.com/RTC-ThreadLocal-for-getting-current-request-in-sling-td4042387.html). My proposal is:
Attach the {{ValidationResult}} to the {{Resource}} by leveraging the {{Resource.getResourceMetadata().put("sling.validation", validationResult)}}. Then make the {{ValidationResult}} accessible by registering an {{AdapterFactory}} for adaptations from {{Resource}} to {{ValidationResult}} which will expose that object again (by looking it up in the Resources metadata).
  

> Do not always throw exceptions to propagate information about failed validations
> --------------------------------------------------------------------------------
>
>                 Key: SLING-6531
>                 URL: https://issues.apache.org/jira/browse/SLING-6531
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions
>    Affects Versions: Sling Models Validation Impl 1.0.0
>            Reporter: Konrad Windszus
>            Assignee: Konrad Windszus
>             Fix For: Sling Models Validation Impl 1.0.0
>
>
> Right now the {{o.a.s.models.validation.impl.ModelValidationImpl}} will always throw an {{InvalidResourceException}} in case the underlying resource is not valid (according to Sling Validation). With the advent of different severities per issue (SLING-5373) this seems a bit too strict because some validators could be used just for informational purposes. Those validations should not prevent the Sling Model from being instantiated.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)