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