Search in sources :

Example 71 with OperationResult

use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.

the class PageResource method refreshSchemaPerformed.

private void refreshSchemaPerformed(AjaxRequestTarget target) {
    Task task = createSimpleTask(OPERATION_REFRESH_SCHEMA);
    OperationResult parentResult = new OperationResult(OPERATION_REFRESH_SCHEMA);
    try {
        ResourceUtils.deleteSchema(resourceModel.getObject(), getModelService(), getPrismContext(), task, parentResult);
        // try to load fresh scehma
        getModelService().testResource(resourceModel.getObject().getOid(), task);
    } catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Error refreshing resource schema", e);
        parentResult.recordFatalError("Error refreshing resource schema", e);
    }
    parentResult.computeStatus();
    showResult(parentResult, "pageResource.refreshSchema.failed");
    target.add(getFeedbackPanel());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 72 with OperationResult

use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.

the class ResourceWizardIssuesModel method load.

@NotNull
@Override
protected WizardIssuesDto load() {
    final WizardIssuesDto issuesDto = new WizardIssuesDto();
    if (!resourceModel.isLoaded()) {
        // e.g. in first two wizard steps (IT PROBABLY DOES NOT WORK AS EXPECTED)
        return issuesDto;
    }
    ResourceValidator validator = wizardPage.getResourceValidator();
    ValidationResult validationResult = validator.validate(resourceModel.getObject(), Scope.QUICK, WebComponentUtil.getCurrentLocale(), wizardPage.createSimpleTask("validate"), new OperationResult("validate"));
    issuesDto.fillFrom(validationResult);
    issuesDto.sortIssues();
    return issuesDto;
}
Also used : ResourceValidator(com.evolveum.midpoint.model.api.validator.ResourceValidator) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ValidationResult(com.evolveum.midpoint.model.api.validator.ValidationResult) WizardIssuesDto(com.evolveum.midpoint.web.component.wizard.resource.dto.WizardIssuesDto) NotNull(org.jetbrains.annotations.NotNull)

Example 73 with OperationResult

use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.

the class TestConnectionMessagesPanel method initResultsModel.

