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]; }
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; }
public Object[] getChildren(Object o) { IProfileRegistry registry = ProvUI.getProfileRegistry(session); long[] timestamps = registry.listProfileTimestamps(profileId); // find out which profile states we should hide Map<String, String> hidden = registry.getProfileStateProperties(profileId, IProfile.STATE_PROP_HIDDEN); Map<String, String> tag = registry.getProfileStateProperties(profileId, IProfile.STATE_PROP_TAG); List<RollbackProfileElement> elements = new ArrayList<RollbackProfileElement>(); for (int i = 0; i < timestamps.length; i++) { if (hidden.containsKey(String.valueOf(timestamps[i]))) continue; RollbackProfileElement element = null; String timestamp = String.valueOf(timestamps[i]); if (!tag.containsKey(timestamp)) { element = new RollbackProfileElement(this, profileId, timestamps[i]); } else { element = new RollbackProfileElement(this, profileId, timestamps[i], tag.get(timestamp)); } elements.add(element); // Eliminate the first in the list (earliest) if there was no content at all. // This doesn't always happen, but can, and we don't want to offer the user an empty profile to // revert to. Just reset the list since it only has one element. if (i == 0 && element.getChildren(element).length == 0) elements.clear(); } // current profile is the last one in the list if (elements.size() > 0) elements.get(elements.size() - 1).setIsCurrentProfile(true); return elements.toArray(new RollbackProfileElement[elements.size()]); }