Search in sources :

Example 6 with ResourceObjectEvent

use of com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent in project midpoint by Evolveum.

the class SimpleResourceObjectNotifier method checkApplicability.

@Override
protected boolean checkApplicability(Event event, GeneralNotifierType generalNotifierType, OperationResult result) {
    ResourceObjectEvent resourceObjectEvent = (ResourceObjectEvent) event;
    ObjectDelta<ShadowType> delta = resourceObjectEvent.getShadowDelta();
    if (!delta.isModify()) {
        return true;
    }
    boolean otherThanSyncPresent = deltaContainsOtherPathsThan(delta, functions.getSynchronizationPaths());
    boolean otherThanAuxPresent = deltaContainsOtherPathsThan(delta, functions.getAuxiliaryPaths());
    boolean watchSync = isWatchSynchronizationAttributes((SimpleResourceObjectNotifierType) generalNotifierType);
    boolean watchAux = isWatchAuxiliaryAttributes(generalNotifierType);
    if ((watchSync || otherThanSyncPresent) && (watchAux || otherThanAuxPresent)) {
        return true;
    }
    LOGGER.trace("No relevant attributes in delta, skipping the notifier (watchSync = " + watchSync + ", otherThanSyncPresent = " + otherThanSyncPresent + ", watchAux = " + watchAux + ", otherThanAuxPresent = " + otherThanAuxPresent + ")");
    return false;
}
Also used : ResourceObjectEvent(com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent)

Example 7 with ResourceObjectEvent

use of com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent in project midpoint by Evolveum.

the class SimpleResourceObjectNotifier method getBody.

@Override
protected String getBody(Event event, GeneralNotifierType generalNotifierType, String transport, Task task, OperationResult result) {
    boolean techInfo = Boolean.TRUE.equals(generalNotifierType.isShowTechnicalInformation());
    StringBuilder body = new StringBuilder();
    ResourceObjectEvent resourceObjectEvent = (ResourceObjectEvent) event;
    FocusType owner = (FocusType) resourceObjectEvent.getRequesteeObject();
    ResourceOperationDescription rod = resourceObjectEvent.getAccountOperationDescription();
    ObjectDelta<ShadowType> delta = (ObjectDelta<ShadowType>) rod.getObjectDelta();
    boolean isAccount = resourceObjectEvent.isShadowKind(ShadowKindType.ACCOUNT);
    String objectTypeDescription = isAccount ? "account" : "resource object";
    String userOrOwner = owner instanceof UserType ? "User" : "Owner";
    body.append("Notification about ").append(objectTypeDescription).append("-related operation\n\n");
    if (isAccount) {
        if (owner != null) {
            body.append(userOrOwner).append(": ").append(resourceObjectEvent.getRequesteeDisplayName());
            body.append(" (").append(owner.getName()).append(", oid ").append(owner.getOid()).append(")\n");
        } else {
            body.append(userOrOwner).append(": unknown\n");
        }
    }
    body.append("Notification created on: " + new Date() + "\n\n");
    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");
        }
        named = true;
    } else {
        named = false;
    }
    body.append("\n");
    if (isAccount) {
        body.append((named ? "The" : "An") + " account ");
    } else {
        body.append((named ? "The" : "A") + " resource object ");
    }
    switch(resourceObjectEvent.getOperationStatus()) {
        case SUCCESS:
            body.append("has been successfully ");
            break;
        case IN_PROGRESS:
            body.append("has been ATTEMPTED to be ");
            break;
        case FAILURE:
            body.append("FAILED to be ");
            break;
    }
    final boolean watchSynchronizationAttributes = isWatchSynchronizationAttributes((SimpleResourceObjectNotifierType) generalNotifierType);
    final boolean watchAuxiliaryAttributes = isWatchAuxiliaryAttributes(generalNotifierType);
    if (delta.isAdd()) {
        body.append("created on the resource with attributes:\n");
        body.append(resourceObjectEvent.getContentAsFormattedList(watchSynchronizationAttributes, watchAuxiliaryAttributes));
        body.append("\n");
    } else if (delta.isModify()) {
        body.append("modified on the resource. Modified attributes are:\n");
        body.append(resourceObjectEvent.getContentAsFormattedList(watchSynchronizationAttributes, watchAuxiliaryAttributes));
        body.append("\n");
    } else if (delta.isDelete()) {
        body.append("removed from the resource.\n\n");
    }
    if (resourceObjectEvent.getOperationStatus() == OperationStatus.IN_PROGRESS) {
        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\n");
    functions.addRequesterAndChannelInformation(body, event, result);
    if (techInfo) {
        body.append("----------------------------------------\n");
        body.append("Technical information:\n\n");
        body.append(rod.debugDump(2));
    }
    return body.toString();
}
Also used : ResourceObjectEvent(com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent) ResourceOperationDescription(com.evolveum.midpoint.provisioning.api.ResourceOperationDescription) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Date(java.util.Date)

