use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.
the class ConsistencyTest method test001TestConnectionOpenDJ.
/**
* Test the testResource method. Expect a complete success for now.
*/
@Test
public void test001TestConnectionOpenDJ() throws Exception {
final String TEST_NAME = "test001TestConnectionOpenDJ";
TestUtil.displayTestTile(TEST_NAME);
Task task = taskManager.createTaskInstance();
// GIVEN
assertNoRepoCache();
// WHEN
OperationResultType result = modelWeb.testResource(RESOURCE_OPENDJ_OID);
// THEN
assertNoRepoCache();
displayJaxb("testResource result:", result, SchemaConstants.C_RESULT);
TestUtil.assertSuccess("testResource has failed", result);
OperationResult opResult = new OperationResult(ConsistencyTest.class.getName() + "." + TEST_NAME);
PrismObject<ResourceType> resourceOpenDjRepo = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, opResult);
resourceTypeOpenDjrepo = resourceOpenDjRepo.asObjectable();
assertNoRepoCache();
assertEquals(RESOURCE_OPENDJ_OID, resourceTypeOpenDjrepo.getOid());
display("Initialized OpenDJ resource (respository)", resourceTypeOpenDjrepo);
assertNotNull("Resource schema was not generated", resourceTypeOpenDjrepo.getSchema());
Element resourceOpenDjXsdSchemaElement = ResourceTypeUtil.getResourceXsdSchema(resourceTypeOpenDjrepo);
assertNotNull("Resource schema was not generated", resourceOpenDjXsdSchemaElement);
PrismObject<ResourceType> openDjResourceProvisioninig = provisioningService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, opResult);
display("Initialized OpenDJ resource resource (provisioning)", openDjResourceProvisioninig);
PrismObject<ResourceType> openDjResourceModel = provisioningService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, opResult);
display("Initialized OpenDJ resource OpenDJ resource (model)", openDjResourceModel);
checkOpenDjResource(resourceTypeOpenDjrepo, "repository");
System.out.println("------------------------------------------------------------------");
display("OpenDJ resource schema (repo XML)", DOMUtil.serializeDOMToString(ResourceTypeUtil.getResourceXsdSchema(resourceOpenDjRepo)));
System.out.println("------------------------------------------------------------------");
checkOpenDjResource(openDjResourceProvisioninig.asObjectable(), "provisioning");
checkOpenDjResource(openDjResourceModel.asObjectable(), "model");
// TODO: model web
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.
the class AuditController method getObjectFromLastEvent.
/**
* Side effect: removes the last event.
*
* The reason is that we don't want to use it when rolling back the time later in
* {@link #rollBackTime(PrismObject, List)}. It is the reference event that we want to
* know the object state on.
*/
private <O extends ObjectType> PrismObject<O> getObjectFromLastEvent(PrismObject<O> object, List<AuditEventRecordType> changeTrail, String eventIdentifier) {
if (changeTrail.isEmpty()) {
return object;
}
AuditEventRecordType lastEvent = changeTrail.remove(changeTrail.size() - 1);
if (!eventIdentifier.equals(lastEvent.getEventIdentifier())) {
throw new IllegalStateException("Wrong last event identifier, expected " + eventIdentifier + " but was " + lastEvent.getEventIdentifier());
}
List<ObjectDeltaOperationType> lastEventDeltasOperations = lastEvent.getDelta();
for (ObjectDeltaOperationType lastEventDeltasOperation : lastEventDeltasOperations) {
if (!isApplicable(lastEventDeltasOperation, object, lastEvent)) {
continue;
}
ObjectDeltaType objectDelta = lastEventDeltasOperation.getObjectDelta();
if (objectDelta.getChangeType() == ChangeTypeType.ADD) {
// We are lucky. This is object add, so we have complete object there.
// No need to roll back the operations.
// noinspection unchecked
PrismObject<O> objectToAdd = objectDelta.getObjectToAdd().asPrismObject();
LOGGER.trace("Taking object from add delta in last event {}:\n{}", lastEvent.getEventIdentifier(), objectToAdd.debugDumpLazily(1));
return objectToAdd;
}
}
return null;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.
the class ClusterwideUserSessionManagerImpl method getLoggedInPrincipals.
@Override
@NotNull
public List<UserSessionManagementType> getLoggedInPrincipals(Task task, OperationResult result) {
List<UserSessionManagementType> loggedUsers = guiProfiledPrincipalManager.getLocalLoggedInPrincipals();
Map<String, UserSessionManagementType> usersMap = new HashMap<>();
// fix for mid-6328
loggedUsers.forEach(loggedUser -> {
UserSessionManagementType addedUser = usersMap.get(loggedUser.getFocus().getOid());
if (addedUser != null) {
addedUser.setActiveSessions(addedUser.getActiveSessions() + loggedUser.getActiveSessions());
addedUser.getNode().addAll(loggedUser.getNode());
} else {
usersMap.put(loggedUser.getFocus().getOid(), loggedUser);
}
});
// We try to invoke this call also on nodes that are in transition. We want to get
// information as complete as realistically possible.
clusterExecutionHelper.execute((client, node, result1) -> {
client.path(ClusterServiceConsts.EVENT_LIST_USER_SESSION);
Response response = client.get();
LOGGER.debug("Remote-node retrieval of user sessions finished on {} with status {}, {}", node.getNodeIdentifier(), response.getStatusInfo().getStatusCode(), response.getStatusInfo().getReasonPhrase());
if (response.hasEntity()) {
UserSessionManagementListType remoteSessionsWrapper = response.readEntity(UserSessionManagementListType.class);
List<UserSessionManagementType> remoteSessions = remoteSessionsWrapper.getSession();
for (UserSessionManagementType remoteSession : MiscUtil.emptyIfNull(remoteSessions)) {
UserSessionManagementType existingUser = usersMap.get(remoteSession.getFocus().getOid());
if (existingUser != null) {
existingUser.setActiveSessions(existingUser.getActiveSessions() + remoteSession.getActiveSessions());
existingUser.getNode().addAll(remoteSession.getNode());
} else {
usersMap.put(remoteSession.getFocus().getOid(), remoteSession);
}
}
}
response.close();
}, new ClusterExecutionOptions().tryNodesInTransition(), " list principals from remote nodes ", result);
return new ArrayList<>(usersMap.values());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.
the class TestNoOpTask method test100BucketAnalysisUsingCondition.
@Test
public void test100BucketAnalysisUsingCondition() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
when();
addTask(TASK_BUCKET_ANALYSIS_WITH_CONDITION, result);
waitForTaskCloseOrSuspend(TASK_BUCKET_ANALYSIS_WITH_CONDITION.oid, 10000);
then();
// @formatter:off
TaskType taskAfter = assertTask(TASK_BUCKET_ANALYSIS_WITH_CONDITION.oid, "after").display().assertSuccess().assertClosed().rootActivityState().bucketManagementStatistics().display().assertComplete(// These are all the buckets. We must complete also those that are skipped.
20).end().end().getObjectable();
// @formatter:on
String reportOid = getBucketReportDataOid(taskAfter, ActivityPath.empty());
try (var reader = SimpleReportReader.createForLocalReportData(reportOid, List.of("sequentialNumber", "content-from", "content-to"), commonTaskBeans, result)) {
List<List<String>> rows = reader.getRows();
displayValue("rows of bucket analysis report", rows);
assertThat(rows).as("rows").hasSize(5);
assertThat(rows.get(0)).as("row 0").containsExactly("4", "1500", "2000");
assertThat(rows.get(1)).as("row 1").containsExactly("8", "3500", "4000");
assertThat(rows.get(2)).as("row 2").containsExactly("12", "5500", "6000");
assertThat(rows.get(3)).as("row 3").containsExactly("16", "7500", "8000");
assertThat(rows.get(4)).as("row 4").containsExactly("20", "9500", "10000");
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.
the class TestNoOpTask method test110BucketAnalysisUsingRegularSampling.
@Test
public void test110BucketAnalysisUsingRegularSampling() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
when();
addTask(TASK_BUCKET_ANALYSIS_WITH_REGULAR_SAMPLING, result);
waitForTaskCloseOrSuspend(TASK_BUCKET_ANALYSIS_WITH_REGULAR_SAMPLING.oid, 10000);
then();
// @formatter:off
TaskType taskAfter = assertTask(TASK_BUCKET_ANALYSIS_WITH_REGULAR_SAMPLING.oid, "after").display().assertSuccess().assertClosed().rootActivityState().bucketManagementStatistics().display().assertComplete(// Great! Skipped buckets do not undergo get->complete process.
10).end().end().getObjectable();
// @formatter:on
String reportOid = getBucketReportDataOid(taskAfter, ActivityPath.empty());
try (var reader = SimpleReportReader.createForLocalReportData(reportOid, List.of("sequentialNumber", "content-from", "content-to"), commonTaskBeans, result)) {
List<List<String>> rows = reader.getRows();
displayValue("rows of bucket analysis report", rows);
assertThat(rows).as("rows").hasSize(10);
assertThat(rows.get(0)).as("row 0").containsExactly("20", "950", "1000");
assertThat(rows.get(1)).as("row 1").containsExactly("40", "1950", "2000");
assertThat(rows.get(2)).as("row 2").containsExactly("60", "2950", "3000");
assertThat(rows.get(3)).as("row 3").containsExactly("80", "3950", "4000");
assertThat(rows.get(9)).as("row 9").containsExactly("200", "9950", "10000");
}
}
Aggregations