private IQuery<IInstallableUnit> createQuery(IUDescription iu) {
   String id = iu.getId();
   String version = iu.getVersion();
   if (version == null || version.length() == 0) {
     return QueryUtil.createLatestQuery(QueryUtil.createIUQuery(id));
   } else {
     return QueryUtil.createIUQuery(id, Version.parseVersion(version));
   }
 }
Ejemplo n.º 2
0
  private IQueryResult<IInstallableUnit> searchUnitInThisLocation(
      IQueryable<IInstallableUnit> units, Unit unitReference) {
    Version version = parseVersion(unitReference);

    // the createIUQuery treats 0.0.0 version as "any version", and all other versions as exact
    // versions
    IQuery<IInstallableUnit> matchingIUQuery =
        QueryUtil.createIUQuery(unitReference.getId(), version);
    IQuery<IInstallableUnit> latestMatchingIUQuery = QueryUtil.createLatestQuery(matchingIUQuery);

    IQueryResult<IInstallableUnit> queryResult = units.query(latestMatchingIUQuery, monitor);
    return queryResult;
  }
 private static IQuery<IInstallableUnit> createQuery(IUDescription iu) {
   String id = iu.getId();
   String version = iu.getVersion();
   if (iu.getQueryMatchExpression() != null) {
     return QueryUtil.createMatchQuery(
         iu.getQueryMatchExpression(), (Object[]) iu.getQueryParameters());
   } else {
     if (version == null || version.length() == 0) {
       return QueryUtil.createLatestQuery(QueryUtil.createIUQuery(id));
     } else {
       return QueryUtil.createIUQuery(id, Version.parseVersion(version));
     }
   }
 }
Ejemplo n.º 4
0
  /**
   * (inheritDoc)
   *
   * @see org.goko.featuremanager.service.IFeatureManager#getInstallableUnits()
   */
  @Override
  public List<GkInstallableUnit> getInstallableUnits(IProgressMonitor monitor) throws GkException {
    List<GkInstallableUnit> lstUnits = new ArrayList<GkInstallableUnit>();
    // get the repository managers and define our repositories
    IMetadataRepositoryManager manager =
        (IMetadataRepositoryManager)
            getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);

    try {
      manager.addRepository(new URI("http://update.goko.fr/"));
      manager.loadRepository(new URI("http://update.goko.fr/"), monitor);
    } catch (ProvisionException | OperationCanceledException | URISyntaxException e) {
      throw new GkTechnicalException(e);
    }
    // Query installed units
    IProfileRegistry registry =
        (IProfileRegistry) getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME);
    IProfile profile = registry.getProfile(IProfileRegistry.SELF);
    Collection<IInstallableUnit> lstInstalledUnits =
        profile.query(new UserVisibleRootQuery(), monitor).toUnmodifiableSet();

    // Query "groups"
    IQuery<IInstallableUnit> query =
        QueryUtil.createLatestQuery(
            QueryUtil.createMatchQuery(
                "properties[$0] == $1 && properties[$2] != null",
                "org.eclipse.equinox.p2.type.group",
                "true",
                "org.eclipse.equinox.p2.type.category"));
    Collection<IInstallableUnit> lstInstallableUnit =
        manager.query(query, monitor).toUnmodifiableSet();

    if (CollectionUtils.isNotEmpty(lstInstallableUnit)) {
      for (IInstallableUnit iInstallableUnit : lstInstallableUnit) {
        GkInstallableUnit gkUnit = new GkInstallableUnit(iInstallableUnit);
        // Same ID already installed ?
        for (IInstallableUnit installedUnit : lstInstalledUnits) {
          if (StringUtils.equals(gkUnit.getId(), installedUnit.getId())) {
            gkUnit.setInstalled(true);
            break;
          }
        }

        lstUnits.add(gkUnit);
      }
    }

    return lstUnits;
  }
