Package org.eclipse.equinox.internal.provisional.p2.core

Examples of org.eclipse.equinox.internal.provisional.p2.core.VersionRange


        super(actionType);
    }

    public ResolutionResult reviewProfileChangeAction(IProfile profile) throws ProvisioningException {
        ProvisioningPlan plan;
        IPlanner planner;
        IProfile currentProfile;
        IProfile snapshot = ProvisioningUtils.getProfile(IProfileRegistry.SELF, timestamp);
        if (snapshot == null) {
            throw new ProvisioningException("Invalid Profile Configuration");
        }

        planner = ServiceHolder.getPlanner();
        currentProfile = ProvisioningUtils.getProfile();
        plan = planner.getDiffPlan(currentProfile, snapshot, new NullProgressMonitor());
        if (plan == null) {
            throw new ProvisioningException("Failed to generate the Provisioning Plan");
        }

        return generateResolutionResult(plan.getProfileChangeRequest(), plan, getInitialStatus());
View Full Code Here


    public abstract MultiStatus getInitialStatus();

    private ProvisioningPlan generateProvisioningPlan(ProfileChangeRequest profileChangeRequest)
            throws ProvisioningException {
        IPlanner planner = ServiceHolder.getPlanner();
        ProvisioningContext context = new ProvisioningContext();
        return planner.getProvisioningPlan(profileChangeRequest, context, new NullProgressMonitor());
    }
View Full Code Here

        super(actionType);
    }

    public ProfileChangeRequest generateProfileChangeRequest(IProfile profile, MultiStatus status,
                                                             IProgressMonitor monitor) {
        ProfileChangeRequest request = new ProfileChangeRequest(profile);
        request.removeInstallableUnits(iusToUninstall);
        return request;
    }
