Search in sources :

Example 6 with AccessCertificationCampaignStateType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType in project midpoint by Evolveum.

the class PageCertCampaigns method determineAction.

protected String determineAction(AccessCertificationCampaignType campaign) {
    int currentStage = campaign.getStageNumber();
    int numOfStages = CertCampaignTypeUtil.getNumberOfStages(campaign);
    AccessCertificationCampaignStateType state = campaign.getState();
    String button;
    switch(state) {
        case CREATED:
            button = numOfStages > 0 ? OP_START_CAMPAIGN : null;
            break;
        case IN_REVIEW_STAGE:
            button = OP_CLOSE_STAGE;
            break;
        case REVIEW_STAGE_DONE:
            button = currentStage < numOfStages ? OP_OPEN_NEXT_STAGE : OP_START_REMEDIATION;
            break;
        case IN_REMEDIATION:
        case CLOSED:
        default:
            button = null;
            break;
    }
    return button;
}
Also used : AccessCertificationCampaignStateType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType)

Example 7 with AccessCertificationCampaignStateType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType in project midpoint by Evolveum.

the class CertCampaignDto method resolveCurrentStateName.

private String resolveCurrentStateName(PageBase page) {
    int stageNumber = campaign.getStageNumber();
    AccessCertificationCampaignStateType state = campaign.getState();
    switch(state) {
        case CREATED:
        case IN_REMEDIATION:
        case CLOSED:
            return createStringResourceStatic(page, state).getString();
        case IN_REVIEW_STAGE:
        case REVIEW_STAGE_DONE:
            AccessCertificationStageType stage = CertCampaignTypeUtil.getCurrentStage(campaign);
            String stageName = stage != null ? stage.getName() : null;
            if (stageName != null) {
                String key = createEnumResourceKey(state) + "_FULL";
                return createStringResourceStatic(page, key, stageNumber, stageName).getString();
            } else {
                String key = createEnumResourceKey(state);
                return createStringResourceStatic(page, key).getString() + " " + stageNumber;
            }
        default:
            // todo warning/error?
            return null;
    }
}
Also used : AccessCertificationStageType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationStageType) AccessCertificationCampaignStateType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType)

Example 8 with AccessCertificationCampaignStateType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType in project midpoint by Evolveum.

the class CertificationManagerImpl method closeCurrentStage.

@Override
public void closeCurrentStage(String campaignOid, Task task, OperationResult parentResult) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ObjectAlreadyExistsException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
    Validate.notNull(campaignOid, "campaignOid");
    Validate.notNull(task, "task");
    Validate.notNull(parentResult, "parentResult");
    OperationResult result = parentResult.createSubresult(OPERATION_CLOSE_CURRENT_STAGE);
    result.addParam("campaignOid", campaignOid);
    try {
        AccessCertificationCampaignType campaign = generalHelper.getCampaign(campaignOid, null, task, result);
        result.addParam("campaign", ObjectTypeUtil.toShortString(campaign));
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("closeCurrentStage starting for {}", ObjectTypeUtil.toShortString(campaign));
        }
        securityEnforcer.authorize(ModelAuthorizationAction.CLOSE_CERTIFICATION_CAMPAIGN_REVIEW_STAGE.getUrl(), null, AuthorizationParameters.Builder.buildObject(campaign.asPrismObject()), null, task, result);
        final int currentStageNumber = campaign.getStageNumber();
        final int stages = CertCampaignTypeUtil.getNumberOfStages(campaign);
        final AccessCertificationCampaignStateType state = campaign.getState();
        LOGGER.trace("closeCurrentStage: currentStageNumber={}, stages={}, state={}", currentStageNumber, stages, state);
        if (!IN_REVIEW_STAGE.equals(state)) {
            result.recordFatalError("Couldn't close the current review stage as it is currently not open");
        } else {
            closerHelper.closeStage(campaign, task, result);
        }
    } catch (RuntimeException e) {
        result.recordFatalError("Couldn't close current certification campaign stage: unexpected exception: " + e.getMessage(), e);
        throw e;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AccessCertificationCampaignStateType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType)

