public static long getStaleness(GetOperationOptions options) { if (options == null) { return 0L; } if (options.getStaleness() == null) { return 0L; } return options.getStaleness(); }
public static boolean isMaxStaleness(GetOperationOptions options) { return GetOperationOptions.getStaleness(options) == Long.MAX_VALUE; }
long stalenessOption = GetOperationOptions.getStaleness(SelectorOptions.findRootOptions(options)); PointInTimeType pit = GetOperationOptions.getPointInTimeType(SelectorOptions.findRootOptions(options)); if (pit == null) {
private boolean isCachedShadowValid(Collection<SelectorOptions<GetOperationOptions>> options, PrismObject<ShadowType> repositoryShadow, ResourceType resource) throws ConfigurationException { long stalenessOption = GetOperationOptions.getStaleness(SelectorOptions.findRootOptions(options)); if (stalenessOption == 0L) { return false; } CachingMetadataType cachingMetadata = repositoryShadow.asObjectable().getCachingMetadata(); if (cachingMetadata == null) { if (stalenessOption == Long.MAX_VALUE) { // We must return cached version but there is no cached version. throw new ConfigurationException("Cached version of "+repositoryShadow+" requested, but there is no cached value"); } return false; } if (stalenessOption == Long.MAX_VALUE) { return true; } XMLGregorianCalendar retrievalTimestamp = cachingMetadata.getRetrievalTimestamp(); if (retrievalTimestamp == null) { return false; } long retrievalTimestampMillis = XmlTypeConverter.toMillis(retrievalTimestamp); return (clock.currentTimeMillis() - retrievalTimestampMillis < stalenessOption); }
private static GetOperationOptionsType getOptionsToGetOptionsType(GetOperationOptions options) { GetOperationOptionsType optionsType = new GetOperationOptionsType(); optionsType.setRetrieve(RetrieveOption.toRetrieveOptionType(options.getRetrieve())); optionsType.setResolve(options.getResolve()); optionsType.setResolveNames(options.getResolveNames()); optionsType.setNoFetch(options.getNoFetch()); optionsType.setRaw(options.getRaw()); optionsType.setTolerateRawData(options.getTolerateRawData()); optionsType.setNoDiscovery(options.getDoNotDiscovery()); // TODO relational value search query (but it might become obsolete) optionsType.setAllowNotFound(options.getAllowNotFound()); optionsType.setPointInTimeType(PointInTimeType.toPointInTimeTypeType(options.getPointInTimeType())); optionsType.setDefinitionProcessing(DefinitionProcessingOption.toDefinitionProcessingOptionType(options.getDefinitionProcessing())); optionsType.setStaleness(options.getStaleness()); optionsType.setDistinct(options.getDistinct()); return optionsType; }