Search in sources :

Example 6 with ConnectorHostType

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

the class ConnectorFactoryConnIdImpl method listConnectors.

/**
	 * Returns a list XML representation of the ICF connectors.
	 * 
	 * @throws CommunicationException
	 */
@Override
public Set<ConnectorType> listConnectors(ConnectorHostType host, OperationResult parentRestul) throws CommunicationException {
    OperationResult result = parentRestul.createSubresult(ConnectorFactory.OPERATION_LIST_CONNECTOR);
    result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ConnectorFactoryConnIdImpl.class);
    result.addParam("host", host);
    try {
        if (host == null) {
            Set<ConnectorType> connectors = listLocalConnectors();
            result.recordSuccess();
            return connectors;
        } else {
            // This is necessary as list of the remote connectors is cached locally.
            // So if any remote connector is added then it will not be discovered unless we
            // clear the cache. This may look like inefficiency but in fact the listConnectors() method is
            // used only when discovering new connectors. Normal connector operation is using connector objects
            // stored in repository.
            connectorInfoManagerFactory.clearRemoteCache();
            Set<ConnectorType> connectors = listRemoteConnectors(host);
            result.recordSuccess();
            return connectors;
        }
    } catch (Throwable icfException) {
        Throwable ex = processIcfException(icfException, "list connectors", result);
        result.recordFatalError(ex.getMessage(), ex);
        if (ex instanceof CommunicationException) {
            throw (CommunicationException) ex;
        } else if (ex instanceof RuntimeException) {
            throw (RuntimeException) ex;
        } else if (ex instanceof Error) {
            throw (Error) ex;
        } else {
            throw new SystemException("Unexpected ICF exception: " + ex.getMessage(), ex);
        }
    }
}
Also used : ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 7 with ConnectorHostType

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

the class ConnectorFactoryConnIdImpl method convertToConnectorType.

/**
	 * Converts ICF ConnectorInfo into a midPoint XML connector representation.
	 * 
	 * TODO: schema transformation
	 * 
	 * @param hostType
	 *            host that this connector runs on or null for local connectors
	 */
private ConnectorType convertToConnectorType(ConnectorInfo cinfo, ConnectorHostType hostType) throws SchemaException {
    ConnectorType connectorType = new ConnectorType();
    ConnectorKey key = cinfo.getConnectorKey();
    UcfUtil.addConnectorNames(connectorType, "ConnId", key.getBundleName(), key.getConnectorName(), key.getBundleVersion(), hostType);
    String stringID = keyToNamespaceSuffix(key);
    connectorType.setFramework(SchemaConstants.ICF_FRAMEWORK_URI);
    connectorType.setConnectorType(key.getConnectorName());
    connectorType.setNamespace(ICF_CONFIGURATION_NAMESPACE_PREFIX + stringID);
    connectorType.setConnectorVersion(key.getBundleVersion());
    connectorType.setConnectorBundle(key.getBundleName());
    if (hostType != null) {
        if (hostType.getOid() != null) {
            // bind using connectorHostRef and OID
            ObjectReferenceType ref = new ObjectReferenceType();
            ref.setOid(hostType.getOid());
            ref.setType(ObjectTypes.CONNECTOR_HOST.getTypeQName());
            connectorType.setConnectorHostRef(ref);
        } else {
            // Embed the object
            connectorType.setConnectorHost(hostType);
        }
    }
    PrismSchema connectorSchema = generateConnectorConfigurationSchema(cinfo, connectorType);
    LOGGER.trace("Generated connector schema for {}: {} definitions", connectorType, connectorSchema.getDefinitions().size());
    UcfUtil.setConnectorSchema(connectorType, connectorSchema);
    return connectorType;
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) ConnectorKey(org.identityconnectors.framework.api.ConnectorKey) GuardedString(org.identityconnectors.common.security.GuardedString)

Example 8 with ConnectorHostType

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

the class NameStep method createHostDropDown.

