use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.
the class NameStep method isConfigurationSchemaCompatible.
private boolean isConfigurationSchemaCompatible(PrismObject<ConnectorType> newConnectorObject) {
if (newConnectorObject == null) {
// shouldn't occur
return true;
}
PrismContainer<?> configuration = ResourceTypeUtil.getConfigurationContainer(resourceModelRaw.getObject());
if (configuration == null || configuration.isEmpty() || configuration.getValue().hasNoItems()) {
// no config -> no loss
return true;
}
// for the time being let us simply compare namespaces of the current and old connector
PrismObject<ConnectorType> existingConnectorObject = getExistingConnector();
if (existingConnectorObject == null) {
return true;
}
ConnectorType existingConnector = existingConnectorObject.asObjectable();
ConnectorType newConnector = newConnectorObject.asObjectable();
return StringUtils.equals(existingConnector.getNamespace(), newConnector.getNamespace());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.
the class ConnectorTypeUtil method parseConnectorSchema.
/**
* Returns parsed connector schema
*/
public static PrismSchema parseConnectorSchema(ConnectorType connectorType, PrismContext prismContext) throws SchemaException {
Element connectorSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(connectorType);
if (connectorSchemaElement == null) {
return null;
}
PrismSchema connectorSchema = PrismSchemaImpl.parse(connectorSchemaElement, true, "schema for " + connectorType, prismContext);
// Make sure that the config container definition has a correct compile-time class name
QName configContainerQName = new QName(connectorType.getNamespace(), ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart());
PrismContainerDefinition<ConnectorConfigurationType> configurationContainerDefinition = connectorSchema.findContainerDefinitionByElementName(configContainerQName);
configurationContainerDefinition.toMutable().setCompileTimeClass(ConnectorConfigurationType.class);
return connectorSchema;
}
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 ObjectNotFoundException, SchemaException {
ConnectorStruct struct = new ConnectorStruct();
struct.connectorClass = connectorClass;
ConnectorType connectorType = new ConnectorType();
String bundleName = connectorClass.getPackage().getName();
String type = annotation.type();
if (type == null || 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.setVersion(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);
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 AbstractAdTest method test001ConnectorHostDiscovery.
@Test
public void test001ConnectorHostDiscovery() throws Exception {
final String TEST_NAME = "test001ConnectorHostDiscovery";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.discoverConnectors(connectorHostType, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
SearchResultList<PrismObject<ConnectorType>> connectors = modelService.searchObjects(ConnectorType.class, null, null, task, result);
boolean found = false;
for (PrismObject<ConnectorType> connector : connectors) {
if (CONNECTOR_AD_TYPE.equals(connector.asObjectable().getConnectorType())) {
display("Found connector", connector);
found = true;
}
}
assertTrue("AD Connector not found", found);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.
the class TestSanity method test002AddDerbyResource.
@Test
public void test002AddDerbyResource() throws Exception {
final String TEST_NAME = "test002AddDerbyResource";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME);
checkRepoOpenDjResource();
assertNoRepoCache();
PrismObject<ResourceType> resource = PrismTestUtil.parseObject(new File(RESOURCE_DERBY_FILENAME));
assertParentConsistency(resource);
fillInConnectorRef(resource, IntegrationTestTools.DBTABLE_CONNECTOR_TYPE, result);
OperationResultType resultType = new OperationResultType();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(resultType);
Holder<String> oidHolder = new Holder<String>();
display("Adding Derby Resource", resource);
// WHEN
addObjectViaModelWS(resource.asObjectable(), null, oidHolder, resultHolder);
// THEN
// Check if Derby resource was imported correctly
PrismObject<ResourceType> derbyResource = repositoryService.getObject(ResourceType.class, RESOURCE_DERBY_OID, null, result);
AssertJUnit.assertEquals(RESOURCE_DERBY_OID, derbyResource.getOid());
assertNoRepoCache();
String dbConnectorOid = derbyResource.asObjectable().getConnectorRef().getOid();
PrismObject<ConnectorType> dbConnector = repositoryService.getObject(ConnectorType.class, dbConnectorOid, null, result);
display("DB Connector: ", dbConnector);
// Check if password was encrypted during import
// via JAXB
Object configurationPropertiesElement = JAXBUtil.findElement(derbyResource.asObjectable().getConnectorConfiguration().getAny(), new QName(dbConnector.asObjectable().getNamespace(), "configurationProperties"));
Object passwordElement = JAXBUtil.findElement(JAXBUtil.listChildElements(configurationPropertiesElement), new QName(dbConnector.asObjectable().getNamespace(), "password"));
System.out.println("Password element: " + passwordElement);
// via prisms
PrismContainerValue configurationProperties = derbyResource.findContainer(new ItemPath(ResourceType.F_CONNECTOR_CONFIGURATION, new QName("configurationProperties"))).getValue();
PrismProperty password = configurationProperties.findProperty(new QName(dbConnector.asObjectable().getNamespace(), "password"));
System.out.println("Password property: " + password);
}
Aggregations