Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2015-01-26 17:32:09 -0500
committerPascal Rapicault2015-01-26 23:51:57 -0500
commit6cf7e98bd1fe3001279ba1bde421be18fc457a39 (patch)
tree26d00b598cef404760ad3d70d7cb2b326d1c4d37
parent190aa14d08354dd1ba7385c7acbec07084770cdd (diff)
downloadrt.equinox.p2-6cf7e98bd1fe3001279ba1bde421be18fc457a39.tar.gz
rt.equinox.p2-6cf7e98bd1fe3001279ba1bde421be18fc457a39.tar.xz
rt.equinox.p2-6cf7e98bd1fe3001279ba1bde421be18fc457a39.zip
Publish IUs listed in categories even when they are not associated to aI20150203-1300I20150129-1830I20150128-2000I20150128-0900I20150127-2000I20150127-0900
category
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryIUXMLActionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/updatesite/CategoryXMLActionTest/testIUCategoryCreation07.xml4
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java51
3 files changed, 45 insertions, 15 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<site>
+ <iu id="test.feature.feature.group" range="[0.0, 2.0)"/>
+</site> \ 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<SiteCategory, Set<IInstallableUnit>> categoriesToIUs, IPublisherInfo publisherInfo, IPublisherResult results) {
- if (updateSite == null)
- return;
+ Map<SiteIU, Set<SiteCategory>> 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<IInstallableUnit> 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<IInstallableUnit> categoryIUs = categoriesToIUs.get(category);
- if (categoryIUs == null) {
- categoryIUs = new HashSet<IInstallableUnit>();
- categoriesToIUs.put(category, categoryIUs);
+ Set<SiteCategory> 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<IInstallableUnit> iusInCategory = categoriesToIUs.get(category);
+ if (iusInCategory == null) {
+ iusInCategory = new HashSet<IInstallableUnit>();
+ categoriesToIUs.put(category, iusInCategory);
}
- categoryIUs.addAll(ius);
+ iusInCategory.addAll(ius);
}
}
}
+ private Map<SiteIU, Set<SiteCategory>> getIUToCategoryMappings(IPublisherInfo publisherInfo) {
+ HashMap<SiteIU, Set<SiteCategory>> mappings = new HashMap<SiteIU, Set<SiteCategory>>();
+ 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<SiteCategory> categories = new HashSet<SiteCategory>();
+ 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<IInstallableUnit> getIUs(SiteIU siteIU, IPublisherInfo publisherInfo, IPublisherResult results) {
String id = siteIU.getID();
String range = siteIU.getRange();

Back to the top