Ejemplo n.º 5
0
  /**
   * Finds available WSO2 features in current profile and search for updates to them in WSO2 p2
   * repository for updates.
   *
   * @param monitor
   * @throws Exception
   */
  public void checkForAvailableUpdates(IProgressMonitor monitor) throws Exception {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_18, 6);

    // get all available IUs in update repository
    IMetadataRepository metadataRepo =
        metadataRepoManager.loadRepository(getDevStudioUpdateSite(), progress.newChild(1));
    IQuery<IInstallableUnit> allIUQuery = QueryUtil.createIUAnyQuery();
    IQueryResult<IInstallableUnit> allIUQueryResult =
        metadataRepo.query(allIUQuery, progress.newChild(1));

    // read artifact repository for updates
    IArtifactRepository artifactRepo =
        artifactRepoManager.loadRepository(getDevStudioUpdateSite(), progress.newChild(1));

    // read meta-data of all available features
    Map<String, EnhancedFeature> allFeaturesInUpdateRepo =
        loadWSO2FeaturesInRepo(artifactRepo, allIUQueryResult, progress.newChild(1));

    // get all installed wso2 features
    Collection<IInstallableUnit> installedWSO2Features =
        getInstalledWSO2Features(progress.newChild(1));

    installedWSO2FeaturesMap = new HashMap<String, IInstallableUnit>();
    for (IInstallableUnit iInstallableUnit : installedWSO2Features) {
      installedWSO2FeaturesMap.put(iInstallableUnit.getId(), iInstallableUnit);
    }

    if (progress.isCanceled()) {
      throw new OperationCanceledException();
    }

    URI[] repos = new URI[] {getDevStudioUpdateSite()};
    updateOperation = new UpdateOperation(session, installedWSO2Features);
    updateOperation.getProvisioningContext().setArtifactRepositories(repos);
    updateOperation.getProvisioningContext().setMetadataRepositories(repos);

    // resolve update operation
    IStatus status = updateOperation.resolveModal(progress.newChild(1));
    // user cancelled the job while resolving
    if (status.getSeverity() == IStatus.CANCEL || progress.isCanceled()) {
      throw new OperationCanceledException();
    }
    // there is nothing to update
    if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
      featuresWithPossibleUpdates = new HashMap<String, EnhancedFeature>();
      log.info(Messages.UpdateManager_19);
    } else if (status.getSeverity() == IStatus.ERROR) { // resolution errors
      // something wrong with the updates
      log.info(Messages.UpdateManager_20);
    } else {
      // good to proceed installing updates
      setPossibleUpdates(updateOperation.getPossibleUpdates(), allFeaturesInUpdateRepo);
    }
  }
