private void transformConnectorTimeoutsConfiguration( APIConfiguration apiConfig, PrismContainer<?> connectorTimeoutsContainer) throws SchemaException { if (connectorTimeoutsContainer == null || connectorTimeoutsContainer.getValue() == null) { return; } for (PrismProperty prismProperty : connectorTimeoutsContainer.getValue().getProperties()) { QName propertQName = prismProperty.getElementName(); if (ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION.equals(propertQName.getNamespaceURI())) { String opName = propertQName.getLocalPart(); Class<? extends APIOperation> apiOpClass = ConnectorFactoryIcfImpl.resolveApiOpClass(opName); if (apiOpClass != null) { apiConfig.setTimeout(apiOpClass, parseInt(prismProperty)); } else { throw new SchemaException( "Unknown operation name " + opName + " in " + ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_TIMEOUTS_XML_ELEMENT_NAME); } } } }
private void transformResultsHandlerConfiguration( ResultsHandlerConfiguration resultsHandlerConfiguration, PrismContainer<?> resultsHandlerConfigurationContainer) throws SchemaException { if (resultsHandlerConfigurationContainer == null || resultsHandlerConfigurationContainer.getValue() == null) { return; } for (PrismProperty prismProperty : resultsHandlerConfigurationContainer.getValue().getProperties()) { QName propertyQName = prismProperty.getElementName(); if (propertyQName.getNamespaceURI().equals(ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION)) { String subelementName = propertyQName.getLocalPart(); if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ENABLE_NORMALIZING_RESULTS_HANDLER .equals(subelementName)) { resultsHandlerConfiguration.setEnableNormalizingResultsHandler( parseBoolean(prismProperty)); } else if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ENABLE_FILTERED_RESULTS_HANDLER.equals( subelementName)) { resultsHandlerConfiguration.setEnableFilteredResultsHandler(parseBoolean(prismProperty)); } else if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_FILTERED_RESULTS_HANDLER_IN_VALIDATION_MODE .equals(subelementName)) { resultsHandlerConfiguration.setFilteredResultsHandlerInValidationMode( parseBoolean(prismProperty)); } else if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ENABLE_CASE_INSENSITIVE_HANDLER.equals( subelementName)) { resultsHandlerConfiguration.setEnableCaseInsensitiveFilter(parseBoolean(prismProperty)); } else if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ENABLE_ATTRIBUTES_TO_GET_SEARCH_RESULTS_HANDLER .equals(subelementName)) { resultsHandlerConfiguration.setEnableAttributesToGetSearchResultsHandler( parseBoolean(prismProperty)); } else { throw new SchemaException( "Unexpected element " + propertyQName + " in " + ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT_LOCAL_NAME); } } else { throw new SchemaException( "Unexpected element " + propertyQName + " in " + ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT_LOCAL_NAME); } } }
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); }
private void transformConnectorPoolConfiguration( ObjectPoolConfiguration connectorPoolConfiguration, PrismContainer<?> connectorPoolContainer) throws SchemaException { if (connectorPoolContainer == null || connectorPoolContainer.getValue() == null) { return; } for (PrismProperty prismProperty : connectorPoolContainer.getValue().getProperties()) { QName propertyQName = prismProperty.getElementName(); if (propertyQName.getNamespaceURI().equals(ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION)) { String subelementName = propertyQName.getLocalPart(); if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_MIN_EVICTABLE_IDLE_TIME_MILLIS.equals( subelementName)) { connectorPoolConfiguration.setMinEvictableIdleTimeMillis(parseLong(prismProperty)); } else if (ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_MIN_IDLE .equals(subelementName)) { connectorPoolConfiguration.setMinIdle(parseInt(prismProperty)); } else if (ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_MAX_IDLE .equals(subelementName)) { connectorPoolConfiguration.setMaxIdle(parseInt(prismProperty)); } else if (ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_MAX_OBJECTS .equals(subelementName)) { connectorPoolConfiguration.setMaxObjects(parseInt(prismProperty)); } else if (ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_MAX_WAIT .equals(subelementName)) { connectorPoolConfiguration.setMaxWait(parseLong(prismProperty)); } else { throw new SchemaException( "Unexpected element " + propertyQName + " in " + ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_XML_ELEMENT_NAME); } } else { throw new SchemaException( "Unexpected element " + propertyQName + " in " + ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_XML_ELEMENT_NAME); } } }
public static <T> T deserializeValue( String value, Class clazz, QName itemName, ItemDefinition itemDef, PrismContext prismContext, String language) throws SchemaException { // System.out.println("item value deserialization"); XNode xnode = prismContext.getParserDom().parse(value); // System.out.println("xnode: " + xnode.debugDump()); XNode xmap = null; if (xnode instanceof RootXNode) { xmap = ((RootXNode) xnode).getSubnode(); } // System.out.println("xmap: " + xmap); // else if (xnode instanceof MapXNode){ // xmap = (MapXNode) xnode; // } else if (xnode instanceof PrimitiveXNode){ // xmap = new MapXNode(); // xmap.put(itemName, xnode); // } Item item = prismContext.getXnodeProcessor().parseItem(xmap, itemName, itemDef); // System.out.println("item: " + item.debugDump()); if (item instanceof PrismProperty) { PrismProperty prop = (PrismProperty) item; if (prop.isSingleValue()) { return (T) prop.getRealValue(); } return (T) prop.getRealValues(); } else if (item instanceof PrismContainer) { PrismContainer cont = (PrismContainer) item; return (T) cont.getValue().asContainerable(); } else if (item instanceof PrismReference) { PrismReference ref = (PrismReference) item; return (T) ref.getValue(); } if (item != null) { return (T) item.getValue(0); } // if (prismContext.getBeanConverter().canConvert(clazz)){ // prismContext.getBeanConverter().unmarshall(xmap, clazz); // } else{ // prismContext.getXnodeProcessor().parseContainer(xnode, clazz); // } throw new UnsupportedOperationException("need to be implemented"); }
@Test public void testParseModelContextPrism() throws Exception { System.out.println("===[ testParseModelContextPrism ]==="); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN PrismContainer<LensContextType> lensContextType = prismContext.parseContainer( MODEL_CONTEXT_FILE, LensContextType.class, PrismContext.LANG_XML); // THEN System.out.println("Parsed LensContextType: " + lensContextType.getValue().asContainerable()); }
private void assertTask(PrismObject<TaskType> task) { task.checkConsistence(); assertEquals("Wrong oid", "44444444-4444-4444-4444-000000001111", task.getOid()); PrismObjectDefinition<TaskType> usedDefinition = task.getDefinition(); assertNotNull("No task definition", usedDefinition); PrismAsserts.assertObjectDefinition( usedDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "task"), TaskType.COMPLEX_TYPE, TaskType.class); assertEquals("Wrong class in task", TaskType.class, task.getCompileTimeClass()); TaskType taskType = task.asObjectable(); assertNotNull("asObjectable resulted in null", taskType); assertPropertyValue(task, "name", PrismTestUtil.createPolyString("Task2")); assertPropertyDefinition(task, "name", PolyStringType.COMPLEX_TYPE, 0, 1); assertPropertyValue(task, "taskIdentifier", "44444444-4444-4444-4444-000000001111"); assertPropertyDefinition(task, "taskIdentifier", DOMUtil.XSD_STRING, 0, 1); assertPropertyDefinition( task, "executionStatus", JAXBUtil.getTypeQName(TaskExecutionStatusType.class), 1, 1); PrismProperty<TaskExecutionStatusType> executionStatusProperty = task.findProperty(TaskType.F_EXECUTION_STATUS); PrismPropertyValue<TaskExecutionStatusType> executionStatusValue = executionStatusProperty.getValue(); TaskExecutionStatusType executionStatus = executionStatusValue.getValue(); assertEquals("Wrong execution status", TaskExecutionStatusType.RUNNABLE, executionStatus); PrismContainer extension = task.getExtension(); PrismContainerValue extensionValue = extension.getValue(); assertTrue("Extension parent", extensionValue.getParent() == extension); assertNull("Extension ID", extensionValue.getId()); }
private void transformConnectorConfiguration( ConfigurationProperties configProps, PrismContainer<?> configurationPropertiesContainer, String connectorConfNs) throws ConfigurationException, SchemaException { if (configurationPropertiesContainer == null || configurationPropertiesContainer.getValue() == null) { throw new SchemaException("No configuration properties container in " + connectorType); } int numConfingProperties = 0; List<QName> wrongNamespaceProperties = new ArrayList<>(); for (PrismProperty prismProperty : configurationPropertiesContainer.getValue().getProperties()) { QName propertyQName = prismProperty.getElementName(); // All the elements must be in a connector instance // namespace. if (propertyQName.getNamespaceURI() == null || !propertyQName.getNamespaceURI().equals(connectorConfNs)) { LOGGER.warn( "Found element with a wrong namespace ({}) in {}", propertyQName.getNamespaceURI(), connectorType); wrongNamespaceProperties.add(propertyQName); } else { numConfingProperties++; // Local name of the element is the same as the name // of ICF configuration property String propertyName = propertyQName.getLocalPart(); ConfigurationProperty property = configProps.getProperty(propertyName); if (property == null) { throw new ConfigurationException("Unknown configuration property " + propertyName); } // Check (java) type of ICF configuration property, // behave accordingly Class<?> type = property.getType(); if (type.isArray()) { property.setValue(convertToIcfArray(prismProperty, type.getComponentType())); // property.setValue(prismProperty.getRealValuesArray(type.getComponentType())); } else { // Single-valued property are easy to convert property.setValue(convertToIcfSingle(prismProperty, type)); // property.setValue(prismProperty.getRealValue(type)); } } } // empty configuration is OK e.g. when creating a new resource using wizard if (numConfingProperties == 0 && !wrongNamespaceProperties.isEmpty()) { throw new SchemaException( "No configuration properties found. Wrong namespace? (expected: " + connectorConfNs + ", present e.g. " + wrongNamespaceProperties.get(0) + ")"); } }
@Override public String getCaseInfoButtonTitle( IModel<? extends CertCaseOrDecisionDto> rowModel, PageBase page) { CertCaseOrDecisionDto dto = rowModel.getObject(); AccessCertificationCaseType _case = dto.getCertCase(); if (!(_case instanceof AccessCertificationAssignmentCaseType)) { return null; // should not occur, TODO treat gracefully } AccessCertificationAssignmentCaseType assignmentCase = (AccessCertificationAssignmentCaseType) _case; AssignmentType assignment = assignmentCase.getAssignment(); List<String> infoList = new ArrayList<>(); String assignmentOrInducement; if (Boolean.TRUE.equals(assignmentCase.isIsInducement())) { assignmentOrInducement = page.createStringResource("PageCert.message.textInducement").getString(); } else { assignmentOrInducement = page.createStringResource("PageCert.message.textAssignment").getString(); } String targetType = getLocalizedTypeName(_case.getTargetRef().getType(), page); String targetName = dto.getTargetName(); String objectType = getLocalizedTypeName(_case.getObjectRef().getType(), page); String objectName = dto.getObjectName(); infoList.add( page.createStringResource( "PageCert.message.assignment", assignmentOrInducement, emptyToDash(targetType), emptyToDash(targetName), emptyToDash(objectType), emptyToDash(objectName)) .getString()); if (StringUtils.isNotEmpty(assignment.getDescription())) { infoList.add( page.createStringResource("PageCert.message.textDescription", assignment.getDescription()) .getString()); } if (assignment.getOrder() != null) { infoList.add( page.createStringResource("PageCert.message.textOrder", assignment.getOrder()) .getString()); } if (assignment.getConstruction() != null) { if (assignment.getConstruction().getKind() != null) { infoList.add( page.createStringResource( "PageCert.message.textKind", page.createStringResource(assignment.getConstruction().getKind()).getString()) .getString()); } if (assignment.getConstruction().getIntent() != null) { infoList.add( page.createStringResource( "PageCert.message.textIntent", assignment.getConstruction().getIntent()) .getString()); } } if (_case.getTargetRef().getRelation() != null) { infoList.add( page.createStringResource( "PageCert.message.textRelation", _case.getTargetRef().getRelation().getLocalPart()) .getString()); } Task task = page.createSimpleTask("dummy"); if (assignment.getOrgRef() != null) { String orgName = WebModelServiceUtils.resolveReferenceName( assignment.getOrgRef(), page, task, task.getResult()); infoList.add(page.createStringResource("PageCert.message.textOrg", orgName).getString()); } if (assignment.getTenantRef() != null) { String tenantName = WebModelServiceUtils.resolveReferenceName( assignment.getTenantRef(), page, task, task.getResult()); infoList.add( page.createStringResource("PageCert.message.textTenant", tenantName).getString()); } PrismContainer<? extends Containerable> extensionContainer = assignment.asPrismContainerValue().findContainer(AssignmentType.F_EXTENSION); if (extensionContainer != null && !extensionContainer.isEmpty()) { List<String> extensionItemNameList = new ArrayList<>(); for (Item extensionItem : extensionContainer.getValue().getItems()) { extensionItemNameList.add(extensionItem.getElementName().getLocalPart()); } infoList.add( page.createStringResource( "PageCert.message.textExtensions", StringUtils.join(extensionItemNameList, ", ")) .getString()); } if (assignment.getActivation() != null) { String validFrom = WebComponentUtil.formatDate(assignment.getActivation().getValidFrom()); if (validFrom != null) { infoList.add( page.createStringResource("PageCert.message.textValidFrom", validFrom).getString()); } String validTo = WebComponentUtil.formatDate(assignment.getActivation().getValidTo()); if (validTo != null) { infoList.add( page.createStringResource("PageCert.message.textValidTo", validTo).getString()); } if (assignment.getActivation().getAdministrativeStatus() != null) { infoList.add( page.createStringResource( "PageCert.message.textAdministrativeState", page.createStringResource(assignment.getActivation().getAdministrativeStatus()) .getString()) .getString()); } } String rv = StringUtils.join(infoList, "<br/>"); return rv; }