Hi to all.
We've made a "small" change on Isis applib that allows clearer messages for
validation exceptions.
We wanted to move from this:
org.apache.isis.applib.services.wrapper.InvalidException: Mandatory
at
org.apache.isis.core.wrapper.internal.DomainObjectInvocationHandler.toException(DomainObjectInvocationHandler.java:584)
at
org.apache.isis.core.wrapper.internal.DomainObjectInvocationHandler.notifyListenersAndVetoIfRequired(DomainObjectInvocationHandler.java:556)
at
org.apache.isis.core.wrapper.internal.DomainObjectInvocationHandler.handleActionMethod(DomainObjectInvocationHandler.java:506)
at
org.apache.isis.core.wrapper.internal.DomainObjectInvocationHandler.invoke(DomainObjectInvocationHandler.java:236)
at
org.apache.isis.core.wrapper.internal.InvocationHandlerMethodInterceptor.intercept(InvocationHandlerMethodInterceptor.java:37)
at
com.xms.framework.risk.domain.model.RiskRegister$$EnhancerByCGLIB$$d42e255.addQuantitativeRiskToAsset(<generated>)
at
com.xms.framework.risk.integration.glue.risk.RiskRegisterGlue.when_add_quantitative_risk_to_this_risk_register_with_asset_and_threat_and_likelihood_and_impact(RiskRegisterGlue.java:152)
at ✽.When I add a new quantitative risk to the risk register with name
"risk 1" and asset "A1" and threat "T1" and likelihood 0.50 and impact
1000.00(com/xms/framework/risk/integration/specs/RiskAssessmentSpec_Risk_levelOfRisk.feature:56)
To something like this:
org.apache.isis.applib.services.wrapper.InvalidException: Source:
com.xms.framework.risk.domain.model.RiskRegister@2012052f. Reason: Mandatory.
Identifier:
com.xms.framework.risk.domain.model.RiskRegister#addQuantitativeRiskToAsset(java.lang.String,java.lang.String,com.xms.framework.architecture.domain.model.Entity,com.xms.framework.risk.domain.model.threat.Threat,java.math.BigDecimal,java.math.BigDecimal).
Position: 2. Proposed: null
at
org.apache.isis.core.wrapper.internal.DomainObjectInvocationHandler.toException(DomainObjectInvocationHandler.java:584)
at
org.apache.isis.core.wrapper.internal.DomainObjectInvocationHandler.notifyListenersAndVetoIfRequired(DomainObjectInvocationHandler.java:556)
at
org.apache.isis.core.wrapper.internal.DomainObjectInvocationHandler.handleActionMethod(DomainObjectInvocationHandler.java:506)
at
org.apache.isis.core.wrapper.internal.DomainObjectInvocationHandler.invoke(DomainObjectInvocationHandler.java:236)
at
org.apache.isis.core.wrapper.internal.InvocationHandlerMethodInterceptor.intercept(InvocationHandlerMethodInterceptor.java:37)
at
com.xms.framework.risk.domain.model.RiskRegister$$EnhancerByCGLIB$$d42e255.addQuantitativeRiskToAsset(<generated>)
at
com.xms.framework.risk.integration.glue.risk.RiskRegisterGlue.when_add_quantitative_risk_to_this_risk_register_with_asset_and_threat_and_likelihood_and_impact(RiskRegisterGlue.java:152)
at ✽.When I add a new quantitative risk to the risk register with name
"risk 1" and asset "A1" and threat "T1" and likelihood 0.50 and impact
1000.00(com/xms/framework/risk/integration/specs/RiskAssessmentSpec_Risk_levelOfRisk.feature:56)
We have created a new "getReasonMessage()" method on InteractionEvent as this:
public abstract class InteractionEvent extends EventObject {
.....
/**
* The reason message, if any, that this interaction may have been vetoed or
* otherwise disallowed.
*
* <p>
* This message should be overridden by subclasses for containing the
Reason, the Identifier and any other relevant context information.
*
* @return
*/
public String getReasonMessage() {
if (this.getIdentifier() != null) {
return String.format("Reason: %s. Identifier: %s", this.getReason(),
this.getIdentifier());
} else {
return String.format("Reason: %s", this.getReason());
}
}
.....
}
And use that method to "construct" the InteractionException, instead of
"getReason()":
public abstract class InteractionException extends ApplicationException {
....
public InteractionException(final InteractionEvent interactionEvent) {
- super(interactionEvent.getReason());
+ super(interactionEvent.getReasonMessage());
this.interactionEvent = interactionEvent;
}
....
}
Please, find a git patch attached.
Perhaps there are better ways to implement it. If needed we can create the Jira
issue.
Thanks,
Oscar