Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2009-04-27 13:52:35 +0000
committerPascal Rapicault2009-04-27 13:52:35 +0000
commit2fa927f35a50a8acecaa3e53c553348958d4a4f9 (patch)
treef9d422823ef9c846a7bafe80c57c601d7f016abc /bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java
parentec2e6a45e7e3654674534b29e1ecb9de20b09c29 (diff)
downloadrt.equinox.p2-2fa927f35a50a8acecaa3e53c553348958d4a4f9.tar.gz
rt.equinox.p2-2fa927f35a50a8acecaa3e53c553348958d4a4f9.tar.xz
rt.equinox.p2-2fa927f35a50a8acecaa3e53c553348958d4a4f9.zip
Bug 273177 - [publisher] No metadata generated for a product license
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java
index 77fcb845f..156a682f4 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java
@@ -10,6 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.p2.publisher.actions;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.publisher.*;
@@ -49,6 +51,7 @@ public class RootIUAction extends AbstractPublisherAction {
processCapabilityAdvice(descriptor, info);
processTouchpointAdvice(descriptor, null, info);
processInstallableUnitPropertiesAdvice(descriptor, info);
+ processLicense(descriptor, info);
IInstallableUnit rootIU = MetadataFactory.createInstallableUnit(descriptor);
if (rootIU == null)
return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.error_rootIU_generation, new Object[] {name, id, version}));
@@ -64,6 +67,28 @@ public class RootIUAction extends AbstractPublisherAction {
// result.addIU(generateDefaultCategory(rootIU, rootCategory), IPublisherResult.NON_ROOT);
}
+ protected static void processLicense(InstallableUnitDescription iu, IPublisherInfo info) {
+ Collection advice = info.getAdvice(null, true, iu.getId(), iu.getVersion(), ILicenseAdvice.class);
+ if (advice.size() > 0) {
+ // Only process the first license we find for this IU.
+ ILicenseAdvice entry = (ILicenseAdvice) advice.iterator().next();
+ String licenseText = entry.getLicenseText() == null ? "" : entry.getLicenseText(); //$NON-NLS-1$
+ String licenseUrl = entry.getLicenseURL() == null ? "" : entry.getLicenseURL(); //$NON-NLS-1$
+ if (licenseText.length() > 0 || licenseUrl.length() > 0)
+ iu.setLicense(MetadataFactory.createLicense(toURIOrNull(licenseUrl), licenseText));
+ }
+ }
+
+ private static URI toURIOrNull(String url) {
+ if (url == null)
+ return null;
+ try {
+ return URIUtil.fromString(url);
+ } catch (URISyntaxException e) {
+ return null;
+ }
+ }
+
/**
* This was copied over from Generator to match up with the call from generateRootIU (above).
* It is entirely unclear why it was needed. Should review.

Back to the top