View Full Code Here

        super(actionType);
    }

    public ProfileChangeRequest generateProfileChangeRequest(IProfile profile, MultiStatus status,
                                                             IProgressMonitor monitor) {
        ProfileChangeRequest request = new ProfileChangeRequest(profile);
        for (IInstallableUnit iu : iusToInstall) {
            // If the user is installing a patch, we mark it optional.  This allows
            // the patched IU to be updated later by removing the patch.
            if (Boolean.toString(true).equals(iu.getProperty(IInstallableUnit.PROP_TYPE_PATCH))) {
                request.setInstallableUnitInclusionRules(iu, PlannerHelper.createOptionalInclusionRule(iu));
            }

            // Check to see if it is already installed.  This may alter the request.
            Collector alreadyInstalled = profile.query(new InstallableUnitQuery(iu.getId()), new Collector(), null);

            if (alreadyInstalled.size() > 0) {
                IInstallableUnit installedIU = (IInstallableUnit) alreadyInstalled.iterator().next();
                int compareTo = iu.getVersion().compareTo(installedIU.getVersion());
                // If the iu is a newer version of something already installed, consider this an
                // update request
                if (compareTo > 0) {
                    boolean lockedForUpdate = false;
                    String value = profile.getInstallableUnitProperty(installedIU,
                            IInstallableUnit.PROP_PROFILE_LOCKED_IU);
                    if (value != null) {
                        lockedForUpdate = (Integer.parseInt(value) & IInstallableUnit.LOCK_UPDATE) ==
                                IInstallableUnit.LOCK_UPDATE;
                    }
                    if (lockedForUpdate) {
                        // Add a status telling the user that this implies an update, but the
                        // iu should not be updated
                        status.merge(new Status(IStatus.WARNING, "temp", 10013, installedIU.getId() + "-" +
                                installedIU.getVersion() +
                                " will be ignored because it is already installed, " +
                                "and updates are not permitted.", null));
                    } else {
                        request.addInstallableUnits(new IInstallableUnit[]{iu});
                        request.removeInstallableUnits(new IInstallableUnit[]{installedIU});
                        // Add a status informing the user that the update has been inferred
                        status.merge(new Status(IStatus.WARNING, "temp", 10013, installedIU.getId() + "-" +
                                installedIU.getVersion() +
                                " is already installed, so an update will be performed instead.", null));
                        // Mark it as a root if it hasn't been already
                        if (!Boolean.toString(true).equals(profile.getInstallableUnitProperty(installedIU,
                                IInstallableUnit.PROP_PROFILE_ROOT_IU))) {
                            request.setInstallableUnitProfileProperty(iu, IInstallableUnit.PROP_PROFILE_ROOT_IU,
                                    Boolean.toString(true));
                        }
                    }
                } else if (compareTo < 0) {
                    // An implied downgrade.  We will not put this in the plan, add a status informing the user
                    status.merge(new Status(IStatus.WARNING, "temp", 10004, installedIU.getId() + "-" +
                            installedIU.getVersion() +
                            " will be ignored because a newer version is already installed.", null));
                } else {
                    if (Boolean.toString(true).equals(profile.getInstallableUnitProperty(installedIU,
                            IInstallableUnit.PROP_PROFILE_ROOT_IU)))
                    // It is already a root, nothing to do. We tell the user it was already installed
                    {
                        status.merge(new Status(IStatus.WARNING, "temp", 10005, installedIU.getId() + "-" +
                                installedIU.getVersion() + " will be ignored because it is already installed.", null));
                    } else {
                        // It was already installed but not as a root.
                        // Tell the user that parts of it are already installed and mark it as a root.
                        status.merge(new Status(IStatus.WARNING, "temp", 10006, installedIU.getId() + "-" +
                                installedIU.getVersion() +
                                " is already present because other installed software requires it.  " +
                                "It will be added to the installed software list.", null));
                        request.setInstallableUnitProfileProperty(iu, "org.eclipse.equinox.p2.type.root",
                                Boolean.toString(true));
                    }
                }
            } else {
                // Install it and mark as a root
                request.addInstallableUnits(new IInstallableUnit[]{iu});
                request.setInstallableUnitProfileProperty(iu, "org.eclipse.equinox.p2.type.root",
                        Boolean.toString(true));
            }
        }
        return request;
    }
