Search in sources :

Example 1 with READY

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.READY in project midpoint by Evolveum.

the class TestBucketingStatic method test210GetReleaseCompleteSequenceForWorkers.

/**
 * Check a sequence of get / release / complete operations on coordinator + 5 worker tasks.
 */
@Test
public void test210GetReleaseCompleteSequenceForWorkers() throws Exception {
    OperationResult result = createOperationResult();
    // suspended
    taskAdd(TASK_210_COORDINATOR, result);
    // suspended
    taskAdd(TASK_210_WORKER_1, result);
    // suspended
    taskAdd(TASK_210_WORKER_2, result);
    // suspended
    taskAdd(TASK_210_WORKER_3, result);
    // suspended
    taskAdd(TASK_210_WORKER_4, result);
    // suspended
    taskAdd(TASK_210_WORKER_5, result);
    Task coordinator = taskManager.getTaskPlain(TASK_210_COORDINATOR.oid, result);
    String oidC = TASK_210_COORDINATOR.oid;
    String oidW1 = TASK_210_WORKER_1.oid;
    String oidW2 = TASK_210_WORKER_2.oid;
    String oidW3 = TASK_210_WORKER_3.oid;
    String oidW4 = TASK_210_WORKER_4.oid;
    String oidW5 = TASK_210_WORKER_5.oid;
    when();
    WorkBucketType bucket1 = getWorkBucket(coordinator, oidW1, result);
    WorkBucketType bucket2 = getWorkBucket(coordinator, oidW2, result);
    WorkBucketType bucket3 = getWorkBucket(coordinator, oidW3, result);
    WorkBucketType bucket4 = getWorkBucket(coordinator, oidW4, result);
    // should be the same as bucket4 (the same worker)
    WorkBucketType bucket4a = getWorkBucket(coordinator, oidW4, result);
    then();
    displayValue("1st allocated bucket", bucket1);
    displayValue("2nd allocated bucket", bucket2);
    displayValue("3rd allocated bucket", bucket3);
    displayValue("4th allocated bucket", bucket4);
    displayValue("4+th allocated bucket", bucket4a);
    coordinator.refresh(result);
    displayDumpable("coordinator task after 4+1x allocation", coordinator);
    assertNumericBucket(bucket1, null, 1, 0, 1);
    assertNumericBucket(bucket2, null, 2, 1, 2);
    assertNumericBucket(bucket3, null, 3, 2, 3);
    assertNumericBucket(bucket4, null, 4, 3, 4);
    assertNumericBucket(bucket4a, null, 4, 3, 4);
    List<WorkBucketType> buckets = new ArrayList<>(getBuckets(coordinator));
    sortBucketsBySequentialNumber(buckets);
    assertEquals(4, buckets.size());
    assertNumericBucket(buckets.get(0), WorkBucketStateType.DELEGATED, 1, 0, 1);
    assertNumericBucket(buckets.get(1), WorkBucketStateType.DELEGATED, 2, 1, 2);
    assertNumericBucket(buckets.get(2), WorkBucketStateType.DELEGATED, 3, 2, 3);
    assertNumericBucket(buckets.get(3), WorkBucketStateType.DELEGATED, 4, 3, 4);
    when("complete bucket #2");
    bucketingManager.completeWorkBucket(oidC, oidW2, ActivityPath.empty(), 2, null, null, result);
    then("complete bucket #2");
    coordinator = taskManager.getTaskPlain(coordinator.getOid(), result);
    displayDumpable("coordinator after completion of 2nd bucket", coordinator);
    buckets = new ArrayList<>(getBuckets(coordinator));
    sortBucketsBySequentialNumber(buckets);
    assertEquals(4, buckets.size());
    assertNumericBucket(buckets.get(0), WorkBucketStateType.DELEGATED, 1, 0, 1);
    assertNumericBucket(buckets.get(1), WorkBucketStateType.COMPLETE, 2, 1, 2);
    assertNumericBucket(buckets.get(2), WorkBucketStateType.DELEGATED, 3, 2, 3);
    assertNumericBucket(buckets.get(3), WorkBucketStateType.DELEGATED, 4, 3, 4);
    when("complete bucket #1");
    bucketingManager.completeWorkBucket(oidC, oidW1, ActivityPath.empty(), 1, null, null, result);
    WorkBucketType bucket = getWorkBucket(coordinator, oidW1, result);
    then("complete bucket #1");
    coordinator = taskManager.getTaskPlain(coordinator.getOid(), result);
    displayDumpable("coordinator after completion of 1st bucket and fetching next one", coordinator);
    assertNumericBucket(bucket, null, 5, 4, 5);
    buckets = new ArrayList<>(getBuckets(coordinator));
    sortBucketsBySequentialNumber(buckets);
    assertEquals(4, buckets.size());
    assertNumericBucket(buckets.get(0), WorkBucketStateType.COMPLETE, 2, 1, 2);
    assertNumericBucket(buckets.get(1), WorkBucketStateType.DELEGATED, 3, 2, 3);
    assertNumericBucket(buckets.get(2), WorkBucketStateType.DELEGATED, 4, 3, 4);
    assertNumericBucket(buckets.get(3), WorkBucketStateType.DELEGATED, 5, 4, 5);
    when("no more buckets");
    WorkBucketType nothing = getWorkBucket(coordinator, oidW5, result);
    then("no more buckets");
    assertNull("Found bucket even if none should be found", nothing);
    when("release bucket #4");
    bucketingManager.releaseWorkBucket(oidC, oidW4, ActivityPath.empty(), 4, null, result);
    then("release bucket #4");
    coordinator = taskManager.getTaskPlain(coordinator.getOid(), result);
    displayDumpable("coordinator after releasing of 4th bucket", coordinator);
    buckets = new ArrayList<>(getBuckets(coordinator));
    sortBucketsBySequentialNumber(buckets);
    assertEquals(4, buckets.size());
    assertNumericBucket(buckets.get(0), WorkBucketStateType.COMPLETE, 2, 1, 2);
    assertNumericBucket(buckets.get(1), WorkBucketStateType.DELEGATED, 3, 2, 3);
    assertNumericBucket(buckets.get(2), READY, 4, 3, 4);
    assertNumericBucket(buckets.get(3), WorkBucketStateType.DELEGATED, 5, 4, 5);
    when("complete bucket #3");
    bucketingManager.completeWorkBucket(oidC, oidW3, ActivityPath.empty(), 3, null, null, result);
    bucket = getWorkBucket(coordinator, oidW5, result);
    then("complete bucket #3");
    coordinator = taskManager.getTaskPlain(coordinator.getOid(), result);
    displayDumpable("coordinator after completion of 3rd bucket and getting next one", coordinator);
    assertNumericBucket(bucket, null, 4, 3, 4);
    buckets = new ArrayList<>(getBuckets(coordinator));
    sortBucketsBySequentialNumber(buckets);
    assertEquals(3, buckets.size());
    assertNumericBucket(buckets.get(0), WorkBucketStateType.COMPLETE, 3, 2, 3);
    assertNumericBucket(buckets.get(1), WorkBucketStateType.DELEGATED, 4, 3, 4);
    assertNumericBucket(buckets.get(2), WorkBucketStateType.DELEGATED, 5, 4, 5);
    when("complete bucket #5");
    bucketingManager.completeWorkBucket(oidC, oidW1, ActivityPath.empty(), 5, null, null, result);
    taskManager.closeTask(oidW5, result);
    then("complete bucket #5");
    coordinator = taskManager.getTaskPlain(coordinator.getOid(), result);
    displayDumpable("coordinator after completion of 5th bucket and closing worker5", coordinator);
    buckets = new ArrayList<>(getOrCreateBuckets(coordinator.getWorkState().getActivity()));
    assertEquals(2, buckets.size());
    assertNumericBucket(buckets.get(0), WorkBucketStateType.DELEGATED, 4, 3, 4);
    assertNumericBucket(buckets.get(1), WorkBucketStateType.COMPLETE, 5, 4, 5);
    when("reclaiming mis-allocated bucket");
    bucket = getWorkBucket(coordinator, oidW1, b -> b.withFreeBucketWaitTime(-1).withIsScavenger(true), result);
    assertThat(bucket).isNotNull();
    then("reclaiming mis-allocated bucket");
    coordinator = taskManager.getTaskPlain(coordinator.getOid(), result);
    displayDumpable("coordinator after reclaiming mis-allocated bucket", coordinator);
    assertNumericBucket(bucket, null, 4, 3, 4);
    buckets = new ArrayList<>(getBuckets(coordinator));
    assertEquals(2, buckets.size());
    assertNumericBucket(buckets.get(0), WorkBucketStateType.DELEGATED, 4, 3, 4);
    assertNumericBucket(buckets.get(1), WorkBucketStateType.COMPLETE, 5, 4, 5);
    when("complete bucket #4");
    bucketingManager.completeWorkBucket(oidC, oidW1, ActivityPath.empty(), 4, null, null, result);
    then("complete bucket #4");
    coordinator = taskManager.getTaskPlain(coordinator.getOid(), result);
    displayDumpable("coordinator after completion of 4th bucket", coordinator);
    buckets = new ArrayList<>(getBuckets(coordinator));
    assertEquals(1, buckets.size());
    assertNumericBucket(buckets.get(0), WorkBucketStateType.COMPLETE, 5, 4, 5);
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) AssertJUnit(org.testng.AssertJUnit) Arrays(java.util.Arrays) CommonTaskBeans(com.evolveum.midpoint.repo.common.activity.run.CommonTaskBeans) ActivityPath(com.evolveum.midpoint.schema.util.task.ActivityPath) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) GetBucketOperationOptionsBuilder(com.evolveum.midpoint.repo.common.activity.run.buckets.GetBucketOperationOptions.GetBucketOperationOptionsBuilder) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) BucketingUtil(com.evolveum.midpoint.schema.util.task.BucketingUtil) DebugUtil(com.evolveum.midpoint.util.DebugUtil) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) BucketFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory) COMPLETE(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE) BucketingConfigurationOverrides(com.evolveum.midpoint.repo.common.activity.run.buckets.BucketingConfigurationOverrides) AbstractRepoCommonTest(com.evolveum.midpoint.repo.common.AbstractRepoCommonTest) PrismContext(com.evolveum.midpoint.prism.PrismContext) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ActivityDistributionDefinition(com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition) BucketingManager(com.evolveum.midpoint.repo.common.activity.run.buckets.BucketingManager) BucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory) PrismAsserts(com.evolveum.midpoint.prism.util.PrismAsserts) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) Task(com.evolveum.midpoint.task.api.Task) StringBucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.StringBucketContentFactory) File(java.io.File) Consumer(java.util.function.Consumer) List(java.util.List) TestResource(com.evolveum.midpoint.test.TestResource) READY(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.READY) ContextConfiguration(org.springframework.test.context.ContextConfiguration) PostConstruct(javax.annotation.PostConstruct) BucketingUtil.sortBucketsBySequentialNumber(com.evolveum.midpoint.schema.util.task.BucketingUtil.sortBucketsBySequentialNumber) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) NotNull(org.jetbrains.annotations.NotNull) BucketContentFactoryGenerator(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactoryGenerator) Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test) AbstractRepoCommonTest(com.evolveum.midpoint.repo.common.AbstractRepoCommonTest)