@NotNull
private DropDownFormGroup<PrismObject<ConnectorHostType>> createHostDropDown() {
    return new DropDownFormGroup<PrismObject<ConnectorHostType>>(ID_CONNECTOR_HOST, selectedHostModel, allHostsModel, new IChoiceRenderer<PrismObject<ConnectorHostType>>() {

        @Override
        public PrismObject<ConnectorHostType> getObject(String id, IModel<? extends List<? extends PrismObject<ConnectorHostType>>> choices) {
            if (StringUtils.isBlank(id)) {
                return null;
            }
            return choices.getObject().get(Integer.parseInt(id));
        }

        @Override
        public Object getDisplayValue(PrismObject<ConnectorHostType> object) {
            if (object == null) {
                return NameStep.this.getString("NameStep.hostNotUsed");
            }
            return ConnectorHostTypeComparator.getUserFriendlyName(object);
        }

        @Override
        public String getIdValue(PrismObject<ConnectorHostType> object, int index) {
            return Integer.toString(index);
        }
    }, createStringResource("NameStep.connectorHost"), "col-md-3", "col-md-6", false) {

        @Override
        protected DropDownChoice<PrismObject<ConnectorHostType>> createDropDown(String id, IModel<List<PrismObject<ConnectorHostType>>> choices, IChoiceRenderer<PrismObject<ConnectorHostType>> renderer, boolean required) {
            DropDownChoice<PrismObject<ConnectorHostType>> choice = super.createDropDown(id, choices, renderer, required);
            choice.add(new AjaxFormComponentUpdatingBehavior("change") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    discoverConnectorsPerformed(target);
                }
            });
            return choice;
        }
    };
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IModel(org.apache.wicket.model.IModel) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismObject(com.evolveum.midpoint.prism.PrismObject) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with ConnectorHostType

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

the class PageConnectorHosts method initConnectorHostsColumns.

private List<IColumn<ConnectorHostType, String>> initConnectorHostsColumns() {
    List<IColumn<ConnectorHostType, String>> columns = new ArrayList<>();
    IColumn column = new CheckBoxHeaderColumn<ConnectorHostType>();
    columns.add(column);
    column = new LinkColumn<SelectableBean<ConnectorHostType>>(createStringResource("pageResources.connector.name"), "name", "value.name") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ConnectorHostType>> rowModel) {
            ConnectorHostType host = rowModel.getObject().getValue();
        // resourceDetailsPerformed(target, host.getOid());
        }
    };
    columns.add(column);
    columns.add(new PropertyColumn(createStringResource("pageResources.connector.hostname"), "value.hostname"));
    columns.add(new PropertyColumn(createStringResource("pageResources.connector.port"), "value.port"));
    columns.add(new PropertyColumn(createStringResource("pageResources.connector.timeout"), "value.timeout"));
    columns.add(new CheckBoxColumn(createStringResource("pageResources.connector.protectConnection"), "value.protectConnection"));
    InlineMenuHeaderColumn menu = new InlineMenuHeaderColumn(initInlineHostsMenu());
    columns.add(menu);
    return columns;
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) CheckBoxColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 10 with ConnectorHostType

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

the class PageConnectorHosts method discoveryRemotePerformed.

private void discoveryRemotePerformed(AjaxRequestTarget target) {
    target.add(getFeedbackPanel());
    PageBase page = (PageBase) getPage();
    Task task = page.createSimpleTask(OPERATION_CONNECTOR_DISCOVERY);
    OperationResult result = task.getResult();
    List<SelectableBean<ConnectorHostType>> selected = WebComponentUtil.getSelectedData(getConnectorHostTable());
    if (selected.isEmpty()) {
        warn(getString("pageResources.message.noHostSelected"));
        return;
    }
    for (SelectableBean<ConnectorHostType> bean : selected) {
        if (bean.getValue() != null) {
            ConnectorHostType host = bean.getValue();
            try {
                getModelService().discoverConnectors(host, task, result);
            } catch (Exception ex) {
                result.recordFatalError("Fail to discover connectors on host '" + host.getHostname() + ":" + host.getPort() + "'", ex);
            }
        }
    }
    result.recomputeStatus();
    showResult(result);
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) Task(com.evolveum.midpoint.task.api.Task) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Aggregations

ConnectorHostType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType)9 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 Task (com.evolveum.midpoint.task.api.Task)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)3 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 DropDownFormGroup (com.evolveum.midpoint.web.component.form.DropDownFormGroup)2 HashSet (java.util.HashSet)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 ConnectorKey (org.identityconnectors.framework.api.ConnectorKey)2 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 PipelineItem (com.evolveum.midpoint.model.api.PipelineItem)1 ScriptExecutionException (com.evolveum.midpoint.model.api.ScriptExecutionException)1 PipelineData (com.evolveum.midpoint.model.impl.scripting.PipelineData)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1