@Override public void parseThis(Element element, boolean isRuntime, String shortDescription, PrismContext prismContext) throws SchemaException { parse(element, ((PrismContextImpl) prismContext).getEntityResolver(), this, isRuntime, shortDescription, false, prismContext); }
public static PrismSchema parse(Element element, EntityResolver resolver, boolean isRuntime, String shortDescription, boolean allowDelayedItemDefinitions, PrismContext prismContext) throws SchemaException { return parse(element, resolver, new PrismSchemaImpl(prismContext), isRuntime, shortDescription, allowDelayedItemDefinitions, prismContext); }
public static PrismSchema parseReportConfigurationSchema(PrismObject<ReportType> report, PrismContext context) throws SchemaException { PrismContainer xmlSchema = report.findContainer(ReportType.F_CONFIGURATION_SCHEMA); Element xmlSchemaElement = ObjectTypeUtil.findXsdElement(xmlSchema); if (xmlSchemaElement == null) { //no schema definition available return null; } return PrismSchemaImpl.parse(xmlSchemaElement, true, "schema for " + report, context); }
public static PrismSchema parse(Element element, boolean isRuntime, String shortDescription, PrismContext prismContext) throws SchemaException { return parse(element, ((PrismContextImpl) prismContext).getEntityResolver(), new PrismSchemaImpl(prismContext), isRuntime, shortDescription, false, prismContext); }
/** * 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> configurationContainerDefinition = connectorSchema.findContainerDefinitionByElementName(configContainerQName); configurationContainerDefinition.toMutable().setCompileTimeClass(ConnectorConfigurationType.class); return connectorSchema; }
private void parsePrismSchema(SchemaDescription schemaDescription, boolean allowDelayedItemDefinitions) throws SchemaException { String namespace = schemaDescription.getNamespace(); Element domElement = schemaDescription.getDomElement(); boolean isRuntime = schemaDescription.getCompileTimeClassesPackage() == null; long started = System.currentTimeMillis(); LOGGER.trace("Parsing schema {}, namespace: {}, isRuntime: {}", schemaDescription.getSourceDescription(), namespace, isRuntime); PrismSchema schema = PrismSchemaImpl.parse(domElement, entityResolver, isRuntime, schemaDescription.getSourceDescription(), allowDelayedItemDefinitions, getPrismContext()); if (StringUtils.isEmpty(namespace)) { namespace = schema.getNamespace(); } LOGGER.trace("Parsed schema {}, namespace: {}, isRuntime: {} in {} ms", schemaDescription.getSourceDescription(), namespace, isRuntime, System.currentTimeMillis()-started); schemaDescription.setSchema(schema); detectExtensionSchema(schema); }
public static void assertConnectorSchemaSanity(ConnectorType conn, PrismContext prismContext) throws SchemaException { XmlSchemaType xmlSchemaType = conn.getSchema(); assertNotNull("xmlSchemaType is null",xmlSchemaType); Element connectorXsdSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(conn); assertNotNull("No schema", connectorXsdSchemaElement); Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaType); assertNotNull("No xsd:schema element in xmlSchemaType",xsdElement); display("XSD schema of "+conn, DOMUtil.serializeDOMToString(xsdElement)); // Try to parse the schema PrismSchema schema = null; try { schema = PrismSchemaImpl.parse(xsdElement, true, "schema of "+conn, prismContext); } catch (SchemaException e) { throw new SchemaException("Error parsing schema of "+conn+": "+e.getMessage(),e); } assertConnectorSchemaSanity(schema, conn.toString(), SchemaConstants.ICF_FRAMEWORK_URI.equals(conn.getFramework())); }
private void schemaRoundtrip(PrismContext ctx) throws SchemaException, SAXException, IOException { PrismSchema schema = constructSchema(ctx); assertSchema(schema); // WHEN Document xsdDocument = schema.serializeToXsd(); // THEN Element xsdElement = DOMUtil.getFirstChildElement(xsdDocument); System.out.println("Serialized schema"); System.out.println(DOMUtil.serializeDOMToString(xsdElement)); assertPrefix("xsd", xsdElement); Element displayNameElement = DOMUtil.findElementRecursive(xsdElement, PrismConstants.A_DISPLAY_NAME); assertPrefix(PrismConstants.PREFIX_NS_ANNOTATION, displayNameElement); // re-parse PrismSchema reparsedSchema = PrismSchemaImpl.parse(xsdElement, true, "serialized schema", ctx); System.out.println("Re-parsed schema"); System.out.println(reparsedSchema.debugDump()); assertSchema(reparsedSchema); }
@Test public void test002ConnectorSchema() throws Exception { final String TEST_NAME = "test002ConnectorSchema"; TestUtil.displayTestTitle(TEST_NAME); PrismSchema connectorSchema = connectorFactory.generateConnectorConfigurationSchema(connectorType); IntegrationTestTools.assertConnectorSchemaSanity(connectorSchema, "generated", true); assertEquals("Unexpected number of definitions", 3, connectorSchema.getDefinitions().size()); Document xsdSchemaDom = connectorSchema.serializeToXsd(); assertNotNull("No serialized connector schema", xsdSchemaDom); display("Serialized XSD connector schema", DOMUtil.serializeDOMToString(xsdSchemaDom)); // Try to re-parse PrismSchema reparsedConnectorSchema = PrismSchemaImpl.parse(DOMUtil.getFirstChildElement(xsdSchemaDom), true, "schema fetched from "+cc, PrismTestUtil.getPrismContext()); IntegrationTestTools.assertConnectorSchemaSanity(reparsedConnectorSchema, "re-parsed", true); // TODO: 3 definitions would be cleaner. But we can live with this assertEquals("Unexpected number of definitions in re-parsed schema", 6, reparsedConnectorSchema.getDefinitions().size()); }
PrismSchema schema = PrismSchemaImpl.parse(connectorXsdSchemaElement, true, "connector schema " + conn, prismContext); assertNotNull("Cannot parse schema", schema); assertFalse("Empty schema", schema.isEmpty());
PrismSchema newSchema = PrismSchemaImpl.parse(DOMUtil.getFirstChildElement(parsedXsd), true, "serialized schema", PrismTestUtil.getPrismContext());