Search in sources :

Example 16 with PrismObjectDefinition

use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.

the class TestDummyNoActivation method test158DeleteValidToValidFrom.

@Override
public void test158DeleteValidToValidFrom() throws Exception {
    final String TEST_NAME = "test158DeleteValidToValidFrom";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = ObjectDelta.createModificationDeleteProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, prismContext, XmlTypeConverter.createXMLGregorianCalendar(VALID_TO_MILLIS));
    PrismObjectDefinition def = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class);
    PropertyDelta validFromDelta = PropertyDelta.createModificationDeleteProperty(SchemaConstants.PATH_ACTIVATION_VALID_FROM, def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_VALID_FROM), XmlTypeConverter.createXMLGregorianCalendar(VALID_FROM_MILLIS));
    delta.addModification(validFromDelta);
    delta.checkConsistence();
    try {
        // WHEN
        provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
        AssertJUnit.fail("Unexpected success");
    } catch (SchemaException e) {
    // This is expected
    }
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertFailure(result);
    delta.checkConsistence();
    // check if activation was changed
    DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_WILL_USERNAME);
    assertTrue("Dummy account " + ACCOUNT_WILL_USERNAME + " is disabled, expected enabled", dummyAccount.isEnabled());
    assertNull("Unexpected account validFrom in account " + ACCOUNT_WILL_USERNAME + ": " + dummyAccount.getValidFrom(), dummyAccount.getValidFrom());
    assertNull("Unexpected account validTo in account " + ACCOUNT_WILL_USERNAME + ": " + dummyAccount.getValidTo(), dummyAccount.getValidTo());
    syncServiceMock.assertNotifyFailureOnly();
    assertSteadyResource();
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount)

Example 17 with PrismObjectDefinition

use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.

the class AbstractOrgClosureTest method removeObjectParent.

protected void removeObjectParent(ObjectType object, ObjectReferenceType parentOrgRef, boolean useReplace, OperationResult opResult) throws Exception {
    List<ItemDelta> modifications = new ArrayList<>();
    if (!useReplace) {
        // standard case
        PrismReferenceValue existingValue = parentOrgRef.asReferenceValue();
        ItemDelta removeParent = ReferenceDelta.createModificationDelete(object.getClass(), OrgType.F_PARENT_ORG_REF, prismContext, existingValue.clone());
        modifications.add(removeParent);
    } else {
        // using REPLACE modification
        List<PrismReferenceValue> newValues = new ArrayList<>();
        for (ObjectReferenceType ort : object.getParentOrgRef()) {
            if (!ort.getOid().equals(parentOrgRef.getOid())) {
                newValues.add(ort.asReferenceValue().clone());
            }
        }
        PrismObjectDefinition objectDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(object.getClass());
        ItemDelta replaceParent = ReferenceDelta.createModificationReplace(new ItemPath(OrgType.F_PARENT_ORG_REF), objectDefinition, newValues);
        modifications.add(replaceParent);
    }
    repositoryService.modifyObject(object.getClass(), object.getOid(), modifications, opResult);
    if (object instanceof OrgType) {
        orgGraph.removeEdge(object.getOid(), parentOrgRef.getOid());
    }
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ArrayList(java.util.ArrayList) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 18 with PrismObjectDefinition

use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.

the class ModifyUser method test100ModifyUserApproverMetadata.

@Test
public void test100ModifyUserApproverMetadata() throws Exception {
    PrismObjectDefinition userDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
    ReferenceDelta delta1 = ReferenceDelta.createModificationAdd(new ItemPath(UserType.F_METADATA, MetadataType.F_CREATE_APPROVER_REF), userDefinition, new PrismReferenceValue("target-oid-1", UserType.COMPLEX_TYPE));
    ReferenceDelta delta2 = ReferenceDelta.createModificationAdd(new ItemPath(UserType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF), userDefinition, // the same as in delta1
    new PrismReferenceValue("target-oid-1", UserType.COMPLEX_TYPE));
    repositoryService.modifyObject(UserType.class, userOid, Arrays.asList(delta1, delta2), new OperationResult("asdf"));
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 19 with PrismObjectDefinition

use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.

the class ModifyUser method test050ModifyBigUser.

@Test
public void test050ModifyBigUser() throws Exception {
    PrismObjectDefinition def = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
    PropertyDelta delta = PropertyDelta.createModificationReplaceProperty(ObjectType.F_DESCRIPTION, def, "new description");
    repositoryService.modifyObject(UserType.class, userBigOid, Arrays.asList(delta), new OperationResult("asdf"));
}
Also used : PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 20 with PrismObjectDefinition

use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.

the class SchemaDocMojo method renderSchema.

private void renderSchema(PrismSchema schema, PrismContext prismContext, VelocityEngine velocityEngine, PathGenerator pathGenerator) throws IOException {
    getLog().info("Processing schema: " + schema);
    VelocityContext velocityContext = new VelocityContext();
    populateVelocityContextBase(velocityContext, prismContext, pathGenerator, schema, "..");
    Template template = velocityEngine.getTemplate(TEMPLATE_SCHEMA_NAME);
    Writer writer = new FileWriter(pathGenerator.prepareSchemaOutputFile(schema));
    template.merge(velocityContext, writer);
    writer.close();
    // Object Definitions
    for (PrismObjectDefinition objectDefinition : schema.getObjectDefinitions()) {
        renderObjectDefinition(objectDefinition, schema, prismContext, velocityEngine, pathGenerator);
    }
    // Types
    for (ComplexTypeDefinition typeDefinition : schema.getComplexTypeDefinitions()) {
        renderComplexTypeDefinition(typeDefinition, schema, prismContext, velocityEngine, pathGenerator);
    }
}
Also used : VelocityContext(org.apache.velocity.VelocityContext) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ComplexTypeDefinition(com.evolveum.midpoint.prism.ComplexTypeDefinition) Template(org.apache.velocity.Template)

Aggregations

PrismObjectDefinition (com.evolveum.midpoint.prism.PrismObjectDefinition)21 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 ArrayList (java.util.ArrayList)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)4 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)4 QName (javax.xml.namespace.QName)4 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 Task (com.evolveum.midpoint.task.api.Task)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 Collection (java.util.Collection)3 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)2 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)2 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)2 PrismReference (com.evolveum.midpoint.prism.PrismReference)2 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2