private AssignmentItemDto createAssignmentItem( PrismObject<UserType> user, PrismContainerValue assignment, Task task, OperationResult result) { PrismReference targetRef = assignment.findReference(AssignmentType.F_TARGET_REF); if (targetRef == null || targetRef.isEmpty()) { // account construction PrismContainer construction = assignment.findContainer(AssignmentType.F_CONSTRUCTION); String name = null; String description = null; if (construction.getValue().asContainerable() != null && !construction.isEmpty()) { ConstructionType constr = (ConstructionType) construction.getValue().asContainerable(); description = (String) construction.getPropertyRealValue(ConstructionType.F_DESCRIPTION, String.class); if (constr.getResourceRef() != null) { ObjectReferenceType resourceRef = constr.getResourceRef(); PrismObject resource = WebModelUtils.loadObject( ResourceType.class, resourceRef.getOid(), this, task, result); name = WebMiscUtil.getName(resource); } } return new AssignmentItemDto( AssignmentEditorDtoType.ACCOUNT_CONSTRUCTION, name, description, null); } PrismReferenceValue refValue = targetRef.getValue(); PrismObject value = refValue.getObject(); if (value == null) { // resolve reference value = WebModelUtils.loadObject(ObjectType.class, refValue.getOid(), this, task, result); } if (value == null) { // we couldn't resolve assignment details return new AssignmentItemDto(null, null, null, null); } String name = WebMiscUtil.getName(value); AssignmentEditorDtoType type = AssignmentEditorDtoType.getType(value.getCompileTimeClass()); String relation = refValue.getRelation() != null ? refValue.getRelation().getLocalPart() : null; String description = null; if (RoleType.class.isAssignableFrom(value.getCompileTimeClass())) { description = (String) value.getPropertyRealValue(RoleType.F_DESCRIPTION, String.class); } return new AssignmentItemDto(type, name, description, relation); }
/** * Transforms midPoint XML configuration of the connector to the ICF configuration. * * <p>The "configuration" part of the XML resource definition will be used. * * <p>The provided ICF APIConfiguration will be modified, some values may be overwritten. * * @param apiConfig ICF connector configuration * @param resourceType midPoint XML configuration * @throws SchemaException * @throws ConfigurationException */ public APIConfiguration transformConnectorConfiguration(PrismContainerValue configuration) throws SchemaException, ConfigurationException { APIConfiguration apiConfig = cinfo.createDefaultAPIConfiguration(); ConfigurationProperties configProps = apiConfig.getConfigurationProperties(); // The namespace of all the configuration properties specific to the // connector instance will have a connector instance namespace. This // namespace can be found in the resource definition. String connectorConfNs = connectorType.getNamespace(); PrismContainer configurationPropertiesContainer = configuration.findContainer( ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); if (configurationPropertiesContainer == null) { // Also try this. This is an older way. configurationPropertiesContainer = configuration.findContainer( new QName( connectorConfNs, ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_LOCAL_NAME)); } transformConnectorConfiguration(configProps, configurationPropertiesContainer, connectorConfNs); PrismContainer connectorPoolContainer = configuration.findContainer( new QName( ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION, ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_XML_ELEMENT_NAME)); ObjectPoolConfiguration connectorPoolConfiguration = apiConfig.getConnectorPoolConfiguration(); transformConnectorPoolConfiguration(connectorPoolConfiguration, connectorPoolContainer); PrismProperty producerBufferSizeProperty = configuration.findProperty( new QName( ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION, ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_PRODUCER_BUFFER_SIZE_XML_ELEMENT_NAME)); if (producerBufferSizeProperty != null) { apiConfig.setProducerBufferSize(parseInt(producerBufferSizeProperty)); } PrismContainer connectorTimeoutsContainer = configuration.findContainer( new QName( ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION, ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_TIMEOUTS_XML_ELEMENT_NAME)); transformConnectorTimeoutsConfiguration(apiConfig, connectorTimeoutsContainer); PrismContainer resultsHandlerConfigurationContainer = configuration.findContainer( new QName( ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION, ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT_LOCAL_NAME)); ResultsHandlerConfiguration resultsHandlerConfiguration = apiConfig.getResultsHandlerConfiguration(); transformResultsHandlerConfiguration( resultsHandlerConfiguration, resultsHandlerConfigurationContainer); return apiConfig; }