Example 2 with READY

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.READY in project midpoint by Evolveum.

the class ScheduleNowHelper method scheduleCoordinatorAndWorkersNow.

public void scheduleCoordinatorAndWorkersNow(String coordinatorOid, OperationResult result) throws SchemaException, ObjectNotFoundException {
    TaskQuartzImpl coordinatorTask = taskRetriever.getTaskPlain(coordinatorOid, result);
    TaskSchedulingStateType state = coordinatorTask.getSchedulingState();
    switch(state) {
        case CLOSED:
        case READY:
            // hoping that the task handler will do what is needed (i.e. recreate or restart workers)
            scheduleTaskNow(coordinatorTask, result);
            break;
        case WAITING:
            // this means that workers are either busy (runnable) or are suspended; administrator should do something with that
            String msg1 = "Coordinator " + coordinatorTask + " cannot be run now, because it is in WAITING scheduling state. " + "Please check and resolve state of its worker tasks.";
            LOGGER.error(msg1);
            result.recordFatalError(msg1);
            break;
        case SUSPENDED:
            String msg2 = "Coordinator " + coordinatorTask + " cannot be run now, because it is in SUSPENDED state. " + "Please use appropriate method to schedule its execution.";
            LOGGER.error(msg2);
            result.recordFatalError(msg2);
            break;
        default:
            throw new IllegalStateException("Coordinator " + coordinatorTask + " is in unsupported state: " + state);
    }
}
Also used : TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl) TaskSchedulingStateType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskSchedulingStateType)

