Search in sources :

Example 66 with OperationResult

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

the class PageResources method testResourcePerformed.

private void testResourcePerformed(AjaxRequestTarget target, ResourceType resourceType) {
    OperationResult result = new OperationResult(OPERATION_TEST_RESOURCE);
    // ResourceType resourceType = dto.getValue();
    if (StringUtils.isEmpty(resourceType.getOid())) {
        result.recordFatalError("Resource oid not defined in request");
    }
    Task task = createSimpleTask(OPERATION_TEST_RESOURCE);
    try {
        result = getModelService().testResource(resourceType.getOid(), task);
        // ResourceController.updateResourceState(resourceType.getState(),
        // result);
        // todo de-duplicate code (see the same operation in PageResource)
        // this provides some additional tests, namely a test for schema
        // handling section
        getModelService().getObject(ResourceType.class, resourceType.getOid(), null, task, result);
    } catch (Exception ex) {
        result.recordFatalError("Failed to test resource connection", ex);
    }
    // show any (potential) getObject problems
    if (result.isSuccess()) {
        result.recomputeStatus();
    }
    // if (!result.isSuccess()) {
    showResult(result);
    target.add(getFeedbackPanel());
    // }
    target.add(getResourceTable());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 67 with OperationResult

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

the class ResourceContentPanel method initColumns.

private List<IColumn<SelectableBean<ShadowType>, String>> initColumns() {
    List<ColumnTypeDto<String>> columnDefs = Arrays.asList(new ColumnTypeDto<String>("ShadowType.synchronizationSituation", SelectableBean.F_VALUE + ".synchronizationSituation", ShadowType.F_SYNCHRONIZATION_SITUATION.getLocalPart()), new ColumnTypeDto<String>("ShadowType.intent", SelectableBean.F_VALUE + ".intent", ShadowType.F_INTENT.getLocalPart()));
    List<IColumn<SelectableBean<ShadowType>, String>> columns = new ArrayList<>();
    IColumn<SelectableBean<ShadowType>, String> identifiersColumn = new AbstractColumn<SelectableBean<ShadowType>, String>(createStringResource("pageContentAccounts.identifiers")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ShadowType>>> cellItem, String componentId, IModel<SelectableBean<ShadowType>> rowModel) {
            SelectableBean<ShadowType> dto = rowModel.getObject();
            RepeatingView repeater = new RepeatingView(componentId);
            ShadowType value = dto.getValue();
            if (value != null) {
                for (ResourceAttribute<?> attr : ShadowUtil.getAllIdentifiers(value)) {
                    repeater.add(new Label(repeater.newChildId(), attr.getElementName().getLocalPart() + ": " + attr.getRealValue()));
                }
            }
            cellItem.add(repeater);
        }
    };
    columns.add(identifiersColumn);
    columns.addAll((Collection) ColumnUtils.createColumns(columnDefs));
    ObjectLinkColumn<SelectableBean<ShadowType>> ownerColumn = new ObjectLinkColumn<SelectableBean<ShadowType>>(createStringResource("pageContentAccounts.owner")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<FocusType> createLinkModel(final IModel<SelectableBean<ShadowType>> rowModel) {
            return new AbstractReadOnlyModel<FocusType>() {

                private static final long serialVersionUID = 1L;

                @Override
                public FocusType getObject() {
                    FocusType owner = loadShadowOwner(rowModel);
                    if (owner == null) {
                        return null;
                    }
                    return owner;
                }
            };
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ShadowType>> rowModel, ObjectType targetObjectType) {
            ownerDetailsPerformed(target, (FocusType) targetObjectType);
        }
    };
    columns.add(ownerColumn);
    columns.add(new LinkColumn<SelectableBean<ShadowType>>(createStringResource("PageAccounts.accounts.result")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createLinkModel(final IModel<SelectableBean<ShadowType>> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return getResultLabel(rowModel);
                }
            };
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ShadowType>> rowModel) {
            OperationResultType resultType = getResult(rowModel);
            OperationResult result = OperationResult.createOperationResult(resultType);
            OperationResultPanel body = new OperationResultPanel(ResourceContentPanel.this.getPageBase().getMainPopupBodyId(), new Model<OpResult>(OpResult.getOpResult(pageBase, result)), getPage());
            body.setOutputMarkupId(true);
            ResourceContentPanel.this.getPageBase().showMainPopup(body, target);
        }
    });
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ArrayList(java.util.ArrayList) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) Label(org.apache.wicket.markup.html.basic.Label) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ColumnTypeDto(com.evolveum.midpoint.web.component.data.column.ColumnTypeDto) Item(org.apache.wicket.markup.repeater.Item) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) IModel(org.apache.wicket.model.IModel) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResultPanel(com.evolveum.midpoint.gui.api.component.result.OperationResultPanel) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectLinkColumn(com.evolveum.midpoint.web.component.data.column.ObjectLinkColumn) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) StringResourceModel(org.apache.wicket.model.StringResourceModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel)

