Search in sources :

Example 81 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class ObjectChangesExecutorImpl method executeChangesSync.

private Collection<ObjectDeltaOperation<? extends ObjectType>> executeChangesSync(Collection<ObjectDelta<? extends ObjectType>> deltas, ModelExecuteOptions options, Task task, OperationResult result) {
    try {
        MidPointApplication application = MidPointApplication.get();
        ModelService service = application.getModel();
        Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = service.executeChanges(deltas, options, task, result);
        result.computeStatusIfUnknown();
        return executedDeltas;
    } catch (CommonException | RuntimeException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Error executing changes", e);
        if (!result.isFatalError()) {
            // just to be sure the exception is recorded into the result
            result.recordFatalError(e.getMessage(), e);
        }
    }
    return null;
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) CommonException(com.evolveum.midpoint.util.exception.CommonException) ModelService(com.evolveum.midpoint.model.api.ModelService)

Example 82 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class PageDebugView method savePerformed.

public void savePerformed(AjaxRequestTarget target) {
    if (StringUtils.isEmpty(objectViewDtoModel.getObject().getXml())) {
        error(getString("pageDebugView.message.cantSaveEmpty"));
        target.add(getFeedbackPanel());
        return;
    }
    Task task = createSimpleTask(OPERATION_SAVE_OBJECT);
    OperationResult result = task.getResult();
    try {
        PrismObject<? extends ObjectType> oldObject = objectViewDtoModel.getObject().getObject();
        oldObject.revive(getPrismContext());
        Holder<? extends ObjectType> objectHolder = new Holder<>(null);
        validateObject(result, (Holder) objectHolder);
        if (result.isAcceptable()) {
            PrismObject<? extends ObjectType> newObject = objectHolder.getValue().asPrismObject();
            ObjectDelta<? extends ObjectType> delta = oldObject.diff((PrismObject) newObject, EquivalenceStrategy.LITERAL);
            if (delta.getPrismContext() == null) {
                LOGGER.warn("No prism context in delta {} after diff, adding it", delta);
                delta.revive(getPrismContext());
            }
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Delta to be applied:\n{}", delta.debugDump());
            }
            // quick fix for now (MID-1910), maybe it should be somewhere in objectViewModel..
            // if (isReport(oldObject)){
            // ReportTypeUtil.applyConfigurationDefinition((PrismObject)newObject, delta, getPrismContext());
            // }
            Collection<ObjectDelta<? extends ObjectType>> deltas = MiscUtil.createCollection(delta);
            ModelExecuteOptions options = ModelExecuteOptions.create(getPrismContext());
            if (isTrue(DebugViewOptions.ID_SAVE_AS_RAW)) {
                options.raw(true);
            }
            if (isTrue(DebugViewOptions.ID_REEVALUATE_SEARCH_FILTERS)) {
                options.reevaluateSearchFilters(true);
            }
            if (!isTrue(DebugViewOptions.ID_ENCRYPT)) {
                options.noCrypt(true);
            }
            getModelService().executeChanges(deltas, options, task, result);
            result.computeStatus();
        }
    } catch (Exception ex) {
        result.recordFatalError(getString("WebModelUtils.couldntSaveObject"), ex);
    }
    if (result.isError()) {
        showResult(result);
        target.add(getFeedbackPanel());
    } else {
        showResult(result);
        // to handle returning back to list objects page instead of edit object page
        if (getBreadcrumbs().size() >= 3) {
            redirectBack(3);
        } else {
            redirectBack();
        }
    }
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) Holder(com.evolveum.midpoint.util.Holder) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 83 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class InternalsLoggedInUsersPanel method initLayout.

