use of com.evolveum.midpoint.web.component.prism.ContainerWrapperFactory 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;
}
Aggregations