@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, O extends Objectable> void adopt(PrismContainerValue<C> prismContainerValue, QName typeName, ItemPath path) throws SchemaException { prismContainerValue.revive(this); getSchemaRegistry().applyDefinition(prismContainerValue, typeName, path, false); } //endregion
/** * 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); }
@Override public <T extends Objectable> void adopt(ObjectDelta<T> delta) throws SchemaException { delta.revive(this); getSchemaRegistry().applyDefinition(delta, delta.getObjectTypeClass(), false); }
private void checkTypeResolvable(RootXNodeImpl root) { root.accept(n -> { QName type; if (n instanceof XNodeImpl && (type = ((XNodeImpl) n).getTypeQName()) != null && ((XNodeImpl) n).isExplicitTypeDeclaration()) { if (prismContext.getSchemaRegistry().determineClassForType(type) == null) { // it could be sufficient to find a TD if (prismContext.getSchemaRegistry().findTypeDefinitionByType(type) == null) { throw new IllegalStateException( "Postcondition fail: type " + type + " is not resolvable in:\n" + root.debugDump()); } } } }); } //endregion
/** * 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); } }
@SuppressWarnings("unchecked") private <T> T doParseRealValue(Class<T> clazz, RootXNodeImpl root) throws IOException, SchemaException { if (clazz == null) { ItemInfo info = ItemInfo.determine(itemDefinition, root.getRootElementName(), itemName, null, root.getTypeQName(), typeName, null, ItemDefinition.class, context, prismContext.getSchemaRegistry()); if (info.getItemDefinition() instanceof PrismContainerDefinition) { clazz = ((PrismContainerDefinition) info.getItemDefinition()).getCompileTimeClass(); } if (clazz == null && info.getTypeName() != null) { clazz = (Class) prismContext.getSchemaRegistry().determineClassForType(info.getTypeName()); } } // although bean unmarshaller can process containerables as well, prism unmarshaller is better at it if (clazz != null && !Containerable.class.isAssignableFrom(clazz) && getBeanUnmarshaller().canProcess(clazz)) { return getBeanUnmarshaller().unmarshal(root, clazz, context); } else if (clazz != null && Objectable.class.isAssignableFrom(clazz)) { // we need to NOT strip off OID PrismObject object = (PrismObject) doParseItem(root, clazz); return (T) object.asObjectable(); } else { PrismValue prismValue = doParseItemValue(root, clazz); if (prismValue == null) { return null; } else { return prismValue.getRealValue(); } } }
@Test public void testPrefixMapper() throws SchemaException, SAXException, IOException { System.out.println("===[ testPrefixMapper ]==="); // WHEN PrismContextImpl prismContext = constructInitializedPrismContext(); // THEN assertNotNull("No prism context", prismContext); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); assertNotNull("No schema registry in context", schemaRegistry); DynamicNamespacePrefixMapper prefixMapper = schemaRegistry.getNamespacePrefixMapper(); System.out.println("Prefix mapper:"); System.out.println(DebugUtil.dump(prefixMapper)); assertEquals("Wrong foo prefix", "", prefixMapper.getPrefix(NS_FOO)); assertEquals("Wrong xsd prefix", DOMUtil.NS_W3C_XML_SCHEMA_PREFIX, prefixMapper.getPrefix(XMLConstants.W3C_XML_SCHEMA_NS_URI)); }