View Full Code Here

        this.actionType = actionType;
    }

    public ResolutionResult reviewProfileChangeAction(IProfile profile) throws ProvisioningException {
        MultiStatus initialStatus = getInitialStatus();
        ProfileChangeRequest profileChangeRequest = generateProfileChangeRequest(
                profile, initialStatus, null);
        ProvisioningPlan provisioningPlan = generateProvisioningPlan(profileChangeRequest);
        if (provisioningPlan == null) {
            throw new ProvisioningException("Failed to generate the Provisioning Plan");
        }
View Full Code Here

    public RevertAction(String actionType) {
        super(actionType);
    }

    public ResolutionResult reviewProfileChangeAction(IProfile profile) throws ProvisioningException {
        ProvisioningPlan plan;
        IPlanner planner;
        IProfile currentProfile;
        IProfile snapshot = ProvisioningUtils.getProfile(IProfileRegistry.SELF, timestamp);
        if (snapshot == null) {
            throw new ProvisioningException("Invalid Profile Configuration");
        }

        planner = ServiceHolder.getPlanner();
        currentProfile = ProvisioningUtils.getProfile();
        plan = planner.getDiffPlan(currentProfile, snapshot, new NullProgressMonitor());
        if (plan == null) {
            throw new ProvisioningException("Failed to generate the Provisioning Plan");
        }

        return generateResolutionResult(plan.getProfileChangeRequest(), plan, getInitialStatus());
    }
View Full Code Here

    public ResolutionResult reviewProfileChangeAction(IProfile profile) throws ProvisioningException {
        MultiStatus initialStatus = getInitialStatus();
        ProfileChangeRequest profileChangeRequest = generateProfileChangeRequest(
                profile, initialStatus, null);
        ProvisioningPlan provisioningPlan = generateProvisioningPlan(profileChangeRequest);
        if (provisioningPlan == null) {
            throw new ProvisioningException("Failed to generate the Provisioning Plan");
        }

        return generateResolutionResult(profileChangeRequest, provisioningPlan, initialStatus);
View Full Code Here

        // Now we compare what was requested with what is going to happen.
        if (plan.getStatus().getSeverity() != IStatus.ERROR) {
            IInstallableUnit[] iusAdded = originalRequest.getAddedInstallableUnits();
            for (IInstallableUnit anIusAdded : iusAdded) {
                RequestStatus rs = plan.getRequestStatus(anIusAdded);
                if (rs.getSeverity() == IStatus.ERROR) {
                    // This is a serious error so it must also appear in the overall status
                    IStatus fail = new Status(IStatus.ERROR, "temp", 10011, anIusAdded.getId() +
                            " is not applicable to the current configuration and will not be installed.", null);
                    report.addStatus(anIusAdded, fail);
                    report.addSummaryStatus(fail);
                    report.addFailedInstallableUnit(anIusAdded);
                } else {
                    report.addReviewedInstallableUnit(anIusAdded);
                }
            }
            IInstallableUnit[] iusRemoved = originalRequest.getRemovedInstallableUnits();
            for (IInstallableUnit anIusRemoved : iusRemoved) {
                RequestStatus rs = plan.getRequestStatus(anIusRemoved);
                if (rs.getSeverity() == IStatus.ERROR) {
                    // We are making assumptions here about why the planner chose to ignore an uninstall.
                    IStatus fail = new Status(IStatus.INFO, "temp", 10007, anIusRemoved.getId() +
                            " cannot be fully uninstalled because other installed software requires it.  " +
                            "The parts that are not required will be uninstalled.", null);
                    report.addStatus(anIusRemoved, fail);
                    report.addSummaryStatus(fail);
                    report.addFailedUninstallableUnit(anIusRemoved);
                } else {
                    report.addReviewedUninstallableUnit(anIusRemoved);
                }
            }
        }

        // Now process the side effects
        Map sideEffects = plan.getSideEffectChanges();
        for (Object o : sideEffects.keySet()) {
            IInstallableUnit iu = (IInstallableUnit) o;
            RequestStatus rs = (RequestStatus) sideEffects.get(iu);
            if (rs.getInitialRequestType() == RequestStatus.ADDED) {
                report.addStatus(iu, new Status(rs.getSeverity(), "temp", 10010, iu.getId() +
                        " will also be installed in order to complete this operation.", null));
                report.addReviewedInstallableUnit(iu);
            } else {
                report.addStatus(iu, new Status(rs.getSeverity(), "temp", 10009, iu.getId() +
                        " must be uninstalled in order to complete this operation.", null));
                report.addReviewedUninstallableUnit(iu);
            }
        }
View Full Code Here

    public ResolutionResult generateResolutionResult(ProfileChangeRequest originalRequest,
                                                     ProvisioningPlan plan,
                                                     MultiStatus originalStatus)
            throws ProvisioningException {
        IEngine engine = ServiceHolder.getP2Engine();

        ResolutionResult report = new ResolutionResult();
        report.setProvisioningPlan(plan);

        if (nothingToDo(originalRequest)) {
View Full Code Here

        } catch (ProvisioningException e) {
            log.warn("Profile registry unavailable. Default language will be used.");
            return new Collector();
        }

        IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF);
        if (profile == null) {
            log.warn("Profile unavailable. Default language will be used.");
            return new Collector();
        }
        IUPropertyQuery iuQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_FRAGMENT, "true"); //$NON-NLS-1$
        Collector collected = profile.query(iuQuery, localeFragmentCollector, null);
        LocaleCollectorCache.put(locale, new SoftReference(collected));
        return collected;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.equinox.internal.provisional.p2.core.VersionRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.