|
Lines 39-51
Link Here
|
| 39 |
private SiteCategory defaultCategory; |
39 |
private SiteCategory defaultCategory; |
| 40 |
private HashSet defaultCategorySet; |
40 |
private HashSet defaultCategorySet; |
| 41 |
private URI location; |
41 |
private URI location; |
|
|
42 |
private String categoryQualifier = null; |
| 42 |
|
43 |
|
| 43 |
public SiteXMLAction(URI location) { |
44 |
/** |
|
|
45 |
* Creates a SiteXMLAction from a Location (URI) with an optional qualifier to use for category names |
| 46 |
* @param location The location of the update site |
| 47 |
* @param categoryQualifier The qualifier to prepend to categories. This qualifier is used |
| 48 |
* to ensure that the category IDs are unique between update sites. If <b>null</b> a default |
| 49 |
* qualifier will be generated |
| 50 |
*/ |
| 51 |
public SiteXMLAction(URI location, String categoryQualifier) { |
| 44 |
this.location = location; |
52 |
this.location = location; |
|
|
53 |
this.categoryQualifier = categoryQualifier; |
| 45 |
} |
54 |
} |
| 46 |
|
55 |
|
| 47 |
public SiteXMLAction(UpdateSite updateSite) { |
56 |
/** |
|
|
57 |
* Creates a SiteXMLAction from an Update site with an optional qualifier to use for category names |
| 58 |
* @param updateSite The update site |
| 59 |
* @param categoryQualifier The qualifier to prepend to categories. This qualifier is used |
| 60 |
* to ensure that the category IDs are unique between update sites. If <b>null</b> a default |
| 61 |
* qualifier will be generated |
| 62 |
*/ |
| 63 |
public SiteXMLAction(UpdateSite updateSite, String categoryQualifier) { |
| 48 |
this.updateSite = updateSite; |
64 |
this.updateSite = updateSite; |
|
|
65 |
this.categoryQualifier = categoryQualifier; |
| 49 |
} |
66 |
} |
| 50 |
|
67 |
|
| 51 |
private void initialize() { |
68 |
private void initialize() { |
|
Lines 236-242
Link Here
|
| 236 |
protected void generateCategoryIUs(Map categoriesToFeatures, IPublisherResult result) { |
253 |
protected void generateCategoryIUs(Map categoriesToFeatures, IPublisherResult result) { |
| 237 |
for (Iterator it = categoriesToFeatures.keySet().iterator(); it.hasNext();) { |
254 |
for (Iterator it = categoriesToFeatures.keySet().iterator(); it.hasNext();) { |
| 238 |
SiteCategory category = (SiteCategory) it.next(); |
255 |
SiteCategory category = (SiteCategory) it.next(); |
| 239 |
result.addIU(createCategoryIU(category, (Set) categoriesToFeatures.get(category), null), IPublisherResult.NON_ROOT); |
256 |
result.addIU(createCategoryIU(category, (Set) categoriesToFeatures.get(category), null, createQualifier()), IPublisherResult.NON_ROOT); |
| 240 |
} |
257 |
} |
| 241 |
} |
258 |
} |
| 242 |
|
259 |
|
|
Lines 247-256
Link Here
|
| 247 |
* @param parentCategory The parent category, or <code>null</code> |
264 |
* @param parentCategory The parent category, or <code>null</code> |
| 248 |
* @return an IU representing the category |
265 |
* @return an IU representing the category |
| 249 |
*/ |
266 |
*/ |
| 250 |
public static IInstallableUnit createCategoryIU(SiteCategory category, Set featureIUs, IInstallableUnit parentCategory) { |
267 |
public static IInstallableUnit createCategoryIU(SiteCategory category, Set featureIUs, IInstallableUnit parentCategory, String categoryQualifier) { |
| 251 |
InstallableUnitDescription cat = new MetadataFactory.InstallableUnitDescription(); |
268 |
InstallableUnitDescription cat = new MetadataFactory.InstallableUnitDescription(); |
| 252 |
cat.setSingleton(true); |
269 |
cat.setSingleton(true); |
| 253 |
String categoryId = category.getName(); |
270 |
String categoryId = categoryQualifier + category.getName(); |
| 254 |
cat.setId(categoryId); |
271 |
cat.setId(categoryId); |
| 255 |
cat.setVersion(Version.emptyVersion); |
272 |
cat.setVersion(Version.emptyVersion); |
| 256 |
cat.setProperty(IInstallableUnit.PROP_NAME, category.getLabel()); |
273 |
cat.setProperty(IInstallableUnit.PROP_NAME, category.getLabel()); |
|
Lines 293-296
Link Here
|
| 293 |
return MetadataFactory.createInstallableUnit(cat); |
310 |
return MetadataFactory.createInstallableUnit(cat); |
| 294 |
} |
311 |
} |
| 295 |
|
312 |
|
|
|
313 |
/** |
| 314 |
* Creates a qualifier that can be prepended to a category to the category is unique |
| 315 |
* between multiple repositories |
| 316 |
*/ |
| 317 |
private String createQualifier() { |
| 318 |
if (categoryQualifier != null) |
| 319 |
return categoryQualifier + "."; //$NON-NLS-1$ |
| 320 |
if (updateSite != null) |
| 321 |
return URIUtil.toUnencodedString(updateSite.getLocation()) + "."; //$NON-NLS-1$ |
| 322 |
return ""; //$NON-NLS-1$ |
| 323 |
} |
| 324 |
|
| 296 |
} |
325 |
} |