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;
}
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
}
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);
}
}
}
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));
}
}
}
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());
}
Aggregations