diff --git a/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/UiConfigService.java b/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/UiConfigService.java index 56dcb26d..536c1e5c 100644 --- a/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/UiConfigService.java +++ b/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/UiConfigService.java @@ -11,4 +11,5 @@ public interface UiConfigService { ZonedDateTime getLastModified(); String[] getExcludedProperties(); String getLinksType(); + boolean isExcludeTags(); } diff --git a/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/GridResourcesGeneratorImpl.java b/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/GridResourcesGeneratorImpl.java index a25c90fa..37457f78 100644 --- a/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/GridResourcesGeneratorImpl.java +++ b/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/GridResourcesGeneratorImpl.java @@ -72,10 +72,6 @@ public class GridResourcesGeneratorImpl implements GridResourcesGenerator { description = "Finds broken links under the specified path for further outputting them in a report" ) @interface Configuration { - @AttributeDefinition( - name = "Exclude tags", - description = "If checked, the internal links starting with /content/cq:tags will be excluded" - ) boolean excludeTags() default true; @AttributeDefinition( name = "Status codes", @@ -107,7 +103,6 @@ int[] allowedStatusCodes() default { private ExecutorService executorService; - private boolean excludeTags; private int[] allowedStatusCodes; private int threadsPerCore; @@ -118,7 +113,6 @@ int[] allowedStatusCodes() default { @Activate @Modified protected void activate(Configuration configuration) { - excludeTags = configuration.excludeTags(); allowedStatusCodes = configuration.allowedStatusCodes(); threadsPerCore = configuration.threadsPerCore(); } @@ -307,7 +301,7 @@ private boolean isExcludedByPattern(String href) { } private boolean isExcludedTag(String href) { - return excludeTags && href.startsWith(TAGS_LOCATION); + return uiConfigService.isExcludeTags() && href.startsWith(TAGS_LOCATION); } private boolean isExcludedProperty(String propertyName) { @@ -410,7 +404,7 @@ private Map getGenerationStatsMap(LinksCounter allLinksCounter, stats.put(GenerationStatsProps.PN_REPORT_LINKS_TYPE, uiConfigService.getLinksType()); stats.put(GenerationStatsProps.PN_EXCLUDED_LINK_PATTERNS, getExcludedLinksPatterns()); - stats.put(GenerationStatsProps.PN_EXCLUDED_TAGS, excludeTags); + stats.put(GenerationStatsProps.PN_EXCLUDED_TAGS, uiConfigService.isExcludeTags()); stats.put(GenerationStatsProps.PN_ALLOWED_STATUS_CODES, allowedStatusCodes); stats.put(GenerationStatsProps.PN_ALL_INTERNAL_LINKS, allLinksCounter.getInternalLinks()); diff --git a/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/UiConfigServiceImpl.java b/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/UiConfigServiceImpl.java index 502faf2c..d4200875 100644 --- a/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/UiConfigServiceImpl.java +++ b/core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/UiConfigServiceImpl.java @@ -24,6 +24,7 @@ public class UiConfigServiceImpl implements UiConfigService { private static final String PN_PATH = "path"; private static final String PN_EXCLUDED_PROPERTIES = "excludedProperties"; private static final String PN_LINKS_TYPE = "linksType"; + private static final String PN_EXCLUDE_TAGS = "excludeTags"; private static final String DEFAULT_PATH = "/content"; @Reference @@ -72,6 +73,11 @@ public String getLinksType() { return getProperty(PN_LINKS_TYPE, String.class).orElse(GenerationStatsProps.REPORT_LINKS_TYPE_ALL); } + @Override + public boolean isExcludeTags() { + return getProperty(PN_EXCLUDE_TAGS, Boolean.class).orElse(true); + } + private Optional getProperty(String name, Class clazz){ try(ResourceResolver resourceResolver = repositoryHelper.getServiceResourceResolver()){ return Optional.ofNullable(resourceResolver.getResource(CONFIG_PATH)) diff --git a/core/src/test/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/GridResourcesGeneratorImplTest.java b/core/src/test/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/GridResourcesGeneratorImplTest.java index 4d91b0b3..4076673b 100644 --- a/core/src/test/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/GridResourcesGeneratorImplTest.java +++ b/core/src/test/java/com/exadel/etoolbox/linkinspector/core/services/data/impl/GridResourcesGeneratorImplTest.java @@ -147,6 +147,7 @@ void setup() throws NoSuchFieldException { when(uiConfigService.getLastModified()).thenReturn(TEST_LAST_MODIFIED_BOUNDARY); when(uiConfigService.getExcludedProperties()).thenReturn(new String[]{TEST_EXCLUDED_PROPERTY}); when(uiConfigService.getLinksType()).thenReturn(GenerationStatsProps.REPORT_LINKS_TYPE_ALL); + when(uiConfigService.isExcludeTags()).thenReturn(true); PrivateAccessor.setField(fixture, UI_CONFIG_FIELD, uiConfigService); } @@ -370,7 +371,6 @@ private static GridResourcesGeneratorImpl.Configuration mockConfig() { GridResourcesGeneratorImpl.Configuration config = mock(GridResourcesGeneratorImpl.Configuration.class); when(config.threadsPerCore()).thenReturn(60); - when(config.excludeTags()).thenReturn(true); return config; } diff --git a/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.filter.js b/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.filter.js index 1450dfaa..8422dd76 100644 --- a/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.filter.js +++ b/ui.apps/src/main/content/jcr_root/apps/etoolbox-link-inspector/clientlibs/link-inspector-ui/js/console-ui.filter.js @@ -113,6 +113,9 @@ $('

').text("Links type(The type of links in the report)").appendTo(dialog.content); dialog.content.appendChild(linksTypeSelect); + const $excludeTagsCheckbox = $('Exclude tags(If checked, the internal links starting with /content/cq:tags will be excluded)'); + $excludeTagsCheckbox.appendTo(dialog.content); + $.ajax({ type: "GET", url: "/content/etoolbox-link-inspector/data/config.json" @@ -125,6 +128,7 @@ $lastModifiedContentField.val(data.lastModifiedBoundary); populateMultifield(excludedPropertiesMultifield, data.excludedProperties); linksTypeSelect.value = data.linksType; + $excludeTagsCheckbox.attr("checked", data.excludeTags); }) function createMultifield(){ @@ -174,7 +178,9 @@ "lastModifiedBoundary": $lastModifiedContentField.val(), "excludedProperties": getMultifieldValues(excludedPropertiesMultifield), "excludedProperties@TypeHint": "String[]", - "linksType": linksTypeSelect.value + "linksType": linksTypeSelect.value, + "excludeTags":!!$excludeTagsCheckbox.attr("checked"), + "excludeTags@TypeHint": "Boolean" }, dataType: "json", encode: true