Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Won't Fix
-
core-1.8.0
-
None
Description
As raised by Oscar:
I’m not sure how to use the SudoService inside a FixtureScript.
I have the following:
public class DemoWithAllRecordsFixture extends FixtureScript {
public DemoWithAllRecordsFixture()
{ this.withDiscoverability(Discoverability.DISCOVERABLE); } @Override
protected void execute(
final ExecutionContext executionContext)
The ExcelInheritedConditionsSNPGenotypeFixture contains many wrapped action invocations, so the following exception is thrown:
Caused by: org.apache.isis.applib.services.wrapper.HiddenException: Reason: Could not locate application user for initialisation. Identifier: com.tellmegen.domain.model.inheritedconditions.InheritedCondition#upsertSNPGenotype(java.lang.Integer,com.tellmegen.domain.model.AppliesToSex,java.lang.String,java.lang.String,com.tellmegen.domain.model.inheritedconditions.InheritedConditionHeredity,com.tellmegen.domain.model.inheritedconditions.InheritedConditionPhenotype,com.tellmegen.domain.model.inheritedconditions.InheritedConditionStatus,java.lang.String,java.lang.String)
at org.apache.isis.core.wrapper.handlers.DomainObjectInvocationHandler.toException(DomainObjectInvocationHandler.java:732)
at org.apache.isis.core.wrapper.handlers.DomainObjectInvocationHandler.notifyListenersAndVetoIfRequired(DomainObjectInvocationHandler.java:700)
at org.apache.isis.core.wrapper.handlers.DomainObjectInvocationHandler.checkVisibility(DomainObjectInvocationHandler.java:682)
at org.apache.isis.core.wrapper.handlers.DomainObjectInvocationHandler.handleActionMethod(DomainObjectInvocationHandler.java:607)
at org.apache.isis.core.wrapper.handlers.DomainObjectInvocationHandler.invoke(DomainObjectInvocationHandler.java:263)
at org.apache.isis.core.wrapper.proxy.ProxyInstantiatorForJavassist$1.invoke(ProxyInstantiatorForJavassist.java:72)
at com.tellmegen.domain.model.inheritedconditions.InheritedCondition_$$jvstcc_7.upsertSNPGenotype(InheritedCondition$$_jvstcc_7.java)
at com.tellmegen.domain.model.importing.ImportInheritedConditionSNPGenotype.saveToDatabase(ImportInheritedConditionSNPGenotype.java:244)
at com.tellmegen.domain.model.importing.ImportInheritedConditionsSNPGenotypeService.importInheritedConditionsSNPGenotypes(ImportInheritedConditionsSNPGenotypeService.java:38)
at com.tellmegen.fixture.model.inheritedconditionsnpgenotype.ExcelInheritedConditionsSNPGenotypeFixture.execute(ExcelInheritedConditionsSNPGenotypeFixture.java:24)
at org.apache.isis.applib.fixturescripts.FixtureScript$ExecutionContext.executeChildIfNotAlready(FixtureScript.java:549)
at org.apache.isis.applib.fixturescripts.FixtureScript$ExecutionContext.executeChildT(FixtureScript.java:528)
at org.apache.isis.applib.fixturescripts.FixtureScript$ExecutionContext.executeChildT(FixtureScript.java:498)
at org.apache.isis.applib.fixturescripts.FixtureScript$ExecutionContext.executeChild(FixtureScript.java:487)
at com.tellmegen.fixture.TellMeGenDemoWithAllRecordsFixture.execute(TellMeGenDemoWithAllRecordsFixture.java:34)
If try to use them inside a SudoService.sudo(…) call I don’t have access to the “executionContext” (it’s private).
So basically, I would need to make the “executionContext” field of FixtureScript “public”, or being able to use SudoService to override the User globally, without needing to use a “Callable” construct.