Example 9 with AccessCertificationCampaignStateType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType in project midpoint by Evolveum.

the class CertificationManagerImpl method startRemediation.

@Override
public void startRemediation(String campaignOid, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, SecurityViolationException, ObjectAlreadyExistsException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
    Validate.notNull(campaignOid, "campaignOid");
    Validate.notNull(task, "task");
    Validate.notNull(parentResult, "parentResult");
    OperationResult result = parentResult.createSubresult(OPERATION_CLOSE_CURRENT_STAGE);
    result.addParam("campaignOid", campaignOid);
    try {
        AccessCertificationCampaignType campaign = generalHelper.getCampaign(campaignOid, null, task, result);
        result.addParam("campaign", ObjectTypeUtil.toShortString(campaign));
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("startRemediation starting for {}", ObjectTypeUtil.toShortString(campaign));
        }
        securityEnforcer.authorize(ModelAuthorizationAction.START_CERTIFICATION_REMEDIATION.getUrl(), null, AuthorizationParameters.Builder.buildObject(campaign.asPrismObject()), null, task, result);
        final int currentStageNumber = campaign.getStageNumber();
        final int lastStageNumber = CertCampaignTypeUtil.getNumberOfStages(campaign);
        final AccessCertificationCampaignStateType state = campaign.getState();
        LOGGER.trace("startRemediation: currentStageNumber={}, stages={}, state={}", currentStageNumber, lastStageNumber, state);
        if (currentStageNumber != lastStageNumber) {
            result.recordFatalError("Couldn't start the remediation as the campaign is not in its last stage (" + lastStageNumber + "); current stage: " + currentStageNumber);
        } else if (!REVIEW_STAGE_DONE.equals(state)) {
            result.recordFatalError("Couldn't start the remediation as the last stage was not properly closed.");
        } else {
            List<ItemDelta<?, ?>> deltas = updateHelper.createDeltasForStageNumberAndState(lastStageNumber + 1, IN_REMEDIATION);
            updateHelper.modifyObjectPreAuthorized(AccessCertificationCampaignType.class, campaignOid, deltas, task, result);
            if (CertCampaignTypeUtil.isRemediationAutomatic(campaign)) {
                remediationTaskHandler.launch(campaign, result);
            } else {
                result.recordWarning("The automated remediation is not configured. The campaign state was set to IN REMEDIATION, but all remediation actions have to be done by hand.");
            }
            campaign = updateHelper.refreshCampaign(campaign, result);
            eventHelper.onCampaignStageStart(campaign, task, result);
        }
    } catch (RuntimeException e) {
        result.recordFatalError("Couldn't start the remediation: unexpected exception: " + e.getMessage(), e);
        throw e;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AccessCertificationCampaignStateType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType)

Aggregations

AccessCertificationCampaignStateType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 CertificationHandler (com.evolveum.midpoint.certification.impl.handlers.CertificationHandler)2 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 AuditingConstants (com.evolveum.midpoint.cases.api.AuditingConstants)1 Clock (com.evolveum.midpoint.common.Clock)1 ModelAuditService (com.evolveum.midpoint.model.api.ModelAuditService)1 ModelService (com.evolveum.midpoint.model.api.ModelService)1 com.evolveum.midpoint.prism (com.evolveum.midpoint.prism)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 com.evolveum.midpoint.schema (com.evolveum.midpoint.schema)1 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)1 CertCampaignTypeUtil.norm (com.evolveum.midpoint.schema.util.CertCampaignTypeUtil.norm)1 Task (com.evolveum.midpoint.task.api.Task)1 TaskManager (com.evolveum.midpoint.task.api.TaskManager)1 com.evolveum.midpoint.util.exception (com.evolveum.midpoint.util.exception)1 Trace (com.evolveum.midpoint.util.logging.Trace)1