private void initLayout() {
    MainObjectListPanel<F> table = new MainObjectListPanel(ID_TABLE, FocusType.class, null) {

        @Override
        protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
            if (WebComponentUtil.hasDetailsPage(object.getClass())) {
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, object.getOid());
                getPageBase().navigateToNext(WebComponentUtil.getObjectDetailsPage(object.getClass()), parameters);
            }
        }

        @Override
        protected List<IColumn<SelectableBean<F>, String>> createDefaultColumns() {
            return InternalsLoggedInUsersPanel.this.initColumns();
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return initInlineMenu();
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return null;
        }

        @Override
        protected ISelectableDataProvider<UserSessionManagementType, SelectableBean<F>> createProvider() {
            LoadableModel<List<UserSessionManagementType>> principals = new LoadableModel<List<UserSessionManagementType>>(true) {

                @Override
                protected List<UserSessionManagementType> load() {
                    return loadLoggedInPrincipals();
                }
            };
            return new SelectableListDataProvider<SelectableBean<F>, UserSessionManagementType>(InternalsLoggedInUsersPanel.this, principals) {

                @Override
                protected SelectableBean<F> createObjectWrapper(UserSessionManagementType principal) {
                    SelectableBeanImpl<F> user = new SelectableBeanImpl<>((F) principal.getFocus());
                    user.setActiveSessions(principal.getActiveSessions());
                    user.setNodes(principal.getNode());
                    return user;
                }
            };
        }

        @Override
        protected boolean isCreateNewObjectEnabled() {
            return false;
        }

        @Override
        protected List<Component> createToolbarButtonsList(String buttonId) {
            return new ArrayList<>();
        }

        @Override
        protected boolean enableSavePageSize() {
            return false;
        }
    };
    add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) UserSessionManagementType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementType) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ArrayList(java.util.ArrayList) List(java.util.List) Component(org.apache.wicket.Component)

Example 84 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class ObjectLinkColumn method populateItem.

@Override
public void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, final IModel<T> rowModel) {
    IModel<ObjectType> superModel = createLinkModel(rowModel);
    final ObjectType targetObjectType = superModel.getObject();
    IModel<String> nameModel = new PropertyModel<>(superModel, FocusType.F_NAME.getLocalPart() + ".orig");
    cellItem.add(new AjaxLinkPanel(componentId, nameModel) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ObjectLinkColumn.this.onClick(target, rowModel, targetObjectType);
        }

        @Override
        public boolean isEnabled() {
            return ObjectLinkColumn.this.isEnabled(rowModel);
        }
    });
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PropertyModel(org.apache.wicket.model.PropertyModel)

Example 85 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class ReferenceAutocomplete method getIterator.

@Override
public Iterator<ObjectReferenceType> getIterator(String input) {
    FormComponent<ObjectReferenceType> inputField = getBaseFormComponent();
    String realInput = StringUtils.isEmpty(input) ? (!inputField.hasRawInput() ? inputField.getValue() : inputField.getRawInput()) : input;
    if (StringUtils.isEmpty(realInput)) {
        return Collections.emptyIterator();
    }
    Class<ObjectType> type = getReferenceTargetObjectType();
    ObjectQuery query = pageBase.getPrismContext().queryFor(type).item(ObjectType.F_NAME).containsPoly(realInput).matchingNorm().build();
    query.setPaging(pageBase.getPrismContext().queryFactory().createPaging(0, getMaxRowsCount()));
    List<PrismObject<ObjectType>> objectsList = WebModelServiceUtils.searchObjects(type, query, new OperationResult("searchObjects"), pageBase);
    return ObjectTypeUtil.objectListToReferences(objectsList).iterator();
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)243 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)126 Test (org.testng.annotations.Test)97 Task (com.evolveum.midpoint.task.api.Task)82 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)79 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)78 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)68 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)55 ArrayList (java.util.ArrayList)51 Holder (javax.xml.ws.Holder)48 QName (javax.xml.namespace.QName)32 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)30 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)29 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)28 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)26 PrismObject (com.evolveum.midpoint.prism.PrismObject)25 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)25 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)24 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)22