Example 68 with OperationResult

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

the class PageAdminResources method loadResource.

protected PrismObject<ResourceType> loadResource(Collection<SelectorOptions<GetOperationOptions>> options) {
    OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCE);
    PrismObject<ResourceType> resource = null;
    try {
        Task task = createSimpleTask(OPERATION_LOAD_RESOURCE);
        LOGGER.trace("getObject(resource) oid={}, options={}", getResourceOid(), options);
        resource = getModelService().getObject(ResourceType.class, getResourceOid(), options, task, result);
        result.recomputeStatus();
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("getObject(resource) result\n:{}", result.debugDump());
        }
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get resource", ex);
        result.recordFatalError("Couldn't get resource, reason: " + ex.getMessage(), ex);
    }
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        if (resource != null) {
            showResult(result);
        } else {
            getSession().error(getString("pageAdminResources.message.cantLoadResource"));
            throw new RestartResponseException(PageResources.class);
        }
    }
    return resource;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 69 with OperationResult

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

the class PageAdminResources method deleteSyncTokenPerformed.

protected void deleteSyncTokenPerformed(AjaxRequestTarget target, ResourceType resourceType) {
    //        ResourceDto dto = model.getObject();
    String resourceOid = resourceType.getOid();
    String handlerUri = "http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3";
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resourceOid);
    PrismObject<TaskType> oldTask;
    OperationResult result = new OperationResult(OPERATION_DELETE_SYNC_TOKEN);
    ObjectQuery query = QueryBuilder.queryFor(TaskType.class, getPrismContext()).item(TaskType.F_OBJECT_REF).ref(resourceOid).and().item(TaskType.F_HANDLER_URI).eq(handlerUri).build();
    List<PrismObject<TaskType>> taskList = WebModelServiceUtils.searchObjects(TaskType.class, query, result, this);
    if (taskList.size() != 1) {
        error(getString("pageResource.message.invalidTaskSearch"));
    } else {
        oldTask = taskList.get(0);
        saveTask(oldTask, result);
    }
    result.recomputeStatus();
    showResult(result);
    target.add(getFeedbackPanel());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 70 with OperationResult

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

the class PageConnectorHosts method deleteHostConfirmedPerformed.

private void deleteHostConfirmedPerformed(AjaxRequestTarget target) {
    Table hostTable = getConnectorHostTable();
    List<SelectableBean<ConnectorHostType>> selected = WebComponentUtil.getSelectedData(hostTable);
    OperationResult result = new OperationResult(OPERATION_DELETE_HOSTS);
    for (SelectableBean<ConnectorHostType> selectable : selected) {
        try {
            Task task = createSimpleTask(OPERATION_DELETE_HOSTS);
            if (selectable.getValue() != null) {
                ObjectDelta<ConnectorHostType> delta = ObjectDelta.createDeleteDelta(ConnectorHostType.class, selectable.getValue().getOid(), getPrismContext());
                getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
            }
        } catch (Exception ex) {
            result.recordPartialError("Couldn't delete host.", ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete host", ex);
        }
    }
    result.recomputeStatus();
    if (result.isSuccess()) {
        result.recordStatus(OperationResultStatus.SUCCESS, "The resource(s) have been successfully deleted.");
    }
    BaseSortableDataProvider provider = (BaseSortableDataProvider) hostTable.getDataTable().getDataProvider();
    provider.clearCache();
    showResult(result);
    target.add(getFeedbackPanel(), (Component) hostTable);
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) Task(com.evolveum.midpoint.task.api.Task) Table(com.evolveum.midpoint.web.component.data.Table) DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) BaseSortableDataProvider(com.evolveum.midpoint.web.component.data.BaseSortableDataProvider) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

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