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;
}
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;
}
}
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();
}
}
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();
}
}
Aggregations