public static ConnectorSchema getConnectorSchema(PrismObject<ConnectorType> connector, PrismContext prismContext) throws SchemaException { Element connectorXsdSchema = ConnectorTypeUtil.getConnectorXsdSchema(connector); if (connectorXsdSchema == null) { return null; } Object userDataEntry = connector.getUserData(USER_DATA_KEY_PARSED_CONNECTOR_SCHEMA); if (userDataEntry != null) { if (userDataEntry instanceof ConnectorSchema) { return (ConnectorSchema)userDataEntry; } else { throw new IllegalStateException("Expected ConnectorSchema under user data key "+ USER_DATA_KEY_PARSED_CONNECTOR_SCHEMA + "in "+connector+", but got "+userDataEntry.getClass()); } } else { //InternalMonitor.recordConnectorSchemaParse(); ConnectorSchemaImpl parsedSchema = ConnectorSchemaImpl.parse(connectorXsdSchema, "connector schema of "+connector, prismContext); if (parsedSchema == null) { throw new IllegalStateException("Parsed schema is null: most likely an internall error"); } parsedSchema.setUsualNamespacePrefix(ConnectorSchemaImpl.retrieveUsualNamespacePrefix(connector.asObjectable())); connector.setUserData(USER_DATA_KEY_PARSED_CONNECTOR_SCHEMA, parsedSchema); return parsedSchema; } }
public static void setConnectorXsdSchema(ConnectorType connectorType, Element xsdElement) { PrismObject<ConnectorType> connector = connectorType.asPrismObject(); setConnectorXsdSchema(connector, xsdElement); }
public PrismSchema getConnectorSchema(ConnectorType connectorType) throws SchemaException { PrismObject<ConnectorType> connector = connectorType.asPrismObject(); PrismSchema connectorSchema; Object userDataEntry = connector.getUserData(USER_DATA_KEY_PARSED_CONNECTOR_SCHEMA); if (userDataEntry == null) { InternalMonitor.recordCount(InternalCounters.CONNECTOR_SCHEMA_PARSE_COUNT); connectorSchema = ConnectorTypeUtil.parseConnectorSchema(connectorType, prismContext); if (connectorSchema == null) { throw new SchemaException("No connector schema in "+connectorType); } connector.setUserData(USER_DATA_KEY_PARSED_CONNECTOR_SCHEMA, connectorSchema); } else { if (userDataEntry instanceof PrismSchema) { connectorSchema = (PrismSchema)userDataEntry; } else { throw new IllegalStateException("Expected PrismSchema under user data key "+ USER_DATA_KEY_PARSED_CONNECTOR_SCHEMA+ "in "+connectorType+", but got "+userDataEntry.getClass()); } } return connectorSchema; }
.findConfigurationContainerDefinition(connectorType, connectorSchema); if (configurationContainerDefinition == null) { throw new SchemaException("No configuration container definition in schema of " + connectorType);
/** * 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; }
public static void setConnectorSchema(ConnectorType connectorType, PrismSchema connectorSchema) throws SchemaException { Document xsdDoc = connectorSchema.serializeToXsd(); Element xsdElement = DOMUtil.getFirstChildElement(xsdDoc); ConnectorTypeUtil.setConnectorXsdSchema(connectorType, xsdElement); }
if (userDataEntry == null) { InternalMonitor.recordCount(InternalCounters.CONNECTOR_SCHEMA_PARSE_COUNT); PrismSchema connectorSchema = ConnectorTypeUtil.parseConnectorSchema(connectorType, prismContext); if (connectorSchema == null) { throw new SchemaException("No connector schema in "+connectorType);
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())); }
Element connectorSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(connector); MutablePrismSchema connectorSchema = null; if (connectorSchemaElement == null) {
Element connectorXsdSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(conn); assertNotNull("No schema", connectorXsdSchemaElement);
Element connectorSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(connector); MutablePrismSchema connectorSchema; if (connectorSchemaElement == null) {