private void initResultsModel(String resourceOid) {
    OperationResult result = new OperationResult(OPERATION_TEST_CONNECTION);
    List<OpResult> resourceResultsDto = new ArrayList<>();
    List<ConnectorStruct> connectorStructs = new ArrayList<>();
    if (StringUtils.isNotEmpty(resourceOid)) {
        Task task = parentPage.createSimpleTask(OPERATION_TEST_CONNECTION);
        try {
            result = parentPage.getModelService().testResource(resourceOid, task);
        } catch (ObjectNotFoundException e) {
            result.recordFatalError("Failed to test resource connection", e);
        }
        for (OperationResult subresult : result.getSubresults()) {
            if (isConnectorResult(subresult)) {
                ConnectorStruct connectorStruct = new ConnectorStruct();
                connectorStruct.connectorName = (String) subresult.getParams().get(OperationResult.PARAM_NAME);
                if (connectorStruct.connectorName == null) {
                    connectorStruct.connectorName = "";
                }
                connectorStruct.connectorResultsDto = new ArrayList<>();
                for (OperationResult subsubresult : subresult.getSubresults()) {
                    if (isKnownResult(subsubresult)) {
                        connectorStruct.connectorResultsDto.add(OpResult.getOpResult(parentPage, subsubresult));
                    }
                }
                connectorStructs.add(connectorStruct);
            } else if (isKnownResult(subresult)) {
                // resource operation
                resourceResultsDto.add(OpResult.getOpResult(parentPage, subresult));
            }
        }
        if (result.isSuccess()) {
            result.recomputeStatus();
        }
    }
    modelResourceResults = new ListModel<>(resourceResultsDto);
    connectorResourceResults = new ListModel<>(connectorStructs);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OpResult(com.evolveum.midpoint.gui.api.component.result.OpResult) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 74 with OperationResult

use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.

the class PageAccount method loadAccount.

private ObjectWrapper<ShadowType> loadAccount(PageParameters parameters) {
    Task task = createSimpleTask(OPERATION_LOAD_ACCOUNT);
    OperationResult result = task.getResult();
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(ShadowType.F_RESOURCE, GetOperationOptions.createResolve());
    StringValue oid = parameters != null ? parameters.get(OnePageParameterEncoder.PARAMETER) : null;
    PrismObject<ShadowType> account = WebModelServiceUtils.loadObject(ShadowType.class, oid.toString(), options, PageAccount.this, task, result);
    if (account == null) {
        getSession().error(getString("pageAccount.message.cantEditAccount"));
        showResult(result);
        throw new RestartResponseException(PageResources.class);
    }
    ObjectWrapper wrapper = ObjectWrapperUtil.createObjectWrapper(null, null, account, ContainerStatus.MODIFYING, task, this);
    OperationResultType fetchResult = account.getPropertyRealValue(ShadowType.F_FETCH_RESULT, OperationResultType.class);
    wrapper.setFetchResult(OperationResult.createOperationResult(fetchResult));
    wrapper.setShowEmpty(false);
    return wrapper;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) RestartResponseException(org.apache.wicket.RestartResponseException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) StringValue(org.apache.wicket.util.string.StringValue)

Example 75 with OperationResult

use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.

the class RunReportPopupPanel method runConfirmPerformed.

//    private void addFormUpdatingBehavior(FormComponent parent, String id, final IModel<JasperReportParameterDto> model) {
//        Component c = parent.get(id);
//        if (c == null) {
//            return;
//        }
//        c.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
//    }
private void runConfirmPerformed(AjaxRequestTarget target, IModel<ReportDto> model) {
    ReportDto reportDto = model.getObject();
    PrismContainerDefinition<ReportParameterType> paramContainerDef = getPrismContext().getSchemaRegistry().findContainerDefinitionByElementName(ReportConstants.REPORT_PARAMS_PROPERTY_NAME);
    PrismContainer<ReportParameterType> paramContainer;
    try {
        paramContainer = paramContainerDef.instantiate();
        ReportParameterType reportParam = new ReportParameterType();
        PrismContainerValue<ReportParameterType> reportParamValue = reportParam.asPrismContainerValue();
        reportParamValue.revive(getPrismContext());
        paramContainer.add(reportParamValue);
        List<JasperReportParameterDto> params = getParametersView().getModelObject();
        for (JasperReportParameterDto paramDto : params) {
            if (paramDto.getValue() == null) {
                continue;
            }
            List<JasperReportValueDto> values = paramDto.getValue();
            Class<?> paramClass = paramDto.getType();
            boolean multivalue = false;
            if (List.class.isAssignableFrom(paramClass)) {
                paramClass = paramDto.getNestedType();
                if (paramClass == null) {
                    getSession().error("Nested type for list must be defined!");
                    target.add(getPageBase().getFeedbackPanel());
                    return;
                }
            }
            QName typeName = getPrismContext().getSchemaRegistry().determineTypeForClass(paramClass);
            PrismPropertyDefinitionImpl<?> def = new PrismPropertyDefinitionImpl<>(new QName(ReportConstants.NS_EXTENSION, paramDto.getName()), typeName, getPrismContext());
            def.setDynamic(true);
            def.setRuntimeSchema(true);
            // TODO multivalue is always 'false' here ...
            def.setMaxOccurs(multivalue ? -1 : 1);
            PrismProperty prop = def.instantiate();
            for (JasperReportValueDto paramValue : values) {
                Object realValue = paramValue.getValue();
                if (realValue == null) {
                    continue;
                }
                if (AuditEventType.class.isAssignableFrom(paramClass)) {
                    paramClass = AuditEventTypeType.class;
                    realValue = AuditEventType.fromAuditEventType((AuditEventType) realValue);
                } else if (AuditEventStage.class.isAssignableFrom(paramClass)) {
                    paramClass = AuditEventStageType.class;
                    realValue = AuditEventStage.fromAuditEventStage((AuditEventStage) realValue);
                }
                prop.addRealValue(realValue);
            }
            if (!prop.isEmpty()) {
                reportParamValue.add(prop);
            }
        }
    } catch (SchemaException | ClassNotFoundException e) {
        OperationResult result = new OperationResult("Parameters serialization");
        result.recordFatalError("Could not serialize parameters");
        getPageBase().showResult(result);
        return;
    }
    runConfirmPerformed(target, reportDto.getObject().asObjectable(), paramContainer);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) QName(javax.xml.namespace.QName) ReportParameterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportParameterType) ReportDto(com.evolveum.midpoint.web.page.admin.reports.dto.ReportDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AuditEventStage(com.evolveum.midpoint.audit.api.AuditEventStage) JasperReportParameterDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto) JasperReportValueDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportValueDto) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) PrismObject(com.evolveum.midpoint.prism.PrismObject) AuditEventStageType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventStageType)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3475 Test (org.testng.annotations.Test)2435 Task (com.evolveum.midpoint.task.api.Task)2390 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1059 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)725 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)637 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)414 PrismObject (com.evolveum.midpoint.prism.PrismObject)388 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)376 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)320 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)288 ArrayList (java.util.ArrayList)262 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)252 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)250 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)231 QName (javax.xml.namespace.QName)198 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)197 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)182 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)171 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)149