@Override public String debugDump() { return debugDump(0); }
private void notifyAny(ResourceOperationDescription operationDescription) { cache.invalidate(operationDescription.getResource(), operationDescription.getCurrentShadow()); }
public ObjectDelta<ShadowType> getShadowDelta() { return (ObjectDelta<ShadowType>) accountOperationDescription.getObjectDelta(); }
public static ResourceOperationDescription createResourceFailureDescription( PrismObject<ShadowType> conflictedShadow, ResourceType resource, ObjectDelta<ShadowType> delta, OperationResult parentResult) { ResourceOperationDescription failureDesc = new ResourceOperationDescription(); failureDesc.setCurrentShadow(conflictedShadow); failureDesc.setObjectDelta(delta); failureDesc.setResource(resource.asPrismObject()); failureDesc.setResult(parentResult); failureDesc.setSourceChannel(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_DISCOVERY)); return failureDesc; }
ObjectDelta<ShadowType> delta = (ObjectDelta<ShadowType>) rod.getObjectDelta(); body.append("Resource: " + resourceObjectEvent.getResourceName() + " (oid " + resourceObjectEvent.getResourceOid() + ")\n"); boolean named; if (rod.getCurrentShadow() != null && rod.getCurrentShadow().asObjectable().getName() != null) { if (isAccount) { body.append("Account: " + rod.getCurrentShadow().asObjectable().getName() + "\n"); } else { body.append("Resource object: " + rod.getCurrentShadow().asObjectable().getName() + " (kind: " + rod.getCurrentShadow().asObjectable().getKind() + ")\n"); body.append("The operation will be retried.\n\n"); } else if (resourceObjectEvent.getOperationStatus() == OperationStatus.FAILURE) { body.append("Error: " + resourceObjectEvent.getAccountOperationDescription().getResult().getMessage() + "\n\n"); body.append("----------------------------------------\n"); body.append("Technical information:\n\n"); body.append(rod.debugDump(2));
private void executeNotifyAny(OperationStatus status, ResourceOperationDescription operationDescription, Task task, OperationResult result) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("AccountOperationListener.notify ({}) called with operationDescription = {}", status, operationDescription.debugDump()); } if (operationDescription.getObjectDelta() == null) { LOGGER.warn("Object delta is null, exiting the change listener."); return; } if (operationDescription.getCurrentShadow() == null) { LOGGER.warn("Current shadow is null, exiting the change listener."); return; } // for the time being, we deal only with accounts here if (operationDescription.getObjectDelta().getObjectTypeClass() == null || !ShadowType.class.isAssignableFrom(operationDescription.getObjectDelta().getObjectTypeClass())) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Object that was changed was not an account, exiting the operation listener (class = {})", operationDescription.getObjectDelta().getObjectTypeClass()); } return; } ResourceObjectEvent request = createRequest(status, operationDescription, task, result); notificationManager.processEvent(request, task, result); }
event.getAccountOperationDescription().getCurrentShadow(), null)); } else { event.getAccountOperationDescription().getCurrentShadow(), null)); } catch (SchemaException e) { LoggingUtils.logUnexpectedException(LOGGER, "Unable to determine the shadow change; operation = {}", e, event.getAccountOperationDescription().debugDump()); rv.append("(unable to determine the change because of schema exception: ").append(e.getMessage()).append(")\n");
@Override public void notifyFailure(ResourceOperationDescription failureDescription, Task task, OperationResult parentResult) { Validate.notNull(failureDescription, "Operation description of resource object shadow must not be null."); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Resource operation failure notification\n{} ", failureDescription.debugDump()); } failureDescription.checkConsistence(); if ((null != operationListeners) && (!operationListeners.isEmpty())) { for (ResourceOperationListener listener : new ArrayList<>(operationListeners)) { // sometimes there is registration/deregistration from within //LOGGER.trace("Listener: {}", listener.getClass().getSimpleName()); try { listener.notifyFailure(failureDescription, task, parentResult); } catch (RuntimeException e) { LOGGER.error("Exception {} thrown by operation failure listener {}: {}-{}", new Object[]{ e.getClass(), listener.getName(), e.getMessage(), e }); parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifyFailure") .recordWarning("Operation failure listener has thrown unexpected exception", e); } } } else { LOGGER.debug("Operation failure received but listener list is empty, there is nobody to get the message"); } }
public ShadowType getShadow() { PrismObject<? extends ShadowType> shadow = accountOperationDescription.getCurrentShadow(); return shadow != null ? shadow.asObjectable() : null; }
private ResourceObjectEvent createRequest(OperationStatus status, ResourceOperationDescription operationDescription, Task task, OperationResult result) { ResourceObjectEvent event = new ResourceObjectEvent(lightweightIdentifierGenerator); event.setAccountOperationDescription(operationDescription); event.setOperationStatus(status); event.setChangeType(operationDescription.getObjectDelta().getChangeType()); // fortunately there's 1:1 mapping String accountOid = operationDescription.getObjectDelta().getOid(); PrismObject<UserType> user = findRequestee(accountOid, task, result, operationDescription.getObjectDelta().isDelete()); if (user != null) { event.setRequestee(new SimpleObjectRefImpl(notificationsUtil, user.asObjectable())); } // otherwise, appropriate messages were already logged if (task != null && task.getOwner() != null) { event.setRequester(new SimpleObjectRefImpl(notificationsUtil, task.getOwner())); } else { LOGGER.warn("No owner for task {}, therefore no requester will be set for event {}", task, event.getId()); } if (task != null && task.getChannel() != null) { event.setChannel(task.getChannel()); } else if (operationDescription.getSourceChannel() != null) { event.setChannel(operationDescription.getSourceChannel()); } return event; }
public String getResourceOid() { return getAccountOperationDescription().getResource().getOid(); }
private void notifyOp(String notificationDesc, ResourceOperationDescription opDescription, Task task, OperationResult parentResult, boolean failure) { LOGGER.debug("Notify "+notificationDesc+" mock called with:\n{}", opDescription.debugDump()); assertNotNull("No result", opDescription.getResult()); assertNotNull("No resource", opDescription.getResource()); assertNotNull("No parent result", parentResult); assertNotNull("Current shadow not present", opDescription.getCurrentShadow()); assertNotNull("Delta not present", opDescription.getObjectDelta()); if (opDescription.getCurrentShadow() != null) { ShadowType currentShadowType = opDescription.getCurrentShadow().asObjectable(); if (currentShadowType != null) { assertNotNull("Current shadow does not have an OID", opDescription.getCurrentShadow().getOid()); assertNotNull("Current shadow has null attributes", currentShadowType.getAttributes()); assertFalse("Current shadow has empty attributes", ShadowUtil if (!opDescription.getObjectDelta().isDelete() && !failure){ try { repositoryService.getObject(currentShadowType.getClass(), currentShadowType.getOid(), null, new OperationResult("mockSyncService."+notificationDesc)); if (opDescription.getObjectDelta() != null && !failure) { assertNotNull("Delta has null OID", opDescription.getObjectDelta().getOid());
@Override public void notifySuccess(ResourceOperationDescription successDescription, Task task, OperationResult parentResult) { Validate.notNull(successDescription, "Operation description of resource object shadow must not be null."); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Resource operation success notification\n{} ", successDescription.debugDump()); } successDescription.checkConsistence(); if ((null != operationListeners) && (!operationListeners.isEmpty())) { for (ResourceOperationListener listener : new ArrayList<>(operationListeners)) { // sometimes there is registration/deregistration from within //LOGGER.trace("Listener: {}", listener.getClass().getSimpleName()); try { listener.notifySuccess(successDescription, task, parentResult); } catch (RuntimeException e) { LOGGER.error("Exception {} thrown by operation success listener {}: {}-{}", new Object[]{ e.getClass(), listener.getName(), e.getMessage(), e }); parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifySuccess") .recordWarning("Operation success listener has thrown unexpected exception", e); } } } else { LOGGER.debug("Operation success received but listener list is empty, there is nobody to get the message"); } }
private ResourceOperationDescription createSuccessOperationDescription(ProvisioningContext ctx, PrismObject<ShadowType> shadowType, ObjectDelta delta, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { ResourceOperationDescription operationDescription = new ResourceOperationDescription(); operationDescription.setCurrentShadow(shadowType); operationDescription.setResource(ctx.getResource().asPrismObject()); if (ctx.getTask() != null) { operationDescription.setSourceChannel(ctx.getTask().getChannel()); } operationDescription.setObjectDelta(delta); operationDescription.setResult(parentResult); return operationDescription; }
public boolean isShadowIntent(String intent) { if (StringUtils.isNotEmpty(intent)) { return intent.equals(accountOperationDescription.getCurrentShadow().asObjectable().getIntent()); } else { return StringUtils.isEmpty(accountOperationDescription.getCurrentShadow().asObjectable().getIntent()); } }
public PolyStringType getResourceName() { return getAccountOperationDescription().getResource().asObjectable().getName(); }
@Override public void notifyInProgress(ResourceOperationDescription inProgressDescription, Task task, OperationResult parentResult) { Validate.notNull(inProgressDescription, "Operation description of resource object shadow must not be null."); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Resource operation in-progress notification\n{} ", inProgressDescription.debugDump()); } inProgressDescription.checkConsistence(); if ((null != operationListeners) && (!operationListeners.isEmpty())) { for (ResourceOperationListener listener : new ArrayList<>(operationListeners)) { // sometimes there is registration/deregistration from within //LOGGER.trace("Listener: {}", listener.getClass().getSimpleName()); try { listener.notifyInProgress(inProgressDescription, task, parentResult); } catch (RuntimeException e) { LOGGER.error("Exception {} thrown by operation in-progress listener {}: {}-{}", new Object[]{ e.getClass(), listener.getName(), e.getMessage(), e }); parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifyInProgress") .recordWarning("Operation in-progress listener has thrown unexpected exception", e); } } } else { LOGGER.debug("Operation in-progress received but listener list is empty, there is nobody to get the message"); } }
public String getShadowName() { return getNotificationFunctions().getShadowName(getAccountOperationDescription().getCurrentShadow()); }
public String getPlaintextPassword() { ObjectDelta delta = getAccountOperationDescription().getObjectDelta(); return delta != null ? getNotificationFunctions().getPlaintextPasswordFromDelta(delta) : null; }
public boolean isShadowKind(ShadowKindType shadowKindType) { ShadowKindType actualKind = accountOperationDescription.getCurrentShadow().asObjectable().getKind(); if (actualKind != null) { return actualKind.equals(shadowKindType); } else { return ShadowKindType.ACCOUNT.equals(shadowKindType); } }