use of com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType in project midpoint by Evolveum.
the class LocalizationServiceImpl method translate.
private String translate(PolyStringTranslationArgumentType polyStringTranslationArgument, Locale locale) {
String value = polyStringTranslationArgument.getValue();
if (value != null) {
return value;
}
PolyStringTranslationType translation = polyStringTranslationArgument.getTranslation();
if (translation != null) {
return translate(translation, locale);
}
return null;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType in project midpoint by Evolveum.
the class ValuePolicyProcessor method testLength.
private StringLimitationResult testLength(String value, LimitationsType limitations, OperationResult result, List<LocalizableMessage> messages) {
if (limitations.getMinLength() == null && limitations.getMaxLength() == null) {
return null;
}
StringLimitationResult limitation = new StringLimitationResult();
limitation.setMinOccurs(limitations.getMinLength());
limitation.setMaxOccurs(limitations.getMaxLength());
PolyStringType name = new PolyStringType("characters");
PolyStringTranslationType translation = new PolyStringTranslationType();
translation.setKey("ValuePolicy.characters");
name.setTranslation(translation);
limitation.setName(name);
limitation.setSuccess(true);
if (limitations.getMinLength() != null && value.length() < limitations.getMinLength()) {
LocalizableMessage msg = new LocalizableMessageBuilder().key("ValuePolicy.minimalSizeNotMet").arg(limitations.getMinLength()).arg(value.length()).build();
result.addSubresult(new OperationResult("Check global minimal length", OperationResultStatus.FATAL_ERROR, msg));
messages.add(msg);
limitation.setSuccess(false);
}
if (limitations.getMaxLength() != null && value.length() > limitations.getMaxLength()) {
LocalizableMessage msg = new LocalizableMessageBuilder().key("ValuePolicy.maximalSizeExceeded").arg(limitations.getMaxLength()).arg(value.length()).build();
result.addSubresult(new OperationResult("Check global maximal length", OperationResultStatus.FATAL_ERROR, msg));
messages.add(msg);
limitation.setSuccess(false);
}
return limitation;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType in project midpoint by Evolveum.
the class ValuePolicyProcessor method testMinimalUniqueCharacters.
private StringLimitationResult testMinimalUniqueCharacters(String password, LimitationsType limitations, OperationResult result, List<LocalizableMessage> message) {
if (limitations.getMinUniqueChars() == null) {
return null;
}
HashSet<String> distinctCharacters = new HashSet<>(StringPolicyUtils.stringTokenizer(password));
StringLimitationResult limitation = new StringLimitationResult();
limitation.setMinOccurs(limitations.getMinUniqueChars());
PolyStringType name = new PolyStringType("unique characters");
PolyStringTranslationType translation = new PolyStringTranslationType();
translation.setKey("ValuePolicy.uniqueCharacters");
name.setTranslation(translation);
limitation.setName(name);
limitation.setSuccess(true);
if (limitations.getMinUniqueChars() > distinctCharacters.size()) {
LocalizableMessage msg = new LocalizableMessageBuilder().key("ValuePolicy.minimalUniqueCharactersNotMet").arg(limitations.getMinUniqueChars()).arg(distinctCharacters.size()).build();
result.addSubresult(new OperationResult("Check minimal count of unique chars", OperationResultStatus.FATAL_ERROR, msg));
message.add(msg);
limitation.setSuccess(false);
}
return limitation;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType in project midpoint by Evolveum.
the class ValuePolicyProcessor method testCheckExpression.
private List<StringLimitationResult> testCheckExpression(String newPassword, LimitationsType lims, ExpressionProfile expressionProfile, ObjectBasedValuePolicyOriginResolver<?> originResolver, String shortDesc, Task task, OperationResult result, List<LocalizableMessage> messages) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
List<StringLimitationResult> limitations = new ArrayList<>();
for (CheckExpressionType checkExpression : lims.getCheckExpression()) {
ExpressionType expressionType = checkExpression.getExpression();
if (expressionType == null) {
continue;
}
StringLimitationResult limitation = new StringLimitationResult();
PolyStringType name = null;
if (checkExpression.getDisplay() != null) {
name = checkExpression.getDisplay().getLabel();
limitation.setHelp(checkExpression.getDisplay().getHelp());
}
if (name == null) {
name = new PolyStringType("Check expression");
PolyStringTranslationType translation = new PolyStringTranslationType();
translation.setKey("ValuePolicy.checkExpression");
name.setTranslation(translation);
}
limitation.setName(name);
limitation.setSuccess(true);
if (!checkExpression(newPassword, expressionType, expressionProfile, originResolver, shortDesc, task, result)) {
LocalizableMessage msg;
if (checkExpression.getLocalizableFailureMessage() != null) {
msg = LocalizationUtil.toLocalizableMessage(checkExpression.getLocalizableFailureMessage());
} else if (checkExpression.getFailureMessage() != null) {
msg = LocalizableMessageBuilder.buildFallbackMessage(checkExpression.getFailureMessage());
} else {
msg = LocalizableMessageBuilder.buildKey("ValuePolicy.checkExpressionFailed");
}
result.addSubresult(new OperationResult("Check expression", OperationResultStatus.FATAL_ERROR, msg));
messages.add(msg);
limitation.setSuccess(false);
}
limitations.add(limitation);
}
return limitations;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType in project midpoint by Evolveum.
the class DefaultColumnUtils method createColumns.
private static <C extends Containerable> void createColumns(GuiObjectListViewType view, Class<? extends C> type) {
view.createColumnList();
List<GuiObjectColumnType> columns = view.getColumn();
List<ColumnWrapper> defaultColumns = getColumnsForType(type);
String previousColumn = null;
for (ColumnWrapper defaultColumn : defaultColumns) {
String localPathPath = defaultColumn.getPath().lastName().getLocalPart();
String columnName = localPathPath + "Column";
GuiObjectColumnType column = new GuiObjectColumnType();
column.setName(columnName);
column.setPreviousColumn(previousColumn);
ItemPathType itemPathType = new ItemPathType();
itemPathType.setItemPath(defaultColumn.getPath());
column.setPath(itemPathType);
column.setDisplayValue(defaultColumn.getDisplayValue());
if (defaultColumn.isSortable()) {
column.setSortProperty(localPathPath);
}
if (!StringUtils.isEmpty(defaultColumn.getLabel())) {
DisplayType display = new DisplayType();
PolyStringType label = new PolyStringType(defaultColumn.getLabel());
label.setTranslation(new PolyStringTranslationType().key(defaultColumn.getLabel()));
display.setLabel(label);
column.setDisplay(display);
}
columns.add(column);
previousColumn = columnName;
}
}
Aggregations