From 6cf7e98bd1fe3001279ba1bde421be18fc457a39 Mon Sep 17 00:00:00 2001
From: Pascal Rapicault
Date: Mon, 26 Jan 2015 17:32:09 -0500
Subject: Publish IUs listed in categories even when they are not associated to
a category
---
.../tests/updatesite/CategoryIUXMLActionTest.java | 5 +++
.../testIUCategoryCreation07.xml | 4 ++
.../internal/p2/updatesite/SiteXMLAction.java | 51 +++++++++++++++-------
3 files changed, 45 insertions(+), 15 deletions(-)
create mode 100644 bundles/org.eclipse.equinox.p2.tests/testData/updatesite/CategoryXMLActionTest/testIUCategoryCreation07.xml
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryIUXMLActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryIUXMLActionTest.java
index 9ce4ba43d..0c0e8a7d1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryIUXMLActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryIUXMLActionTest.java
@@ -68,6 +68,11 @@ public class CategoryIUXMLActionTest extends AbstractProvisioningTest {
doCategoryNotSetTest();
}
+ public void testIUCategoryCreation07() throws Exception {
+ IQueryResult result = actionResult.query(QueryUtil.createIUCategoryQuery(), new NullProgressMonitor());
+ assertEquals("1.0", 1, queryResultSize(result));
+ }
+
private void doCategorySetTest() {
IQueryResult result = actionResult.query(QueryUtil.createIUCategoryQuery(), new NullProgressMonitor());
assertEquals("1.0", 1, queryResultSize(result));
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/updatesite/CategoryXMLActionTest/testIUCategoryCreation07.xml b/bundles/org.eclipse.equinox.p2.tests/testData/updatesite/CategoryXMLActionTest/testIUCategoryCreation07.xml
new file mode 100644
index 000000000..44570b7f4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/updatesite/CategoryXMLActionTest/testIUCategoryCreation07.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
index 56e9e8d4b..0f0ee0427 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
@@ -214,33 +214,54 @@ public class SiteXMLAction extends AbstractPublisherAction {
}
private void addSiteIUsToCategories(Map> categoriesToIUs, IPublisherInfo publisherInfo, IPublisherResult results) {
- if (updateSite == null)
- return;
+ Map> iusToCategories = getIUToCategoryMappings(publisherInfo);
SiteModel site = updateSite.getSite();
if (site == null)
return;
SiteIU[] siteIUs = site.getIUs();
for (SiteIU siteIU : siteIUs) {
- String[] categoryNames = siteIU.getCategoryNames();
- if (categoryNames.length == 0)
- continue;
Collection ius = getIUs(siteIU, publisherInfo, results);
- if (ius.size() == 0)
+ if (ius == null)
continue;
- for (String categoryName : categoryNames) {
- SiteCategory category = site.getCategory(categoryName);
- if (category == null)
- continue;
- Set categoryIUs = categoriesToIUs.get(category);
- if (categoryIUs == null) {
- categoryIUs = new HashSet();
- categoriesToIUs.put(category, categoryIUs);
+ Set categories = iusToCategories.get(siteIU);
+ // if there are no categories for this feature then add it to the default category.
+ if (categories == null || categories.isEmpty())
+ categories = defaultCategorySet;
+ for (SiteCategory category : categories) {
+ Set iusInCategory = categoriesToIUs.get(category);
+ if (iusInCategory == null) {
+ iusInCategory = new HashSet();
+ categoriesToIUs.put(category, iusInCategory);
}
- categoryIUs.addAll(ius);
+ iusInCategory.addAll(ius);
}
}
}
+ private Map> getIUToCategoryMappings(IPublisherInfo publisherInfo) {
+ HashMap> mappings = new HashMap>();
+ if (updateSite == null)
+ return mappings;
+ SiteModel site = updateSite.getSite();
+ if (site == null)
+ return mappings;
+
+ SiteIU[] ius = site.getIUs();
+ for (int i = 0; i < ius.length; i++) {
+ //add a mapping for each category this feature belongs to
+ String[] categoryNames = ius[i].getCategoryNames();
+ Set categories = new HashSet();
+ mappings.put(ius[i], categories);
+ for (int j = 0; j < categoryNames.length; j++) {
+ SiteCategory category = site.getCategory(categoryNames[j]);
+ if (category != null)
+ categories.add(category);
+ }
+ }
+ return mappings;
+
+ }
+
private Collection getIUs(SiteIU siteIU, IPublisherInfo publisherInfo, IPublisherResult results) {
String id = siteIU.getID();
String range = siteIU.getRange();
--
cgit v1.2.3