Search in sources :

Example 26 with ResourceType

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

the class ResourceDetailsTabPanel method determineActivationMappings.

private SourceTarget determineActivationMappings(ResourceType resource) {
    if (resource.getSchemaHandling() != null && CollectionUtils.isNotEmpty(resource.getSchemaHandling().getObjectType())) {
        boolean hasOutbound = false;
        boolean hasInbound = false;
        for (ResourceObjectTypeDefinitionType resourceObjectTypeDefinition : resource.getSchemaHandling().getObjectType()) {
            if (hasInbound && hasOutbound) {
                return SourceTarget.SOURCE_TARGET;
            }
            if (resourceObjectTypeDefinition.getActivation() == null) {
                continue;
            }
            if (!hasOutbound) {
                ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
                if (activationDef.getAdministrativeStatus() != null && CollectionUtils.isNotEmpty(activationDef.getAdministrativeStatus().getOutbound())) {
                    hasOutbound = true;
                }
            }
            if (!hasOutbound) {
                ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
                if (activationDef.getValidFrom() != null && CollectionUtils.isNotEmpty(activationDef.getValidFrom().getOutbound())) {
                    hasOutbound = true;
                }
            }
            if (!hasOutbound) {
                ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
                if (activationDef.getValidTo() != null && CollectionUtils.isNotEmpty(activationDef.getValidTo().getOutbound())) {
                    hasOutbound = true;
                }
            }
            if (!hasOutbound) {
                ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
                if (activationDef.getExistence() != null && CollectionUtils.isNotEmpty(activationDef.getExistence().getOutbound())) {
                    hasOutbound = true;
                }
            }
            if (!hasInbound) {
                ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
                if (activationDef.getAdministrativeStatus() != null && CollectionUtils.isNotEmpty(activationDef.getAdministrativeStatus().getInbound())) {
                    hasInbound = true;
                }
            }
            if (!hasInbound) {
                ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
                if (activationDef.getValidFrom() != null && CollectionUtils.isNotEmpty(activationDef.getValidFrom().getInbound())) {
                    hasInbound = true;
                }
            }
            if (!hasInbound) {
                ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
                if (activationDef.getValidTo() != null && CollectionUtils.isNotEmpty(activationDef.getValidTo().getInbound())) {
                    hasInbound = true;
                }
            }
            if (!hasInbound) {
                ResourceActivationDefinitionType activationDef = resourceObjectTypeDefinition.getActivation();
                if (activationDef.getExistence() != null && CollectionUtils.isNotEmpty(activationDef.getExistence().getInbound())) {
                    hasInbound = true;
                }
            }
        }
        if (hasInbound) {
            return SourceTarget.SOURCE;
        }
        if (hasOutbound) {
            return SourceTarget.TARGET;
        }
    }
    return SourceTarget.NOT_DEFINED;
}
Also used : ResourceActivationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceActivationDefinitionType) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType)

Example 27 with ResourceType

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

the class ResourceDetailsTabPanel method createLastAvailabilityStatusInfo.

private InfoBoxPanel createLastAvailabilityStatusInfo(ResourceType resource) {
    String messageKey = "PageResource.resource.availabilityUnknown";
    String backgroundColor = "bg-gray";
    String icon = "fa-question";
    OperationalStateType operationalState = resource.getOperationalState();
    if (operationalState != null) {
        AvailabilityStatusType lastAvailabilityStatus = operationalState.getLastAvailabilityStatus();
        if (lastAvailabilityStatus != null) {
            if (lastAvailabilityStatus == AvailabilityStatusType.UP) {
                messageKey = "PageResource.resource.up";
                backgroundColor = "bg-green";
                icon = "fa-power-off";
            } else if (lastAvailabilityStatus == AvailabilityStatusType.DOWN) {
                backgroundColor = "bg-red";
                messageKey = "PageResource.resource.down";
                icon = "fa-ban";
            } else if (lastAvailabilityStatus == AvailabilityStatusType.BROKEN) {
                backgroundColor = "bg-yellow";
                messageKey = "PageResource.resource.broken";
                icon = "fa-warning";
            }
        }
    }
    InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, parentPage.getString(messageKey));
    ConnectorType connectorType = resource.getConnector();
    if (connectorType == null) {
        // Connector not found. Probably bad connectorRef reference.
        infoBoxType.setNumber("--");
        infoBoxType.setDescription("--");
    } else {
        String connectorName = StringUtils.substringAfterLast(WebComponentUtil.getEffectiveName(connectorType, ConnectorType.F_CONNECTOR_TYPE), ".");
        String connectorVersion = connectorType.getConnectorVersion();
        infoBoxType.setNumber(connectorName);
        infoBoxType.setDescription(connectorVersion);
    }
    Model<InfoBoxType> boxModel = new Model<InfoBoxType>(infoBoxType);
    InfoBoxPanel lastAvailabilityStatus = new InfoBoxPanel(ID_LAST_AVAILABILITY_STATUS, boxModel);
    lastAvailabilityStatus.setOutputMarkupId(true);
    return lastAvailabilityStatus;
}
Also used : InfoBoxType(com.evolveum.midpoint.web.component.box.InfoBoxType) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationalStateType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationalStateType) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) AvailabilityStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType) InfoBoxPanel(com.evolveum.midpoint.web.component.box.InfoBoxPanel)

