use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType in project midpoint by Evolveum.
the class ConfigurationStep method createConfigContainerWrappers.
@NotNull
private List<ContainerWrapper> createConfigContainerWrappers() throws SchemaException {
PrismObject<ResourceType> resource = resourceModelNoFetch.getObject();
PrismContainer<ConnectorConfigurationType> configuration = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
List<ContainerWrapper> containerWrappers = new ArrayList<>();
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();
((PrismContainerDefinitionImpl) definitionFixed).setMaxOccurs(1);
configuration = definitionFixed.instantiate();
}
List<PrismContainerDefinition> containerDefinitions = getSortedConfigContainerDefinitions(configuration);
for (PrismContainerDefinition<?> containerDef : containerDefinitions) {
ItemPath containerPath = new ItemPath(ResourceType.F_CONNECTOR_CONFIGURATION, containerDef.getName());
PrismContainer container = configuration.findContainer(containerDef.getName());
ContainerWrapperFactory cwf = new ContainerWrapperFactory(parentPage);
ContainerWrapper containerWrapper;
if (container != null) {
containerWrapper = cwf.createContainerWrapper(container, ContainerStatus.MODIFYING, containerPath, parentPage.isReadOnly());
} else {
container = containerDef.instantiate();
containerWrapper = cwf.createContainerWrapper(container, ContainerStatus.ADDING, containerPath, parentPage.isReadOnly());
}
containerWrappers.add(containerWrapper);
}
return containerWrappers;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType in project midpoint by Evolveum.
the class TestSchemaSanity method testResourceDefinition.
@Test
public void testResourceDefinition() {
System.out.println("===[ testResourceDefinition ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
// WHEN
PrismObjectDefinition<ResourceType> resourceDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON, "resource"));
assertNotNull("No resource definition", resourceDefinition);
System.out.println("Resource definition:");
System.out.println(resourceDefinition.debugDump());
PrismObjectDefinition<ResourceType> resourceDefinitionByClass = schemaRegistry.findObjectDefinitionByCompileTimeClass(ResourceType.class);
assertTrue("Different user def", resourceDefinition == resourceDefinitionByClass);
assertEquals("Wrong compile-time class in resource definition", ResourceType.class, resourceDefinition.getCompileTimeClass());
PrismAsserts.assertPropertyDefinition(resourceDefinition, ResourceType.F_NAME, PolyStringType.COMPLEX_TYPE, 0, 1);
PrismAsserts.assertPropertyDefinition(resourceDefinition, ResourceType.F_DESCRIPTION, DOMUtil.XSD_STRING, 0, 1);
assertFalse("Resource definition is marked as runtime", resourceDefinition.isRuntimeSchema());
PrismContainerDefinition<ConnectorConfigurationType> connectorConfContainerDef = resourceDefinition.findContainerDefinition(ResourceType.F_CONNECTOR_CONFIGURATION);
PrismAsserts.assertDefinition(connectorConfContainerDef, ResourceType.F_CONNECTOR_CONFIGURATION, ConnectorConfigurationType.COMPLEX_TYPE, 1, 1);
assertTrue("<connectorConfiguration> is NOT dynamic", connectorConfContainerDef.isDynamic());
// assertFalse("<connectorConfiguration> is runtime", connectorConfContainerDef.isRuntimeSchema());
assertEquals("Wrong compile-time class for <connectorConfiguration> in resource definition", ConnectorConfigurationType.class, connectorConfContainerDef.getCompileTimeClass());
PrismContainerDefinition<XmlSchemaType> schemaContainerDef = resourceDefinition.findContainerDefinition(ResourceType.F_SCHEMA);
PrismAsserts.assertDefinition(schemaContainerDef, ResourceType.F_SCHEMA, XmlSchemaType.COMPLEX_TYPE, 0, 1);
assertFalse("Schema is runtime", schemaContainerDef.isRuntimeSchema());
assertEquals("Wrong compile-time class for <schema> in resource definition", XmlSchemaType.class, schemaContainerDef.getCompileTimeClass());
assertEquals("Unexpected number of definitions in <schema>", 3, schemaContainerDef.getDefinitions().size());
PrismAsserts.assertPropertyDefinition(schemaContainerDef, XmlSchemaType.F_CACHING_METADATA, CachingMetadataType.COMPLEX_TYPE, 0, 1);
PrismAsserts.assertPropertyDefinition(schemaContainerDef, XmlSchemaType.F_DEFINITION, SchemaDefinitionType.COMPLEX_TYPE, 0, 1);
PrismPropertyDefinition definitionPropertyDef = schemaContainerDef.findPropertyDefinition(XmlSchemaType.F_DEFINITION);
assertNotNull("Null <definition> definition", definitionPropertyDef);
// assertFalse("schema/definition is NOT runtime", definitionPropertyDef.isRuntimeSchema());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType 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> configurationContainerDefintion = connectorSchema.findContainerDefinitionByElementName(configContainerQName);
((PrismContainerDefinitionImpl) configurationContainerDefintion).setCompileTimeClass(ConnectorConfigurationType.class);
return connectorSchema;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType in project midpoint by Evolveum.
the class TestUcfDummy method test020CreateConfiguredConnector.
@Test
public void test020CreateConfiguredConnector() throws Exception {
final String TEST_NAME = "test020CreateConfiguredConnector";
TestUtil.displayTestTile(TEST_NAME);
cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "test connector");
assertNotNull("Failed to instantiate connector", cc);
OperationResult result = new OperationResult(TestUcfDummy.class.getName() + "." + TEST_NAME);
PrismContainerValue<ConnectorConfigurationType> configContainer = resourceType.getConnectorConfiguration().asPrismContainerValue();
display("Configuration container", configContainer);
// WHEN
cc.configure(configContainer, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType in project midpoint by Evolveum.
the class TestUcfDummy method test000PrismContextSanity.
@Test
public void test000PrismContextSanity() throws Exception {
final String TEST_NAME = "test000PrismContextSanity";
TestUtil.displayTestTile(TEST_NAME);
SchemaRegistry schemaRegistry = PrismTestUtil.getPrismContext().getSchemaRegistry();
PrismSchema schemaIcfc = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_CONFIGURATION);
assertNotNull("ICFC schema not found in the context (" + SchemaConstants.NS_ICF_CONFIGURATION + ")", schemaIcfc);
PrismContainerDefinition<ConnectorConfigurationType> configurationPropertiesDef = schemaIcfc.findContainerDefinitionByElementName(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
assertNotNull("icfc:configurationProperties not found in icfc schema (" + SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME + ")", configurationPropertiesDef);
PrismSchema schemaIcfs = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_SCHEMA);
assertNotNull("ICFS schema not found in the context (" + SchemaConstants.NS_ICF_SCHEMA + ")", schemaIcfs);
}
Aggregations