Skip to content

Commit

Permalink
#18 Provide a settings console instead of the OSGi config - pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vihnatsenka committed Mar 26, 2024
1 parent 5a49ccf commit a0222a3
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public interface UiConfigService {
String[] getExcludedProperties();
String getLinksType();
boolean isExcludeTags();
Integer[] getStatusCodes();
Integer getThreadsPerCore();
int[] getStatusCodes();
int getThreadsPerCore();
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private boolean isExcludedPath(String path) {
}

private boolean isAllowedErrorCode(int linkStatusCode) {
Integer[] allowedStatusCodes = uiConfigService.getStatusCodes();
int[] allowedStatusCodes = uiConfigService.getStatusCodes();

if (ArrayUtils.isEmpty(allowedStatusCodes) ||
(allowedStatusCodes.length == 1 && allowedStatusCodes[0] < 0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@Component(service = UiConfigService.class)
public class UiConfigServiceImpl implements UiConfigService {
private static final String CONFIG_PATH = "/content/etoolbox-link-inspector/data/config";
private static final String CONFIG_PATH = "/conf/etoolbox-link-inspector/data/config";
private static final String PN_FILTER = "filter";
private static final String PN_EXCLUDED_PATHS = "excludedPaths";
private static final String PN_ACTIVATED_CONTENT = "activatedContent";
Expand Down Expand Up @@ -83,12 +83,12 @@ public boolean isExcludeTags() {
}

@Override
public Integer[] getStatusCodes() {
return getProperty(PN_STATUS_CODES, Integer[].class).orElse(new Integer[]{});
public int[] getStatusCodes() {
return getProperty(PN_STATUS_CODES, int[].class).orElse(new int[]{});
}

@Override
public Integer getThreadsPerCore() {
public int getThreadsPerCore() {
return getProperty(PN_THREADS_PER_CORE, Integer.class).orElse(DEFAULT_THREADS_PER_CORE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private GridResourcesGeneratorImpl getGridResourcesGenerator() throws NoSuchFiel
when(uiConfigService.getExcludedPaths()).thenReturn(new String[0]);
when(uiConfigService.getExcludedProperties()).thenReturn(new String[0]);
when(uiConfigService.getLinksType()).thenReturn(GenerationStatsProps.REPORT_LINKS_TYPE_ALL);
when(uiConfigService.getStatusCodes()).thenReturn(new Integer[]{HttpStatus.SC_NOT_FOUND});
when(uiConfigService.getStatusCodes()).thenReturn(new int[]{HttpStatus.SC_NOT_FOUND});
when(uiConfigService.getThreadsPerCore()).thenReturn(60);
PrivateAccessor.setField(gridResourcesGenerator, UI_CONFIG_FIELD, uiConfigService);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void setup() throws NoSuchFieldException {
when(uiConfigService.getExcludedProperties()).thenReturn(new String[]{TEST_EXCLUDED_PROPERTY});
when(uiConfigService.getLinksType()).thenReturn(GenerationStatsProps.REPORT_LINKS_TYPE_ALL);
when(uiConfigService.isExcludeTags()).thenReturn(true);
when(uiConfigService.getStatusCodes()).thenReturn(new Integer[]{HttpStatus.SC_NOT_FOUND});
when(uiConfigService.getStatusCodes()).thenReturn(new int[]{HttpStatus.SC_NOT_FOUND});
when(uiConfigService.getThreadsPerCore()).thenReturn(60);
PrivateAccessor.setField(fixture, UI_CONFIG_FIELD, uiConfigService);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ void testAllowedStatusCodes() throws IOException, URISyntaxException {

@Test
void testAllowedStatusCodes_emptyConfig() throws IOException, URISyntaxException, NoSuchFieldException {
when(uiConfigService.getStatusCodes()).thenReturn(new Integer[]{});
when(uiConfigService.getStatusCodes()).thenReturn(new int[]{});

context.load().json(TEST_RESOURCES_TREE_PATH, TEST_FOLDER_PATH);
when(externalLinkChecker.checkLink(anyString())).thenReturn(HttpStatus.SC_BAD_REQUEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
allowProxy="{Boolean}true"
categories="[link-inspector-ui]"/>
categories="[link-inspector-ui]"
jsProcessor="[min:gcc;languageIn=ECMASCRIPT_2015,compilationLevel=advanced,languageOut=ECMASCRIPT5]"/>
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
$updateBtn.appendTo(dialog.footer);

const $rootPathField = $('<input is="coral-textfield" class="elc-replacement-input" name="replacement" value="">');
$('<p>').text("Path(The content path for searching broken links. The search path should be located under /content)").appendTo(dialog.content);
$('<p>').text("Path (The content path for searching broken links. The search path should be located under /content)").appendTo(dialog.content);
$rootPathField.appendTo(dialog.content);

const excludedPathsMultifield = createMultifield();
$('<p>').text("Excluded Paths(The list of paths excluded from processing. The specified path and all its children are excluded. The excluded path should not end with slash. Can be specified as a regex)").appendTo(dialog.content);
$('<p>').text("Excluded Paths (The list of paths excluded from processing. The specified path and all its children are excluded. The excluded path should not end with slash. Can be specified as a regex)").appendTo(dialog.content);
dialog.content.appendChild(excludedPathsMultifield);

const $activatedContentCheckbox = $('<coral-checkbox value="activatedContent">Activated Content(If checked, links will be retrieved from activated content only)</coral-checkbox>');
Expand All @@ -75,15 +75,15 @@
$skipContentAfterActivationCheckbox.appendTo(dialog.content);

const filterMultifield = createMultifield();
$('<p>').text("Excluded links patterns(Links are excluded from processing if match any of the specified regex patterns)").appendTo(dialog.content);
$('<p>').text("Excluded links patterns (Links are excluded from processing if match any of the specified regex patterns)").appendTo(dialog.content);
dialog.content.appendChild(filterMultifield);

const $lastModifiedContentField = $('<input is="coral-textfield" class="elc-replacement-input" name="lastMidified" value="">');
$('<p>').text("Last Modified (The content modified before the specified date will be excluded. Tha date should has the ISO-like date-time format, such as '2011-12-03T10:15:30+01:00')").appendTo(dialog.content);
$lastModifiedContentField.appendTo(dialog.content);

const excludedPropertiesMultifield = createMultifield();
$('<p>').text("Excluded Properties(The list of properties excluded from processing. Each value can be specified as a regex)").appendTo(dialog.content);
$('<p>').text("Excluded Properties (The list of properties excluded from processing. Each value can be specified as a regex)").appendTo(dialog.content);
dialog.content.appendChild(excludedPropertiesMultifield);

const linksTypeSelect = new Coral.Select().set({
Expand All @@ -110,7 +110,7 @@
value: "EXTERNAL",
disabled: false
});
$('<p>').text("Links type(The type of links in the report)").appendTo(dialog.content);
$('<p>').text("Links type (The type of links in the report)").appendTo(dialog.content);
dialog.content.appendChild(linksTypeSelect);

const $excludeTagsCheckbox = $('<coral-checkbox value="excludeTags">Exclude tags(If checked, the internal links starting with /content/cq:tags will be excluded)</coral-checkbox>');
Expand All @@ -126,7 +126,7 @@

$.ajax({
type: "GET",
url: "/content/etoolbox-link-inspector/data/config.json"
url: "/conf/etoolbox-link-inspector/data/config.json"
}).done(function (data){
populateMultifield(filterMultifield, data.filter);
$rootPathField.val(data.path);
Expand Down Expand Up @@ -173,7 +173,7 @@
function onSubmit(){
$.ajax({
type: "POST",
url: "/content/etoolbox-link-inspector/data/config",
url: "/conf/etoolbox-link-inspector/data/config",
data: {
'jcr:primaryType': "nt:unstructured",
"filter": getMultifieldValues(filterMultifield),
Expand Down
2 changes: 1 addition & 1 deletion ui.content/src/main/content/META-INF/vault/filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
<filter root="/content/rep:policy" mode="merge"/>
<filter root="/content/etoolbox-link-inspector/link-inspector" mode="replace"/>
<filter root="/content/etoolbox-link-inspector" mode="merge"/>
<filter root="/content/etoolbox-link-inspector/data/config" mode="merge"/>
<filter root="/conf/etoolbox-link-inspector" mode="merge"/>
</workspaceFilter>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:Folder"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:Folder"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
jcr:primaryType="rep:ACL">
<allow
jcr:primaryType="rep:GrantACE"
rep:principalName="everyone"
rep:privileges="{Name}[jcr:read]"/>
</jcr:root>

0 comments on commit a0222a3

Please sign in to comment.