Example 28 with ResourceType

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

the class ResourceDetailsTabPanel method getTaskFor.

private List<TaskType> getTaskFor(List<PrismObject<TaskType>> tasks, ObjectSynchronizationType synchronizationPolicy, PrismObject<ResourceType> resource) throws SchemaException {
    List<TaskType> syncTasks = new ArrayList<TaskType>();
    for (PrismObject<TaskType> task : tasks) {
        PrismProperty<ShadowKindType> taskKind = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND));
        ShadowKindType taskKindValue = null;
        if (taskKind != null) {
            taskKindValue = taskKind.getRealValue();
        }
        PrismProperty<String> taskIntent = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT));
        String taskIntentValue = null;
        if (taskIntent != null) {
            taskIntentValue = taskIntent.getRealValue();
        }
        PrismProperty<QName> taskObjectClass = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.OBJECTCLASS_PROPERTY_NAME));
        QName taskObjectClassValue = null;
        if (taskObjectClass != null) {
            taskObjectClassValue = taskObjectClass.getRealValue();
        }
        // is not accessible in admin-gui)
        if (taskObjectClassValue == null) {
            ObjectClassComplexTypeDefinition taskObjectClassDef = null;
            RefinedResourceSchema schema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
            if (schema == null) {
                throw new SchemaException("No schema defined in resource. Possible configuration problem?");
            }
            if (taskKindValue == null && taskIntentValue == null) {
                taskObjectClassDef = schema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
            }
            if (taskKindValue != null) {
                if (StringUtils.isEmpty(taskIntentValue)) {
                    taskObjectClassDef = schema.findDefaultObjectClassDefinition(taskKindValue);
                } else {
                    taskObjectClassDef = schema.findObjectClassDefinition(taskKindValue, taskIntentValue);
                }
            }
            if (taskObjectClassDef != null) {
                taskObjectClassValue = taskObjectClassDef.getTypeName();
            }
        }
        if (SynchronizationUtils.isPolicyApplicable(taskObjectClassValue, taskKindValue, taskIntentValue, synchronizationPolicy, resource)) {
            syncTasks.add(task.asObjectable());
        }
    }
    return syncTasks;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 29 with ResourceType

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

the class ResourceDetailsTabPanel method initLayout.

