Search in sources :

Example 96 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.

the class MarketplaceCatalog method setUpdatesAvailable.

private boolean setUpdatesAvailable(Map<String, IInstallableUnit> installedIUs, MarketplaceNodeCatalogItem item) {
    boolean needOnlineCheck = false;
    List<MarketplaceNodeInstallableUnitItem> installableUnitItems = item.getInstallableUnitItems();
    for (MarketplaceNodeInstallableUnitItem iuItem : installableUnitItems) {
        String key = createRepositoryIuKey(item.getSiteUrl(), iuItem.getId());
        Version availableVersion = repositoryIuVersionById.get(key);
        iuItem.setUpdateAvailable(false);
        iuItem.setAvailable(false);
        if (availableVersion != null) {
            iuItem.setAvailable(true);
            IInstallableUnit installedIu = installedIUs.get(iuItem.getId());
            if (installedIu != null && installedIu.getVersion().compareTo(availableVersion) < 0) {
                iuItem.setUpdateAvailable(true);
            }
        } else if (!repositoryIuVersionById.containsKey(key)) {
            needOnlineCheck = true;
        }
    }
    return needOnlineCheck;
}
Also used : Version(org.eclipse.equinox.p2.metadata.Version) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 97 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.

the class MarketplaceInfoTest method computeInstalledCatalogNodeIdsNoMarketplaceInfo.

@Test
public void computeInstalledCatalogNodeIdsNoMarketplaceInfo() {
    assertTrue(item.getInstallableUnits().size() > 1);
    assertEquals(0, catalogRegistry.getNodeKeyToIU().size());
    Map<String, IInstallableUnit> installedIus = new HashMap<String, IInstallableUnit>();
    InstallableUnit mainIu = addIU(installedIus, item.getInstallableUnits().get(0));
    Set<? extends INode> installedCatalogNodeIds = catalogRegistry.computeInstalledNodes(item.getMarketplaceUrl(), installedIus);
    assertNotNull(installedCatalogNodeIds);
    assertEquals(0, installedCatalogNodeIds.size());
    for (String iu : item.getInstallableUnits()) {
        addIU(installedIus, iu);
    }
    mainIu.setProperty(MarketplaceInfo.MPC_NODE_IU_PROPERTY, item.getData().getUrl());
    installedCatalogNodeIds = catalogRegistry.computeInstalledNodes(item.getMarketplaceUrl(), installedIus);
    assertNotNull(installedCatalogNodeIds);
    assertEquals(1, installedCatalogNodeIds.size());
    assertEquals(item.getData().getUrl(), installedCatalogNodeIds.iterator().next().getUrl());
}
Also used : HashMap(java.util.HashMap) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) InstallableUnit(org.eclipse.equinox.internal.p2.metadata.InstallableUnit) Test(org.junit.Test)

Example 98 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.

the class MarketplaceInfoTest method addIU.

private InstallableUnit addIU(Map<String, IInstallableUnit> installedIus, String id) {
    InstallableUnit installableUnit = (InstallableUnit) installedIus.get(id);
    if (installableUnit == null) {
        installableUnit = new InstallableUnit();
        installableUnit.setId(id);
        IInstallableUnit iu = installableUnit;
        installedIus.put(iu.getId(), iu);
    }
    return installableUnit;
}
Also used : IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) InstallableUnit(org.eclipse.equinox.internal.p2.metadata.InstallableUnit)

Example 99 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.

the class CompositeProfileChangeOperation method updateRequest.

