@PostConstruct public void registerForResourceObjectChangeNotifications() { notificationManager.registerNotificationListener(synchronizationService); }
@PreDestroy public void unregisterForResourceObjectChangeNotifications() { notificationManager.unregisterNotificationListener(synchronizationService); } }
private void notifyResourceObjectChangeListeners(ResourceObjectShadowChangeDescription change, Task task, OperationResult parentResult) { changeNotificationDispatcher.notifyChange(change, task, parentResult); }
private void notifyAfterAdd( ProvisioningContext ctx, PrismObject<ShadowType> addedShadow, ProvisioningOperationState<AsynchronousOperationReturnValue<PrismObject<ShadowType>>> opState, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { ObjectDelta<ShadowType> delta = DeltaFactory.Object.createAddDelta(addedShadow); ResourceOperationDescription operationDescription = createSuccessOperationDescription(ctx, addedShadow, delta, parentResult); if (opState.isExecuting()) { operationListener.notifyInProgress(operationDescription, task, parentResult); } else if (opState.isCompleted()) { operationListener.notifySuccess(operationDescription, task, parentResult); } }
private void handleErrorHandlerException(ProvisioningContext ctx, ProvisioningOperationState<? extends AsynchronousOperationResult> opState, ObjectDelta<ShadowType> delta, Task task, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException { // Error handler had re-thrown the exception. We will throw the exception later. But first we need to record changes in opState. shadowManager.recordOperationException(ctx, opState, delta, parentResult); PrismObject<ShadowType> shadow = opState.getRepoShadow(); if (delta.isAdd()) { // This is more precise. Besides, there is no repo shadow in some cases (e.g. adding protected shadow). shadow = delta.getObjectToAdd(); } ResourceOperationDescription operationDescription = ProvisioningUtil.createResourceFailureDescription(shadow, ctx.getResource(), delta, parentResult); operationListener.notifyFailure(operationDescription, task, parentResult); }
ResourceOperationDescription operationDescription = createSuccessOperationDescription(ctx, repoShadow, repoShadow.createDeleteDelta(), parentResult); operationListener.notifySuccess(operationDescription, task, parentResult); return null; } else {
dispatcher.notifyEvent(eventDescription, task, parentResult); parentResult.computeStatus(); task.setResult(parentResult);
private void notifyAfterDelete( ProvisioningContext ctx, PrismObject<ShadowType> shadow, ProvisioningOperationState<AsynchronousOperationResult> opState, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createDeleteDelta(shadow.getCompileTimeClass(), shadow.getOid()); ResourceOperationDescription operationDescription = createSuccessOperationDescription(ctx, shadow, delta, parentResult); if (opState.isExecuting()) { operationListener.notifyInProgress(operationDescription, task, parentResult); } else { operationListener.notifySuccess(operationDescription, task, parentResult); } }
public String addShadow(PrismObject<ShadowType> shadowToAdd, OperationProvisioningScriptsType scripts, ResourceType resource, ProvisioningOperationOptions options, Task task, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, ObjectAlreadyExistsException, SchemaException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, EncryptionException { Validate.notNull(shadowToAdd, "Object to add must not be null."); InternalMonitor.recordCount(InternalCounters.SHADOW_CHANGE_OPERATION_COUNT); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Start adding shadow object{}:\n{}", getAdditionalOperationDesc(scripts, options), shadowToAdd.debugDump(1)); } ProvisioningContext ctx = ctxFactory.create(shadowToAdd, task, parentResult); try { ctx.assertDefinition(); } catch (SchemaException e) { parentResult.recordFatalError(e); ResourceOperationDescription operationDescription = ProvisioningUtil.createResourceFailureDescription( shadowToAdd, ctx.getResource(), shadowToAdd.createAddDelta(), parentResult); operationListener.notifyFailure(operationDescription, task, parentResult); throw e; } ProvisioningOperationState<AsynchronousOperationReturnValue<PrismObject<ShadowType>>> opState = new ProvisioningOperationState<>(); return addShadowAttempt(ctx, shadowToAdd, scripts, opState, options, task, parentResult); }
ResourceOperationDescription operationDescription = createSuccessOperationDescription(ctx, repoShadow, notificationDelta, parentResult); operationListener.notifySuccess(operationDescription, task, parentResult);
@PostConstruct public void registerForResourceObjectChangeNotifications() { notificationManager.registerNotificationListener(this); }
@PreDestroy public void unregisterForResourceObjectChangeNotifications() { notificationManager.unregisterNotificationListener(this); }
private void reactShadowGone(PrismObject<ShadowType> shadow, PrismObject<ResourceType> resource, Task task, OperationResult result) { try { provisioningService.applyDefinition(shadow, task, result); ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription(); change.setSourceChannel(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_RECON)); change.setResource(resource); ObjectDelta<ShadowType> shadowDelta = shadow.getPrismContext().deltaFactory().object() .createDeleteDelta(ShadowType.class, shadow.getOid() ); change.setObjectDelta(shadowDelta); // Need to also set current shadow. This will get reflected in "old" object in lens context change.setCurrentShadow(shadow); ModelImplUtils.clearRequestee(task); changeNotificationDispatcher.notifyChange(change, task, result); } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) { processShadowReconError(e, shadow, result); } }
private void notifyAfterModify( ProvisioningContext ctx, PrismObject<ShadowType> repoShadow, Collection<? extends ItemDelta> modifications, ProvisioningOperationState<AsynchronousOperationReturnValue<Collection<PropertyDelta<PrismPropertyValue>>>> opState, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModifyDelta(repoShadow.getOid(), modifications, repoShadow.getCompileTimeClass()); ResourceOperationDescription operationDescription = createSuccessOperationDescription(ctx, repoShadow, delta, parentResult); if (opState.isExecuting()) { operationListener.notifyInProgress(operationDescription, task, parentResult); } else { operationListener.notifySuccess(operationDescription, task, parentResult); } }
Task task = taskManager.createTaskInstance(); ResourceOperationDescription failureDescription = ProvisioningUtil.createResourceFailureDescription(conflictingShadow, ctx.getResource(), null, parentResult); changeNotificationDispatcher.notifyFailure(failureDescription, task, parentResult); shadowManager.deleteConflictedShadowFromRepo(conflictingShadow, parentResult);
@PostConstruct public void register() { notificationManager.registerNotificationListener((ResourceObjectChangeListener)this); notificationManager.registerNotificationListener((ResourceOperationListener)this); }
private void exitAssociationSearchExpressionEvaluatorCache() { AssociationSearchExpressionEvaluatorCache cache = AssociationSearchExpressionEvaluatorCache.exitCache(); if (cache == null) { return; // shouldn't occur } Object invalidator = cache.getClientContextInformation(); if (invalidator == null || !(invalidator instanceof AssociationSearchExpressionCacheInvalidator)) { return; // shouldn't occur either } changeNotificationDispatcher.unregisterNotificationListener((ResourceObjectChangeListener) invalidator); changeNotificationDispatcher.unregisterNotificationListener((ResourceOperationListener) invalidator); }
changeNotificationDispatcher.notifyChange(change, task, result);
ResourceOperationDescription operationDescription = ProvisioningUtil.createResourceFailureDescription( shadowToAdd, ctx.getResource(), shadowToAdd.createAddDelta(), parentResult); operationListener.notifyFailure(operationDescription, task, parentResult); throw e;
private void enterAssociationSearchExpressionEvaluatorCache() { AssociationSearchExpressionEvaluatorCache cache = AssociationSearchExpressionEvaluatorCache.enterCache(); AssociationSearchExpressionCacheInvalidator invalidator = new AssociationSearchExpressionCacheInvalidator(cache); cache.setClientContextInformation(invalidator); changeNotificationDispatcher.registerNotificationListener((ResourceObjectChangeListener) invalidator); changeNotificationDispatcher.registerNotificationListener((ResourceOperationListener) invalidator); }