Example 8 with ResourceObjectEvent

use of com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent in project midpoint by Evolveum.

the class AccountPasswordNotifier method checkApplicability.

@Override
protected boolean checkApplicability(Event event, GeneralNotifierType generalNotifierType, OperationResult result) {
    if (!event.isSuccess()) {
        LOGGER.trace("Operation was not successful, exiting.");
        return false;
    }
    ResourceObjectEvent resourceObjectEvent = (ResourceObjectEvent) event;
    ObjectDelta<? extends ShadowType> delta = resourceObjectEvent.getAccountOperationDescription().getObjectDelta();
    if (delta == null) {
        // should not occur
        LOGGER.trace("Object delta is null, exiting. Event = " + event);
        return false;
    }
    return functions.getPlaintextPasswordFromDelta(delta) != null;
}
Also used : ResourceObjectEvent(com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent)

Example 9 with ResourceObjectEvent

use of com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent in project midpoint by Evolveum.

the class KindIntentFilterHelper method processEvent.

@Override
public boolean processEvent(Event event, EventHandlerType eventHandlerType, NotificationManager notificationManager, Task task, OperationResult result) {
    if (eventHandlerType.getObjectKind().isEmpty() && eventHandlerType.getObjectIntent().isEmpty()) {
        return true;
    }
    if (!(event instanceof ResourceObjectEvent)) {
        // or should we return false?
        return true;
    }
    ResourceObjectEvent resourceObjectEvent = (ResourceObjectEvent) event;
    logStart(LOGGER, event, eventHandlerType, eventHandlerType.getStatus());
    boolean retval = true;
    if (!eventHandlerType.getObjectKind().isEmpty()) {
        retval = false;
        for (ShadowKindType shadowKindType : eventHandlerType.getObjectKind()) {
            if (shadowKindType == null) {
                LOGGER.warn("Filtering on null shadowKindType; filter = " + eventHandlerType);
            } else if (resourceObjectEvent.isShadowKind(shadowKindType)) {
                retval = true;
                break;
            }
        }
    }
    if (retval) {
        // now check the intent
        if (!eventHandlerType.getObjectIntent().isEmpty()) {
            retval = false;
            for (String intent : eventHandlerType.getObjectIntent()) {
                if (intent == null) {
                    LOGGER.warn("Filtering on null intent; filter = " + eventHandlerType);
                } else if (resourceObjectEvent.isShadowIntent(intent)) {
                    retval = true;
                    break;
                }
            }
        }
    }
    logEnd(LOGGER, event, eventHandlerType, retval);
    return retval;
}
Also used : ResourceObjectEvent(com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Aggregations

ResourceObjectEvent (com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent)9 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)3 ResourceOperationDescription (com.evolveum.midpoint.provisioning.api.ResourceOperationDescription)2 ModelContext (com.evolveum.midpoint.model.api.context.ModelContext)1 ModelElementContext (com.evolveum.midpoint.model.api.context.ModelElementContext)1 ModelEvent (com.evolveum.midpoint.notifications.api.events.ModelEvent)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)1 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1 Date (java.util.Date)1