Search in sources :

Example 31 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method testPasswordString.

@Test
public void testPasswordString() throws Exception {
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = evaluator.evaluateMappingDynamicReplace("mapping-script-system-variables-password.xml", "testPasswordString", // target
    "employeeType", // changed property
    new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), // changed values
    evaluator.createProtectedString("weighAnch0r"));
    // THEN
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTriplePlus(outputTriple, "weighAnch0r");
    PrismAsserts.assertTripleMinus(outputTriple, "d3adM3nT3llN0Tal3s");
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 32 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class ResourceValidatorImpl method checkSchemaHandlingDefaults.

private void checkSchemaHandlingDefaults(ResourceValidationContext ctx, SchemaHandlingType schemaHandling) {
    int defAccount = 0, defEntitlement = 0, defGeneric = 0;
    int totalAccount = 0;
    for (ResourceObjectTypeDefinitionType def : schemaHandling.getObjectType()) {
        if (Boolean.TRUE.equals(def.isDefault())) {
            switch(fillDefault(def.getKind())) {
                case ACCOUNT:
                    defAccount++;
                    break;
                case ENTITLEMENT:
                    defEntitlement++;
                    break;
                case GENERIC:
                    defGeneric++;
                    break;
                default:
                    throw new IllegalStateException();
            }
        }
        if (fillDefault(def.getKind()) == ShadowKindType.ACCOUNT) {
            totalAccount++;
        }
    }
    checkMultipleDefaultDefinitions(ctx, ShadowKindType.ACCOUNT, defAccount);
    checkMultipleDefaultDefinitions(ctx, ShadowKindType.ENTITLEMENT, defEntitlement);
    checkMultipleDefaultDefinitions(ctx, ShadowKindType.GENERIC, defGeneric);
    if (totalAccount > 0 && defAccount == 0) {
        ctx.validationResult.add(Issue.Severity.INFO, CAT_SCHEMA_HANDLING, C_NO_DEFAULT_ACCOUNT_SCHEMA_HANDLING_DEFAULT_DEFINITION, getString(ctx.bundle, CLASS_DOT + C_NO_DEFAULT_ACCOUNT_SCHEMA_HANDLING_DEFAULT_DEFINITION), ctx.resourceRef, new ItemPath(ResourceType.F_SCHEMA_HANDLING, SchemaHandlingType.F_OBJECT_TYPE));
    }
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 33 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class Visualizer method createSceneItemCommon.

private SceneItemImpl createSceneItemCommon(Item<?, ?> item) {
    SceneItemImpl si = new SceneItemImpl(createSceneItemName(item));
    ItemDefinition<?> def = item.getDefinition();
    if (def != null) {
        si.setOperational(def.isOperational());
    }
    si.setSourceItem(item);
    si.setSourceRelPath(new ItemPath(item.getElementName()));
    return si;
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 34 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TriggerScannerTaskHandler method removeTrigger.

private void removeTrigger(PrismObject<ObjectType> object, PrismContainerValue<TriggerType> triggerCVal, Task task, PrismContainerDefinition<TriggerType> triggerContainerDef) {
    ContainerDelta<TriggerType> triggerDelta = triggerContainerDef.createEmptyDelta(new ItemPath(F_TRIGGER));
    triggerDelta.addValuesToDelete(triggerCVal.clone());
    Collection<? extends ItemDelta> modifications = MiscSchemaUtil.createCollection(triggerDelta);
    // This is detached result. It will not take part of the task result. We do not really care.
    OperationResult result = new OperationResult(TriggerScannerTaskHandler.class.getName() + ".removeTrigger");
    try {
        repositoryService.modifyObject(object.getCompileTimeClass(), object.getOid(), modifications, result);
        result.computeStatus();
        task.recordObjectActionExecuted(object, ChangeType.MODIFY, null);
    } catch (ObjectNotFoundException e) {
        // Object is gone. Ergo there are no triggers left. Ergo the trigger was removed.
        // Ergo this is not really an error.
        task.recordObjectActionExecuted(object, ChangeType.MODIFY, e);
        LOGGER.trace("Unable to remove trigger from {}: {} (but this is probably OK)", object, e.getMessage(), e);
    } catch (SchemaException | ObjectAlreadyExistsException e) {
        task.recordObjectActionExecuted(object, ChangeType.MODIFY, e);
        LOGGER.error("Unable to remove trigger from {}: {}", object, e.getMessage(), e);
    } catch (Throwable t) {
        task.recordObjectActionExecuted(object, ChangeType.MODIFY, t);
        throw t;
    } finally {
        // maybe OK (absolute correctness is not quite important here)
        task.markObjectActionExecutedBoundary();
    }
}
Also used : TriggerType(com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 35 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method updateShadowActivation.

private void updateShadowActivation(AjaxRequestTarget target, List<FocusSubwrapperDto<ShadowType>> accounts, boolean enabled) {
    if (!isAnyProjectionSelected(target, projectionModel)) {
        return;
    }
    for (FocusSubwrapperDto<ShadowType> account : accounts) {
        if (!account.isLoadedOK()) {
            continue;
        }
        ObjectWrapper<ShadowType> wrapper = account.getObject();
        ContainerWrapper<ActivationType> activation = wrapper.findContainerWrapper(new ItemPath(ShadowType.F_ACTIVATION));
        if (activation == null) {
            warn(getString("pageAdminFocus.message.noActivationFound", wrapper.getDisplayName()));
            continue;
        }
        PropertyWrapper enabledProperty = (PropertyWrapper) activation.findPropertyWrapper(ActivationType.F_ADMINISTRATIVE_STATUS);
        if (enabledProperty == null || enabledProperty.getValues().size() != 1) {
            warn(getString("pageAdminFocus.message.noEnabledPropertyFound", wrapper.getDisplayName()));
            continue;
        }
        ValueWrapper value = (ValueWrapper) enabledProperty.getValues().get(0);
        ActivationStatusType status = enabled ? ActivationStatusType.ENABLED : ActivationStatusType.DISABLED;
        ((PrismPropertyValue) value.getValue()).setValue(status);
        wrapper.setSelected(false);
    }
    target.add(getFeedbackPanel(), get(createComponentPath(ID_SHADOWS)));
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Aggregations

ItemPath (com.evolveum.midpoint.prism.path.ItemPath)693 Test (org.testng.annotations.Test)184 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)143 QName (javax.xml.namespace.QName)137 Task (com.evolveum.midpoint.task.api.Task)104 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)84 ArrayList (java.util.ArrayList)79 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)71 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)68 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)61 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)48 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)46 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)41 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)41 PrismObject (com.evolveum.midpoint.prism.PrismObject)38 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)38 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)38 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)33 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)31 NotNull (org.jetbrains.annotations.NotNull)30