Search in sources :

Example 36 with ResourceType

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

the class PageResources method initResourceColumns.

private List<IColumn<SelectableBean<ResourceType>, String>> initResourceColumns() {
    List<IColumn<SelectableBean<ResourceType>, String>> columns = new ArrayList<>();
    columns.add(new PropertyColumn(createStringResource("pageResources.connectorType"), SelectableBean.F_VALUE + ".connector.connectorType"));
    columns.add(new PropertyColumn(createStringResource("pageResources.version"), SelectableBean.F_VALUE + ".connector.connectorVersion"));
    return columns;
}
Also used : IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)

Example 37 with ResourceType

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

the class PageResources method deleteResourcePerformed.

private void deleteResourcePerformed(AjaxRequestTarget target, ResourceType single) {
    List<ResourceType> selected = isAnyResourceSelected(target, single);
    singleDelete = single;
    if (selected.isEmpty()) {
        return;
    }
    ConfirmationPanel dialog = new ConfirmationPanel(((PageBase) getPage()).getMainPopupBodyId(), createDeleteConfirmString("pageResources.message.deleteResourceConfirm", "pageResources.message.deleteResourcesConfirm", true)) {

        @Override
        public void yesPerformed(AjaxRequestTarget target) {
            ((PageBase) getPage()).hideMainPopup(target);
            deleteResourceConfirmedPerformed(target);
        }
    };
    ((PageBase) getPage()).showMainPopup(dialog, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 38 with ResourceType

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

the class PageResources method deleteResourceConfirmedPerformed.

private void deleteResourceConfirmedPerformed(AjaxRequestTarget target) {
    List<ResourceType> selected = new ArrayList<>();
    if (singleDelete != null) {
        selected.add(singleDelete);
    } else {
        selected = getResourceTable().getSelectedObjects();
    }
    OperationResult result = new OperationResult(OPERATION_DELETE_RESOURCES);
    for (ResourceType resource : selected) {
        try {
            Task task = createSimpleTask(OPERATION_DELETE_RESOURCES);
            ObjectDelta<ResourceType> delta = ObjectDelta.createDeleteDelta(ResourceType.class, resource.getOid(), getPrismContext());
            getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
        } catch (Exception ex) {
            result.recordPartialError("Couldn't delete resource.", ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete resource", ex);
        }
    }
    result.recomputeStatus();
    if (result.isSuccess()) {
        result.recordStatus(OperationResultStatus.SUCCESS, "The resource(s) have been successfully deleted.");
    }
    getResourceTable().clearCache();
    showResult(result);
    target.add(getFeedbackPanel(), (Component) getResourceTable());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 39 with ResourceType

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

the class ResourceContentPanel method newTaskPerformed.

private void newTaskPerformed(String category, AjaxRequestTarget target) {
    TaskType taskType = new TaskType();
    PrismProperty<ShadowKindType> pKind;
    try {
        pKind = taskType.asPrismObject().findOrCreateProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND));
        pKind.setRealValue(getKind());
    } catch (SchemaException e) {
        getSession().warn("Could not set kind for new task " + e.getMessage());
    }
    PrismProperty<String> pIntent;
    try {
        pIntent = taskType.asPrismObject().findOrCreateProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT));
        pIntent.setRealValue(getIntent());
    } catch (SchemaException e) {
        getSession().warn("Could not set kind for new task " + e.getMessage());
    }
    PrismObject<ResourceType> resource = getResourceModel().getObject();
    taskType.setObjectRef(ObjectTypeUtil.createObjectRef(resource));
    taskType.setCategory(category);
    setResponsePage(new PageTaskAdd(taskType));
    ;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PageTaskAdd(com.evolveum.midpoint.web.page.admin.server.PageTaskAdd)

Example 40 with ResourceType

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

the class PageResourceEdit method updateConnectorRef.

/**
     * Method which attempts to resolve connector reference filter to actual connector (if necessary).
     *
     * @param resource {@link PrismObject} resource
     */
private void updateConnectorRef(PrismObject<ResourceType> resource, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    if (resource == null) {
        return;
    }
    PrismReference resourceRef = resource.findReference(ResourceType.F_CONNECTOR_REF);
    if (resourceRef == null || resourceRef.getValue() == null) {
        return;
    }
    PrismReferenceValue refValue = resourceRef.getValue();
    if (StringUtils.isNotEmpty(refValue.getOid())) {
        return;
    }
    if (refValue.getFilter() == null) {
        return;
    }
    SchemaRegistry registry = getPrismContext().getSchemaRegistry();
    PrismObjectDefinition objDef = registry.findObjectDefinitionByCompileTimeClass(ConnectorType.class);
    ObjectFilter filter = QueryConvertor.parseFilter(refValue.getFilter(), objDef);
    List<PrismObject<ConnectorType>> connectors = getModelService().searchObjects(ConnectorType.class, ObjectQuery.createObjectQuery(filter), null, task, result);
    if (connectors.size() != 1) {
        return;
    }
    PrismObject<ConnectorType> connector = connectors.get(0);
    refValue.setOid(connector.getOid());
    refValue.setTargetType(ConnectorType.COMPLEX_TYPE);
    refValue.setFilter(null);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) PrismReference(com.evolveum.midpoint.prism.PrismReference) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry)

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