Search in sources :

Example 16 with PolyStringTranslationType

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;
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyStringTranslationType(com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType)

Example 17 with PolyStringTranslationType

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;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) StringLimitationResult(com.evolveum.midpoint.model.api.validator.StringLimitationResult) LocalizableMessage(com.evolveum.midpoint.util.LocalizableMessage) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) LocalizableMessageBuilder(com.evolveum.midpoint.util.LocalizableMessageBuilder) PolyStringTranslationType(com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType)

Example 18 with PolyStringTranslationType

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;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) StringLimitationResult(com.evolveum.midpoint.model.api.validator.StringLimitationResult) LocalizableMessage(com.evolveum.midpoint.util.LocalizableMessage) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) LocalizableMessageBuilder(com.evolveum.midpoint.util.LocalizableMessageBuilder) PolyStringTranslationType(com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType)

Example 19 with PolyStringTranslationType

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;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) CheckExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CheckExpressionType) StringLimitationResult(com.evolveum.midpoint.model.api.validator.StringLimitationResult) LocalizableMessage(com.evolveum.midpoint.util.LocalizableMessage) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CheckExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CheckExpressionType) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) PolyStringTranslationType(com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType)

Example 20 with PolyStringTranslationType

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;
    }
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) PolyStringTranslationType(com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType)

Aggregations

PolyStringTranslationType (com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType)19 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)16 StringLimitationResult (com.evolveum.midpoint.model.api.validator.StringLimitationResult)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 LocalizableMessage (com.evolveum.midpoint.util.LocalizableMessage)5 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 LocalizableMessageBuilder (com.evolveum.midpoint.util.LocalizableMessageBuilder)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 ExpressionProfile (com.evolveum.midpoint.schema.expression.ExpressionProfile)2 LocalizableMessageListBuilder (com.evolveum.midpoint.util.LocalizableMessageListBuilder)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 LimitationsType (com.evolveum.midpoint.xml.ns._public.common.common_3.LimitationsType)2 StringLimitType (com.evolveum.midpoint.xml.ns._public.common.common_3.StringLimitType)2 NotNull (org.jetbrains.annotations.NotNull)2 AutoCompleteTextPanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)1 StandardLoggerType (com.evolveum.midpoint.gui.impl.page.admin.configuration.component.StandardLoggerType)1 MutablePrismPropertyDefinition (com.evolveum.midpoint.prism.MutablePrismPropertyDefinition)1 PrimitiveType (com.evolveum.midpoint.prism.PrimitiveType)1 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 PrismObjectDefinition (com.evolveum.midpoint.prism.PrismObjectDefinition)1