Search in sources :

Example 1 with CapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType in project midpoint by Evolveum.

the class AddCapabilityDialog method initLayout.

private void initLayout(WebMarkupContainer container) {
    List<IColumn<CapabilityDto<CapabilityType>, String>> columns = initColumns();
    TablePanel<CapabilityDto<CapabilityType>> table = new TablePanel<>(ID_TABLE, createProvider(), columns);
    table.setOutputMarkupId(true);
    table.setShowPaging(false);
    container.add(table);
    AjaxButton cancelButton = new AjaxButton(ID_CANCEL, createStringResource("addCapabilityDialog.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            cancelPerformed(ajaxRequestTarget);
        }
    };
    container.add(cancelButton);
    AjaxButton addButton = new AjaxButton(ID_ADD, createStringResource("addCapabilityDialog.button.Add")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addPerformed(target);
        }
    };
    container.add(addButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) CapabilityDto(com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 2 with CapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType in project midpoint by Evolveum.

the class ResourceManager method supportsCapability.

private <T extends CapabilityType> boolean supportsCapability(ConnectorInstanceSpecificationType additionalConnectorType, Collection<Object> nativeCapabilities, Class<T> capabilityClass) {
    CapabilitiesType specifiedCapabilitiesType = additionalConnectorType.getCapabilities();
    if (specifiedCapabilitiesType != null) {
        CapabilityCollectionType configuredCapCollectionType = specifiedCapabilitiesType.getConfigured();
        if (configuredCapCollectionType != null) {
            T configuredCap = CapabilityUtil.getCapability(configuredCapCollectionType.getAny(), capabilityClass);
            if (configuredCap != null && !CapabilityUtil.isCapabilityEnabled(configuredCap)) {
                return false;
            }
        }
    }
    T cap = CapabilityUtil.getCapability(nativeCapabilities, capabilityClass);
    if (cap == null) {
        return false;
    }
    return CapabilityUtil.isCapabilityEnabled(cap);
}
Also used : CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) CapabilitiesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType)

Example 3 with CapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType in project midpoint by Evolveum.

the class CapabilityStep method savePerformed.

private void savePerformed() {
    Task task = getPageBase().createSimpleTask(OPERATION_SAVE_CAPABILITIES);
    OperationResult result = task.getResult();
    ModelService modelService = getPageBase().getModelService();
    boolean saved = false;
    try {
        PrismObject<ResourceType> oldResource;
        final PrismObject<ResourceType> resourceObject = resourceModel.getObject();
        ResourceType resource = resourceObject.asObjectable();
        List<Object> unsupportedCapabilities = new ArrayList<>();
        if (resource.getCapabilities().getConfigured() != null) {
            for (Object o : resource.getCapabilities().getConfigured().getAny()) {
                CapabilityType capabilityType = CapabilityUtil.asCapabilityType(o);
                if (!Capability.supports(capabilityType.getClass())) {
                    unsupportedCapabilities.add(o);
                }
            }
        }
        // AnyArrayList that is used to implement getAny() is really strange (e.g. doesn't support iterator.remove();
        // and its support for clear() is questionable) -- so let's recreate it altogether
        resource.getCapabilities().setConfigured(new CapabilityCollectionType());
        resource.getCapabilities().getConfigured().getAny().addAll(unsupportedCapabilities);
        ObjectFactory capabilityFactory = new ObjectFactory();
        for (CapabilityDto dto : dtoModel.getObject().getCapabilities()) {
            JAXBElement<? extends CapabilityType> jaxbCapability = createJAXBCapability(dto.getCapability(), capabilityFactory);
            if (jaxbCapability != null) {
                resource.getCapabilities().getConfigured().getAny().add(jaxbCapability);
            }
        }
        oldResource = WebModelServiceUtils.loadObject(ResourceType.class, resource.getOid(), getPageBase(), task, result);
        if (oldResource != null) {
            ObjectDelta<ResourceType> delta = parentPage.computeDiff(oldResource, resourceObject);
            if (!delta.isEmpty()) {
                parentPage.logDelta(delta);
                @SuppressWarnings("unchecked") Collection<ObjectDelta<? extends ObjectType>> deltas = WebComponentUtil.createDeltaCollection(delta);
                modelService.executeChanges(deltas, null, getPageBase().createSimpleTask(OPERATION_SAVE_CAPABILITIES), result);
                parentPage.resetModels();
                saved = true;
            }
        }
    } catch (CommonException | RuntimeException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save capabilities", e);
        result.recordFatalError("Couldn't save capabilities", e);
    } finally {
        result.computeStatusIfUnknown();
        setResult(result);
    }
    if (parentPage.showSaveResultInPage(saved, result)) {
        getPageBase().showResult(result);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ModelService(com.evolveum.midpoint.model.api.ModelService) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) CapabilityDto(com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto) PrismObject(com.evolveum.midpoint.prism.PrismObject) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 4 with CapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType in project midpoint by Evolveum.

the class AddCapabilityDialog method loadModel.

private List<CapabilityDto<CapabilityType>> loadModel(IModel<CapabilityStepDto> capabilityModel) {
    List<Class<? extends CapabilityType>> existingCapabilityClasses = new ArrayList<>();
    for (CapabilityDto cap : capabilityModel.getObject().getCapabilities()) {
        existingCapabilityClasses.add(cap.getCapability().getClass());
    }
    List<CapabilityDto<CapabilityType>> rv = new ArrayList<>();
    for (Capability supportedCapability : Capability.values()) {
        if (!existingCapabilityClasses.contains(supportedCapability.getClazz())) {
            // 'among natives' doesn't matter here
            rv.add(new CapabilityDto<>(CapabilityStep.fillDefaults(supportedCapability.newInstance()), false));
        }
    }
    return rv;
}
Also used : CapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType) Capability(com.evolveum.midpoint.web.component.wizard.resource.dto.Capability) CapabilityDto(com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto) ArrayList(java.util.ArrayList)

Aggregations

CapabilityDto (com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto)3 CapabilityCollectionType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType)2 CapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType)2 ModelService (com.evolveum.midpoint.model.api.ModelService)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)1 Capability (com.evolveum.midpoint.web.component.wizard.resource.dto.Capability)1 CapabilitiesType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType)1 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)1 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)1 ArrayList (java.util.ArrayList)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)1