Skip to content

Commit

Permalink
New dependencies on licensed extensions are not covered by existing l…
Browse files Browse the repository at this point in the history
…icenses when upgrading licensed extensions #174

* description update
  • Loading branch information
oanalavinia committed Oct 24, 2024
1 parent 30f2764 commit b37e5e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.xwiki.stability.Unstable;

/**
* Description in progress.
* Receive licenses updates from store or renew existing licenses if properties have changed.
*
* @version $Id$
* @since 1.27
Expand All @@ -34,7 +34,8 @@
public interface LicenseUpdater
{
/**
* Make request to store for renewing this extension's license. Description in progress.
* Renew this extension's license for including new properties (e.g. new licensed feature ids after changed
* dependencies). Request the license renewal to store and update the license locally as well.
*
* @param extensionId extension for which the license needs an update
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
import com.xwiki.licensing.internal.helpers.HttpClientUtils;

/**
* Handle license updates processes. Description in progress.
* Default implementation of {@link LicenseUpdater}.
*
* @version $Id$
* @since 1.27
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javax.inject.Provider;
import javax.inject.Singleton;

import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.xwiki.component.annotation.Component;
import org.xwiki.extension.ExtensionId;
Expand All @@ -48,7 +49,10 @@
import com.xwiki.licensing.Licensor;

/**
* Description in progress.
* Listen to licensed extensions upgrades or install in order to trigger a license renewal if needed. A license renew
* it's needed if licensed dependencies (direct or transitive) have changed between versions, or if the currnt license
* has outdated feature ids. Listen also for the install event in case a license was already generated for an older
* uninstalled version.
*
* @version $Id$
* @since 1.27
Expand Down Expand Up @@ -162,7 +166,7 @@ private void extensionUpgraded(InstalledExtension installedExtension, Object dat
if (!licensedDependencies.equals(previousDependencies) || licensedFeatureIdsChanges(license, installedExtension,
licensedDependencies))
{
logger.debug("New licensed dependencies found.");
logger.debug("There are licensed dependencies changes between old and current extension version.");
licenseUpdater.renewLicense(installedExtension.getId());
}
}
Expand All @@ -176,9 +180,10 @@ private boolean licensedFeatureIdsChanges(License license, InstalledExtension in
List<String> licensedDependenciesIds =
licensedDependencies.stream().map(ExtensionId::getId).collect(Collectors.toList());

boolean changedDependencies = !licensedDependenciesIds.equals(licenseFeatureIds);
boolean changedDependencies = !CollectionUtils.isEqualCollection(licensedDependenciesIds, licenseFeatureIds);
if (changedDependencies) {
logger.debug("License contains outdated feature ids [{}]", licenseFeatureIds);
logger.debug("License contains outdated feature ids: [{}]. New feature ids: [{}]", licenseFeatureIds,
licensedDependenciesIds);
}
return changedDependencies;
}
Expand Down

0 comments on commit b37e5e1

Please sign in to comment.