protected IProfile getSelfProfile() { if (profileRegistry != null) { String selfID = System.getProperty("eclipse.p2.profile"); //$NON-NLS-1$ if (selfID == null) selfID = IProfileRegistry.SELF; return profileRegistry.getProfile(selfID); } return null; }
static IProfile[] getProfiles(IProvisioningAgent agent) { IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); if (profileRegistry == null) return new IProfile[0]; return profileRegistry.getProfiles(); }
private long findMostRecentResetTimestamp(IProfileRegistry registry, IProfile profile) { long[] history = registry.listProfileTimestamps(profile.getProfileId()); int index = history.length - 1; boolean found = false; while (!(found = IProfile.STATE_SHARED_INSTALL_VALUE_BEFOREFLUSH.equals(registry.getProfileStateProperties(profile.getProfileId(), history[index]).get(IProfile.STATE_PROP_SHARED_INSTALL))) && index > 0) { index--; } if (!found) return -1; return history[index]; }
/** * Deletes the profile associated with this target handle, if any. Returns * <code>true</code> if a profile existed and was deleted, otherwise <code>false</code>. * * @throws CoreException if unable to delete the profile */ public static void deleteProfile(ITargetHandle handle) throws CoreException { IProfileRegistry registry = getProfileRegistry(); if (registry != null) { IProfile profile = registry.getProfile(getProfileId(handle)); if (profile != null) { String location = profile.getProperty(IProfile.PROP_INSTALL_FOLDER); registry.removeProfile(getProfileId(handle)); if (location != null && location.length() > 0) { File folder = new File(location); if (folder.exists()) { delete(folder); } } } } }
static IProfile addProfile(IProvisioningAgent agent, String profileId, Map<String, String> properties) throws ProvisionException { IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); if (profileRegistry == null) return null; IProfile profile = profileRegistry.getProfile(profileId); if (profile != null) return profile; Map<String, String> profileProperties = new HashMap<String, String>(properties); if (profileProperties.get(IProfile.PROP_ENVIRONMENTS) == null) { EnvironmentInfo info = (EnvironmentInfo) ServiceHelper.getService(Activator.getContext(), EnvironmentInfo.class.getName()); if (info != null) profileProperties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=" + info.getOS() + ",osgi.ws=" + info.getWS() + ",osgi.arch=" + info.getOSArch()); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ else profileProperties.put(IProfile.PROP_ENVIRONMENTS, ""); //$NON-NLS-1$ } return profileRegistry.addProfile(profileId, profileProperties); }
long[] profiles = profileRegistry.listProfileTimestamps(profile.getProfileId()); if (profiles.length == 0) targetProfile = profileRegistry.getProfile(profile.getProfileId(), profiles[profiles.length - 1]); } else { targetProfile = profileRegistry.getProfile(profile.getProfileId(), revertToPreviousState);
private void cleanupProfileRegistry() { IProfileRegistry registry = (IProfileRegistry) ProvisioningUI.getDefaultUI().getSession().getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME); long[] history = registry.listProfileTimestamps(toImportFrom.getProfileId()); for (int i = 0; i < history.length; i++) { if (history[i] < toImportFrom.getTimestamp()) try { registry.removeProfile(toImportFrom.getProfileId(), history[i]); } catch (ProvisionException e) { //Can't happen } } }
registry.removeProfile(profileID); props.put(IProfile.PROP_NL, TargetPlatform.getNL()); profile = registry.addProfile(profileID, props);
static void removeProfile(IProvisioningAgent agent, String profileId) { IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); if (profileRegistry == null) return; profileRegistry.removeProfile(profileId); }
static long[] getProfileTimestamps(IProvisioningAgent agent, String profileId) { if (profileId == null) { profileId = IProfileRegistry.SELF; } IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); if (profileRegistry == null) return null; return profileRegistry.listProfileTimestamps(profileId); }
private void createProfile(ITargetDefinition target) throws CoreException, ProvisionException { // create a new profile IProfileRegistry registry = getProfileRegistry(); if (registry == null) { throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, Messages.AbstractTargetHandle_0)); } Map<String, String> properties = new HashMap<>(); properties.put(IProfile.PROP_INSTALL_FOLDER, INSTALL_FOLDERS.append(Long.toString(LocalTargetHandle.nextTimeStamp())).toOSString()); properties.put(IProfile.PROP_CACHE, BUNDLE_POOL.toOSString()); properties.put(IProfile.PROP_INSTALL_FEATURES, Boolean.TRUE.toString()); properties.put(IProfile.PROP_ENVIRONMENTS, generateEnvironmentProperties(target)); properties.put(IProfile.PROP_NL, generateNLProperty(target)); properties.put(PROP_SEQUENCE_NUMBER, Integer.toString(((TargetDefinition) target).getSequenceNumber())); properties.put(PROP_PROVISION_MODE, getProvisionMode(target)); properties.put(PROP_ALL_ENVIRONMENTS, Boolean.toString(getIncludeAllEnvironments())); properties.put(PROP_AUTO_INCLUDE_SOURCE, Boolean.toString(getIncludeSource())); properties.put(PROP_INCLUDE_CONFIGURE_PHASE, Boolean.toString(getIncludeConfigurePhase())); fProfile = registry.addProfile(getProfileId(target), properties); }
IProfile profile; try { profile = registry.addProfile(profileId, filter); } catch (ProvisionException e) { throw new StatusException("Adding a profile failed (" + profileId + " " + filter + ")", e.getStatus()); registry.removeProfile(profileId);
void deleteSelectedSnapshots() { IStructuredSelection selection = (IStructuredSelection) configsViewer.getSelection(); if (selection.isEmpty()) return; String title = selection.size() == 1 ? ProvUIMessages.RevertProfilePage_DeleteSingleConfigurationTitle : ProvUIMessages.RevertProfilePage_DeleteMultipleConfigurationsTitle; String confirmMessage = selection.size() == 1 ? ProvUIMessages.RevertProfilePage_ConfirmDeleteSingleConfig : ProvUIMessages.RevertProfilePage_ConfirmDeleteMultipleConfigs; if (MessageDialog.openConfirm(configsViewer.getControl().getShell(), title, confirmMessage)) { Iterator<?> iter = selection.iterator(); while (iter.hasNext()) { Object selected = iter.next(); // If it is a recognized element and it is not the current profile, then it can be deleted. if (selected instanceof RollbackProfileElement && !((RollbackProfileElement) selected).isCurrentProfile()) { RollbackProfileElement snapshot = (RollbackProfileElement) selected; IProfileRegistry registry = ProvUI.getProfileRegistry(getSession()); if (registry != null) { try { registry.removeProfile(profileId, snapshot.getTimestamp()); } catch (ProvisionException e) { ProvUI.handleException(e, null, StatusManager.SHOW | StatusManager.LOG); } } } } configsViewer.refresh(); } }
private String getBaseTimestamp(String id) { IProvisioningAgent baseAgent = (IProvisioningAgent) agent.getService(IProvisioningAgent.SHARED_BASE_AGENT); if (baseAgent == null) return null; IProfileRegistry registry = (IProfileRegistry) baseAgent.getService(IProfileRegistry.SERVICE_NAME); if (registry == null) return null; long[] revisions = registry.listProfileTimestamps(id); if (revisions.length >= 1) { return Long.toString(revisions[revisions.length - 1]); } return null; }
private IProfile getCurrentProfile(IProvisioningAgent agent) { IProfileRegistry pr = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); if (pr == null) return null; return pr.getProfile(IProfileRegistry.SELF); }
public IQueryResult<IProfile> query(IQuery<IProfile> query, IProgressMonitor monitor) { IProfile[] profiles = ProvUI.getProfileRegistry(ui.getSession()).getProfiles(); SubMonitor sub = SubMonitor.convert(monitor, ProvUIMessages.QueryableProfileRegistry_QueryProfileProgress, profiles.length); try { return query.perform(Arrays.asList(profiles).iterator()); } finally { sub.done(); } } }
private boolean isFirstTimeRunningThisSharedInstance(IProvisioningAgent agent, IProfileRegistry registry, IProfile currentProfile) { long[] history = registry.listProfileTimestamps(currentProfile.getProfileId()); boolean isInitial = IProfile.STATE_SHARED_INSTALL_VALUE_INITIAL.equals(registry.getProfileStateProperties(currentProfile.getProfileId(), history[0]).get(IProfile.STATE_PROP_SHARED_INSTALL)); if (isInitial) { if (getLastMigration() >= history[0]) return false; //This detect the case where the user has not done any migration. Map<String, String> sharedRelatedValues = registry.getProfileStateProperties(currentProfile.getProfileId(), IProfile.STATE_PROP_SHARED_INSTALL); if (sharedRelatedValues.containsValue(IProfile.STATE_SHARED_INSTALL_VALUE_NEW)) return false; return true; } return false; }
getProfileRegistry().removeProfile(fProfile.getProfileId(), oldTimestamp);
private String getBaseTimestamp(String id) { IProvisioningAgent baseAgent = (IProvisioningAgent) agent.getService(IProvisioningAgent.SHARED_BASE_AGENT); if (baseAgent == null) return null; IProfileRegistry registry = (IProfileRegistry) baseAgent.getService(IProfileRegistry.SERVICE_NAME); if (registry == null) return null; long[] revisions = registry.listProfileTimestamps(id); if (revisions.length >= 1) { return Long.toString(revisions[revisions.length - 1]); } return null; }
private IProfile getProfile(String id) { IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); return profileRegistry == null ? null : profileRegistry.getProfile(id); }