use of org.netbeans.modules.autoupdate.updateprovider.BackupUpdateProvider in project netbeans-rcp-lite by outersky.
the class UpdateUnitFactory method addElement.
private void addElement(Map<String, UpdateUnit> impls, UpdateElement element, UpdateProvider provider) {
// find if corresponding element exists
UpdateUnit unit = impls.get(element.getCodeName());
// XXX: it's should be moved in UI what should filter all elements w/ broken dependencies
// #101515: Plugin Manager must filter updates by platform dependency
boolean passed = false;
UpdateElementImpl elImpl = Trampoline.API.impl(element);
if (elImpl instanceof ModuleUpdateElementImpl && elImpl.getModuleInfos() != null && elImpl.getModuleInfos().size() == 1) {
for (Dependency d : elImpl.getModuleInfos().get(0).getDependencies()) {
if (Dependency.TYPE_REQUIRES == d.getType()) {
// log.log (Level.FINEST, "Dependency: NAME: " + d.getName () + ", TYPE: " + d.getType () + ": " + d.toString ());
if (d.getName().startsWith("org.openide.modules.os")) {
// NOI18N
for (ModuleInfo info : InstalledModuleProvider.getInstalledModules().values()) {
if (Arrays.asList(info.getProvides()).contains(d.getName())) {
log.log(Level.FINEST, element + " which requires OS " + d + " succeed.");
passed = true;
break;
}
}
if (!passed) {
log.log(Level.FINE, element + " which requires OS " + d + " fails.");
return;
}
}
}
}
}
UpdateUnitImpl unitImpl = null;
if (unit == null) {
switch(elImpl.getType()) {
case MODULE:
unitImpl = new ModuleUpdateUnitImpl(element.getCodeName());
break;
case KIT_MODULE:
unitImpl = new KitModuleUpdateUnitImpl(element.getCodeName());
break;
case STANDALONE_MODULE:
case FEATURE:
unitImpl = new FeatureUpdateUnitImpl(element.getCodeName(), elImpl.getType());
break;
case CUSTOM_HANDLED_COMPONENT:
unitImpl = new NativeComponentUpdateUnitImpl(element.getCodeName());
break;
case LOCALIZATION:
unitImpl = new LocalizationUpdateUnitImpl(element.getCodeName());
break;
default:
assert false : "Unsupported for type " + elImpl.getType();
}
unit = Trampoline.API.createUpdateUnit(unitImpl);
impls.put(unit.getCodeName(), unit);
} else {
unitImpl = Trampoline.API.impl(unit);
}
if (provider == InstalledUpdateProvider.getDefault()) {
if (unitImpl.getInstalled() == null) {
unitImpl.setInstalled(element);
}
} else if (provider instanceof BackupUpdateProvider) {
unitImpl.setBackup(element);
} else {
// suppose common UpdateProvider
unitImpl.addUpdate(element);
}
// set UpdateUnit into element
elImpl.setUpdateUnit(unit);
}
Aggregations