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);
}
}
}
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;
}
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;
}
};
}
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;
}
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);
}
Aggregations