Skip to content

merkle-open/magnolia-powernode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magnolia Powernode

The PowerNode module provides a special wrapper for JCR nodes with extended functionality.

Advantages:

  • Fully compatible to JCR nodes: PowerNode implements the javax.jcr.Node interface
  • No checked RepositoryExceptions: all checked exceptions either handled or wrapped in runtime exceptions
  • Stream compatible: since there are no checked exceptions, PowerNodes can be easily used in streams
  • Blossom compatible: PowerNodes can be injected into Blossom templates

Setup

  • Add Maven dependency:

    <dependency>
        <groupId>com.namics.oss.magnolia</groupId>
        <artifactId>magnolia-powernode</artifactId>
        <version>2.0.7</version>
    </dependency>
  • Add binding for ZoneId provider

    import info.magnolia.context.MgnlContext;
    import info.magnolia.context.WebContext;
    import info.magnolia.ui.framework.util.TimezoneUtil;
    
    import javax.inject.Inject;
    import javax.inject.Provider;
    import java.time.ZoneId;
    import java.util.Optional;
    
    public class TimeZoneProvider implements Provider<ZoneId> {
    
      @Override
      public ZoneId get() {
          return Optional
                  .ofNullable(MgnlContext.getWebContextOrNull())
                  .map(WebContext::getUser)
                  .map(TimezoneUtil::getUserZoneId)
                  .orElseGet(ZoneId::systemDefault);
      }
    }
    <components>
      <id>main</id>
      <component>
        <type>java.time.ZoneId</type>
        <provider>com.namics.engagement.web.configuration.TimeZoneProvider</provider>
      </component>
    </components>
  • Import Spring Configuration:

    @Configuration
    @Import({PowerNodeConfiguration.class})
    public class BlossomServletConfiguration {
        //...
    }
  • If needed, add the DelegatingPowerNodeArgumentResolver in the BlossomServletConfiguration as follows:

    @Override
    protected void addArgumentResolvers(final List<HandlerMethodArgumentResolver> argumentResolvers) {
          argumentResolvers.add(delegatingPowerNodeArgumentResolverFactory.create(new BlossomHandlerMethodArgumentResolver()));
    }