From 90bcd5631be894b76a609714cb707a923f5d8592 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 10 Jan 2024 14:40:09 +0100 Subject: [PATCH] Switch to JSON HBS template for defining OSGi configurations (#38) --- changes.xml | 3 + .../main/roles/__projectName__-aem-cms.yaml | 6 +- ...tName__-aem-cms-config.osgiconfig.json.hbs | 145 ++++++++++++++++++ ...jectName__-aem-cms-config.provisioning.hbs | 117 -------------- 4 files changed, 152 insertions(+), 119 deletions(-) create mode 100644 src/main/resources/archetype-resources/config-definition/src/main/templates/__projectName__-aem-cms/__projectName__-aem-cms-config.osgiconfig.json.hbs delete mode 100644 src/main/resources/archetype-resources/config-definition/src/main/templates/__projectName__-aem-cms/__projectName__-aem-cms-config.provisioning.hbs diff --git a/changes.xml b/changes.xml index 8daeca03..ebec210f 100644 --- a/changes.xml +++ b/changes.xml @@ -27,6 +27,9 @@ Update to Handler 2.x. + + Switch to JSON HBS template for defining OSGi configurations. + Update dependencies. diff --git a/src/main/resources/archetype-resources/config-definition/src/main/roles/__projectName__-aem-cms.yaml b/src/main/resources/archetype-resources/config-definition/src/main/roles/__projectName__-aem-cms.yaml index a30f1c0e..468ed07f 100644 --- a/src/main/resources/archetype-resources/config-definition/src/main/roles/__projectName__-aem-cms.yaml +++ b/src/main/resources/archetype-resources/config-definition/src/main/roles/__projectName__-aem-cms.yaml @@ -33,9 +33,11 @@ files: #end # AEM OSGi System Configuration -- file: ${projectName}-aem-cms-config.provisioning +- file: ${projectName}-aem-cms-config.osgiconfig.json dir: packages - template: ${projectName}-aem-cms-config.provisioning.hbs + template: ${projectName}-aem-cms-config.osgiconfig.json.hbs + validators: + - none # allow trailing commas in JSON picked up by post processor postProcessors: - aem-contentpackage-osgiconfig postProcessorOptions: diff --git a/src/main/resources/archetype-resources/config-definition/src/main/templates/__projectName__-aem-cms/__projectName__-aem-cms-config.osgiconfig.json.hbs b/src/main/resources/archetype-resources/config-definition/src/main/templates/__projectName__-aem-cms/__projectName__-aem-cms-config.osgiconfig.json.hbs new file mode 100644 index 00000000..b5beb8cd --- /dev/null +++ b/src/main/resources/archetype-resources/config-definition/src/main/templates/__projectName__-aem-cms/__projectName__-aem-cms-config.osgiconfig.json.hbs @@ -0,0 +1,145 @@ +{ + "configurations": { + + // Set loglevel for project-specific bundles + "org.apache.sling.commons.log.LogManager.factory.config-${projectName}": { + "org.apache.sling.commons.log.file": "logs/error.log", + "org.apache.sling.commons.log.level": "{{app.logLevel}}", + "org.apache.sling.commons.log.names": ["io.wcm","${package}"] + }, + + // Disable built-in AEM link checker by default (enable it only when configured properly). + "com.day.cq.rewriter.linkchecker.impl.LinkCheckerTransformerFactory": { + "linkcheckertransformer.disableChecking": true + }, + +#if ( $optionContextAwareConfig == "y" ) +#if ( $optionAemVersion == "6.5" ) + // Update Context-Aware config settings as it is configured by default in latest AEM version + "org.apache.sling.caconfig.management.impl.ConfigurationManagementSettingsImpl": { + "ignorePropertyNameRegex": ["^(jcr|cq):.+$","^sling:resourceType$"], + "configCollectionPropertiesResourceNames": ["jcr:content","."] + }, + +#end + // Context path strategy + "io.wcm.caconfig.extensions.contextpath.impl.RootTemplateContextPathStrategy-${projectName}": { + "templatePaths": ["#if($optionEditableTemplates=='y')/conf/${projectName}/settings/wcm/templates/homepage#else/apps/${projectName}/core/templates/homepage#end"], + "minLevel": 1, + "maxLevel": 5, + "contextPathRegex": "^/content/(dam/)?(${projectName}/.*)?$", + "configPathPatterns": ["/conf/$2"] + }, + + // Store context-aware configuration in cq:Page nodes in /conf + "io.wcm.caconfig.extensions.persistence.impl.PagePersistenceStrategy": { + "enabled": true + }, + +#end +#if ( $optionWcmioHandler == "y" ) + // Service user mapping for wcm.io URL handler + "org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-${projectName}-wcmio-handler-wcm": { + "user.mapping": [ + "io.wcm.handler.url:clientlibs-service=[sling-scripting]", + "io.wcm.wcm.commons:component-properties=[sling-scripting]" + ] + }, + + // Service user mapping for wcm.io Media Handler + "org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-${projectName}-wcmio-handler-media-dynamicmedia": { + "user.mapping": [ + "io.wcm.handler.media:dynamic-media-support=[configuration-reader-service]" + ] + }, + + // Required DS components for systemready check + "org.apache.felix.hc.generalchecks.DsComponentsCheck-${projectName}-systemready": { + "hc.name": "${projectName} - Required Components", + "hc.tags": ["${projectName}","systemready"], + "statusForMissing": "TEMPORARILY_UNAVAILABLE", + "components.list": [ + "${package}.config.impl.LinkHandlerConfigImpl", + "${package}.config.impl.MediaFormatProviderImpl", + "${package}.config.impl.MediaHandlerConfigImpl", + "io.wcm.caconfig.extensions.contextpath.impl.RootTemplateContextPathStrategy", + "io.wcm.caconfig.extensions.persistence.impl.PagePersistenceStrategy", + "io.wcm.handler.mediasource.dam.impl.dynamicmedia.DynamicMediaSupportServiceImpl" + ] + }, + +#end + }, + + "configurations:author": { + + // Show "Sites" view in TouchUI after login + "com.day.cq.commons.servlets.RootMappingServlet": { + "rootmapping.target": "/sites.html" + }, + +#if ( $optionAemVersion == "cloud" ) +#[[{{#if aem.disableAuthorUsageStatisticsCollection ~}}]]# + // Disable usage tracking by default for admins (esp. for local usage) + "com.adobe.cq.experiencelog.impl.ExperienceLogConfigServlet": { + "enabled": false + }, + +{{/if ~}} +#end +#if ( $optionWcmioHandler == "y" ) + // Instance type + "io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl": { + "instance.type": "author" + }, + + // Service user mapping for wcm.io Media Handler + "org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-${projectName}-wcmio-handler-media-metadata": { + "user.mapping": [ + "io.wcm.handler.media:dam-rendition-metadata=[dam-writer-service]" + ] + }, + + // Support previews of inline images in edit dialogs on Authoring instances for these resource types + "io.wcm.handler.media.impl.InlineImageAuthorPreviewServlet": { + "sling.servlet.resourceTypes": ["wcm-io/wcm/core/components/wcmio/responsiveimage/v1/responsiveimage"] + }, + +#end + }, + + "configurations:publish": { + +#if ( $optionContextAwareConfig == "y" ) + // Disable Configuration Editor on publish + "io.wcm.caconfig.editor.impl.EditorConfig": { + "enabled": false + }, + +#end + // Disable default renderings for Sling GET servlet on publish + "org.apache.sling.servlets.get.DefaultGetServlet": { + "enable.html": "false", + "enable.json": "true", + "enable.txt": "false", + "enable.xml": "false", + "index": "false", + "index.files": ["index","index.html"], + "aliases": "xml:pdf", + "json.maximumresults": 100 + }, + +#if ( $optionWcmioHandler == "y" ) + // Instance type + "io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl": { + "instance.type": "publish" + }, + +#end + }, + + "repoinit": [ + // Create root folder below /apps for application + "create path /apps/${projectName}(sling:Folder)" + ] +} diff --git a/src/main/resources/archetype-resources/config-definition/src/main/templates/__projectName__-aem-cms/__projectName__-aem-cms-config.provisioning.hbs b/src/main/resources/archetype-resources/config-definition/src/main/templates/__projectName__-aem-cms/__projectName__-aem-cms-config.provisioning.hbs deleted file mode 100644 index c13a3241..00000000 --- a/src/main/resources/archetype-resources/config-definition/src/main/templates/__projectName__-aem-cms/__projectName__-aem-cms-config.provisioning.hbs +++ /dev/null @@ -1,117 +0,0 @@ -[feature name=${projectName}-aem-cms-config] - - -[configurations] - - # Set loglevel for project-specific bundles - org.apache.sling.commons.log.LogManager.factory.config-${projectName} - org.apache.sling.commons.log.file="logs/error.log" - org.apache.sling.commons.log.level="{{app.logLevel}}" - org.apache.sling.commons.log.names=["io.wcm","${package}"] - - # Disable built-in AEM link checker by default (enable it only when configured properly). - com.day.cq.rewriter.linkchecker.impl.LinkCheckerTransformerFactory - linkcheckertransformer.disableChecking=B"true" - -#if ( $optionContextAwareConfig == "y" ) -#if ( $optionAemVersion == "6.5" ) - # Update Context-Aware config settings as it is configured by default in latest AEM version - org.apache.sling.caconfig.management.impl.ConfigurationManagementSettingsImpl - ignorePropertyNameRegex=["^(jcr|cq):.+$","^sling:resourceType$"] - configCollectionPropertiesResourceNames=["jcr:content","."] - -#end - # Context path strategy - io.wcm.caconfig.extensions.contextpath.impl.RootTemplateContextPathStrategy-${projectName} - templatePaths=["#if($optionEditableTemplates=='y')/conf/${projectName}/settings/wcm/templates/homepage#else/apps/${projectName}/core/templates/homepage#end"] - minLevel=I"1" - maxLevel=I"5" - contextPathRegex="^/content/(dam/)?(${projectName}/.*)?$" - configPathPatterns=["/conf/$2"] - - # Store context-aware configuration in cq:Page nodes in /conf - io.wcm.caconfig.extensions.persistence.impl.PagePersistenceStrategy - enabled=B"true" - -#end -#if ( $optionWcmioHandler == "y" ) - # Service user mapping for wcm.io URL handler - org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-${projectName}-wcmio-handler-wcm - user.mapping=["io.wcm.handler.url:clientlibs-service\=[sling-scripting]","io.wcm.wcm.commons:component-properties\=[sling-scripting]"] - - # Service user mapping for wcm.io Media Handler - org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-${projectName}-wcmio-handler-media-dynamicmedia - user.mapping=["io.wcm.handler.media:dynamic-media-support\=[configuration-reader-service]"] - - # Required DS components for systemready check - org.apache.felix.hc.generalchecks.DsComponentsCheck-${projectName}-systemready - hc.name="${projectName}\ -\ Required Components" - hc.tags=["${projectName}","systemready"] - statusForMissing="TEMPORARILY_UNAVAILABLE" - components.list=[ - "${package}.config.impl.LinkHandlerConfigImpl", - "${package}.config.impl.MediaFormatProviderImpl", - "${package}.config.impl.MediaHandlerConfigImpl", - "io.wcm.caconfig.extensions.contextpath.impl.RootTemplateContextPathStrategy", - "io.wcm.caconfig.extensions.persistence.impl.PagePersistenceStrategy", - "io.wcm.handler.mediasource.dam.impl.dynamicmedia.DynamicMediaSupportServiceImpl"] - -#end -[configurations runModes=author] - - # Show "Sites" view in TouchUI after login - com.day.cq.commons.servlets.RootMappingServlet - rootmapping.target="/sites.html" - -#if ( $optionAemVersion == "cloud" ) -#[[{{#if aem.disableAuthorUsageStatisticsCollection ~}}]]# - # Disable usage tracking by default for admins (esp. for local usage) - com.adobe.cq.experiencelog.impl.ExperienceLogConfigServlet - enabled=B"false" - -{{/if ~}} -#end -#if ( $optionWcmioHandler == "y" ) - # Instance type - io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl - instance.type="author" - - # Service user mapping for wcm.io Media Handler - org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-${projectName}-wcmio-handler-media-metadata - user.mapping=["io.wcm.handler.media:dam-rendition-metadata\=[dam-writer-service]"] - - # Support previews of inline images in edit dialogs on Authoring instances for these resource types - io.wcm.handler.media.impl.InlineImageAuthorPreviewServlet - sling.servlet.resourceTypes=["wcm-io/wcm/core/components/wcmio/responsiveimage/v1/responsiveimage"] - -#end - -[configurations runModes=publish] - -#if ( $optionContextAwareConfig == "y" ) - # Disable Configuration Editor on publish - io.wcm.caconfig.editor.impl.EditorConfig - enabled=B"false" - -#end - # Disable default renderings for Sling GET servlet on publish - org.apache.sling.servlets.get.DefaultGetServlet - enable.html=B"false" - enable.json=B"true" - enable.txt=B"false" - enable.xml=B"false" - index=B"false" - index.files=["index","index.html"] - aliases="xml:pdf" - json.maximumresults=I"100" - -#if ( $optionWcmioHandler == "y" ) - # Instance type - io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl - instance.type="publish" - -#end - -[:repoinit] -# Create root folder below /apps for application -create path /apps/${projectName}(sling:Folder)