Uploaded image for project: 'Alfresco One Platform'
  1. Alfresco One Platform
  2. ACE-5305

Dojo package location prefixed by another package name ends up not loading widget / service code

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.0, Community Edition 201612 GA
    • Fix Version/s: None
    • Component/s: Web Scripts and Surf
    • Labels:
      None
    • ACT Numbers:

      Community

      Description

      This issue has been raised as a result of https://github.com/Alfresco/Aikau/issues/926. The following is taken directly from that issue...


      This issue is very likely related to the Surf library but since it is encountered solely when using Aikau, I'm filing it here.

      When multiple Dojo packages have been configured in a way where the source location of a package A is prefixed with the name of another package B, any widgets / services of package A referenced in JSON model will not work as their source code is not contained in the aggregated JS file. As far as I was able to determine via debugging, this is the result of a second, redundant package mapping process.

      <config evaluator="string-compare" condition="WebFramework">
         <web-framework>
            <dojo-pages>
               <packages>
                  <!-- a  package mapping ending in a location prefixed by another package name is problematic -->
                  <package name="A" location="B/path/to/files" />
                  <package name="B" location="js/B/path/to/files" />
               </packages>
            </dojo-pages>
         </web-framework>
      </config>
      
      model.jsonModel = { widgets : [{name : 'A/moduleId'}] /* ... */ };
      

      During dependency collection, the DojoDependencyHandler.getPath(String, String) operation is called to resolve a (potentially relative) module ID to the source path of the JS (or CSS, HTML, properties) file.
      While outputting the aggregated dependency source, the DojoDependencyHandler.getPath(String, String) operation is called again with the already resolved source path. When the first folder in the path happens to be a name of a Dojo package, that packages location is prefixed to the already resolved path.

      The result of this redundant mapping of package locations is that the DojoDependencyHandler.outputDependency(String, String, DojoDependencies) operation can't find a resource input stream for the invalid path and returns the String "null", which will be output as the "source" of the module. The output in the aggregated JS file looks like this

      'A/moduleId':function(){
      null},
      

      I have compiled a set of test files in the following gist: https://gist.github.com/AFaust/f1c3930c336a33e6fcb8

      This was found in 5.0.d using Aikau 1.0.51 but appears to also be present in 5.0.3 (which might have had newer Spring libraries).

      The example of course is using a constructed constellation, but we have actually arrived naturally in a such a situation with two separate, independant modules. Our Aikau library module defines a package "prodyna" with a location "js/prodyna" (using common Aikau root path) while our Enhanced Search module (predating Aikau and faceted search page) now defines a package "enhanced-search" with location "prodyna/enhanced-search/dojo" for a custom SearchBox widget. The location was chosen to keep all source files relating to that module in one distinct root.

      A workaround exists by simply refactoring the module packages structures, but a long term solution should prevent accidental conflicts with modules not under the control of a customer / developer.

        Attachments

          Activity

            People

            • Assignee:
              pmunassigned PM Unassigned
              Reporter:
              afaust Axel Faust
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: