ProvisioningPlan plan,
MultiStatus originalStatus)
throws ProvisioningException {
IEngine engine = ServiceHolder.getP2Engine();
ResolutionResult report = new ResolutionResult();
report.setProvisioningPlan(plan);
if (nothingToDo(originalRequest)) {
report.addSummaryStatus(new Status(IStatus.ERROR, "temp", 10050,
"Cannot complete the request. See the error log for details.", null));
IStatus[] details = originalStatus.getChildren();
for (IStatus detail : details) {
report.addSummaryStatus(detail);
}
return report;
}
// If there was already some status supplied before resolution, this should get included
// with the report.
if (originalStatus != null && originalStatus.getChildren().length > 0) {
report.addSummaryStatus(originalStatus);
}
// If the overall plan had a non-OK status, capture that in the report.
if (!plan.getStatus().isOK()) {
report.addSummaryStatus(plan.getStatus());
}
// 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);
}
}
long size = 0;
if (report.getReviewedInstallableUnits().length != 0) {
size = getSize(plan,
plan.getProfileChangeRequest().getProfile(), engine, new ProvisioningContext(), null);
}
report.setInstallationSize(getFormattedSize(size));
return report;
}