use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class AbstractLdapHierarchyTest method test310RenameUserGorc.
@Test
public void test310RenameUserGorc() throws Exception {
final String TEST_NAME = "test310RenameUserGorc";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(AbstractLdapHierarchyTest.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<UserType> userBefore = createUser(USER_GORC_USERNAME, USER_GORC_GIVEN_NAME, USER_GORC_FAMILY_NAME, orgCortuvHradOid);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyObjectReplaceProperty(UserType.class, userGorcOid, UserType.F_NAME, task, result, new PolyString(USER_GORC_USERNAME2));
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
dumpOrgTree();
dumpLdap();
PrismObject<UserType> userAfter = getAndAssertUser(USER_GORC_USERNAME2, ORG_CORTUV_HRAD_NAME2, ORG_ROYULA_CARPATHIA_NAME);
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class AbstractLdapHierarchyTest method test300RenameOrgCortuvHrad.
@Test
public void test300RenameOrgCortuvHrad() throws Exception {
final String TEST_NAME = "test300RenameOrgCortuvHrad";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(AbstractLdapHierarchyTest.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<OrgType> orgBefore = createOrg(ORG_CORTUV_HRAD_NAME, orgRolyulaCarpathiaOid);
// WHEN
TestUtil.displayWhen(TEST_NAME);
display("Adding org", orgBefore);
modifyObjectReplaceProperty(OrgType.class, orgCortuvHradOid, OrgType.F_NAME, task, result, new PolyString(ORG_CORTUV_HRAD_NAME2));
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
dumpOrgTree();
dumpLdap();
PrismObject<OrgType> orgAfter = getAndAssertFunctionalOrg(ORG_CORTUV_HRAD_NAME2, orgRolyulaCarpathiaOid);
assertEquals("Cortuv hrad org OID changed after rename", orgCortuvHradOid, orgAfter.getOid());
getAndAssertUser(USER_DEZI_USERNAME, ORG_VYSNE_VLKODLAKY_NAME, ORG_CORTUV_HRAD_NAME2, ORG_ROYULA_CARPATHIA_NAME);
assertSubOrgs(orgAfter, 1);
assertSubOrgs(orgRolyulaCarpathiaOid, 1);
assertSubOrgs(ORG_TOP_OID, 1);
assertSubOrgs(orgVysneVlkodlakyOid, 0);
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestActivation method test600AddUser1.
// attempt to simulate MID-3348 (unsuccessful for now)
@Test
public void test600AddUser1() throws Exception {
final String TEST_NAME = "test600AddUser1";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<UserType> user1 = prismContext.createObject(UserType.class);
DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_NAME).replace(new PolyString("user1")).item(UserType.F_ASSIGNMENT).add(ObjectTypeUtil.createAssignmentTo(resourceDummyCoral).asPrismContainerValue()).item(ACTIVATION_ADMINISTRATIVE_STATUS_PATH).replace(ActivationStatusType.DISABLED).asObjectDelta(null).applyTo((PrismObject) user1);
ObjectDelta<UserType> addDelta = user1.createAddDelta();
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(addDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
user1 = getUser(user1.getOid());
display("User after change execution", user1);
DummyAccount dummyAccount = dummyResourceCoral.getAccountByUsername("user1");
display("Dummy account", dummyAccount);
checkSuspendedAttribute(dummyAccount, Boolean.TRUE);
String accountOid = getSingleLinkOid(user1);
PrismObject<ShadowType> shadow = getShadowModel(accountOid);
display("Shadow: ", shadow);
// TODO check real state of the account and shadow
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class RObjectTextInfo method createItemsSet.
public static <T extends ObjectType> Set<RObjectTextInfo> createItemsSet(@NotNull ObjectType object, @NotNull RObject repo, @NotNull RepositoryContext repositoryContext) {
FullTextSearchConfigurationType config = repositoryContext.repositoryService.getFullTextSearchConfiguration();
if (!FullTextSearchConfigurationUtil.isEnabled(config)) {
return Collections.emptySet();
}
Set<ItemPath> paths = FullTextSearchConfigurationUtil.getFullTextSearchItemPaths(config, object.getClass());
List<PrismValue> values = new ArrayList<>();
for (ItemPath path : paths) {
Object o = object.asPrismObject().find(path);
if (o == null) {
// shouldn't occur
} else if (o instanceof PrismValue) {
values.add((PrismValue) o);
} else if (o instanceof Item) {
values.addAll(((Item<?, ?>) o).getValues());
} else {
throw new IllegalStateException("Unexpected value " + o + " in " + object + " at " + path);
}
}
// not a (hash) set in order to preserve order
List<String> allWords = new ArrayList<>();
for (PrismValue value : values) {
if (value == null) {
continue;
}
if (value instanceof PrismPropertyValue) {
Object realValue = value.getRealValue();
if (realValue == null) {
// skip
} else if (realValue instanceof String) {
append(allWords, (String) realValue, repositoryContext.prismContext);
} else if (realValue instanceof PolyString) {
append(allWords, (PolyString) realValue, repositoryContext.prismContext);
} else {
append(allWords, realValue.toString(), repositoryContext.prismContext);
}
}
}
LOGGER.trace("Indexing {}:\n items: {}\n values: {}\n words: {}", object, paths, values, allWords);
return createItemsSet(repo, allWords);
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class SqlRepositoryServiceImpl method modifyObject.
@Override
public <T extends ObjectType> void modifyObject(Class<T> type, String oid, Collection<? extends ItemDelta> modifications, RepoModifyOptions options, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
Validate.notNull(modifications, "Modifications must not be null.");
Validate.notNull(type, "Object class in delta must not be null.");
Validate.notEmpty(oid, "Oid must not null or empty.");
Validate.notNull(result, "Operation result must not be null.");
OperationResult subResult = result.createSubresult(MODIFY_OBJECT);
subResult.addParam("type", type.getName());
subResult.addParam("oid", oid);
subResult.addCollectionOfSerializablesAsParam("modifications", modifications);
if (modifications.isEmpty() && !RepoModifyOptions.isExecuteIfNoChanges(options)) {
LOGGER.debug("Modification list is empty, nothing was modified.");
subResult.recordStatus(OperationResultStatus.SUCCESS, "Modification list is empty, nothing was modified.");
return;
}
if (InternalsConfig.encryptionChecks) {
CryptoUtil.checkEncrypted(modifications);
}
if (InternalsConfig.consistencyChecks) {
ItemDelta.checkConsistence(modifications, ConsistencyCheckScope.THOROUGH);
} else {
ItemDelta.checkConsistence(modifications, ConsistencyCheckScope.MANDATORY_CHECKS_ONLY);
}
if (LOGGER.isTraceEnabled()) {
for (ItemDelta modification : modifications) {
if (modification instanceof PropertyDelta<?>) {
PropertyDelta<?> propDelta = (PropertyDelta<?>) modification;
if (propDelta.getPath().equivalent(new ItemPath(ObjectType.F_NAME))) {
Collection<PrismPropertyValue<PolyString>> values = propDelta.getValues(PolyString.class);
for (PrismPropertyValue<PolyString> pval : values) {
PolyString value = pval.getValue();
LOGGER.trace("NAME delta: {} - {}", value.getOrig(), value.getNorm());
}
}
}
}
}
final String operation = "modifying";
int attempt = 1;
SqlPerformanceMonitor pm = getPerformanceMonitor();
long opHandle = pm.registerOperationStart("modifyObject");
try {
while (true) {
try {
objectUpdater.modifyObjectAttempt(type, oid, modifications, options, subResult);
return;
} catch (RuntimeException ex) {
attempt = baseHelper.logOperationAttempt(oid, operation, attempt, ex, subResult);
pm.registerOperationNewTrial(opHandle, attempt);
}
}
} finally {
pm.registerOperationFinish(opHandle, attempt);
}
}
Aggregations