Ejemplo n.º 6
0
 /**
  * Add in an IU that sets the toast.id system property to identify the client running this profile
  */
 private IProvisioningPlan installIdIU(IProvisioningPlan plan) {
   IQuery query = QueryUtil.createIUQuery("toast.id");
   IQueryResult toastIU = plan.getProfile().query(query, null);
   // If we find the id IU then it is already installed.
   //		if (!toastIU.isEmpty())
   //			return plan;
   IInstallableUnit idIU = createIdIU(plan.getProfile().getProfileId());
   plan.addInstallableUnit(idIU);
   return plan;
 }
  private void verifyBundleCU() {

    final String bundleCUId = flavor + configSpec + ORG_ECLIPSE_CORE_COMMANDS;
    IQueryResult queryResult =
        publisherResult.query(QueryUtil.createIUQuery(bundleCUId), new NullProgressMonitor());
    assertEquals(1, queryResultSize(queryResult));
    IInstallableUnitFragment fragment = (IInstallableUnitFragment) queryResult.iterator().next();

    assertNull(fragment.getFilter()); // no filter if config spec is ANY

    assertTrue(fragment.getVersion().equals(version));

    assertFalse(fragment.isSingleton());

    final Collection<IProvidedCapability> providedCapabilities = fragment.getProvidedCapabilities();
    verifyProvidedCapability(
        providedCapabilities, IInstallableUnit.NAMESPACE_IU_ID, bundleCUId, version);
    verifyProvidedCapability(
        providedCapabilities,
        "org.eclipse.equinox.p2.flavor",
        flavor + configSpec,
        version); //$NON-NLS-1$
    assertEquals(2, providedCapabilities.size());

    assertEquals(0, fragment.getRequirements().size());

    final Collection<IRequirement> hostRequirements = fragment.getHost();
    verifyRequiredCapability(
        hostRequirements,
        "osgi.bundle",
        ORG_ECLIPSE_CORE_COMMANDS,
        new VersionRange(BUNDLE_VERSION)); // $NON-NLS-1$
    verifyRequiredCapability(
        hostRequirements,
        "org.eclipse.equinox.p2.eclipse.type",
        "bundle",
        new VersionRange(Version.create("1.0.0"), true, Version.create("2.0.0"), false),
        1,
        1,
        false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    assertTrue(hostRequirements.size() == 2);

    final Collection<ITouchpointData> touchpointData = fragment.getTouchpointData();
    assertEquals(1, touchpointData.size());
    ITouchpointData data = touchpointData.iterator().next();
    ITouchpointInstruction instruction = data.getInstruction("install"); // $NON-NLS-1$
    assertEquals("installBundle(bundle:${artifact})", instruction.getBody()); // $NON-NLS-1$
    instruction = data.getInstruction("uninstall"); // $NON-NLS-1$
    assertEquals("uninstallBundle(bundle:${artifact})", instruction.getBody()); // $NON-NLS-1$
    instruction = data.getInstruction("configure"); // $NON-NLS-1$
    assertEquals("setStartLevel(startLevel:2);", instruction.getBody()); // $NON-NLS-1$
    instruction = data.getInstruction("unconfigure"); // $NON-NLS-1$
    assertEquals("setStartLevel(startLevel:-1);", instruction.getBody()); // $NON-NLS-1$
  }
Ejemplo n.º 8
0
  public IStatus service(Command command, IProcess context)
      throws InterruptedException, CoreException {
    UpdateFeature updateFeature = (UpdateFeature) command;
    String featureId = updateFeature.getId();

    ProvisioningSession session = PlatformPlugin.createProvisioningSession();

    IProfile profile = PlatformPlugin.getProfileRegistry().getProfile(IProfileRegistry.SELF);
    IQuery<IInstallableUnit> query =
        QueryUtil.createLatestQuery(QueryUtil.createIUQuery(featureId));
    IQueryResult<IInstallableUnit> result = profile.query(query, new NullProgressMonitor());

    if (result.isEmpty()) {
      return Status.OK_STATUS;
    }

    UpdateOperation op = new UpdateOperation(session, result.toSet());
    IStatus status = op.resolveModal(new NullProgressMonitor());

    if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
      return Status.OK_STATUS;
    }
    if (status.getSeverity() == IStatus.CANCEL) {
      // should not happen,
      throw new CoreException(status);
    }

    if (status.getSeverity() == IStatus.ERROR) {
      throw new CoreException(status);
    }

    ProvisioningJob job = op.getProvisioningJob(null);
    if (job == null) {
      return Status.OK_STATUS;
    }

    status = job.runModal(new NullProgressMonitor());
    if (status.getSeverity() == IStatus.CANCEL) throw new CoreException(status);

    return Status.OK_STATUS;
  }
 /*
  * Return a boolean value indicating whether or not the IU with the given ID and version
  * is installed. We do this by loading the profile registry and seeing if it is there.
  */
 public boolean isInstalled(String id, String version) {
   File location =
       new File(output, getRootFolder() + "/p2/org.eclipse.equinox.p2.engine/profileRegistry");
   SimpleProfileRegistry registry =
       new SimpleProfileRegistry(
           getAgent(), location, new SurrogateProfileHandler(getAgent()), false);
   IProfile[] profiles = registry.getProfiles();
   assertEquals("1.0 Should only be one profile in registry.", 1, profiles.length);
   IQueryResult queryResult =
       profiles[0].query(QueryUtil.createIUQuery(id, Version.create(version)), null);
   return !queryResult.isEmpty();
 }
Ejemplo n.º 10
0
  public void testGreedy() throws ProvisionException, OperationCanceledException {
    URI heliosRepo = getTestData("helios", "testData/bug306279/repo/helios").toURI();
    URI rienaRepo2 =
        getTestData("rienatoolbox-a", "testData/bug306279/repo/rienatoolbox-a").toURI();
    IMetadataRepository repo1 = getMetadataRepositoryManager().loadRepository(heliosRepo, null);
    assertFalse(
        repo1
            .query(
                QueryUtil.createIUQuery("org.eclipse.rap.jface.databinding"),
                new NullProgressMonitor())
            .isEmpty());
    IMetadataRepository repo2 = getMetadataRepositoryManager().loadRepository(rienaRepo2, null);

    IPlanner planner = getPlanner(getAgent());
    IProfile profile = createProfile(getName());
    IProfileChangeRequest request = new ProfileChangeRequest(profile);
    Set<IInstallableUnit> ius =
        repo2
            .query(
                QueryUtil.createIUQuery("org.eclipse.riena.toolbox.feature.feature.group"),
                new NullProgressMonitor())
            .toUnmodifiableSet();
    request.addAll(ius);
    ProvisioningContext ctx = new ProvisioningContext(getAgent());
    ctx.setMetadataRepositories(new URI[] {heliosRepo, rienaRepo2});
    IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor());

    assertOK("resolution failed", plan.getStatus());
    assertEquals(
        0,
        plan.getAdditions()
            .query(
                QueryUtil.createIUQuery("org.eclipse.rap.jface.databinding"),
                new NullProgressMonitor())
            .toUnmodifiableSet()
            .size());
    System.out.println(plan);
  }
 public IInstallableUnit getRemoteIU(String id, String version) {
   File location =
       new File(output, getRootFolder() + "/p2/org.eclipse.equinox.p2.engine/profileRegistry");
   SimpleProfileRegistry registry =
       new SimpleProfileRegistry(
           getAgent(), location, new SurrogateProfileHandler(getAgent()), false);
   IProfile[] profiles = registry.getProfiles();
   assertEquals("1.0 Should only be one profile in registry.", 1, profiles.length);
   IQueryResult queryResult =
       profiles[0].query(QueryUtil.createIUQuery(id, Version.create(version)), null);
   assertEquals(
       "1.1 Should not have more than one IU wth the same ID and version.",
       1,
       queryResultSize(queryResult));
   return (IInstallableUnit) queryResult.iterator().next();
 }
