use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class SearchIterativeTest method test130AddOneForOne.
@Test
public void test130AddOneForOne() throws Exception {
OperationResult result = new OperationResult("test130AddOneForOne");
final List<PrismObject<UserType>> objects = new ArrayList<>();
ResultHandler handler = new ResultHandler() {
@Override
public boolean handle(PrismObject object, OperationResult parentResult) {
objects.add(object);
System.out.print("Got object " + object.getOid());
try {
int number = Integer.parseInt(((UserType) object.asObjectable()).getCostCenter());
if (number >= 0) {
UserType user = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).instantiate().asObjectable();
user.setOid("user-" + (2 * BASE + COUNT - number) + "-FF");
user.setName(new PolyStringType(new PolyString("user-new-" + number)));
user.setCostCenter(String.valueOf(-number));
repositoryService.addObject(user.asPrismObject(), null, parentResult);
System.out.print(" ... creating object " + user.getOid());
}
} catch (ObjectAlreadyExistsException | SchemaException e) {
throw new SystemException(e);
}
System.out.println();
return true;
}
};
repositoryService.searchObjectsIterative(UserType.class, null, handler, null, true, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
boolean[] map = assertObjects(objects, null);
for (int i = 0; i < COUNT; i++) {
if (i % 2 == 0) {
assertFalse("Object " + (BASE + i) + " does exist but it should not", map[i]);
} else {
assertTrue("Object " + (BASE + i) + " does not exist but it should", map[i]);
}
}
System.out.println("Object processed: " + objects.size());
int count = repositoryService.countObjects(UserType.class, null, result);
assertEquals("Wrong # of objects after operation", COUNT, count);
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class NodeRegistrar method verifyNodeObject.
/**
* Checks whether this Node object was not overwritten by another node (implying there is duplicate node ID in cluster).
*
* @param result
*/
void verifyNodeObject(OperationResult result) {
PrismObject<NodeType> nodeInRepo;
String oid = nodePrism.getOid();
PolyStringType myName = nodePrism.asObjectable().getName();
LOGGER.trace("Verifying node record with OID = " + oid);
// first, let us check the record of this node - whether it exists and whether the internalNodeIdentifier is OK
try {
nodeInRepo = getRepositoryService().getObject(NodeType.class, oid, null, result);
} catch (ObjectNotFoundException e) {
if (doesNodeExist(result, myName)) {
LoggingUtils.logException(LOGGER, "The record of this node cannot be read (OID {} not found), but " + "another node record with the name '{}' exists. It seems that in this cluster " + "there are two or more nodes with the same name '{}'. Stopping the scheduler " + "to minimize the damage.", e, oid, myName, myName);
registerNodeError(NodeErrorStatusType.DUPLICATE_NODE_ID_OR_NAME);
return;
} else {
LoggingUtils.logException(LOGGER, "The record of this node cannot be read (OID {} not found). It " + "seems it was deleted in the meantime. Please check the reason. Stopping the scheduler " + "to minimize the damage.", e, oid, myName, myName);
// actually we could re-register the node, but it is safer (and easier for now :) to stop the node instead
registerNodeError(NodeErrorStatusType.NODE_REGISTRATION_FAILED);
return;
}
} catch (SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Cannot check the record of this node (OID = {}) because of schema exception. Stopping the scheduler.", e, oid);
registerNodeError(NodeErrorStatusType.NODE_REGISTRATION_FAILED);
return;
}
// check the internalNodeIdentifier
String existingId = nodePrism.asObjectable().getInternalNodeIdentifier();
String idInRepo = nodeInRepo.asObjectable().getInternalNodeIdentifier();
if (!existingId.equals(idInRepo)) {
LOGGER.error("Internal node identifier has been overwritten in the repository. " + "Probably somebody has overwritten it in the meantime, i.e. another node with the name of '" + nodePrism.asObjectable().getName() + "' is running. Stopping the scheduler.");
registerNodeError(NodeErrorStatusType.DUPLICATE_NODE_ID_OR_NAME);
return;
}
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class AbstractEDirTest method test500AddOrgMeleeIsland.
// TODO: create account with a group membership
@Test
public void test500AddOrgMeleeIsland() throws Exception {
final String TEST_NAME = "test500AddOrgMeleeIsland";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<OrgType> org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate();
OrgType orgType = org.asObjectable();
orgType.setName(new PolyStringType(GROUP_MELEE_ISLAND_NAME));
AssignmentType metaroleAssignment = new AssignmentType();
ObjectReferenceType metaroleRef = new ObjectReferenceType();
metaroleRef.setOid(ROLE_META_ORG_OID);
metaroleRef.setType(RoleType.COMPLEX_TYPE);
metaroleAssignment.setTargetRef(metaroleRef);
orgType.getAssignment().add(metaroleAssignment);
// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(org, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
orgMeleeIslandOid = org.getOid();
Entry entry = assertLdapGroup(GROUP_MELEE_ISLAND_NAME);
org = getObject(OrgType.class, orgMeleeIslandOid);
groupMeleeOid = getSingleLinkOid(org);
PrismObject<ShadowType> shadow = getShadowModel(groupMeleeOid);
display("Shadow (model)", shadow);
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class AbstractAdLdapTest method test500AddOrgMeleeIsland.
@Test
public void test500AddOrgMeleeIsland() throws Exception {
final String TEST_NAME = "test500AddOrgMeleeIsland";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<OrgType> org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate();
OrgType orgType = org.asObjectable();
orgType.setName(new PolyStringType(GROUP_MELEE_ISLAND_NAME));
AssignmentType metaroleAssignment = new AssignmentType();
ObjectReferenceType metaroleRef = new ObjectReferenceType();
metaroleRef.setOid(ROLE_META_ORG_OID);
metaroleRef.setType(RoleType.COMPLEX_TYPE);
metaroleAssignment.setTargetRef(metaroleRef);
orgType.getAssignment().add(metaroleAssignment);
// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(org, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
orgMeleeIslandOid = org.getOid();
Entry entry = assertLdapGroup(GROUP_MELEE_ISLAND_NAME);
org = getObject(OrgType.class, orgMeleeIslandOid);
groupMeleeOid = getSingleLinkOid(org);
PrismObject<ShadowType> shadow = getShadowModel(groupMeleeOid);
display("Shadow (model)", shadow);
assertLdapConnectorInstances(2);
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class ModelClientUtil method createPolyStringType.
// public static SearchFilterType parseSearchFilterType(String filterClauseAsXml) throws IOException, SAXException {
// Element filterClauseAsElement = parseElement(filterClauseAsXml);
// SearchFilterType searchFilterType = new SearchFilterType();
// searchFilterType.setFilterClause(filterClauseAsElement);
// return searchFilterType;
// }
public static PolyStringType createPolyStringType(String string, Document doc) {
PolyStringType polyStringType = new PolyStringType();
polyStringType.setOrig(string);
return polyStringType;
}
Aggregations