Example 3 with READY

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.READY in project midpoint by Evolveum.

the class WebComponentUtil method createMenuItemsFromActions.

@NotNull
public static List<InlineMenuItem> createMenuItemsFromActions(@NotNull List<GuiActionType> actions, String operation, PageBase pageBase, @NotNull Supplier<Collection<? extends ObjectType>> selectedObjectsSupplier) {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    actions.forEach(action -> {
        if (action.getTaskTemplateRef() == null) {
            return;
        }
        String templateOid = action.getTaskTemplateRef().getOid();
        if (StringUtils.isEmpty(templateOid)) {
            return;
        }
        String label = action.getDisplay() != null && PolyStringUtils.isNotEmpty(action.getDisplay().getLabel()) ? action.getDisplay().getLabel().getOrig() : action.getName();
        menuItems.add(new InlineMenuItem(Model.of(label)) {

            private static final long serialVersionUID = 1L;

            @Override
            public InlineMenuItemAction initAction() {
                return new ColumnMenuAction<SelectableBean<ObjectType>>() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        OperationResult result = new OperationResult(operation);
                        try {
                            Collection<String> oids;
                            if (getRowModel() != null) {
                                oids = Collections.singletonList(getRowModel().getObject().getValue().getOid());
                            } else {
                                oids = CollectionUtils.emptyIfNull(selectedObjectsSupplier.get()).stream().filter(o -> o.getOid() != null).map(o -> o.getOid()).collect(Collectors.toSet());
                            }
                            if (!oids.isEmpty()) {
                                @NotNull Item<PrismValue, ItemDefinition> extensionQuery = prepareExtensionValues(oids);
                                MidPointPrincipal principal = pageBase.getPrincipal();
                                if (principal == null) {
                                    throw new SecurityViolationException("No current user");
                                }
                                TaskType newTask = pageBase.getModelService().getObject(TaskType.class, templateOid, createCollection(createExecutionPhase()), pageBase.createSimpleTask(operation), result).asObjectable();
                                newTask.setName(PolyStringType.fromOrig(newTask.getName().getOrig() + " " + (int) (Math.random() * 10000)));
                                newTask.setOid(null);
                                newTask.setTaskIdentifier(null);
                                newTask.setOwnerRef(createObjectRef(principal.getFocus()));
                                newTask.setExecutionState(RUNNABLE);
                                newTask.setSchedulingState(READY);
                                newTask.asPrismObject().getOrCreateExtension().add(extensionQuery);
                                ObjectSetBasedWorkDefinitionType workDef = ObjectSetUtil.getObjectSetDefinitionFromTask(newTask);
                                QueryType query = (QueryType) extensionQuery.getRealValue();
                                ObjectSetType objectSet = workDef.getObjects();
                                if (objectSet == null) {
                                    objectSet = new ObjectSetType();
                                    objectSet.setType(ObjectType.COMPLEX_TYPE);
                                }
                                objectSet.setQuery(query);
                                workDef.setObjects(objectSet);
                                ObjectDelta<TaskType> delta = DeltaFactory.Object.createAddDelta(newTask.asPrismObject());
                                Collection<ObjectDeltaOperation<? extends ObjectType>> executedChanges = saveTask(delta, result, pageBase);
                                String newTaskOid = ObjectDeltaOperation.findAddDeltaOid(executedChanges, newTask.asPrismObject());
                                newTask.setOid(newTaskOid);
                                newTask.setTaskIdentifier(newTaskOid);
                                result.setInProgress();
                                result.setBackgroundTaskOid(newTask.getOid());
                            } else {
                                result.recordWarning(pageBase.createStringResource("WebComponentUtil.message.createMenuItemsFromActions.warning").getString());
                            }
                        } catch (Exception ex) {
                            result.recordFatalError(result.getOperation(), ex);
                            target.add(pageBase.getFeedbackPanel());
                        } finally {
                            pageBase.showResult(result);
                            target.add(pageBase.getFeedbackPanel());
                        }
                    }
                };
            }

            /**
             * Extension values are task-dependent. Therefore, in the future we will probably make
             * this behaviour configurable. For the time being we assume that the task template will be
             * of "iterative task handler" type and so it will expect mext:objectQuery extension property.
             *
             * FIXME
             */
            @NotNull
            private Item<PrismValue, ItemDefinition> prepareExtensionValues(Collection<String> oids) throws SchemaException {
                PrismContext prismContext = pageBase.getPrismContext();
                ObjectQuery objectQuery = prismContext.queryFor(ObjectType.class).id(oids.toArray(new String[0])).build();
                QueryType queryBean = pageBase.getQueryConverter().createQueryType(objectQuery);
                PrismContainerDefinition<?> extDef = PrismContext.get().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class).findContainerDefinition(TaskType.F_EXTENSION);
                ItemDefinition<Item<PrismValue, ItemDefinition>> def = extDef != null ? extDef.findItemDefinition(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY) : null;
                if (def == null) {
                    throw new SchemaException("No definition of " + SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY + " in the extension");
                }
                Item<PrismValue, ItemDefinition> extensionItem = def.instantiate();
                extensionItem.add(prismContext.itemFactory().createValue(queryBean));
                return extensionItem;
            }
        });
    });
    return menuItems;
}
Also used : PrismPropertyPanelContext(com.evolveum.midpoint.gui.impl.factory.panel.PrismPropertyPanelContext) PageUsers(com.evolveum.midpoint.web.page.admin.users.PageUsers) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) Scene(com.evolveum.midpoint.model.api.visualizer.Scene) PageResourceWizard(com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard) StringValue(org.apache.wicket.util.string.StringValue) PatternDateConverter(org.apache.wicket.datetime.PatternDateConverter) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) Roles(org.apache.wicket.authroles.authorization.strategies.role.Roles) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ValueStatus(com.evolveum.midpoint.web.component.prism.ValueStatus) CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) OnePageParameterEncoder(com.evolveum.midpoint.web.util.OnePageParameterEncoder) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) PolyStringTranslationType(com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) PageAccount(com.evolveum.midpoint.web.page.admin.resources.content.PageAccount) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) DeltaFactory(com.evolveum.midpoint.prism.delta.DeltaFactory) CaseTypeUtil(com.evolveum.midpoint.schema.util.cases.CaseTypeUtil) SelectorOptions.createCollection(com.evolveum.midpoint.schema.SelectorOptions.createCollection) com.evolveum.midpoint.util(com.evolveum.midpoint.util) PageReport(com.evolveum.midpoint.web.page.admin.reports.PageReport) StringResourceModel(org.apache.wicket.model.StringResourceModel) Constructor(java.lang.reflect.Constructor) Supplier(java.util.function.Supplier) CollectionUtils(org.apache.commons.collections4.CollectionUtils) MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) DateValidator(com.evolveum.midpoint.web.util.DateValidator) StreamSupport(java.util.stream.StreamSupport) PageService(com.evolveum.midpoint.web.page.admin.services.PageService) Collator(java.text.Collator) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) DurationFormatUtils(org.apache.commons.lang3.time.DurationFormatUtils) PageArchetype(com.evolveum.midpoint.web.page.admin.archetype.PageArchetype) PageUser(com.evolveum.midpoint.web.page.admin.users.PageUser) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) EvaluatedTriggerGroupDto(com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto) PageServiceSelfProfile(com.evolveum.midpoint.web.page.self.PageServiceSelfProfile) ConstructorUtils(org.apache.commons.lang3.reflect.ConstructorUtils) com.evolveum.midpoint.schema.util(com.evolveum.midpoint.schema.util) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) PageObjectTemplate(com.evolveum.midpoint.web.page.admin.objectTemplate.PageObjectTemplate) AuthorizationConstants(com.evolveum.midpoint.security.api.AuthorizationConstants) TaskCategory(com.evolveum.midpoint.task.api.TaskCategory) IRequestHandler(org.apache.wicket.request.IRequestHandler) AuthUtil(com.evolveum.midpoint.authentication.api.util.AuthUtil) CaseWorkItemUtil(com.evolveum.midpoint.schema.util.cases.CaseWorkItemUtil) RequestCycle(org.apache.wicket.request.cycle.RequestCycle) PageMessageTemplate(com.evolveum.midpoint.gui.impl.page.admin.messagetemplate.PageMessageTemplate) AbstractAssignmentTypePanel(com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.component.assignmentType.AbstractAssignmentTypePanel) GuiChannel(com.evolveum.midpoint.gui.impl.GuiChannel) IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile) ResourceUtils(com.evolveum.midpoint.model.api.util.ResourceUtils) ActivityStateUtil(com.evolveum.midpoint.schema.util.task.ActivityStateUtil) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) PageValuePolicy(com.evolveum.midpoint.web.page.admin.valuePolicy.PageValuePolicy) Collectors(java.util.stream.Collectors) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Nullable(org.jetbrains.annotations.Nullable) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) PageResources(com.evolveum.midpoint.web.page.admin.resources.PageResources) READY(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskSchedulingStateType.READY) PrismReferenceValueWrapperImpl(com.evolveum.midpoint.gui.impl.prism.wrapper.PrismReferenceValueWrapperImpl) com.evolveum.midpoint.schema(com.evolveum.midpoint.schema) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) PageOrgSelfProfile(com.evolveum.midpoint.web.page.self.PageOrgSelfProfile) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) BaseSortableDataProvider(com.evolveum.midpoint.web.component.data.BaseSortableDataProvider) FormComponent(org.apache.wicket.markup.html.form.FormComponent) GuiStyleConstants(com.evolveum.midpoint.gui.api.GuiStyleConstants) VerhoeffCheckDigit(org.apache.commons.validator.routines.checkdigit.VerhoeffCheckDigit) ObjectDetailsModels(com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels) ApprovalUtils(com.evolveum.midpoint.schema.util.cases.ApprovalUtils) PageResource(com.evolveum.midpoint.web.page.admin.resources.PageResource) PageShadow(com.evolveum.midpoint.gui.impl.page.admin.resource.PageShadow) PageRoleSelfProfile(com.evolveum.midpoint.web.page.self.PageRoleSelfProfile) SceneUtil(com.evolveum.midpoint.web.component.prism.show.SceneUtil) PageTasks(com.evolveum.midpoint.web.page.admin.server.PageTasks) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) org.apache.commons.lang3(org.apache.commons.lang3) ApprovalContextUtil(com.evolveum.midpoint.schema.util.cases.ApprovalContextUtil) com.evolveum.midpoint.gui.api.prism.wrapper(com.evolveum.midpoint.gui.api.prism.wrapper) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) ObjectTypeUtil.createObjectRef(com.evolveum.midpoint.schema.util.ObjectTypeUtil.createObjectRef) com.evolveum.midpoint.prism.query(com.evolveum.midpoint.prism.query) ObjectSetUtil(com.evolveum.midpoint.schema.util.task.work.ObjectSetUtil) ChangeType(com.evolveum.midpoint.prism.delta.ChangeType) ItemVisibility(com.evolveum.midpoint.web.component.prism.ItemVisibility) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) WorkItemTypeUtil(com.evolveum.midpoint.schema.util.cases.WorkItemTypeUtil) PageMessageTemplates(com.evolveum.midpoint.gui.impl.page.admin.messagetemplate.PageMessageTemplates) GetOperationOptions.createExecutionPhase(com.evolveum.midpoint.schema.GetOperationOptions.createExecutionPhase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) PrintWriter(java.io.PrintWriter) Label(org.apache.wicket.markup.html.basic.Label) Model(org.apache.wicket.model.Model) Task(com.evolveum.midpoint.task.api.Task) InvocationTargetException(java.lang.reflect.InvocationTargetException) PageServices(com.evolveum.midpoint.web.page.admin.services.PageServices) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage) PageRole(com.evolveum.midpoint.web.page.admin.roles.PageRole) ChangesByState(com.evolveum.midpoint.wf.api.ChangesByState) QName(javax.xml.namespace.QName) PageOrg(com.evolveum.midpoint.gui.impl.page.admin.org.PageOrg) TabbedPanel(com.evolveum.midpoint.web.component.TabbedPanel) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) PolyStringUtils(com.evolveum.midpoint.prism.util.PolyStringUtils) Form(org.apache.wicket.markup.html.form.Form) java.util(java.util) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) TaskTypeUtil(com.evolveum.midpoint.schema.util.task.TaskTypeUtil) SimpleDateFormat(java.text.SimpleDateFormat) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) LayeredIconCssStyle(com.evolveum.midpoint.gui.impl.component.icon.LayeredIconCssStyle) Trace(com.evolveum.midpoint.util.logging.Trace) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) LocalizationService(com.evolveum.midpoint.common.LocalizationService) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) com.evolveum.midpoint.model.api(com.evolveum.midpoint.model.api) PageCase(com.evolveum.midpoint.web.page.admin.cases.PageCase) IDataProvider(org.apache.wicket.markup.repeater.data.IDataProvider) IVisitor(org.apache.wicket.util.visit.IVisitor) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) SceneDto(com.evolveum.midpoint.web.component.prism.show.SceneDto) TableId(com.evolveum.midpoint.web.session.UserProfileStorage.TableId) PageRoles(com.evolveum.midpoint.web.page.admin.roles.PageRoles) PageBase.createStringResourceStatic(com.evolveum.midpoint.gui.api.page.PageBase.createStringResourceStatic) RUNNABLE(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStateType.RUNNABLE) StringWriter(java.io.StringWriter) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) PrismPropertyValueWrapper(com.evolveum.midpoint.gui.impl.prism.wrapper.PrismPropertyValueWrapper) ItemName(com.evolveum.midpoint.prism.path.ItemName) ItemPathCollectionsUtil(com.evolveum.midpoint.prism.path.ItemPathCollectionsUtil) AuthorizationAction(com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction) S_FilterEntryOrEmpty(com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ObjectTypeGuiDescriptor(com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor) IVisit(org.apache.wicket.util.visit.IVisit) Behavior(org.apache.wicket.behavior.Behavior) PageTask(com.evolveum.midpoint.web.page.admin.server.PageTask) PageOrgUnit(com.evolveum.midpoint.web.page.admin.orgs.PageOrgUnit) PageDescriptor(com.evolveum.midpoint.authentication.api.authorization.PageDescriptor) TaskInformation(com.evolveum.midpoint.schema.util.task.TaskInformation) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) PageObjectCollection(com.evolveum.midpoint.web.page.admin.objectCollection.PageObjectCollection) NonEmptyModel(com.evolveum.midpoint.gui.api.model.NonEmptyModel) PageUserSelfProfile(com.evolveum.midpoint.web.page.self.PageUserSelfProfile) Breadcrumb(com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb) URI(java.net.URI) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) DateTimeFormat(org.joda.time.format.DateTimeFormat) Experimental(com.evolveum.midpoint.util.annotation.Experimental) Predicate(java.util.function.Predicate) IFeedback(org.apache.wicket.feedback.IFeedback) DateLabelComponent(com.evolveum.midpoint.web.component.DateLabelComponent) Contract(org.jetbrains.annotations.Contract) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) ExpressionUtil(com.evolveum.midpoint.repo.common.expression.ExpressionUtil) DisplayableValueChoiceRenderer(com.evolveum.midpoint.web.component.input.DisplayableValueChoiceRenderer) NotNull(org.jetbrains.annotations.NotNull) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) BreadcrumbPageInstance(com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageInstance) ModelExecuteOptions.toModelExecutionOptionsBean(com.evolveum.midpoint.model.api.ModelExecuteOptions.toModelExecutionOptionsBean) AuthenticatedWebApplication(org.apache.wicket.authroles.authentication.AuthenticatedWebApplication) GuiProfiledPrincipal(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal) DynamicFormPanel(com.evolveum.midpoint.web.component.prism.DynamicFormPanel) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) IconCssStyle(com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle) MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) org.apache.wicket(org.apache.wicket) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) Table(com.evolveum.midpoint.web.component.data.Table) BreadcrumbPageClass(com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageClass) SubscriptionType(com.evolveum.midpoint.gui.api.SubscriptionType) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) OperationResultStatusPresentationProperties(com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties) Selectable(com.evolveum.midpoint.web.component.util.Selectable) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ReadOnlyValueModel(com.evolveum.midpoint.gui.api.model.ReadOnlyValueModel) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) Panel(org.apache.wicket.markup.html.panel.Panel) com.evolveum.midpoint.schema.processor(com.evolveum.midpoint.schema.processor) Protector(com.evolveum.midpoint.prism.crypto.Protector) NumberUtils(org.apache.commons.lang3.math.NumberUtils) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) NotNull(org.jetbrains.annotations.NotNull) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) InvocationTargetException(java.lang.reflect.InvocationTargetException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) SelectorOptions.createCollection(com.evolveum.midpoint.schema.SelectorOptions.createCollection) PageObjectCollection(com.evolveum.midpoint.web.page.admin.objectCollection.PageObjectCollection) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with READY

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.READY in project midpoint by Evolveum.

