Skip to main content
Skip table of contents

Managing expired downloads

Client applications can manage expired asset and licence disposal in a batch. On user input or on periodic check (for example on startup), the client application can retrieve all expired licences. Based on that information, the client application can act by doing one if the following:

  • Erasing licences from the PAK and related downloaded assets from the device.
  • Renewing licences.

This operation takes place when the user decides to delete a downloaded asset on the device.

Example code

The following code shows how to find and purge any expired licenses and the assets to which they belong:

JAVA
public List<Download> findInvalidDownloadAt(Date xDate) { 
  // Fetch all downloads
  Download[] downloads = mDownloadManager.getDownloads();
  List<Download> result = new List<Download>();

  for (Download download : downloads) {
    // Find the stored entitlement associated with the download.
    String prmSyntax = download.getAsset().getPRMSyntax();
    if (prmSyntax == null || prmSyntax.isEmpty()) {
      // Download is in the clear, ignore
      continue;
    }

    // Check that either no entitlement is present, or all entitlements are expired at the given date.
    boolean isInvalid = true;
    List<PakCoreDrmEntitlement> entitlements = drmAgent.generateListOfStoredDrmEntitlements(prmSyntax,””);
    for (PakCoreDrmEntitlement entitlement : entitlements) {
      if (entilement.getExpirationDate().after(date)) {
        isInvalid = false;
        break;
      }
    }

    // Return the download if all licenses are expired at the given date
    if (isInvalid) {
      result.add(download);
    }
  }
  return result;
}

public boolean removeExpiredAssets(Date xDate) {
  boolean result = true;
  // Fetch all downloads, and go through all of them
  Download[] downloads = mDownloadManager.getDownloads();
  for (Download download : downloads) {
    if (isExpired(download, xDate) {
      result &= removeAssetByUUID(download.getUUID());
    }
  }
  return result;
}
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.