You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Angela Schreiber (Jira)" <ji...@apache.org> on 2021/07/30 12:27:00 UTC
[jira] [Updated] (SLING-10692) VaultPackageAssembler.mergeFilters
drops propertyFilterSets
[ https://issues.apache.org/jira/browse/SLING-10692?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Angela Schreiber updated SLING-10692:
-------------------------------------
Description:
[~kpauls], write providing a fix for https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/97 i noticed that if the option 'matchProperties=true' is present with any entry of a given {{PathFilterSet}} those entries will be drop from the {{WorkspaceFilter}} upon {{mergeFilters}} because the method only transfers node-PathFilterSet(s):
{code}
public void mergeFilters(@NotNull WorkspaceFilter filter) {
for (PathFilterSet pathFilterSet : filter.getFilterSets()) {
if (!OSGI_BUNDLE_PATTERN.matcher(pathFilterSet.getRoot()).matches()) {
this.filter.add(pathFilterSet);
}
}
}
{code}
what it should do instead would likely be something along the following lines
{code}
public void mergeFilters(@NotNull WorkspaceFilter filter) {
Map<String, PathFilterSet> propFilterSets = new LinkedHashMap<>();
filter.getPropertyFilterSets().forEach(pathFilterSet -> propFilterSets.put(pathFilterSet.getRoot(), pathFilterSet));
for (PathFilterSet pathFilterSet : filter.getFilterSets()) {
if (!OSGI_BUNDLE_PATTERN.matcher(pathFilterSet.getRoot()).matches()) {
PathFilterSet propSet = propFilterSets.remove(pathFilterSet.getRoot());
if (propSet != null) {
this.filter.add(pathFilterSet, propSet);
} else {
this.filter.add(pathFilterSet);
}
}
}
}
{code}
I didn't yet write extensive tests to verify that this actually works property, but I suspect that in addition there might be changes required to the {{createAdjustedFilter}} method.... at a first glance it seems that a combination of {{DefaultWorkspaceFilter#addPropertyFilterSet(PathFilterSet set)}} and {{#add(PathFilterSet set)}} isn't equivalent of {{DefaultWorkspaceFilter#add(PathFilterSet nodeFilter, PathFilterSet propFilter)}} which might result in subtle differences when generating the new Filter source.
wdyt? i don't know how common 'matchProperties=true' is in practice but if present this issue would lead to a different behavior of the content package.
was:
[~kpauls], write providing a fix for https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/97 i noticed that if the option 'matchProperties=true' is present with any entry of a given {{PathFilterSet}} those entries will be drop from the {{WorkspaceFilter}} upon {{mergeFilters}} because the method only transfers node-PathFilterSet(s):
{code}
public void mergeFilters(@NotNull WorkspaceFilter filter) {
for (PathFilterSet pathFilterSet : filter.getFilterSets()) {
if (!OSGI_BUNDLE_PATTERN.matcher(pathFilterSet.getRoot()).matches()) {
this.filter.add(pathFilterSet);
}
}
}
{code}
what it should do instead would likely be something along the following lines
{code}
public void mergeFilters(@NotNull WorkspaceFilter filter) {
Map<String, PathFilterSet> propFilterSets = new LinkedHashMap<>();
filter.getPropertyFilterSets().forEach(pathFilterSet -> propFilterSets.put(pathFilterSet.getRoot(), pathFilterSet));
for (PathFilterSet pathFilterSet : filter.getFilterSets()) {
if (!OSGI_BUNDLE_PATTERN.matcher(pathFilterSet.getRoot()).matches()) {
PathFilterSet propSet = propFilterSets.remove(pathFilterSet.getRoot());
if (propSet != null) {
this.filter.add(pathFilterSet, propSet);
} else {
this.filter.add(pathFilterSet);
}
}
}
}
{code}
I didn't yet write extensive tests to verify that this actually works property, but I suspect that in addition there might be changes required to the {{createAdjustedFilter}} method.... at a first glance it seems that a combination of {{DefaultWorkspaceFilter#addPropertyFilterSet(PathFilterSet set)}} and {{#add(PathFilterSet set)}} isn't equivalent of {{DefaultWorkspaceFilter#add(PathFilterSet nodeFilter, PathFilterSet propFilter)}} which might result in subtle differences when generating the new Filter source.
wdyt? i don't know how common 'matchProperties=true' is in practice but if present this issue would lead to an different behavior of the content package.
> VaultPackageAssembler.mergeFilters drops propertyFilterSets
> -----------------------------------------------------------
>
> Key: SLING-10692
> URL: https://issues.apache.org/jira/browse/SLING-10692
> Project: Sling
> Issue Type: Bug
> Components: Content-Package to Feature Model Converter
> Reporter: Angela Schreiber
> Priority: Major
>
> [~kpauls], write providing a fix for https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/97 i noticed that if the option 'matchProperties=true' is present with any entry of a given {{PathFilterSet}} those entries will be drop from the {{WorkspaceFilter}} upon {{mergeFilters}} because the method only transfers node-PathFilterSet(s):
> {code}
> public void mergeFilters(@NotNull WorkspaceFilter filter) {
> for (PathFilterSet pathFilterSet : filter.getFilterSets()) {
> if (!OSGI_BUNDLE_PATTERN.matcher(pathFilterSet.getRoot()).matches()) {
> this.filter.add(pathFilterSet);
> }
> }
> }
> {code}
> what it should do instead would likely be something along the following lines
> {code}
> public void mergeFilters(@NotNull WorkspaceFilter filter) {
> Map<String, PathFilterSet> propFilterSets = new LinkedHashMap<>();
> filter.getPropertyFilterSets().forEach(pathFilterSet -> propFilterSets.put(pathFilterSet.getRoot(), pathFilterSet));
> for (PathFilterSet pathFilterSet : filter.getFilterSets()) {
> if (!OSGI_BUNDLE_PATTERN.matcher(pathFilterSet.getRoot()).matches()) {
> PathFilterSet propSet = propFilterSets.remove(pathFilterSet.getRoot());
> if (propSet != null) {
> this.filter.add(pathFilterSet, propSet);
> } else {
> this.filter.add(pathFilterSet);
> }
> }
> }
> }
> {code}
> I didn't yet write extensive tests to verify that this actually works property, but I suspect that in addition there might be changes required to the {{createAdjustedFilter}} method.... at a first glance it seems that a combination of {{DefaultWorkspaceFilter#addPropertyFilterSet(PathFilterSet set)}} and {{#add(PathFilterSet set)}} isn't equivalent of {{DefaultWorkspaceFilter#add(PathFilterSet nodeFilter, PathFilterSet propFilter)}} which might result in subtle differences when generating the new Filter source.
> wdyt? i don't know how common 'matchProperties=true' is in practice but if present this issue would lead to a different behavior of the content package.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)