Search in sources :

Example 41 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class CleanupTest method createObjectDeltaOperation.

private ObjectDeltaOperation createObjectDeltaOperation(int i) throws Exception {
    ObjectDeltaOperation delta = new ObjectDeltaOperation();
    delta.setExecutionResult(new OperationResult("asdf"));
    UserType user = new UserType();
    prismContext.adopt(user);
    PolyStringType name = new PolyStringType();
    name.setOrig("a" + i);
    name.setNorm("a" + i);
    user.setName(name);
    delta.setObjectDelta(ObjectDelta.createAddDelta(user.asPrismObject()));
    return delta;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 42 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class TestVisualizer method test110UserWithContainers.

@Test
public void test110UserWithContainers() throws Exception {
    final String TEST_NAME = "test101UserWithContainers";
    Task task = createTask(TEST_NAME);
    PrismObject<UserType> u = prismContext.createObject(UserType.class);
    UserType ut = u.asObjectable();
    u.setOid("456");
    ut.setName(new PolyStringType("user456"));
    ut.setFullName(new PolyStringType("User User456"));
    ut.setActivation(new ActivationType(prismContext));
    ut.getActivation().setAdministrativeStatus(ActivationStatusType.ENABLED);
    ut.getActivation().setValidTo(XmlTypeConverter.createXMLGregorianCalendar(2020, 1, 1, 0, 0, 0));
    AssignmentType ass1 = new AssignmentType(prismContext);
    ass1.setActivation(new ActivationType(prismContext));
    ass1.getActivation().setAdministrativeStatus(ActivationStatusType.ENABLED);
    ass1.getActivation().setValidTo(XmlTypeConverter.createXMLGregorianCalendar(2019, 1, 1, 0, 0, 0));
    ass1.setTargetRef(createObjectRef(ROLE_SUPERUSER_OID, ROLE));
    ut.getAssignment().add(ass1);
    AssignmentType ass2 = new AssignmentType(prismContext);
    ass2.setTargetRef(createObjectRef("777", ROLE));
    ut.getAssignment().add(ass2);
    AssignmentType ass3 = new AssignmentType(prismContext);
    ass3.setConstruction(new ConstructionType(prismContext));
    ass3.getConstruction().setResourceRef(createObjectRef(RESOURCE_DUMMY_OID, RESOURCE));
    ut.getAssignment().add(ass3);
    /// WHEN
    displayWhen(TEST_NAME);
    final Scene scene = visualizer.visualize(u, task, task.getResult());
    // THEN
    displayThen(TEST_NAME);
    display("scene", scene);
// TODO some asserts
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) Scene(com.evolveum.midpoint.model.api.visualizer.Scene) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 43 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class SqlRepositoryServiceImpl method addObject.

@Override
public <T extends ObjectType> String addObject(PrismObject<T> object, RepoAddOptions options, OperationResult result) throws ObjectAlreadyExistsException, SchemaException {
    Validate.notNull(object, "Object must not be null.");
    validateName(object);
    Validate.notNull(result, "Operation result must not be null.");
    if (options == null) {
        options = new RepoAddOptions();
    }
    LOGGER.debug("Adding object type '{}', overwrite={}, allowUnencryptedValues={}", object.getCompileTimeClass().getSimpleName(), options.isOverwrite(), options.isAllowUnencryptedValues());
    if (InternalsConfig.encryptionChecks && !RepoAddOptions.isAllowUnencryptedValues(options)) {
        CryptoUtil.checkEncrypted(object);
    }
    if (InternalsConfig.consistencyChecks) {
        object.checkConsistence(ConsistencyCheckScope.THOROUGH);
    } else {
        object.checkConsistence(ConsistencyCheckScope.MANDATORY_CHECKS_ONLY);
    }
    if (LOGGER.isTraceEnabled()) {
        // Explicitly log name
        PolyStringType namePolyType = object.asObjectable().getName();
        LOGGER.trace("NAME: {} - {}", namePolyType.getOrig(), namePolyType.getNorm());
    }
    OperationResult subResult = result.createSubresult(ADD_OBJECT);
    subResult.addParam("object", object);
    subResult.addParam("options", options);
    final String operation = "adding";
    int attempt = 1;
    String oid = object.getOid();
    while (true) {
        try {
            return objectUpdater.addObjectAttempt(object, options, subResult);
        } catch (RuntimeException ex) {
            attempt = baseHelper.logOperationAttempt(oid, operation, attempt, ex, subResult);
        }
    }
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) RepoAddOptions(com.evolveum.midpoint.repo.api.RepoAddOptions)

Example 44 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class SequenceTest method concurrencyUniversal.

private void concurrencyUniversal(String name, String sequenceFileName, long duration, WorkerThread[] workerThreads, boolean alwaysOrder) throws Exception {
    Session session = getFactory().openSession();
    session.doWork(new Work() {

        @Override
        public void execute(Connection connection) throws SQLException {
            System.out.println(">>>>" + connection.getTransactionIsolation());
        }
    });
    session.close();
    final File file = new File(TEST_DIR + sequenceFileName);
    PrismObject<SequenceType> sequence = prismContext.parseObject(file);
    sequence.asObjectable().setName(new PolyStringType(name));
    OperationResult result = new OperationResult("Concurrency Test");
    String oid = repositoryService.addObject(sequence, null, result);
    LOGGER.info("*** Object added: " + oid + " ***");
    LOGGER.info("*** Starting modifier threads ***");
    for (WorkerThread t : workerThreads) {
        t.setOid(oid);
        t.start();
    }
    LOGGER.info("*** Waiting " + duration + " ms ***");
    Thread.sleep(duration);
    for (WorkerThread t : workerThreads) {
        t.stop = true;
    }
    long endTime = System.currentTimeMillis() + STOP_TIMEOUT;
    for (; ; ) {
        long remaining = endTime - System.currentTimeMillis();
        if (remaining <= 0) {
            break;
        }
        for (WorkerThread t : workerThreads) {
            t.join(remaining);
            remaining = endTime - System.currentTimeMillis();
            if (remaining <= 0) {
                break;
            }
        }
    }
    for (WorkerThread t : workerThreads) {
        LOGGER.info("Worker thread {} finished after {} iterations with result: {}", t.id, t.counter, t.threadResult != null ? t.threadResult : "OK");
    }
    for (WorkerThread t : workerThreads) {
        if (t.threadResult != null) {
            throw new AssertionError("Worker thread " + t.id + " finished with an exception: " + t.threadResult, t.threadResult);
        }
    }
    List<Long> allValues = new ArrayList<>();
    for (WorkerThread t : workerThreads) {
        allValues.addAll(t.values);
    }
    if (alwaysOrder || workerThreads.length > 1) {
        Collections.sort(allValues);
    }
    LOGGER.trace("Checking a list of {} values", allValues.size());
    for (int i = 0; i < allValues.size(); i++) {
        if (allValues.get(i) != i) {
            LOGGER.error("Incorrect value at position {}: {}", i, allValues.get(i));
            for (WorkerThread t : workerThreads) {
                LOGGER.info("Thread {}: {}", t.id, t.values);
            }
            fail("Incorrect value at position " + i + ": " + allValues.get(i));
        }
    }
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SequenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType) Work(org.hibernate.jdbc.Work) File(java.io.File) Session(org.hibernate.Session)

Example 45 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class SearchIterativeTest method createObjects.

protected void createObjects() throws com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException, com.evolveum.midpoint.util.exception.SchemaException {
    OperationResult result = new OperationResult("add objects");
    for (int i = BASE; i < BASE + COUNT; i++) {
        UserType user = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).instantiate().asObjectable();
        user.setOid("user-" + i + "-00");
        user.setName(new PolyStringType(new PolyString("user-" + i)));
        user.setCostCenter(String.valueOf(i));
        repositoryService.addObject(user.asPrismObject(), null, result);
    }
    result.recomputeStatus();
    assertTrue(result.isSuccess());
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Aggregations

PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)94 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)26 Test (org.testng.annotations.Test)23 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)20 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)14 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)12 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)12 QName (javax.xml.namespace.QName)11 Task (com.evolveum.midpoint.task.api.Task)10 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)10 File (java.io.File)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)9 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)8 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)7 ArrayList (java.util.ArrayList)7 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)5 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)4 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4