public void testChangeIUProperty() { // Add into the profile the version a1; ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); req.setInstallableUnitProfileProperty( a1, IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString()); IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); engine.perform(plan, null); assertProfileContainsAll("A1 is missing", profile, new IInstallableUnit[] {a1}); IProfileRegistry profileRegistry = getProfileRegistry(); profile = profileRegistry.getProfile(profile.getProfileId()); IQueryResult c = profile.query(new UserVisibleRootQuery(), null); assertEquals(queryResultSize(c), 1); System.gc(); ProfileChangeRequest req2 = ProfileChangeRequest.createByProfileId(getAgent(), profile.getProfileId()); req2.removeInstallableUnits(new IInstallableUnit[] {a1}); req2.addInstallableUnits(new IInstallableUnit[] {a2}); // req2.setInstallableUnitProfileProperty(a2, IProfile.PROP_PROFILE_ROOT_IU, // Boolean.TRUE.toString()); IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); assertInstallOperand(plan2, a2); engine.perform(plan2, null); profile = getProfile(profile.getProfileId()); assertProfileContains("A2 is missing", profile, new IInstallableUnit[] {a2}); }
/** * (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; }
public Collection getInstalled(String id) { IProfile profile = registry.getProfile(id); if (profile == null) return Collections.EMPTY_LIST; IQuery query = new IUProfilePropertyQuery(PROP_TOAST_ROOT, "true"); IQueryResult result = profile.query(query, new NullProgressMonitor()); return result.toUnmodifiableSet(); }
public void addProfile(String id, Map properties) { IProfile profile = registry.getProfile(id); if (profile != null || properties == null) return; String location = new File(URIUtil.append(dataLocation, id)).toString(); String environment = "osgi.os=" + properties.get("osgi.os"); environment += ",osgi.ws=" + properties.get("osgi.ws"); environment += ",osgi.arch=" + properties.get("osgi.arch"); Map props = new HashMap(); props.put(IProfile.PROP_INSTALL_FOLDER, location); props.put(IProfile.PROP_CACHE, location); props.put(IProfile.PROP_ENVIRONMENTS, environment); try { profile = registry.addProfile(id, props); } catch (ProvisionException e) { LogUtility.logError("Error adding profile: " + id, e); } }
public IStatus uninstall(String id, String feature, IProgressMonitor monitor) { IProfile profile = registry.getProfile(id); if (profile == null) return new Status( IStatus.ERROR, LogUtility.getStatusId(this), "Cannot find profile for: " + id); IInstallableUnit unit = findFeature(feature); if (unit == null) return new Status( IStatus.ERROR, LogUtility.getStatusId(this), "Cannot find feature : " + feature); IProfileChangeRequest request = planner.createChangeRequest(profile); request.remove(unit); return performOperation(profile, request, monitor); }
public void removeProfile(String id) { registry.removeProfile(id); }
public Collection getProfiles() { IProfile[] profiles = registry.getProfiles(); Collection result = new ArrayList(profiles.length); for (int i = 0; i < profiles.length; i++) result.add(profiles[i].getProfileId()); return result; }