private void updateRequest(ProfileChangeRequest request, ProfileChangeOperation operation, MultiStatus status, IProgressMonitor monitor) {
    // TODO we do too much here - this already does the plan resolution, which is expensive...
    IStatus result = operation.resolveModal(monitor);
    status.merge(result);
    if (status.getSeverity() != IStatus.ERROR) {
        IProfileChangeRequest operationChangeRequest = operation.getProfileChangeRequest();
        Collection<IInstallableUnit> additions = operationChangeRequest.getAdditions();
        Collection<IInstallableUnit> removals = operationChangeRequest.getRemovals();
        Collection<IRequirement> extraRequirements = operationChangeRequest.getExtraRequirements();
        request.removeAll(removals);
        request.addAll(additions);
        if (extraRequirements != null) {
            request.addExtraRequirements(extraRequirements);
        }
        if (operationChangeRequest instanceof ProfileChangeRequest) {
            ProfileChangeRequest internalRequest = (ProfileChangeRequest) operationChangeRequest;
            Map<IInstallableUnit, List<String>> installableUnitProfilePropertiesToRemove = internalRequest.getInstallableUnitProfilePropertiesToRemove();
            for (Entry<IInstallableUnit, List<String>> entry : installableUnitProfilePropertiesToRemove.entrySet()) {
                List<String> properties = entry.getValue();
                if (properties != null && !properties.isEmpty()) {
                    IInstallableUnit iu = entry.getKey();
                    for (String property : properties) {
                        request.removeInstallableUnitProfileProperty(iu, property);
                    }
                }
            }
            Map<IInstallableUnit, Map<String, String>> installableUnitProfilePropertiesToAdd = internalRequest.getInstallableUnitProfilePropertiesToAdd();
            for (Entry<IInstallableUnit, Map<String, String>> entry : installableUnitProfilePropertiesToAdd.entrySet()) {
                Map<String, String> properties = entry.getValue();
                if (properties != null && !properties.isEmpty()) {
                    IInstallableUnit iu = entry.getKey();
                    for (Entry<String, String> property : properties.entrySet()) {
                        request.setInstallableUnitProfileProperty(iu, property.getKey(), property.getValue());
                    }
                }
            }
            String[] propertiesToRemove = internalRequest.getPropertiesToRemove();
            for (String property : propertiesToRemove) {
                request.removeProfileProperty(property);
            }
            Map<String, String> propertiesToAdd = internalRequest.getPropertiesToAdd();
            for (Entry<String, String> property : propertiesToAdd.entrySet()) {
                request.setProfileProperty(property.getKey(), property.getValue());
            }
        }
    }
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IStatus(org.eclipse.core.runtime.IStatus) IProfileChangeRequest(org.eclipse.equinox.p2.planner.IProfileChangeRequest) IProfileChangeRequest(org.eclipse.equinox.p2.planner.IProfileChangeRequest) ProfileChangeRequest(org.eclipse.equinox.internal.p2.director.ProfileChangeRequest) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 100 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.

the class ResolveFeatureNamesOperation method run.

public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
    try {
        SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.ResolveFeatureNamesOperation_resolvingFeatures, 100);
        try {
            List<IMetadataRepository> repositories = addRepositories(monitor.newChild(50));
            List<IInstallableUnit> installableUnits = queryInstallableUnits(monitor.newChild(50), repositories);
            Set<String> resolvedFeatureIds = new HashSet<String>();
            for (IInstallableUnit iu : installableUnits) {
                FeatureDescriptor descriptor = new FeatureDescriptor(iu);
                resolvedFeatureIds.add(descriptor.getId());
                resolvedFeatureIds.add(descriptor.getSimpleId());
                featureDescriptors.add(descriptor);
            }
            for (CatalogItem catalogItem : items) {
                for (String iu : catalogItem.getInstallableUnits()) {
                    if (!resolvedFeatureIds.contains(iu)) {
                        FeatureDescriptor descriptor = new FeatureDescriptor(iu);
                        unresolvedFeatureDescriptors.add(descriptor);
                    }
                }
            }
        } finally {
            // SECURITY: resolving feature names should never add repositories
            removeAddedRepositoryLocations();
            monitor.done();
        }
    } catch (OperationCanceledException e) {
        throw new InterruptedException();
    } catch (Exception e) {
        throw new InvocationTargetException(e);
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository) HashSet(java.util.HashSet)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)153 Test (org.junit.Test)58 ArrayList (java.util.ArrayList)44 File (java.io.File)38 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)25 HashSet (java.util.HashSet)18 IStatus (org.eclipse.core.runtime.IStatus)18 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)16 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)15 HashMap (java.util.HashMap)13 LinkedHashSet (java.util.LinkedHashSet)11 CoreException (org.eclipse.core.runtime.CoreException)11 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)11 ResourceUtil.resourceFile (org.eclipse.tycho.p2.tools.test.util.ResourceUtil.resourceFile)11 URI (java.net.URI)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 SubMonitor (org.eclipse.core.runtime.SubMonitor)9 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)9 Status (org.eclipse.core.runtime.Status)8 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)8