@Override public long getTimestamp() { return profile.getTimestamp(); }
private boolean checkTimestamps(IProfile profile, IProfile internalProfile) { long[] timestamps = listProfileTimestamps(profile.getProfileId()); if (timestamps.length == 0) { if (DebugHelper.DEBUG_PROFILE_REGISTRY) DebugHelper.debug(PROFILE_REGISTRY, "check timestamp: expected " + profile.getTimestamp() + " but no profiles were found"); //$NON-NLS-1$ //$NON-NLS-2$ resetProfiles(); return false; } long currentTimestamp = (timestamps.length == 0) ? -1 : timestamps[timestamps.length - 1]; if (profile.getTimestamp() != currentTimestamp) { if (DebugHelper.DEBUG_PROFILE_REGISTRY) DebugHelper.debug(PROFILE_REGISTRY, "check timestamp: expected " + profile.getTimestamp() + " but was " + currentTimestamp); //$NON-NLS-1$ //$NON-NLS-2$ if (internalProfile.getTimestamp() != currentTimestamp) resetProfiles(); return false; } return true; }
private boolean checkTimestamps(IProfile profile, IProfile internalProfile) { long[] timestamps = listProfileTimestamps(profile.getProfileId()); if (timestamps.length == 0) { if (DebugHelper.DEBUG_PROFILE_REGISTRY) DebugHelper.debug(PROFILE_REGISTRY, "check timestamp: expected " + profile.getTimestamp() + " but no profiles were found"); //$NON-NLS-1$ //$NON-NLS-2$ resetProfiles(); return false; } long currentTimestamp = (timestamps.length == 0) ? -1 : timestamps[timestamps.length - 1]; if (profile.getTimestamp() != currentTimestamp) { if (DebugHelper.DEBUG_PROFILE_REGISTRY) DebugHelper.debug(PROFILE_REGISTRY, "check timestamp: expected " + profile.getTimestamp() + " but was " + currentTimestamp); //$NON-NLS-1$ //$NON-NLS-2$ if (internalProfile.getTimestamp() != currentTimestamp) resetProfiles(); return false; } return true; }
public synchronized void removeProfile(String id, long timestamp) throws ProvisionException { if (SELF.equals(id)) id = self; if (profiles != null) { IProfile profile = getProfile(id); if (profile != null && profile.getTimestamp() == timestamp) throw new ProvisionException(Messages.SimpleProfileRegistry_CannotRemoveCurrentSnapshot); } File profileDirectory = getProfileFolder(id); if (!profileDirectory.isDirectory()) return; File profileFile = new File(profileDirectory, Long.toString(timestamp) + PROFILE_GZ_EXT); if (!profileFile.exists()) { profileFile = new File(profileDirectory, Long.toString(timestamp) + PROFILE_EXT); if (!profileFile.exists()) return; } FileUtils.deleteAll(profileFile); // Ignore the return value here. If there was a problem removing the profile state // properties we don't want to fail the whole operation since the profile state itself // was removed successfully removeProfileStateProperties(id, timestamp, null); }
@Override public synchronized void removeProfile(String id, long timestamp) throws ProvisionException { if (SELF.equals(id)) id = self; if (profiles != null) { IProfile profile = getProfile(id); if (profile != null && profile.getTimestamp() == timestamp) throw new ProvisionException(Messages.SimpleProfileRegistry_CannotRemoveCurrentSnapshot); } File profileDirectory = getProfileFolder(id); if (!profileDirectory.isDirectory()) return; File profileFile = new File(profileDirectory, Long.toString(timestamp) + PROFILE_GZ_EXT); if (!profileFile.exists()) { profileFile = new File(profileDirectory, Long.toString(timestamp) + PROFILE_EXT); if (!profileFile.exists()) return; } FileUtils.deleteAll(profileFile); // Ignore the return value here. If there was a problem removing the profile state // properties we don't want to fail the whole operation since the profile state itself // was removed successfully removeProfileStateProperties(id, timestamp, null); }
writer.println(" " + NLS.bind(IDEWorkbenchMessages.ConfigurationLogUpdateSection_lastChangedOn, DateFormat.getDateInstance().format(new Date(profile.getTimestamp())))); //$NON-NLS-1$ writer.println(" " + NLS.bind(IDEWorkbenchMessages.ConfigurationLogUpdateSection_location, profile.getProperty(IProfile.PROP_INSTALL_FOLDER))); //$NON-NLS-1$ writer.println(" " + NLS.bind(IDEWorkbenchMessages.ConfigurationLogUpdateSection_timestamp, Long.toString(profile.getTimestamp()))); //$NON-NLS-1$ writer.println();
public synchronized IProfile getProfile(String id, long timestamp) { if (SELF.equals(id)) id = self; if (profiles != null) { IProfile profile = getProfile(id); if (profile != null && profile.getTimestamp() == timestamp) return profile; } File profileDirectory = getProfileFolder(id); if (!profileDirectory.isDirectory()) return null; File profileFile = new File(profileDirectory, Long.toString(timestamp) + PROFILE_GZ_EXT); if (!profileFile.exists()) { profileFile = new File(profileDirectory, Long.toString(timestamp) + PROFILE_EXT); if (!profileFile.exists()) return null; } Parser parser = new Parser(EngineActivator.getContext(), EngineActivator.ID); try { parser.parse(profileFile); } catch (IOException e) { LogHelper.log(new Status(IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.error_parsing_profile, profileFile), e)); } return parser.getProfileMap().get(id); }
private void writeTimestamps() { timestamps.clear(); timestamps.put(PROFILE_TIMESTAMP, Long.toString(profile.getTimestamp())); for (Entry<String, IMetadataRepository> entry : repositoryMap.entrySet()) { IMetadataRepository repository = entry.getValue();
@Override public synchronized IProfile getProfile(String id, long timestamp) { if (SELF.equals(id)) id = self; if (profiles != null) { IProfile profile = getProfile(id); if (profile != null && profile.getTimestamp() == timestamp) return profile; } File profileDirectory = getProfileFolder(id); if (!profileDirectory.isDirectory()) return null; File profileFile = new File(profileDirectory, Long.toString(timestamp) + PROFILE_GZ_EXT); if (!profileFile.exists()) { profileFile = new File(profileDirectory, Long.toString(timestamp) + PROFILE_EXT); if (!profileFile.exists()) return null; } Parser parser = new Parser(EngineActivator.getContext(), EngineActivator.ID); try { parser.parse(profileFile); } catch (IOException e) { LogHelper.log(new Status(IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.error_parsing_profile, profileFile), e)); } return parser.getProfileMap().get(id); }
private IProfile getSharedProfile(String id) { SimpleProfileRegistry registry = getProfileRegistry(); long[] timestamps = registry.listProfileTimestamps(id); if (timestamps.length == 0) return null; long currentTimestamp = timestamps[timestamps.length - 1]; //see if we have a cached profile if (cachedProfile != null) { IProfile profile = cachedProfile.get(); if (profile != null && profile.getProfileId().equals(id) && profile.getTimestamp() == currentTimestamp) return profile; } final Profile profile = (Profile) registry.getProfile(id, currentTimestamp); if (profile != null) cachedProfile = new SoftReference<IProfile>(profile); if (!EngineActivator.EXTENDED) { return profile; } setUpRepos(); return profile; }
private IProfile getSharedProfile(String id) { SimpleProfileRegistry registry = getProfileRegistry(); long[] timestamps = registry.listProfileTimestamps(id); if (timestamps.length == 0) return null; long currentTimestamp = timestamps[timestamps.length - 1]; //see if we have a cached profile if (cachedProfile != null) { IProfile profile = cachedProfile.get(); if (profile != null && profile.getProfileId().equals(id) && profile.getTimestamp() == currentTimestamp) return profile; } final Profile profile = (Profile) registry.getProfile(id, currentTimestamp); if (profile != null) cachedProfile = new SoftReference<>(profile); if (!EngineActivator.EXTENDED) { return profile; } setUpRepos(); return profile; }
private IInstallableUnit createIUForMetaRequirements(IProfile profile, Collection<IRequirement> metaRequirements) { InstallableUnitDescription description = new InstallableUnitDescription(); String id = getActionGatheringIUId(profile); description.setId(id); Version version = Version.createOSGi(1, 0, 0, Long.toString(profile.getTimestamp())); description.setVersion(version); description.addRequirements(metaRequirements); ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<>(); IProvidedCapability providedCapability = MetadataFactory .createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, id, version); providedCapabilities.add(providedCapability); description.addProvidedCapabilities(providedCapabilities); IInstallableUnit actionsIU = MetadataFactory.createInstallableUnit(description); return actionsIU; }
public void writeProfile(IProfile profile) { start(PROFILE_ELEMENT); attribute(ID_ATTRIBUTE, profile.getProfileId()); attribute(TIMESTAMP_ATTRIBUTE, Long.toString(profile.getTimestamp())); writeProperties(profile.getProperties()); ArrayList<IInstallableUnit> ius = new ArrayList<IInstallableUnit>(profile.query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet()); Collections.sort(ius, new Comparator<IInstallableUnit>() { public int compare(IInstallableUnit iu1, IInstallableUnit iu2) { int IdCompare = iu1.getId().compareTo(iu2.getId()); if (IdCompare != 0) return IdCompare; return iu1.getVersion().compareTo(iu2.getVersion()); } }); writeInstallableUnits(ius.iterator(), ius.size()); writeInstallableUnitsProperties(ius.iterator(), ius.size(), profile); end(PROFILE_ELEMENT); flush(); }
public void writeProfile(IProfile profile) { start(PROFILE_ELEMENT); attribute(ID_ATTRIBUTE, profile.getProfileId()); attribute(TIMESTAMP_ATTRIBUTE, Long.toString(profile.getTimestamp())); writeProperties(profile.getProperties()); ArrayList<IInstallableUnit> ius = new ArrayList<>(profile.query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet()); Collections.sort(ius, new Comparator<IInstallableUnit>() { @Override public int compare(IInstallableUnit iu1, IInstallableUnit iu2) { int IdCompare = iu1.getId().compareTo(iu2.getId()); if (IdCompare != 0) return IdCompare; return iu1.getVersion().compareTo(iu2.getVersion()); } }); writeInstallableUnits(ius.iterator(), ius.size()); writeInstallableUnitsProperties(ius.iterator(), ius.size(), profile); end(PROFILE_ELEMENT); flush(); }
private static IInstallableUnit createSharedProfileIU(final IProfile sharedProfile) { InstallableUnitDescription iuDescription = new InstallableUnitDescription(); iuDescription.setId("SharedProfile_" + sharedProfile.getProfileId()); //$NON-NLS-1$ iuDescription.setVersion(Version.createOSGi(1, 0, 0, Long.toString(sharedProfile.getTimestamp()))); ArrayList<IProvidedCapability> iuCapabilities = new ArrayList<IProvidedCapability>(); IProvidedCapability selfCapability = MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, iuDescription.getId(), iuDescription.getVersion()); iuCapabilities.add(selfCapability); iuDescription.addProvidedCapabilities(iuCapabilities); ArrayList<IRequirement> iuRequirements = new ArrayList<IRequirement>(); IQueryResult<IInstallableUnit> allIUs = sharedProfile.query(QueryUtil.createIUAnyQuery(), null); for (Iterator<IInstallableUnit> iterator = allIUs.iterator(); iterator.hasNext();) { IInstallableUnit iu = iterator.next(); IMatchExpression<IInstallableUnit> iuMatcher = ExpressionUtil.getFactory().<IInstallableUnit> matchExpression(ExpressionUtil.parse("id == $0 && version == $1"), iu.getId(), iu.getVersion()); //$NON-NLS-1$ iuRequirements.add(MetadataFactory.createRequirement(iuMatcher, null, 0, 1, true)); } iuDescription.addRequirements(iuRequirements); iuDescription.setProperty(IInstallableUnit.PROP_NAME, NLS.bind(Messages.Shared_Profile, null)); IInstallableUnit sharedProfileIU = MetadataFactory.createInstallableUnit(iuDescription); return sharedProfileIU; }
private static IInstallableUnit createSharedProfileIU(final IProfile sharedProfile) { InstallableUnitDescription iuDescription = new InstallableUnitDescription(); iuDescription.setId("SharedProfile_" + sharedProfile.getProfileId()); //$NON-NLS-1$ iuDescription.setVersion(Version.createOSGi(1, 0, 0, Long.toString(sharedProfile.getTimestamp()))); ArrayList<IProvidedCapability> iuCapabilities = new ArrayList<>(); IProvidedCapability selfCapability = MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, iuDescription.getId(), iuDescription.getVersion()); iuCapabilities.add(selfCapability); iuDescription.addProvidedCapabilities(iuCapabilities); ArrayList<IRequirement> iuRequirements = new ArrayList<>(); IQueryResult<IInstallableUnit> allIUs = sharedProfile.query(QueryUtil.createIUAnyQuery(), null); for (Iterator<IInstallableUnit> iterator = allIUs.iterator(); iterator.hasNext();) { IInstallableUnit iu = iterator.next(); IMatchExpression<IInstallableUnit> iuMatcher = ExpressionUtil.getFactory().matchExpression(ExpressionUtil.parse("id == $0 && version == $1"), iu.getId(), iu.getVersion()); //$NON-NLS-1$ iuRequirements.add(MetadataFactory.createRequirement(iuMatcher, null, 0, 1, true)); } iuDescription.addRequirements(iuRequirements); iuDescription.setProperty(IInstallableUnit.PROP_NAME, NLS.bind(Messages.Shared_Profile, null)); IInstallableUnit sharedProfileIU = MetadataFactory.createInstallableUnit(iuDescription); return sharedProfileIU; }
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 } } }
if (profile.getTimestamp() != installerProfile.getTimestamp()) { IProvisioningPlan plan = engine.createPlan(initialRequest.getProfile(), initialContext); plan.setStatus(new Status(ERROR, PI_DIRECTOR,
private IProvisioningPlan generatePlan(Projector newSolution, Collection<IInstallableUnit> newState, ProfileChangeRequest request, ProvisioningContext context) { // Compute the attachment of the new state if not provided if (newState == null) { newState = newSolution.extractSolution(); newState = AttachmentHelper.attachFragments(newState.iterator(), newSolution.getFragmentAssociation()); } ProvisioningContext noRepoContext = createNoRepoContext(request); // Compute the attachment of the previous state Object initialSolution = getSolutionFor( new ProfileChangeRequest(new EverythingOptionalProfile(request.getProfile())), noRepoContext, new NullProgressMonitor()); if (initialSolution instanceof IProvisioningPlan) { LogHelper.log(new Status(ERROR, PI_DIRECTOR, "The resolution of the previous state contained in profile " + request.getProfile().getProfileId() //$NON-NLS-1$ + " version " + request.getProfile().getTimestamp() + " failed.")); //$NON-NLS-1$//$NON-NLS-2$ return (IProvisioningPlan) initialSolution; } Iterator<IInstallableUnit> profileState = request.getProfile().query(QueryUtil.createIUAnyQuery(), null) .iterator(); Collection<IInstallableUnit> initialState = AttachmentHelper.attachFragments(profileState, ((Projector) initialSolution).getFragmentAssociation()); // Generate the plan return generateProvisioningPlan(initialState, newState, request, null, context); }
long oldTimestamp = fProfile.getTimestamp(); IPhaseSet phases = PhaseSetFactory.createDefaultPhaseSetExcluding(new String[] {PhaseSetFactory.PHASE_CHECK_TRUST, PhaseSetFactory.PHASE_CONFIGURE, PhaseSetFactory.PHASE_UNCONFIGURE, PhaseSetFactory.PHASE_UNINSTALL}); IEngine engine = getEngine();