@Override public PrismContext createPrismContext() throws SchemaException, FileNotFoundException { SchemaRegistryImpl schemaRegistry = createSchemaRegistry(); PrismContextImpl context = PrismContextImpl.create(schemaRegistry); context.setDefinitionFactory(createDefinitionFactory()); context.setDefaultRelation(SchemaConstants.ORG_DEFAULT); context.setObjectsElementName(SchemaConstants.C_OBJECTS); if (InternalsConfig.isPrismMonitoring()) { context.setMonitor(new InternalMonitor()); } context.setParsingMigrator(new MidpointParsingMigrator()); return context; }
private BeanMarshaller getBeanMarshaller() { return ((PrismContextImpl) prismContext).getBeanMarshaller(); }
private static DomLexicalProcessor getDomParser(@NotNull PrismContext prismContext) { return ((PrismContextImpl) prismContext).getParserDom(); }
public PrismContext createEmptyPrismContext() throws SchemaException, FileNotFoundException { SchemaRegistryImpl schemaRegistry = createSchemaRegistry(); PrismContextImpl context = PrismContextImpl.createEmptyContext(schemaRegistry); context.setDefinitionFactory(createDefinitionFactory()); context.setDefaultRelation(SchemaConstants.ORG_DEFAULT); context.setObjectsElementName(SchemaConstants.C_OBJECTS); return context; }
/** * TODO rewrite this method using Prism API */ @Override public void serializeFaultMessage(Detail detail, Object faultInfo, QName faultMessageElementName, Trace logger) { try { XNodeImpl faultMessageXnode = prismContext.getBeanMarshaller().marshall(faultInfo); RootXNodeImpl xroot = new RootXNodeImpl(faultMessageElementName, faultMessageXnode); xroot.setExplicitTypeDeclaration(true); QName faultType = prismContext.getSchemaRegistry().determineTypeForClass(faultInfo.getClass()); xroot.setTypeQName(faultType); prismContext.getParserDom().serializeUnderElement(xroot, faultMessageElementName, detail); } catch (SchemaException e) { logger.error("Error serializing fault message (SOAP fault detail): {}", e.getMessage(), e); } }
PrismContextImpl context = PrismContextImpl.create(schemaRegistry); context.setDefinitionFactory(new SchemaDefinitionFactory()); context.initialize();
/** * Set up the specified object with prism context instance and schema definition. */ @Override public <C extends Containerable> void adopt(PrismContainer<C> container, Class<C> declaredType) throws SchemaException { container.revive(this); getSchemaRegistry().applyDefinition(container, declaredType, false); }
public static PrismContextImpl constructPrismContext(File extraSchema) throws SchemaException, FileNotFoundException { SchemaRegistryImpl schemaRegistry = new SchemaRegistryImpl(); schemaRegistry.setCatalogResourceName(TEST_CATALOG_RESOURCE_NAME); DynamicNamespacePrefixMapper prefixMapper = new GlobalDynamicNamespacePrefixMapper(); // Set default namespace? schemaRegistry.setNamespacePrefixMapper(prefixMapper); schemaRegistry.registerPrismDefaultSchemaResource("xml/ns/test/foo-1.xsd", "foo", ObjectFactory.class.getPackage()); schemaRegistry.registerPrismSchemaResource("xml/ns/test/foo-types-1.xsd", "foot", null); schemaRegistry.registerPrismSchemaResource("xml/ns/public/types-3.xsd", "t", com.evolveum.prism.xml.ns._public.types_3.ObjectFactory.class.getPackage()); schemaRegistry.registerPrismSchemaResource("xml/ns/public/query-3.xsd", "q", com.evolveum.prism.xml.ns._public.query_3.ObjectFactory.class.getPackage()); schemaRegistry.registerPrismSchemasFromDirectory(SCHEMA_DIR); if (extraSchema != null){ schemaRegistry.registerPrismSchemaFile(extraSchema); } prefixMapper.registerPrefix(XMLConstants.W3C_XML_SCHEMA_NS_URI, DOMUtil.NS_W3C_XML_SCHEMA_PREFIX, false); prefixMapper.registerPrefix(PrismConstants.NS_ANNOTATION, PrismConstants.PREFIX_NS_ANNOTATION, false); prefixMapper.registerPrefix(PrismInternalTestUtil.NS_WEAPONS, PrismInternalTestUtil.NS_WEAPONS_PREFIX, false); PrismContextImpl prismContext = PrismContextImpl.create(schemaRegistry); prismContext.setObjectsElementName(new QName("http://midpoint.evolveum.com/xml/ns/public/common/common-3", "objects")); return prismContext; }
public static PrismContextImpl constructInitializedPrismContext() throws SchemaException, SAXException, IOException { PrismContextImpl context = constructPrismContext(); context.initialize(); return context; }
@Override public <C extends Containerable, O extends Objectable> void adopt(C containerable, Class<O> type, ItemPath path) throws SchemaException { PrismContainerValue<C> prismContainerValue = containerable.asPrismContainerValue(); adopt(prismContainerValue, type, path); }
public static PrismContextImpl create(@NotNull SchemaRegistryImpl schemaRegistry) { return new PrismContextImpl(schemaRegistry); }
@Override public <C extends Containerable, O extends Objectable> void adopt(PrismContainerValue<C> prismContainerValue, Class<O> type, ItemPath path) throws SchemaException { prismContainerValue.revive(this); getSchemaRegistry().applyDefinition(prismContainerValue, type, path, false); }
@Override public <C extends Containerable> void adopt(PrismContainer<C> container) throws SchemaException { adopt(container, container.getCompileTimeClass()); }
public static PrismContextImpl createEmptyContext(@NotNull SchemaRegistryImpl schemaRegistry) { return new PrismContextImpl(schemaRegistry); }
@NotNull private BeanMarshaller getBeanMarshaller() { return ((PrismContextImpl) getPrismContext()).getBeanMarshaller(); } //endregion
private XmlAsStringType unmarshalXmlAsStringFromMap(MapXNodeImpl map, Class<XmlAsStringType> beanClass, ParsingContext parsingContext) throws SchemaException { // reading a string represented a XML-style content // used e.g. when reading report templates (embedded XML) // A necessary condition: there may be only one map entry. if (map.size() > 1) { throw new SchemaException("Map with more than one item cannot be parsed as a string: " + map); } else if (map.isEmpty()) { return new XmlAsStringType(); } else { Entry<QName, XNodeImpl> entry = map.entrySet().iterator().next(); DomLexicalProcessor domParser = ((PrismContextImpl) prismContext).getParserDom(); String value = domParser.write(entry.getValue(), entry.getKey(), null); return new XmlAsStringType(value); } }
@Override public <C extends Containerable, O extends Objectable> void adopt(PrismContainerValue<C> prismContainerValue, QName typeName, ItemPath path) throws SchemaException { prismContainerValue.revive(this); getSchemaRegistry().applyDefinition(prismContainerValue, typeName, path, false); } //endregion
@Override public void adopt(Objectable objectable) throws SchemaException { adopt(objectable.asPrismObject(), objectable.getClass()); }
@Override public QName determineTypeForClass(Class<?> clazz) { if (XmlTypeConverter.canConvert(clazz)) { return XsdTypeMapper.toXsdType(clazz); } else { return ((PrismContextImpl) prismContext).getBeanMarshaller().determineTypeForClass(clazz); } }
final DomLexicalProcessor domLexicalProcessor = ((PrismContextImpl) prismContext).getParserDom(); String ok = domLexicalProcessor.write(valOkNode, new QName("ok"), null); System.out.println("correct value serialized to: " + ok);