Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align applicability checks with text generation
Notifiers were applied to events based on criteria that were different from those used to generate textual representation of the events. This sometimes lead to events with empty list of modifications (e.g. in MID-5849). This commit aligns those two aspects. Also we have refactored some years-old code e.g. cleaned up Event class hierarchy. Quick applicability check is now carried out before nested event handlers are invoked, making their execution more intuitive and robust. (cherry picked from commit fce73ae)
- Loading branch information
Showing
70 changed files
with
2,644 additions
and
2,215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 36 additions & 79 deletions
115
...rc/main/java/com/evolveum/midpoint/notifications/api/events/AccessCertificationEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,53 @@ | ||
/* | ||
* Copyright (c) 2010-2017 Evolveum and contributors | ||
* Copyright (c) 2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.notifications.api.events; | ||
|
||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.schema.result.OperationResultStatus; | ||
import com.evolveum.midpoint.schema.util.CertCampaignTypeUtil; | ||
import com.evolveum.midpoint.task.api.LightweightIdentifierGenerator; | ||
import com.evolveum.midpoint.util.DebugUtil; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationStageDefinitionType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.EventCategoryType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.EventOperationType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.EventStatusType; | ||
import org.apache.commons.lang.Validate; | ||
|
||
import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType.*; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Any event that is related to access certification. | ||
* | ||
* @author mederly | ||
* An event related to access certification. | ||
*/ | ||
public abstract class AccessCertificationEvent extends BaseEvent { | ||
|
||
// all these must not be null | ||
protected AccessCertificationCampaignType campaign; | ||
protected OperationResultStatus status; | ||
protected EventOperationType operationType; | ||
|
||
|
||
public AccessCertificationEvent(LightweightIdentifierGenerator lightweightIdentifierGenerator, AccessCertificationCampaignType campaign, EventOperationType opType) { | ||
super(lightweightIdentifierGenerator); | ||
Validate.notNull(campaign, "campaign"); | ||
Validate.notNull(opType, "opType"); | ||
this.campaign = campaign; | ||
this.operationType = opType; | ||
this.status = OperationResultStatus.SUCCESS; // TODO fix this temporary implementation | ||
} | ||
|
||
public AccessCertificationCampaignType getCampaign() { | ||
return campaign; | ||
} | ||
|
||
@Override | ||
public boolean isRelatedToItem(ItemPath itemPath) { | ||
return false; // not supported for this kind of events | ||
} | ||
|
||
@Override | ||
public boolean isStatusType(EventStatusType eventStatusType) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isOperationType(EventOperationType eventOperationType) { | ||
return this.operationType.equals(eventOperationType); | ||
} | ||
|
||
@Override | ||
public boolean isCategoryType(EventCategoryType eventCategoryType) { | ||
return EventCategoryType.ACCESS_CERTIFICATION_EVENT.equals(eventCategoryType); | ||
} | ||
|
||
public String getCampaignName() { | ||
return campaign.getName().getOrig(); | ||
} | ||
|
||
public OperationResultStatus getStatus() { | ||
return status; | ||
} | ||
|
||
public EventOperationType getOperationType() { | ||
return operationType; | ||
} | ||
|
||
public AccessCertificationStageDefinitionType getCurrentStageDefinition() { | ||
if (campaign.getState() != IN_REVIEW_STAGE && campaign.getState() != REVIEW_STAGE_DONE) { | ||
return null; | ||
} | ||
return CertCampaignTypeUtil.findStageDefinition(campaign, campaign.getStageNumber()); | ||
} | ||
|
||
@Override | ||
protected void debugDumpCommon(StringBuilder sb, int indent) { | ||
super.debugDumpCommon(sb, indent); | ||
DebugUtil.debugDumpWithLabelToStringLn(sb, "campaign", campaign, indent + 1); | ||
DebugUtil.debugDumpWithLabelToStringLn(sb, "status", status, indent + 1); | ||
DebugUtil.debugDumpWithLabelToStringLn(sb, "operationType", operationType, indent + 1); | ||
} | ||
public interface AccessCertificationEvent extends Event { | ||
|
||
/** | ||
* Type of the operation: usually | ||
* - ADD (opening campaign/stage) | ||
* - DELETE (closing campaign/stage). | ||
* | ||
* In special cases there can be MODIFY e.g. meaning "stage deadline approaching". | ||
*/ | ||
EventOperationType getOperationType(); | ||
|
||
/** | ||
* Status of the operation. | ||
* (Currently always SUCCESS.) | ||
*/ | ||
OperationResultStatus getStatus(); | ||
|
||
/** | ||
* Related certification campaign. | ||
*/ | ||
@NotNull AccessCertificationCampaignType getCampaign(); | ||
|
||
/** | ||
* Name of the related certification campaign. | ||
*/ | ||
default String getCampaignName() { | ||
return getCampaign().getName().getOrig(); | ||
} | ||
|
||
/** | ||
* Definition of the current stage. | ||
*/ | ||
AccessCertificationStageDefinitionType getCurrentStageDefinition(); | ||
} |
Oops, something went wrong.