Ejemplo n.º 12
0
  /**
   * Searches available features in WSO2 p2 repository for the current version of Developer Studio
   * and filters new features that can be installed.
   *
   * @param monitor
   * @throws Exception
   */
  public void checkForAvailableFeatures(IProgressMonitor monitor) throws Exception {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_21, 5);

    // get all available IUs in release repository
    IMetadataRepository metadataRepository =
        metadataRepoManager.loadRepository(getDevStudioReleaseSite(), progress.newChild(1));
    IQuery<IInstallableUnit> allIUQuery = QueryUtil.createIUAnyQuery();
    IQueryResult<IInstallableUnit> allIUQueryResult =
        metadataRepository.query(allIUQuery, progress.newChild(1));

    // load artifact repository for releases
    IArtifactRepository artifactRepository =
        artifactRepoManager.loadRepository(getDevStudioReleaseSite(), progress.newChild(1));

    // read meta-data of all available features
    Map<String, EnhancedFeature> allFeaturesInReleaseRepo =
        loadWSO2FeaturesInRepo(artifactRepository, allIUQueryResult, progress.newChild(1));

    Collection<IInstallableUnit> filteredIUs =
        filterInstallableUnits(
            WSO2_FEATURE_PREFIX, FEATURE_GROUP_IU_ID_SFX, allIUQueryResult, progress.newChild(1));
    allAvailableFeatures = new HashMap<String, IInstallableUnit>();
    availableNewFeatures = new HashMap<String, EnhancedFeature>();
    for (IInstallableUnit iInstallableUnit : filteredIUs) {
      allAvailableFeatures.put(iInstallableUnit.getId(), iInstallableUnit);
      if (!installedWSO2FeaturesMap.containsKey(iInstallableUnit.getId())) {
        availableNewFeatures.put(
            iInstallableUnit.getId(), allFeaturesInReleaseRepo.get(iInstallableUnit.getId()));
      } else {
        Version versionInstalled =
            installedWSO2FeaturesMap.get(iInstallableUnit.getId()).getVersion();
        // if the version we have is greater than the installed version view it in the available
        // feature list
        if (versionInstalled != null
            && (iInstallableUnit.getVersion().compareTo(versionInstalled) == 1)) {
          availableNewFeatures.put(
              iInstallableUnit.getId(), allFeaturesInReleaseRepo.get(iInstallableUnit.getId()));
        }
      }
    }
  }
