Search in sources :

Example 1 with SingleLocalizableMessage

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

the class ObjectValidator method msg.

private <V extends PrismValue, D extends ItemDefinition> void msg(ValidationResult result, OperationResultStatus status, Item<V, D> item, String message) {
    ValidationItem resultItem = new ValidationItem();
    resultItem.setStatus(status);
    if (item != null) {
        resultItem.setItemPath(item.getPath());
    }
    LocalizableMessage lMessage = new SingleLocalizableMessage(null, null, message);
    resultItem.setMessage(lMessage);
    result.addItem(resultItem);
}
Also used : SingleLocalizableMessage(com.evolveum.midpoint.util.SingleLocalizableMessage) SingleLocalizableMessage(com.evolveum.midpoint.util.SingleLocalizableMessage) LocalizableMessage(com.evolveum.midpoint.util.LocalizableMessage)

Example 2 with SingleLocalizableMessage

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

the class TestPrismSerialization method testSerializeExecuteCredentialResetResponseType.

@Test
public void testSerializeExecuteCredentialResetResponseType() throws Exception {
    PrismContext prismContext = getPrismContext();
    SingleLocalizableMessage localizableMessage = new SingleLocalizableMessage("execute.reset.credential.bad.request", null, "Failed to execute reset password. Bad request.");
    LocalizableMessageType localizableMessageBean = LocalizationUtil.createLocalizableMessageType(localizableMessage);
    ExecuteCredentialResetResponseType response = new ExecuteCredentialResetResponseType();
    response.setMessage(localizableMessageBean);
    QName fakeQName = new QName(PrismConstants.NS_TYPES, "object");
    prismContext.adopt(response);
    String xml = prismContext.xmlSerializer().serializeAnyData(response, fakeQName);
    System.out.println(xml);
}
Also used : PrismTestUtil.getPrismContext(com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext) QName(javax.xml.namespace.QName) ExecuteCredentialResetResponseType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ExecuteCredentialResetResponseType) SingleLocalizableMessage(com.evolveum.midpoint.util.SingleLocalizableMessage) Test(org.testng.annotations.Test)

Example 3 with SingleLocalizableMessage

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

the class PruningOperation method processPruneRuleExclusionTrigger.

private void processPruneRuleExclusionTrigger(EvaluatedAssignmentImpl<F> newAssignment, EvaluatedPolicyRuleImpl pruneRule, EvaluatedExclusionTrigger exclusionTrigger) {
    EvaluatedAssignment<FocusType> conflictingAssignment = exclusionTrigger.getConflictingAssignment();
    if (conflictingAssignment == null) {
        throw new SystemException("Added assignment " + newAssignment + ", the exclusion prune rule was triggered but there is no conflicting assignment in the trigger");
    }
    LOGGER.debug("Pruning assignment {} because it conflicts with added assignment {}", conflictingAssignment, newAssignment);
    if (conflictingAssignment.isPresentInOldObject()) {
        // This is the usual (good) case. The conflicting assignment was present in the old object so we can remove it
        // by means of secondary delta.
        // noinspection unchecked
        PrismContainerValue<AssignmentType> assignmentValueToRemove = conflictingAssignment.getAssignment().asPrismContainerValue().clone();
        PrismObjectDefinition<F> focusDef = context.getFocusContext().getObjectDefinition();
        ContainerDelta<AssignmentType> assignmentDelta = beans.prismContext.deltaFactory().container().createDelta(FocusType.F_ASSIGNMENT, focusDef);
        // noinspection unchecked
        assignmentDelta.addValuesToDelete(assignmentValueToRemove);
        context.getFocusContext().swallowToSecondaryDeltaUnchecked(assignmentDelta);
        prunedViaSecondaryDelta = true;
    } else {
        // Conflicting assignment was not present in old object i.e. it was added in the meanwhile into secondary delta.
        // We create trigger for this with enforcementOverride = true, so it will be reported as policy violation
        // even if not enforcement policy action is present. See also MID-4766.
        SingleLocalizableMessage message = new LocalizableMessageBuilder().key("PolicyViolationException.message.prunedRolesAssigned").arg(ObjectTypeUtil.createDisplayInformation(newAssignment.getTarget(), false)).arg(ObjectTypeUtil.createDisplayInformation(conflictingAssignment.getTarget(), false)).build();
        pruneRule.addTrigger(new EvaluatedExclusionTrigger(exclusionTrigger.getConstraint(), message, null, exclusionTrigger.getConflictingAssignment(), exclusionTrigger.getConflictingTarget(), exclusionTrigger.getConflictingPath(), true));
        enforcementOverrideGenerated = true;
    }
}
Also used : EvaluatedExclusionTrigger(com.evolveum.midpoint.model.api.context.EvaluatedExclusionTrigger) SystemException(com.evolveum.midpoint.util.exception.SystemException) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) SingleLocalizableMessage(com.evolveum.midpoint.util.SingleLocalizableMessage) LocalizableMessageBuilder(com.evolveum.midpoint.util.LocalizableMessageBuilder)

Example 4 with SingleLocalizableMessage

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

the class StartInstruction method setName.

public void setName(String name, LocalizableMessage localizable) {
    PolyStringType polyName = PolyStringType.fromOrig(name);
    if (localizable != null) {
        if (!(localizable instanceof SingleLocalizableMessage)) {
            throw new UnsupportedOperationException("Localizable messages other than SingleLocalizableMessage cannot be used for approval case names: " + localizable);
        } else {
            polyName.setTranslation(PolyStringTranslationType.fromLocalizableMessage((SingleLocalizableMessage) localizable));
        }
    }
    aCase.setName(polyName);
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) SingleLocalizableMessage(com.evolveum.midpoint.util.SingleLocalizableMessage)

Example 5 with SingleLocalizableMessage

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

the class TestPrismSerialization method testSerializeMessage.

@Test
public void testSerializeMessage() throws Exception {
    PrismContext prismContext = getPrismContext();
    SingleLocalizableMessage localizableMessage = new SingleLocalizableMessage("execute.reset.credential.bad.request", null, "Failed to execute reset password. Bad request.");
    LocalizableMessageType localizableMessageBean = LocalizationUtil.createLocalizableMessageType(localizableMessage);
    QName fakeQName = new QName(PrismConstants.NS_TYPES, "object");
    String xml = prismContext.xmlSerializer().serializeAnyData(localizableMessageBean, fakeQName);
    System.out.println(xml);
}
Also used : PrismTestUtil.getPrismContext(com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext) QName(javax.xml.namespace.QName) SingleLocalizableMessage(com.evolveum.midpoint.util.SingleLocalizableMessage) Test(org.testng.annotations.Test)

Aggregations

SingleLocalizableMessage (com.evolveum.midpoint.util.SingleLocalizableMessage)5 PrismTestUtil.getPrismContext (com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext)2 QName (javax.xml.namespace.QName)2 Test (org.testng.annotations.Test)2 EvaluatedExclusionTrigger (com.evolveum.midpoint.model.api.context.EvaluatedExclusionTrigger)1 LocalizableMessage (com.evolveum.midpoint.util.LocalizableMessage)1 LocalizableMessageBuilder (com.evolveum.midpoint.util.LocalizableMessageBuilder)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 ExecuteCredentialResetResponseType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ExecuteCredentialResetResponseType)1 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)1 FocusType (com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType)1 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)1