Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-1230

[WON'T FIX] How use SudoService with fixture scripts that themselves are nested?

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • core-1.8.0
    • 2.0.0-M5
    • Docs & Website
    • 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)

      { executionContext.executeChild(this, new ExcelInheritedConditionsSNPGenotypeFixture()); executionContext.executeChild(this, new ExcelDrugsSNPGenotypeFixture()); executionContext.executeChild(this, new ExcelTraitsSNPGenotypeFixture()); }

      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.

      Attachments

        Activity

          People

            danhaywood Daniel Keir Haywood
            danhaywood Daniel Keir Haywood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: