use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.
the class ConnectorFactoryConnIdImpl method convertToConnectorType.
/**
* Converts ICF ConnectorInfo into a midPoint XML connector representation.
* <p>
* 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) {
// bind using connectorHostRef and OID
ObjectReferenceType ref = new ObjectReferenceType();
ref.setOid(hostType.getOid());
ref.setType(ObjectTypes.CONNECTOR_HOST.getTypeQName());
ref.asReferenceValue().setObject(hostType.asPrismObject());
connectorType.setConnectorHostRef(ref);
}
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.ConnectorType in project midpoint by Evolveum.
the class ConnectorFactoryConnIdImpl method listConnectors.
/**
* Returns a list XML representation of the ICF connectors.
*/
@Override
public Set<ConnectorType> listConnectors(ConnectorHostType host, OperationResult parentResult) throws CommunicationException {
OperationResult result = parentResult.createSubresult(ConnectorFactory.OPERATION_LIST_CONNECTORS);
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 = processConnIdException(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.ConnectorType in project midpoint by Evolveum.
the class ConnectorFactoryBuiltinImpl method createConnectorStruct.
private ConnectorStruct createConnectorStruct(Class<?> connectorClass, ManagedConnector annotation) throws SchemaException {
ConnectorStruct struct = new ConnectorStruct();
if (!ConnectorInstance.class.isAssignableFrom(connectorClass)) {
throw new IllegalStateException("Connector class " + connectorClass + " is not of ConnectorInstance type");
}
// noinspection unchecked
struct.connectorClass = (Class<? extends ConnectorInstance>) connectorClass;
ConnectorType connectorType = new ConnectorType();
String bundleName = connectorClass.getPackage().getName();
String type = annotation.type();
if (type.isEmpty()) {
type = connectorClass.getSimpleName();
}
String version = annotation.version();
UcfUtil.addConnectorNames(connectorType, "Built-in", bundleName, type, version, null);
connectorType.setConnectorBundle(bundleName);
connectorType.setConnectorType(type);
connectorType.setConnectorVersion(version);
connectorType.setFramework(SchemaConstants.UCF_FRAMEWORK_URI_BUILTIN);
String namespace = CONFIGURATION_NAMESPACE_PREFIX + bundleName + "/" + type;
connectorType.setNamespace(namespace);
struct.connectorObject = connectorType;
PrismSchema connectorSchema = generateConnectorConfigurationSchema(struct);
// noinspection ConstantConditions (probably can be null in the future)
if (connectorSchema != null) {
LOGGER.trace("Generated connector schema for {}: {} definitions", connectorType, connectorSchema.getDefinitions().size());
UcfUtil.setConnectorSchema(connectorType, connectorSchema);
struct.connectorConfigurationSchema = connectorSchema;
} else {
LOGGER.warn("No connector schema generated for {}", connectorType);
}
return struct;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.
the class ConfigurationStep method createConfigContainerWrappers.
// @NotNull
private PrismContainerWrapper<ConnectorConfigurationType> createConfigContainerWrappers() throws SchemaException {
PrismObject<ResourceType> resource = resourceModelNoFetch.getObject();
PrismContainer<ConnectorConfigurationType> configuration = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
if (parentPage.isNewResource()) {
return null;
}
ItemStatus configurationStatus = ItemStatus.NOT_CHANGED;
if (configuration == null) {
PrismObject<ConnectorType> connector = ResourceTypeUtil.getConnectorIfPresent(resource);
if (connector == null) {
throw new IllegalStateException("No resolved connector object in resource object");
}
ConnectorType connectorType = connector.asObjectable();
PrismSchema schema;
try {
schema = ConnectorTypeUtil.parseConnectorSchema(connectorType, parentPage.getPrismContext());
} catch (SchemaException e) {
throw new SystemException("Couldn't parse connector schema: " + e.getMessage(), e);
}
PrismContainerDefinition<ConnectorConfigurationType> definition = ConnectorTypeUtil.findConfigurationContainerDefinition(connectorType, schema);
// Fixing (errorneously) set maxOccurs = unbounded. See MID-2317 and related issues.
PrismContainerDefinition<ConnectorConfigurationType> definitionFixed = definition.clone();
definitionFixed.toMutable().setMaxOccurs(1);
configuration = definitionFixed.instantiate();
configurationStatus = ItemStatus.ADDED;
}
Task task = getPageBase().createSimpleTask(OPERATION_CREATE_CONFIGURATION_WRAPPERS);
WrapperContext ctx = new WrapperContext(task, getResult());
ctx.setReadOnly(parentPage.isReadOnly());
ctx.setShowEmpty(ItemStatus.ADDED == configurationStatus);
return getPageBase().createItemWrapper(configuration, configurationStatus, ctx);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.
the class NameStep method discoverConnectorsPerformed.
@SuppressWarnings("unchecked")
private void discoverConnectorsPerformed(AjaxRequestTarget target) {
DropDownChoice<PrismObject<ConnectorHostType>> connectorHostChoice = ((DropDownFormGroup<PrismObject<ConnectorHostType>>) get(ID_CONNECTOR_HOST)).getInput();
PrismObject<ConnectorHostType> connectorHostObject = connectorHostChoice.getModelObject();
ConnectorHostType host = connectorHostObject != null ? connectorHostObject.asObjectable() : null;
if (host != null) {
discoverConnectors(host);
allConnectorsModel.reset();
}
relevantConnectorsModel.reset();
DropDownFormGroup<PrismObject<ConnectorType>> connectorDropDown = getConnectorDropDown();
PrismObject<ConnectorType> selectedConnector = connectorDropDown.getInput().getModelObject();
if (selectedConnector != null) {
if (!isConnectorOnHost(selectedConnector, connectorHostObject)) {
PrismObject<ConnectorType> compatibleConnector = null;
for (PrismObject<ConnectorType> relevantConnector : relevantConnectorsModel.getObject()) {
if (isConfigurationSchemaCompatible(relevantConnector)) {
compatibleConnector = relevantConnector;
break;
}
}
selectedConnectorModel.setObject(compatibleConnector);
}
}
target.add(connectorDropDown.getInput(), connectorDropDown.getAdditionalInfoComponent(), ((PageBase) getPage()).getFeedbackPanel());
}
Aggregations