adobe / asset-share-commons

A modern, open-source asset share reference implementation built on Adobe Experience Manager (AEM)
https://opensource.adobe.com/asset-share-commons/
Apache License 2.0
88 stars 107 forks source link

New SearchPredicate is not recognized w/o bundle restart #327

Closed HitmanInWis closed 5 years ago

HitmanInWis commented 6 years ago

Describe the bug If a bundle includes an implementation of com.adobe.aem.commons.assetshare.search.searchpredicates.SearchPredicate, the com.adobe.aem.commons.assetshare.search.impl.datasources.SearchPredicatesDataSource instance does not pick up the search predicate.

This results in a case where a configured Search Restriction on the asset share results component will be lost if the author saves the dialog not realizing the custom Search Restriction is no longer valid.

This can be resolved manually by restarting the Asset Share bundle, but the reference is lost again if the custom bundle is reinstalled/restarted.

Environment

Expected behavior SearchPredicatesDataSource should always reflect the latest list of SearchPredicate implementations.

HitmanInWis commented 6 years ago

I believe the solution would be to update:

    @Reference(cardinality = ReferenceCardinality.MULTIPLE)
    private transient Collection<SearchPredicate> searchPredicates;

to

    @Reference(cardinality = ReferenceCardinality.MULTIPLE, policyOption = ReferencePolicyOption.GREEDY)
    private transient Collection<SearchPredicate> searchPredicates;

It also begs the question if similar changes should be made to other classes.

davidjgonzalez commented 6 years ago

@HitmanInWis you wanna PR? i can but don't want to steal your commits since you did the hard work of tracking it down ;)

Agree we should do a sanity check of other @Reference's in the proj