the class ValuePolicyProcessor method cardinalityCounter.

/**
 * Count cardinality
 */
private Map<Integer, List<String>> cardinalityCounter(Map<StringLimitType, List<String>> lims, List<String> password, Boolean skipMatchedLims, boolean uniquenessReached, OperationResult op) {
    HashMap<String, Integer> counter = new HashMap<>();
    for (Map.Entry<StringLimitType, List<String>> entry : lims.entrySet()) {
        final StringLimitType key = entry.getKey();
        int counterKey = 1;
        List<String> chars = entry.getValue();
        int i;
        if (password != null) {
            i = charIntersectionCounter(entry.getValue(), password);
        } else {
            i = 0;
        }
        // If max is exceed then error unable to continue
        if (key.getMaxOccurs() != null && i > key.getMaxOccurs()) {
            OperationResult o = new OperationResult("Limitation check :" + key.getDescription());
            o.recordFatalError("Exceeded maximal value for this limitation. " + i + ">" + key.getMaxOccurs());
            op.addSubresult(o);
            return null;
        // if max is all ready reached or skip enabled for minimal skip
        // counting
        } else if (key.getMaxOccurs() != null && i == key.getMaxOccurs()) {
            continue;
        // other cases minimum is not reached
        } else if ((key.getMinOccurs() == null || i >= key.getMinOccurs()) && !skipMatchedLims) {
            continue;
        }
        for (String s : chars) {
            if (null == password || !password.contains(s) || uniquenessReached) {
                counter.put(s, counterKey);
            }
        }
        // TODO this is suspicious
        counterKey++;
    }
    // If need to remove disabled chars (already reached limitations)
    if (password != null) {
        for (Map.Entry<StringLimitType, List<String>> entry : lims.entrySet()) {
            StringLimitType l = entry.getKey();
            int i = charIntersectionCounter(entry.getValue(), password);
            if (l.getMaxOccurs() != null && i > l.getMaxOccurs()) {
                OperationResult o = new OperationResult("Limitation check :" + l.getDescription());
                o.recordFatalError("Exceeded maximal value for this limitation. " + i + ">" + l.getMaxOccurs());
                op.addSubresult(o);
                return null;
            } else if (l.getMaxOccurs() != null && i == l.getMaxOccurs()) {
                // limitation matched remove all used chars
                LOGGER.trace("Skip " + l.getDescription());
                for (String charToRemove : entry.getValue()) {
                    counter.remove(charToRemove);
                }
            }
        }
    }
    // Transpose to better format
    Map<Integer, List<String>> ret = new HashMap<>();
    for (Map.Entry<String, Integer> entry : counter.entrySet()) {
        // if not there initialize
        ret.computeIfAbsent(entry.getValue(), k -> new ArrayList<>());
        ret.get(entry.getValue()).add(entry.getKey());
    }
    return ret;
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) StringLimitType(com.evolveum.midpoint.xml.ns._public.common.common_3.StringLimitType) LocalizableMessageList(com.evolveum.midpoint.util.LocalizableMessageList) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap)

