public static <O extends ObjectType> Long parseVersion(PrismObject<O> object) { String version = object.getVersion(); if (version == null) { return null; } return Long.valueOf(version); }
/** * Returns currently cached version. FOR DIAGNOSTICS ONLY. */ public synchronized String getVersion(String oid) { if (oid == null) { return null; } PrismObject<ResourceType> cachedResource = cache.get(oid); if (cachedResource == null) { return null; } return cachedResource.getVersion(); }
public void putObject(String oid, PrismObject<? extends ObjectType> object) { objects.put(oid, object); versions.put(oid, object.getVersion()); }
<T extends ObjectType> void afterAddObject(@NotNull String oid, @NotNull PrismObject<T> object) { if (notRelevant(oid)) { return; } String version = object.getVersion(); if (version == null) { throw new IllegalStateException("No version in object " + object); } expectedVersion = Integer.parseInt(version); initialized = true; //System.out.println(Thread.currentThread().getName() + ": afterAddObject: " + this); }
@XmlAttribute(name = "version") public String getVersion() { return asPrismContainer().getVersion(); }
public static <O extends ObjectType> void assertVersion(PrismObject<O> object, String expectedVersion) { assertEquals("Wrong version for "+object, expectedVersion, object.getVersion()); }
public String getObjectReadVersion() { // Do NOT use version from object current. // Current object may be re-read, but the computation // might be based on older data (objectOld). // if (getObjectCurrent() != null) { // return getObjectCurrent().getVersion(); // } if (getObjectOld() != null) { return getObjectOld().getVersion(); } return null; }
public synchronized PrismObject<ResourceType> get(PrismObject<ResourceType> resource, GetOperationOptions options) throws SchemaException { return get(resource.getOid(), resource.getVersion(), options); }
public <T extends ObjectType> void beforeModifyObject(PrismObject<T> object) { if (notRelevant(object.getOid())) { return; } checkExpectedVersion(object.getVersion()); }
<T extends ObjectType> void afterGetObject(PrismObject<T> object) { if (notRelevant(object.getOid())) { return; } checkExpectedVersion(object.getVersion()); }
private void applyLoggingConfiguration(PrismObject<SystemConfigurationType> configuration, OperationResult result) { try { LoggingConfigurationType loggingWithProfiling = ProfilingConfigurationManager .checkSystemProfilingConfiguration(configuration); if (loggingWithProfiling != null) { LoggingConfigurationManager.configure(loggingWithProfiling, configuration.getVersion(), midpointConfiguration, result); } } catch (Throwable t) { LoggingUtils.logUnexpectedException(LOGGER, "Couldn't apply logging configuration", t); lastVersionApplied = null; } }
protected void assertResourceVersionIncrement(PrismObject<ResourceType> resource, int expectedIncrement) { assertResourceVersionIncrement(resource.getVersion(), expectedIncrement); }
void cacheConfiguredConnector(ConnectorSpec connectorSpec, ConnectorInstance configuredConnectorInstance) { ConfiguredConnectorInstanceEntry cacheEntry = new ConfiguredConnectorInstanceEntry(); cacheEntry.connectorOid = connectorSpec.getConnectorOid(); String resourceVersion = connectorSpec.getResource().getVersion(); if (resourceVersion == null) { throw new IllegalArgumentException("Resource version is null, cannot cache connector for "+ connectorSpec.getResource()); } cacheEntry.configuration = connectorSpec.getConnectorConfiguration(); cacheEntry.connectorInstance = configuredConnectorInstance; connectorInstanceCache.put(connectorSpec.getCacheKey(), cacheEntry); }
private void loadSystemConfiguration(OperationResult result) throws ObjectNotFoundException, SchemaException { Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createReadOnly()); systemConfiguration = cacheRepositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), options, result); systemConfigurationCheckTimestamp = System.currentTimeMillis(); if (systemConfiguration != null && systemConfiguration.getVersion() == null) { LOGGER.warn("Retrieved system configuration with null version"); } }
public PrismObject<SystemConfigurationType> getSystemConfiguration(OperationResult result) throws ObjectNotFoundException, SchemaException { PrismObject<SystemConfigurationType> config = cacheRepositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result); if (LOGGER.isTraceEnabled()) { if (config == null) { LOGGER.warn("No system configuration object"); } else { LOGGER.trace("System configuration version read from repo: " + config.getVersion()); } } return config; }
private void singleModify(CarefulAnt<ResourceType> ant, int iteration, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { // GIVEN ItemDelta<?,?> itemDelta = ant.createDelta(iteration); Collection<? extends ItemDelta<?,?>> modifications = MiscSchemaUtil.createCollection(itemDelta); System.out.println("itemDelta: " + itemDelta.debugDump()); // WHEN repositoryService.modifyObject(ResourceType.class, RESOURCE_OPENDJ_OID, modifications, result); // THEN PrismObject<ResourceType> resourceAfter = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, result); SqlRepoTestUtil.assertVersionProgress(lastVersion, resourceAfter.getVersion()); lastVersion = resourceAfter.getVersion(); System.out.println("Version: "+lastVersion); ant.assertModification(resourceAfter, iteration); }
protected void executeAndCheckModification(List<ItemDelta<?,?>> modifications, OperationResult result, int versionDelta, List<String> keysWithGeneratedTimestamps, List<String> replacedKeys) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, IOException { RepoModifyOptions modifyOptions = getModifyOptions(); if (RepoModifyOptions.isExecuteIfNoChanges(modifyOptions) && versionDelta == 0) { versionDelta = 1; } PrismObject<LookupTableType> before = getFullTable(tableOid, result); repositoryService.modifyObject(LookupTableType.class, tableOid, modifications, modifyOptions, result); checkTable(tableOid, result, before, modifications, Integer.parseInt(before.getVersion()) + versionDelta, keysWithGeneratedTimestamps, replacedKeys); }
protected void executeAndCheckModification(List<ItemDelta<?, ?>> modifications, OperationResult result, int versionDelta) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, IOException { RepoModifyOptions modifyOptions = getModifyOptions(); if (RepoModifyOptions.isExecuteIfNoChanges(modifyOptions) && versionDelta == 0) { versionDelta = 1; } PrismObject<AccessCertificationCampaignType> before = getFullCampaign(campaign1Oid, result); int expectedVersion = Integer.parseInt(before.getVersion()) + versionDelta; List<ItemDelta> savedModifications = (List) CloneUtil.cloneCollectionMembers(modifications); repositoryService.modifyObject(AccessCertificationCampaignType.class, campaign1Oid, modifications, modifyOptions, result); checkCampaign(campaign1Oid, result, before, savedModifications, expectedVersion); }
public PrismObject<ResourceType> getResource(PrismObject<ResourceType> repositoryObject, GetOperationOptions options, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException{ InternalMonitor.getResourceCacheStats().recordRequest(); PrismObject<ResourceType> cachedResource = resourceCache.get(repositoryObject, options); if (cachedResource != null) { InternalMonitor.getResourceCacheStats().recordHit(); return cachedResource; } LOGGER.debug("Storing fetched resource {}, version {} to cache (previously cached version {})", repositoryObject.getOid(), repositoryObject.getVersion(), resourceCache.getVersion(repositoryObject.getOid())); return loadAndCacheResource(repositoryObject, options, task, parentResult); }
private void checkCampaign(String campaignOid, OperationResult result, PrismObject<AccessCertificationCampaignType> expectedObject, List<ItemDelta> modifications, Integer expectedVersion) throws SchemaException, ObjectNotFoundException, IOException { expectedObject.setOid(campaignOid); if (modifications != null) { ItemDeltaCollectionsUtil.applyTo(modifications, expectedObject); } LOGGER.trace("Expected object = \n{}", expectedObject.debugDump()); PrismObject<AccessCertificationCampaignType> campaign = getFullCampaign(campaignOid, result); LOGGER.trace("Actual object from repo = \n{}", campaign.debugDump()); PrismAsserts.assertEquivalent("Campaign is not as expected", expectedObject, campaign); if (expectedVersion != null) { AssertJUnit.assertEquals("Incorrect version", (int) expectedVersion, Integer.parseInt(campaign.getVersion())); } }