protected void initLayout(IModel model, PageBase parentPage) {
    PrismObject<ResourceType> resourceObject = (PrismObject<ResourceType>) model.getObject();
    ResourceType resource = resourceObject.asObjectable();
    add(createLastAvailabilityStatusInfo(resource));
    add(createSourceTargetInfo(resource));
    add(createSchemaStatusInfo(resource));
    CapabilitiesPanel capabilities = new CapabilitiesPanel(PANEL_CAPABILITIES, capabilitiesModel);
    add(capabilities);
    List<ResourceConfigurationDto> resourceConfigList = createResourceConfigList(resource);
    ListDataProvider<ResourceConfigurationDto> resourceConfigProvider = new ListDataProvider<ResourceConfigurationDto>(ResourceDetailsTabPanel.this, new ListModel<ResourceConfigurationDto>(resourceConfigList));
    List<ColumnTypeDto<String>> columns = Arrays.asList(new ColumnTypeDto<String>("ShadowType.kind", "objectTypeDefinition.kind", ShadowType.F_KIND.getLocalPart()), new ColumnTypeDto<String>("ShadowType.objectClass", "objectTypeDefinition.objectClass.localPart", ShadowType.F_OBJECT_CLASS.getLocalPart()), new ColumnTypeDto<String>("ShadowType.intent", "objectTypeDefinition.intent", ShadowType.F_INTENT.getLocalPart()), new ColumnTypeDto<String>("ResourceType.isSync", "sync", null));
    List<IColumn<SelectableBean<ResourceType>, String>> tableColumns = ColumnUtils.createColumns(columns);
    PropertyColumn tasksColumn = new PropertyColumn(PageBase.createStringResourceStatic(this, "ResourceType.tasks"), "definedTasks") {

        @Override
        public void populateItem(Item item, String componentId, final IModel rowModel) {
            ResourceConfigurationDto conf = (ResourceConfigurationDto) rowModel.getObject();
            RepeatingView repeater = new RepeatingView(componentId);
            for (final TaskType task : conf.getDefinedTasks()) {
                repeater.add(new LinkPanel(repeater.newChildId(), new Model<String>(task.getName().getOrig())) {

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        ResourceDetailsTabPanel.this.taskDetailsPerformed(target, task.getOid());
                    }
                });
            }
            item.add(repeater);
        }
    };
    tableColumns.add(tasksColumn);
    BoxedTablePanel<ResourceConfigurationDto> resourceConfig = new BoxedTablePanel("resourceConfig", resourceConfigProvider, tableColumns);
    resourceConfig.setAdditionalBoxCssClasses("box-success");
    add(resourceConfig);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) ResourceConfigurationDto(com.evolveum.midpoint.web.page.admin.resources.dto.ResourceConfigurationDto) ColumnTypeDto(com.evolveum.midpoint.web.component.data.column.ColumnTypeDto) LinkPanel(com.evolveum.midpoint.web.component.data.column.LinkPanel) PrismObject(com.evolveum.midpoint.prism.PrismObject) Item(org.apache.wicket.markup.repeater.Item) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) IModel(org.apache.wicket.model.IModel) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) 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) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 30 with ResourceType

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

the class ResourceDetailsTabPanel method determineIfSourceOrTarget.

private SourceTarget determineIfSourceOrTarget(ResourceType resource) {
    if (resource.getSchemaHandling() != null && CollectionUtils.isNotEmpty(resource.getSchemaHandling().getObjectType())) {
        boolean hasOutbound = false;
        boolean hasInbound = false;
        for (ResourceObjectTypeDefinitionType resourceObjectTypeDefinition : resource.getSchemaHandling().getObjectType()) {
            if (CollectionUtils.isEmpty(resourceObjectTypeDefinition.getAttribute())) {
                continue;
            }
            if (hasInbound && hasOutbound) {
                return SourceTarget.SOURCE_TARGET;
            }
            for (ResourceAttributeDefinitionType attr : resourceObjectTypeDefinition.getAttribute()) {
                if (hasInbound && hasOutbound) {
                    return SourceTarget.SOURCE_TARGET;
                }
                if (!hasOutbound) {
                    hasOutbound = isOutboundDefined(attr);
                }
                if (!hasInbound) {
                    hasInbound = isInboundDefined(attr);
                }
            }
        // TODO: what about situation that we have only
        }
        if (hasOutbound) {
            return SourceTarget.TARGET;
        }
        if (hasInbound) {
            return SourceTarget.SOURCE;
        }
    }
    return SourceTarget.NOT_DEFINED;
}
Also used : ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ResourceAttributeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType)

Aggregations

ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)252 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)199 Test (org.testng.annotations.Test)165 Task (com.evolveum.midpoint.task.api.Task)115 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)58 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)54 PrismObject (com.evolveum.midpoint.prism.PrismObject)50 QName (javax.xml.namespace.QName)45 ArrayList (java.util.ArrayList)37 Element (org.w3c.dom.Element)34 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)33 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)30 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)28 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)27 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)26 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)25 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)24 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)23 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)23