use of org.netbeans.modules.autoupdate.updateprovider.InstalledModuleItem in project netbeans-rcp-lite by outersky.
the class UpdateUnitFactory method appendUpdateItems.
Map<String, UpdateUnit> appendUpdateItems(Map<String, UpdateUnit> originalUnits, UpdateProvider provider) {
assert originalUnits != null : "Map of original UnitImpl cannot be null";
boolean trusted = UpdateUnitProviderImpl.loadTrusted(provider);
Map<String, UpdateItem> items;
try {
items = provider.getUpdateItems();
} catch (IOException ioe) {
log.log(Level.INFO, "Cannot read UpdateItem from UpdateProvider " + provider, ioe);
return originalUnits;
}
assert items != null : "UpdateProvider[" + provider.getName() + "] should return non-null items.";
// append updates
for (String simpleItemId : items.keySet()) {
UpdateElement updateEl = null;
try {
// create UpdateItemImpl
UpdateItemImpl itemImpl = Trampoline.SPI.impl(items.get(simpleItemId));
boolean isKitModule = false;
if (itemImpl instanceof ModuleItem) {
ModuleInfo mi = ((ModuleItem) itemImpl).getModuleInfo();
assert mi != null : "ModuleInfo must be found for " + itemImpl;
isKitModule = Utilities.isKitModule(mi);
}
if (itemImpl instanceof InstalledModuleItem) {
if (isKitModule) {
KitModuleUpdateElementImpl impl = new KitModuleUpdateElementImpl((InstalledModuleItem) itemImpl, null);
updateEl = Trampoline.API.createUpdateElement(impl);
} else {
ModuleUpdateElementImpl impl = new ModuleUpdateElementImpl((InstalledModuleItem) itemImpl, null);
updateEl = Trampoline.API.createUpdateElement(impl);
}
} else if (itemImpl instanceof ModuleItem) {
if (isKitModule) {
KitModuleUpdateElementImpl impl = new KitModuleUpdateElementImpl((ModuleItem) itemImpl, provider.getDisplayName());
updateEl = Trampoline.API.createUpdateElement(impl);
} else {
ModuleUpdateElementImpl impl = new ModuleUpdateElementImpl((ModuleItem) itemImpl, provider.getDisplayName());
updateEl = Trampoline.API.createUpdateElement(impl);
}
} else if (itemImpl instanceof LocalizationItem) {
updateEl = Trampoline.API.createUpdateElement(new LocalizationUpdateElementImpl((LocalizationItem) itemImpl, provider.getDisplayName()));
} else if (itemImpl instanceof NativeComponentItem) {
updateEl = Trampoline.API.createUpdateElement(new NativeComponentUpdateElementImpl((NativeComponentItem) itemImpl, provider.getDisplayName()));
} else if (itemImpl instanceof FeatureItem) {
FeatureUpdateElementImpl impl = new FeatureUpdateElementImpl.Agent((FeatureItem) itemImpl, provider.getDisplayName(), UpdateManager.TYPE.FEATURE);
updateEl = Trampoline.API.createUpdateElement(impl);
} else {
assert false : "Unknown type of UpdateElement " + updateEl;
}
} catch (IllegalArgumentException iae) {
log.log(Level.INFO, iae.getLocalizedMessage(), iae);
}
// add element to map
if (updateEl != null) {
Trampoline.API.impl(updateEl).setCatalogTrusted(trusted);
addElement(originalUnits, updateEl, provider);
}
}
return originalUnits;
}
use of org.netbeans.modules.autoupdate.updateprovider.InstalledModuleItem in project netbeans-rcp-lite by outersky.
the class ModuleUpdateElementImpl method getLicenseId.
@Override
public String getLicenseId() {
if (item instanceof InstalledModuleItem) {
// find the same item from UC
UpdateUnitImpl impl = Trampoline.API.impl(getUpdateUnit());
UpdateElement elWithSameVersion = impl.findUpdateSameAsInstalled();
if (elWithSameVersion != null) {
return elWithSameVersion.getLicenseId();
}
} else {
assert item.getUpdateLicenseImpl() != null : item + " has UpdateLicenseImpl.";
if (item.getUpdateLicenseImpl() != null) {
return item.getUpdateLicenseImpl().getName();
}
}
return null;
}
Aggregations