Ejemplo n.º 13
0
  public List<IServerExtension> getExtensions(IProgressMonitor monitor)
      throws CoreException, ProvisionException {
    try {
      /*
       * To discovery the server adapter, there are three methods:
       * 1. Looking at the site.xml (if it exists). This is the legacy method
       * 2. Looking for the org.eclipse.wst.server.core.serverAdapter property in a p2
       *    update site (that may not have a site.xml). The property is necessary to identify
       *    the InstallableUnit as a server type. Otherwise, all the InstallableUnits will show
       *    up regardless of whether it is a server or not
       * 3. If the user created the p2 update site using a category.xml file (migrating old site.xml
       *    to use category.xml)
       */
      BundleContext bd =
          org.eclipse.wst.server.discovery.internal.Activator.getDefault()
              .getBundle()
              .getBundleContext();
      IProvisioningAgent agent = ExtensionUtility.getAgent(bd);

      URI url2 = new URI(url);

      // Method 1: Looking at the site.xml
      UpdateSiteMetadataRepositoryFactory mrf = new UpdateSiteMetadataRepositoryFactory();
      mrf.setAgent(ExtensionUtility.getAgent(bd));
      // If the site.xml does not exist, the load will throw a
      // org.eclipse.equinox.p2.core.ProvisionException
      List<IServerExtension> list = new ArrayList<IServerExtension>();
      try {
        IMetadataRepository repo = mrf.load(url2, IRepositoryManager.REPOSITORIES_ALL, monitor);
        IQuery<IInstallableUnit> query =
            QueryUtil.createMatchQuery(
                "id ~=/*org.eclipse.wst.server.core.serverAdapter/"); //$NON-NLS-1$

        list = getInstallableUnits(repo, query, url2, monitor);
      } catch (ProvisionException pe) {
        Trace.trace(Trace.WARNING, "Error getting update site information", pe); // $NON-NLS-1$
      }

      // Call Method 2 if there are no results from Method 1 (e.g. if the site.xml exists without
      // specifying any server adapters there or no site.xml exists)
      if (list.isEmpty()) {
        IMetadataRepositoryManager manager =
            (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
        manager.addRepository(url2);
        // Need to query for all IUs
        IQuery<IInstallableUnit> query = QueryUtil.createIUAnyQuery();

        IMetadataRepository repo = manager.loadRepository(url2, monitor);
        List<IServerExtension> list2 = getInstallableUnits(repo, query, url2, monitor);

        int size = list2.size();
        for (int i = 0; i < size; i++) {
          Extension e = (Extension) list2.get(i);
          IInstallableUnit[] iuArr = e.getIUs();
          if (iuArr != null && iuArr.length > 0) {
            if (iuArr[0] != null) {
              if (iuArr[0].getProperty(SERVER_ADAPTER_ID) != null) {
                list.add(e);
              }
            }
          }
        }
      }

      // Call Method 3 if no results from Method 2. Creating the p2 update site using the
      // category.xml will generate
      // a provider property with org.eclipse.wst.server.core.serverAdapter
      if (list.isEmpty()) {
        IMetadataRepositoryManager manager =
            (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
        manager.addRepository(url2);
        IQuery<IInstallableUnit> query =
            QueryUtil.createMatchQuery(
                "id ~=/*org.eclipse.wst.server.core.serverAdapter/"); //$NON-NLS-1$

        IMetadataRepository repo = manager.loadRepository(url2, monitor);
        list = getInstallableUnits(repo, query, url2, monitor);
      }

      return list;
    } catch (ProvisionException e) {
      Trace.trace(Trace.WARNING, "Error getting update info", e); // $NON-NLS-1$
      throw e;
    } catch (Exception e) {
      Trace.trace(Trace.WARNING, "Error getting update info", e); // $NON-NLS-1$

      return new ArrayList<IServerExtension>(0);
    }
  }
Ejemplo n.º 14
0
 /** Return a collection of features that are available to be installed. */
 public Collection getAvailableFeatures() {
   IQuery query = QueryUtil.createIUPropertyQuery(PROP_TOAST_ROOT, Boolean.TRUE.toString());
   IQueryResult result = metadataManager.query(query, new NullProgressMonitor());
   return result.toSet();
 }
Ejemplo n.º 15
0
  public ProfileChangeRequest generateProfileChangeRequest(
      IProfile profile, MultiStatus status, IProgressMonitor monitor) {
    ProfileChangeRequest request = new ProfileChangeRequest(profile);
    String carbonHome = System.getProperty("carbon.home");
    String cacheLocation =
        carbonHome + File.separator + "repository" + File.separator + "components";
    request.setProfileProperty(IProfile.PROP_CACHE, cacheLocation);
    request.setProfileProperty(
        SimpleConfiguratorConstants.PROP_KEY_USE_REFERENCE, Boolean.TRUE.toString());
    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(MetadataFactory.InstallableUnitDescription.PROP_TYPE_PATCH))) {
        request.setInstallableUnitInclusionRules(
            iu, ProfileInclusionRules.createOptionalInclusionRule(iu));
      }

      // Check to see if it is already installed.  This may alter the request.
      Collection alreadyInstalled =
          profile
              .query(QueryUtil.createIUQuery(iu.getId()), new NullProgressMonitor())
              .toUnmodifiableSet();

      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, IProfile.PROP_PROFILE_LOCKED_IU);
          if (value != null) {
            lockedForUpdate =
                (Integer.parseInt(value) & IProfile.LOCK_UPDATE) == IProfile.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, IProfile.PROP_PROFILE_ROOT_IU))) {
              request.setInstallableUnitProfileProperty(
                  iu, IProfile.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, IProfile.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 this if only this is not category type
        if (!Boolean.toString(true)
            .equals(
                iu.getProperty(MetadataFactory.InstallableUnitDescription.PROP_TYPE_CATEGORY))) {
          // 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;
  }