public static void setConnectorXsdSchema(PrismObject<ConnectorType> connector, Element xsdElement) { PrismContainer<XmlSchemaType> schemaContainer; try { schemaContainer = connector.findOrCreateContainer(ConnectorType.F_SCHEMA); PrismProperty<SchemaDefinitionType> definitionProperty = schemaContainer.findOrCreateProperty(XmlSchemaType.F_DEFINITION); ObjectTypeUtil.setXsdSchemaDefinition(definitionProperty, xsdElement); } catch (SchemaException e) { // Should not happen throw new IllegalStateException("Internal schema error: "+e.getMessage(),e); } }
public static void setResourceXsdSchema(PrismObject<ResourceType> resource, Element xsdElement) { try { PrismContainer<XmlSchemaType> schemaContainer = resource.findOrCreateContainer(ResourceType.F_SCHEMA); PrismProperty<SchemaDefinitionType> definitionProperty = schemaContainer.findOrCreateProperty(XmlSchemaType.F_DEFINITION); ObjectTypeUtil.setXsdSchemaDefinition(definitionProperty, xsdElement); } catch (SchemaException e) { // Should not happen throw new IllegalStateException("Internal schema error: "+e.getMessage(),e); } }
@Test public void testAssignmentExtensionContainerProperty() throws Exception { System.out.println("===[ testAssignmentExtensionContainerProperty ]==="); // GIVEN PrismContainer<AssignmentType> assignmentExtensionContainer = parseUserAssignmentContainer(); // WHEN PrismProperty<String> assignmentExtensionStringProperty = assignmentExtensionContainer.findOrCreateProperty(EXTENSION_STRING_TYPE_ELEMENT); // THEN assertNotNull("stringType is null", assignmentExtensionStringProperty); assertNotNull("stringType has no definition", assignmentExtensionStringProperty.getDefinition()); PrismAsserts.assertDefinition(assignmentExtensionStringProperty.getDefinition(), EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); }
private ShadowType createShadow(UserType user, String resourceOid, int resourceId) throws SchemaException { ShadowType shadow = new ShadowType(); shadow.setOid(UUID.randomUUID().toString()); final String DN = "cn=" + user.getName().getOrig() + ",ou=resource" + resourceId + ",dc=example,dc=com"; shadow.setName(createPoly(DN)); shadow.setResourceRef(createRef(resourceOid, ResourceType.COMPLEX_TYPE)); shadow.setKind(ShadowKindType.ACCOUNT); shadow.setIntent("standardAccount"); shadow.setObjectClass(new QName("http://midpoint.evolveum.com/xml/ns/public/resource/instance/" + resourceOid, "AccountObjectClass")); PrismObject<ShadowType> prism = shadow.asPrismObject(); prismContext.adopt(prism); PrismContainer attributes = prism.findOrCreateContainer(ShadowType.F_ATTRIBUTES); PrismProperty property = attributes.findOrCreateProperty(SchemaConstants.ICFS_UID); property.setRealValue(UUID.randomUUID().toString()); property = attributes.findOrCreateProperty(SchemaConstants.ICFS_NAME); property.setRealValue(DN); return shadow; }
@Test public void test550UseVariables() throws Exception { final String TEST_NAME = "test550UseVariables"; TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); OperationResult result = task.getResult(); ExecuteScriptType executeScript = parseRealValue(USE_VARIABLES_FILE); PrismContainer<Containerable> taskExtension = task.getTaskPrismObject().findOrCreateContainer(TaskType.F_EXTENSION); taskExtension .findOrCreateProperty(USER_NAME_TASK_EXTENSION_PROPERTY) .addRealValue("user1"); taskExtension .findOrCreateProperty(STUDY_GROUP_TASK_EXTENSION_PROPERTY) .addRealValues("group1", "group2", "group3"); // WHEN ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(executeScript, emptyMap(), false, task, result); // THEN dumpOutput(output, result); result.computeStatus(); PipelineData data = output.getFinalOutput(); assertEquals("Unexpected # of items in output", 1, data.getData().size()); String returned = data.getData().get(0).getValue().getRealValue(); assertEquals("Wrong returned status", "ok", returned); }
private PrismObject<ShadowType> createAccountShadow(String username) throws SchemaException { ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); ObjectClassComplexTypeDefinition defaultAccountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); ShadowType shadowType = new ShadowType(); PrismTestUtil.getPrismContext().adopt(shadowType); shadowType.setName(PrismTestUtil.createPolyStringType(username)); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resource.getOid()); shadowType.setResourceRef(resourceRef); shadowType.setObjectClass(defaultAccountDefinition.getTypeName()); PrismObject<ShadowType> shadow = shadowType.asPrismObject(); PrismContainer<Containerable> attrsCont = shadow.findOrCreateContainer(ShadowType.F_ATTRIBUTES); PrismProperty<String> icfsNameProp = attrsCont.findOrCreateProperty(SchemaConstants.ICFS_NAME); icfsNameProp.setRealValue(username); return shadow; }
task.getTaskPrismObject() .findContainer(TaskType.F_EXTENSION) .findOrCreateProperty(USER_NAME_TASK_EXTENSION_PROPERTY) .addRealValue(USER_ADMINISTRATOR_USERNAME); task.getTaskPrismObject() .findContainer(TaskType.F_EXTENSION) .findOrCreateProperty(USER_DESCRIPTION_TASK_EXTENSION_PROPERTY) .addRealValue("admin description"); task.setHandlerUri(ModelPublicConstants.SCRIPT_EXECUTION_TASK_HANDLER_URI);
if (assertDefinitions) PrismAsserts.assertDefinition(enabledProperty, DOMUtil.XSD_BOOLEAN, 0, 1); enabledProperty.setRealValue(true); PrismProperty<Boolean> enabledPropertyAgain = activationContainer.findOrCreateProperty(USER_ENABLED_QNAME); PrismProperty<String> assBlueDescriptionProperty = assBlueContainer.findOrCreateProperty(USER_DESCRIPTION_QNAME); assBlueDescriptionProperty.addRealValue("Assignment created out of the blue"); PrismAsserts.assertParentConsistency(user); PrismProperty<String> stringTypeProperty = extensionContainer.findOrCreateProperty(EXTENSION_STRING_TYPE_ELEMENT); assertEquals(EXTENSION_STRING_TYPE_ELEMENT, stringTypeProperty.getElementName()); PrismAsserts.assertParentConsistency(user);