Example 5 with READY

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.READY in project midpoint by Evolveum.

the class LoggingConfigurationManager method prepareConfiguration.

private static String prepareConfiguration(LoggingConfigurationType config) throws SchemaException {
    if (null == config) {
        throw new IllegalArgumentException("Configuration can't be null");
    }
    StringBuilder sb = new StringBuilder();
    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    sb.append("<configuration scan=\"false\" debug=\"true\">\n");
    //find and configure ALL logger and bring it to top of turbo stack
    for (SubSystemLoggerConfigurationType ss : config.getSubSystemLogger()) {
        if ("ALL".contentEquals(ss.getComponent().name())) {
            defineTurbo(sb, ss);
        }
    }
    //Generate subsystem logging quickstep
    for (SubSystemLoggerConfigurationType ss : config.getSubSystemLogger()) {
        if (null == ss.getComponent() || null == ss.getLevel()) {
            LOGGER.error("Subsystem ({}) or level ({})is null", ss.getComponent(), ss.getLevel());
            continue;
        }
        //skip disabled subsystem logger
        if ("OFF".equals(ss.getLevel().name())) {
            continue;
        }
        //All ready defined above
        if ("ALL".contentEquals(ss.getComponent().name())) {
            continue;
        }
        defineTurbo(sb, ss);
    }
    //Generate appenders configuration
    for (AppenderConfigurationType appender : config.getAppender()) {
        prepareAppenderConfiguration(sb, appender, config);
    }
    //define root appender if defined
    if (!StringUtils.isEmpty(config.getRootLoggerAppender())) {
        sb.append("\t<root level=\"");
        sb.append(config.getRootLoggerLevel());
        sb.append("\">\n");
        sb.append("\t\t<appender-ref ref=\"");
        sb.append(config.getRootLoggerAppender());
        sb.append("\" />\n");
        sb.append("\t</root>\n");
    }
    //Generate class based loggers
    for (ClassLoggerConfigurationType logger : config.getClassLogger()) {
        sb.append("\t<logger name=\"");
        sb.append(logger.getPackage());
        sb.append("\" level=\"");
        sb.append(logger.getLevel());
        sb.append("\"");
        //if logger specific appender is defined
        if (null != logger.getAppender() && !logger.getAppender().isEmpty()) {
            sb.append(" additivity=\"false\">\n");
            for (String appenderName : logger.getAppender()) {
                sb.append("\t\t<appender-ref ref=\"");
                sb.append(appenderName);
                sb.append("\"/>");
            }
            sb.append("\t</logger>\n");
        } else {
            sb.append("/>\n");
        }
    }
    generateAuditingLogConfig(config.getAuditing(), sb);
    if (null != config.getAdvanced()) {
        for (Object item : config.getAdvanced().getContent()) {
            sb.append(item.toString());
            sb.append("\n");
        }
    }
    // LevelChangePropagator to propagate log level changes to JUL
    // this keeps us from performance impact of disable JUL logging statements
    // WARNING: if deployed in Tomcat then this propagates only to the JUL loggers in current classloader.
    // It means that ICF connector loggers are not affected by this
    // MAGIC: moved to the end of the "file" as suggested in http://jira.qos.ch/browse/LOGBACK-740
    sb.append("\t<contextListener class=\"ch.qos.logback.classic.jul.LevelChangePropagator\">\n");
    sb.append("\t\t<resetJUL>true</resetJUL>\n");
    sb.append("\t</contextListener>\n");
    sb.append("</configuration>");
    return sb.toString();
}
Also used : SyslogAppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SyslogAppenderConfigurationType) FileAppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType) AppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType) ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType) SubSystemLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 VariablesMap (com.evolveum.midpoint.schema.expression.VariablesMap)2 Task (com.evolveum.midpoint.task.api.Task)2 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)2 NotNull (org.jetbrains.annotations.NotNull)2 AuthorizationAction (com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction)1 PageDescriptor (com.evolveum.midpoint.authentication.api.authorization.PageDescriptor)1 AuthUtil (com.evolveum.midpoint.authentication.api.util.AuthUtil)1 LocalizationService (com.evolveum.midpoint.common.LocalizationService)1 GuiStyleConstants (com.evolveum.midpoint.gui.api.GuiStyleConstants)1 SubscriptionType (com.evolveum.midpoint.gui.api.SubscriptionType)1 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)1 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)1 WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 NonEmptyModel (com.evolveum.midpoint.gui.api.model.NonEmptyModel)1 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 ReadOnlyValueModel (com.evolveum.midpoint.gui.api.model.ReadOnlyValueModel)1 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1