Search in sources :

Example 1 with LocalizableMessageBuilder

use of com.evolveum.midpoint.util.LocalizableMessageBuilder in project midpoint by Evolveum.

the class PageCertDefinitions method createCampaignPerformed.

private void createCampaignPerformed(AjaxRequestTarget target, AccessCertificationDefinitionType definition) {
    LOGGER.debug("Create certification campaign performed for {}", definition.asPrismObject());
    OperationResult result = new OperationResult(OPERATION_CREATE_CAMPAIGN);
    try {
        Task task = createSimpleTask(OPERATION_CREATE_CAMPAIGN);
        if (!Boolean.TRUE.equals(definition.isAdHoc())) {
            AccessCertificationCampaignType campaign = getCertificationService().createCampaign(definition.getOid(), task, result);
            result.setUserFriendlyMessage(new LocalizableMessageBuilder().key("PageCertDefinitions.campaignWasCreated").arg(getOrig(campaign.getName())).build());
        } else {
            result.recordWarning(createStringResource("PageCertDefinitions.message.createCampaignPerformed.warning", definition.getName()).getString());
        }
    } catch (Exception ex) {
        result.recordFatalError(ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    showResult(result);
    target.add(getFeedbackPanel());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) LocalizableMessageBuilder(com.evolveum.midpoint.util.LocalizableMessageBuilder) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Example 2 with LocalizableMessageBuilder

use of com.evolveum.midpoint.util.LocalizableMessageBuilder in project midpoint by Evolveum.

the class ObjectPolicyAspectPart method createDefaultProcessName.

private <T extends ObjectType> LocalizableMessage createDefaultProcessName(ModelInvocationContext<T> ctx, ObjectDelta<T> deltaToApprove) {
    ObjectType focus = ctx.getFocusObjectNewOrOld();
    String opKey;
    if (deltaToApprove.isAdd()) {
        opKey = "Added";
    } else if (deltaToApprove.isDelete()) {
        opKey = "Deleted";
    } else {
        opKey = "Modified";
    }
    return new LocalizableMessageBuilder().key(SchemaConstants.DEFAULT_POLICY_CONSTRAINT_SHORT_MESSAGE_KEY_PREFIX + "objectModification.toBe" + opKey).args(ObjectTypeUtil.createDisplayInformation(asPrismObject(focus), false)).build();
}
Also used : LocalizableMessageBuilder(com.evolveum.midpoint.util.LocalizableMessageBuilder)

Example 3 with LocalizableMessageBuilder

use of com.evolveum.midpoint.util.LocalizableMessageBuilder in project midpoint by Evolveum.

the class ObjectModificationConstraintEvaluator method createMessage.

private <AH extends AssignmentHolderType> LocalizableMessage createMessage(JAXBElement<ModificationPolicyConstraintType> constraint, PolicyRuleEvaluationContext<AH> rctx, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
    String keyPostfix = createStateKey(rctx) + createOperationKey(rctx);
    LocalizableMessage builtInMessage = new LocalizableMessageBuilder().key(SchemaConstants.DEFAULT_POLICY_CONSTRAINT_KEY_PREFIX + CONSTRAINT_KEY_PREFIX + keyPostfix).args(ObjectTypeUtil.createDisplayInformation(rctx.focusContext.getObjectAny(), true)).build();
    return evaluatorHelper.createLocalizableMessage(constraint, rctx, builtInMessage, result);
}
Also used : LocalizableMessage(com.evolveum.midpoint.util.LocalizableMessage) LocalizableMessageBuilder(com.evolveum.midpoint.util.LocalizableMessageBuilder)

Example 4 with LocalizableMessageBuilder

use of com.evolveum.midpoint.util.LocalizableMessageBuilder in project midpoint by Evolveum.

the class ObjectModificationConstraintEvaluator method createShortMessage.

private <AH extends AssignmentHolderType> LocalizableMessage createShortMessage(JAXBElement<ModificationPolicyConstraintType> constraint, PolicyRuleEvaluationContext<AH> rctx, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
    String keyPostfix = createStateKey(rctx) + createOperationKey(rctx);
    LocalizableMessage builtInMessage = new LocalizableMessageBuilder().key(SchemaConstants.DEFAULT_POLICY_CONSTRAINT_SHORT_MESSAGE_KEY_PREFIX + CONSTRAINT_KEY_PREFIX + keyPostfix).args(ObjectTypeUtil.createDisplayInformation(rctx.focusContext.getObjectAny(), false)).build();
    return evaluatorHelper.createLocalizableShortMessage(constraint, rctx, builtInMessage, result);
}
Also used : LocalizableMessage(com.evolveum.midpoint.util.LocalizableMessage) LocalizableMessageBuilder(com.evolveum.midpoint.util.LocalizableMessageBuilder)

Example 5 with LocalizableMessageBuilder

use of com.evolveum.midpoint.util.LocalizableMessageBuilder in project midpoint by Evolveum.

the class AlwaysTrueConstraintEvaluator method createBuiltInMessage.

@NotNull
private <AH extends AssignmentHolderType> LocalizableMessage createBuiltInMessage(String keyPrefix, JAXBElement<AlwaysTruePolicyConstraintType> constraintElement, PolicyRuleEvaluationContext<AH> ctx, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
    AlwaysTruePolicyConstraintType constraint = constraintElement.getValue();
    List<Object> args = new ArrayList<>();
    args.add(evaluatorHelper.createBeforeAfterMessage(ctx));
    String keySuffix;
    if (constraint.getName() != null) {
        args.add(constraint.getName());
        keySuffix = KEY_NAMED;
    } else {
        keySuffix = KEY_UNNAMED;
    }
    LocalizableMessage builtInMessage = new LocalizableMessageBuilder().key(keyPrefix + keySuffix).args(args).build();
    return evaluatorHelper.createLocalizableMessage(constraintElement, ctx, builtInMessage, result);
}
Also used : ArrayList(java.util.ArrayList) AlwaysTruePolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.AlwaysTruePolicyConstraintType) LocalizableMessage(com.evolveum.midpoint.util.LocalizableMessage) LocalizableMessageBuilder(com.evolveum.midpoint.util.LocalizableMessageBuilder) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LocalizableMessageBuilder (com.evolveum.midpoint.util.LocalizableMessageBuilder)24 LocalizableMessage (com.evolveum.midpoint.util.LocalizableMessage)17 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)11 StringLimitationResult (com.evolveum.midpoint.model.api.validator.StringLimitationResult)7 NotNull (org.jetbrains.annotations.NotNull)7 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 PolyStringTranslationType (com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType)4 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)3 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 EvaluatedPolicyRule (com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule)2 EvaluatedSituationTrigger (com.evolveum.midpoint.model.api.context.EvaluatedSituationTrigger)2 EvaluatedAssignmentImpl (com.evolveum.midpoint.model.impl.lens.assignments.EvaluatedAssignmentImpl)2 AssignmentPolicyRuleEvaluationContext (com.evolveum.midpoint.model.impl.lens.projector.policy.AssignmentPolicyRuleEvaluationContext)2 PolicyRuleEvaluationContext (com.evolveum.midpoint.model.impl.lens.projector.policy.PolicyRuleEvaluationContext)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2