Search in sources :

Example 6 with UpdateItem

use of org.netbeans.spi.autoupdate.UpdateItem in project netbeans-rcp-lite by outersky.

the class ArtificialFeaturesProvider method getUpdateItems.

@Override
public Map<String, UpdateItem> getUpdateItems() throws IOException {
    if (!generateArtificialFeatures()) {
        return Collections.emptyMap();
    }
    Map<String, UpdateItem> res = new HashMap<String, UpdateItem>();
    // crate features built on installed modules
    Map<String, Set<ModuleInfo>> categoryToModules = new HashMap<String, Set<ModuleInfo>>();
    for (UpdateItem item : originalItems) {
        UpdateItemImpl impl = Utilities.getUpdateItemImpl(item);
        if (impl instanceof InstalledModuleItem) {
            InstalledModuleItem installedModule = (InstalledModuleItem) impl;
            String category = (String) installedModule.getModuleInfo().getLocalizedAttribute("OpenIDE-Module-Display-Category");
            Module module = Utilities.toModule(installedModule.getModuleInfo().getCodeNameBase(), installedModule.getModuleInfo().getSpecificationVersion());
            assert module != null : "Module found for " + installedModule.getModuleInfo().getCodeNameBase() + ", " + installedModule.getModuleInfo().getSpecificationVersion();
            if (module.isAutoload() || module.isFixed()) {
                continue;
            } else if (module.isEager()) {
                continue;
            } else if (category == null || category.length() == 0) {
                category = UNSORTED_CATEGORY;
            }
            if (!categoryToModules.containsKey(category)) {
                categoryToModules.put(category, new HashSet<ModuleInfo>());
            }
            categoryToModules.get(category).add(installedModule.getModuleInfo());
        } else if (impl instanceof ModuleItem) {
            ModuleItem updateModule = (ModuleItem) impl;
            String category = (String) updateModule.getModuleInfo().getLocalizedAttribute("OpenIDE-Module-Display-Category");
            if (LIBRARIES_CATEGORY.equals(category) || BRIDGES_CATEGORY.equals(category) || FEATURES_CATEGORY.equals(category)) {
                continue;
            }
            if (category == null || category.length() == 0) {
                String dn = (String) updateModule.getModuleInfo().getLocalizedAttribute("OpenIDE-Module-Display-Category");
                if (dn == null || dn.length() == 0) {
                    category = UNSORTED_CATEGORY;
                } else {
                    category = dn;
                }
            }
            if (!categoryToModules.containsKey(category)) {
                categoryToModules.put(category, new HashSet<ModuleInfo>());
            }
            categoryToModules.get(category).add(updateModule.getModuleInfo());
        } else {
        // XXX: ignore other types now
        }
    }
    // make a feature for each one category
    for (String category : categoryToModules.keySet()) {
        if (true) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
        FeatureItem featureItemImpl = createFeatureItem(category, null, /*categoryToModules.get (category)*/
        null, null, null);
        log.log(Level.FINE, "Create FeatureItem[" + category + ", " + featureItemImpl.getSpecificationVersion().toString() + "] containing modules " + featureItemImpl.getDependenciesToModules());
        UpdateItem featureItem = Utilities.createUpdateItem(featureItemImpl);
        res.put(featureItemImpl.getCodeName() + '_' + featureItemImpl.getSpecificationVersion(), featureItem);
    }
    return res;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) UpdateItem(org.netbeans.spi.autoupdate.UpdateItem) ModuleInfo(org.openide.modules.ModuleInfo) Module(org.netbeans.Module) HashSet(java.util.HashSet)

Example 7 with UpdateItem

use of org.netbeans.spi.autoupdate.UpdateItem in project netbeans-rcp-lite by outersky.

the class AutoupdateCatalogProvider method getUpdateItems.

@Override
public Map<String, UpdateItem> getUpdateItems() throws IOException {
    URL toParse = cache.getCatalogURL(codeName);
    if (toParse == null) {
        LOG.log(Level.FINE, "No content in cache for {0} provider. Returns EMPTY_MAP", codeName);
        return Collections.emptyMap();
    }
    Map<String, UpdateItem> map;
    synchronized (cache.getLock(toParse)) {
        map = AutoupdateCatalogParser.getUpdateItems(toParse, this);
    }
    for (UpdateItem ui : map.values()) {
        UpdateItemImpl impl = Trampoline.SPI.impl(ui);
    }
    descriptionInitialized = true;
    return map;
}
Also used : UpdateItem(org.netbeans.spi.autoupdate.UpdateItem) URL(java.net.URL)

Aggregations

UpdateItem (org.netbeans.spi.autoupdate.UpdateItem)7 IOException (java.io.IOException)2 ParseException (java.text.ParseException)2 Module (org.netbeans.Module)2 ModuleItem (org.netbeans.modules.autoupdate.updateprovider.ModuleItem)2 UpdateItemImpl (org.netbeans.modules.autoupdate.updateprovider.UpdateItemImpl)2 ModuleInfo (org.openide.modules.ModuleInfo)2 URL (java.net.URL)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 UpdateElement (org.netbeans.api.autoupdate.UpdateElement)1 FeatureItem (org.netbeans.modules.autoupdate.updateprovider.FeatureItem)1 InstalledModuleItem (org.netbeans.modules.autoupdate.updateprovider.InstalledModuleItem)1 LocalizationItem (org.netbeans.modules.autoupdate.updateprovider.LocalizationItem)1 NativeComponentItem (org.netbeans.modules.autoupdate.updateprovider.NativeComponentItem)1