Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-6100

Make AbstractNodeBuilderTask more flexible

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Neutral Neutral
    • None
    • 5.3.7
    • updatemechanism
    • Yes

      Hi. Whenever I use this great class, I miss a feature that could easily be added with no harm.

      --> Make it possible to override the NodeOperations by a subclass.

      Just add a (protected?) getter for the operations field and use it in the doExecute method. Like this:

          @Override
          protected void doExecute(InstallContext ctx) throws RepositoryException, TaskExecutionException {
              final Node root = getRootNode(ctx);
              final ErrorHandler errorHandler = newErrorHandler(ctx);
              final NodeBuilder nodeBuilder = new NodeBuilder(errorHandler, root, getOperations());
              try {
                  nodeBuilder.exec();
              } catch (NodeOperationException e) {
                  throw new TaskExecutionException(e.getMessage(), e);
              }
          }
      
          protected NodeOperation[] getOperations() {
              return operations;
          }
      

      This little change enables users to override the getter an build node operations with more complex logic if needed. The problem actually is, that in constructors you cannot use instance methods yet. So if you want to generate part of your NodeOperations in a nicely separated method, you have to make that method static and break the possibility to override it again.

      Example: https://git.magnolia-cms.com/gitweb/?p=forge/namics-mgnl-thymeleaf.git;a=blob;f=src/main/java/com/namics/mgnl/thymeleaf/setup/InstallThymeleafTemplateEngineConfigurationTask.java;h=edceef15d4a53a77dba947afec70ea4ce35d731f;hb=HEAD

      Cheers,
      Stefan

        Acceptance criteria

              Unassigned Unassigned
              sbaur Stefan Baur
              Michael Rauch
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD

                    Estimated:
                    Original Estimate - 5m
                    5m
                    Remaining:
                    Remaining Estimate - 5m
                    5m
                    Logged:
                    Time Spent - Not Specified
                    Not Specified