当前位置: 首页>>代码示例>>Java>>正文


Java DOMUtil.serializeDOMToString方法代码示例

本文整理汇总了Java中com.evolveum.midpoint.util.DOMUtil.serializeDOMToString方法的典型用法代码示例。如果您正苦于以下问题:Java DOMUtil.serializeDOMToString方法的具体用法?Java DOMUtil.serializeDOMToString怎么用?Java DOMUtil.serializeDOMToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.evolveum.midpoint.util.DOMUtil的用法示例。


在下文中一共展示了DOMUtil.serializeDOMToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: display

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
public static void display(String title, List<Element> elements) {
	System.out.println(OBJECT_TITLE_OUT_PREFIX + title);
	LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title);
	for(Element e : elements) {
		String s = DOMUtil.serializeDOMToString(e);
		System.out.println(s);
		LOGGER.debug(s);
	}
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:10,代码来源:IntegrationTestTools.java

示例2: getRealRepoValue

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
/**
 * This method provides transformation of {@link Element} value to its object form, e.g. <value>1</value> to
 * {@link Integer} number 1. It's based on element definition from schema registry or xsi:type attribute
 * in that element.
 * <p>
 * Expects only property values (references are handled at other place).
 *
 * @param definition
 * @param value
 * @return
 */
public static Object getRealRepoValue(ItemDefinition definition, Element value) throws SchemaException {
    ValueType willBeSaveAs = definition == null ? null : getValueType(definition.getTypeName());
    QName typeName = definition == null ? DOMUtil.resolveXsiType(value) : definition.getTypeName();

    Validate.notNull(typeName, "Definition was not defined for element value '"
            + DOMUtil.getQNameWithoutPrefix(value) + "' and it doesn't have xsi:type.");

    Object object;
    if (ValueType.STRING.equals(willBeSaveAs)) {
        if (DOMUtil.listChildElements(value).isEmpty()) {
            //simple values
            return value.getTextContent();
        } else {
            //composite elements or containers
            return DOMUtil.serializeDOMToString(value);
        }
    } else {
        object = XmlTypeConverter.toJavaValue(value, typeName);
    }

    object = getAggregatedRepoObject(object);
    if (object == null) {
        throw new IllegalStateException("Can't extract value for saving from prism property value\n" + value);
    }

    return object;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:39,代码来源:RAnyConverter.java

示例3: write

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@NotNull
@Override
public String write(@NotNull XNode xnode, @NotNull QName rootElementName, SerializationContext serializationContext) throws SchemaException {
	DomLexicalWriter serializer = new DomLexicalWriter(schemaRegistry);
	RootXNode xroot = LexicalUtils.createRootXNode(xnode, rootElementName);
	Element element = serializer.serialize(xroot);
	return DOMUtil.serializeDOMToString(element);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:9,代码来源:DomLexicalProcessor.java

示例4: marshalElementToString

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
/**
 * Serializes DOM or JAXB element to string
 */
public String marshalElementToString(Object element, Map<String, Object> properties) throws JAXBException {
	if (element == null) {
		return null;
	}
	if (element instanceof Element) {
		return DOMUtil.serializeDOMToString((Element) element);
	} else if (element instanceof JAXBElement) {
		return marshalElementToString((JAXBElement<?>)element, properties);
	} else {
		throw new IllegalArgumentException("Unsupported element type "+element.getClass().getName());
	}
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:16,代码来源:JaxbTestUtil.java

示例5: testFilterNotInOid

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
public void testFilterNotInOid() throws Exception {
	displayTestTitle("testFilterNotInOid");

	SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_NOT_IN_OID);

	ObjectQuery query = toObjectQuery(UserType.class, filterType);
	displayQuery(query);

	assertNotNull(query);

	ObjectFilter filter = query.getFilter();
	assertTrue("Filter is not of NOT type", filter instanceof NotFilter);

	ObjectFilter subFilter = ((NotFilter) filter).getFilter();
	assertTrue("Subfilter is not of IN_OID type", subFilter instanceof InOidFilter);

	QueryType convertedQueryType = toQueryType(query);
	System.out.println("Re-converted query type");
	System.out.println(convertedQueryType.debugDump());

	Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext());
	LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump());

	System.out.println("Serialized filter (JAXB->DOM)");
	String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement);
	System.out.println(filterAsString);
	LOGGER.info(filterAsString);

	DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "not"));
	assertEquals("wrong # of inOid subfilters", 1, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "inOid").getLength());
	assertEquals("wrong # of value subfilters", 4, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "value").getLength());
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:34,代码来源:TestQueryConvertors.java

示例6: testFilterNotFullText

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
public void testFilterNotFullText() throws Exception {
	displayTestTitle("testFilterNotFullText");

	SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_NOT_FULL_TEXT);

	ObjectQuery query = toObjectQuery(UserType.class, filterType);
	displayQuery(query);

	assertNotNull(query);

	ObjectFilter filter = query.getFilter();
	assertTrue("Filter is not of NOT type", filter instanceof NotFilter);

	ObjectFilter subFilter = ((NotFilter) filter).getFilter();
	assertTrue("Subfilter is not of FULL_TEXT type", subFilter instanceof FullTextFilter);

	QueryType convertedQueryType = toQueryType(query);
	System.out.println("Re-converted query type");
	System.out.println(convertedQueryType.debugDump());

	Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext());
	LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump());

	System.out.println("Serialized filter (JAXB->DOM)");
	String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement);
	System.out.println(filterAsString);
	LOGGER.info(filterAsString);

	DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "not"));
	assertEquals("wrong # of fullText subfilters", 1, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "fullText").getLength());
	assertEquals("wrong # of value subfilters", 2, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "value").getLength());
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:34,代码来源:TestQueryConvertors.java

示例7: testRoundTripGeneric

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
public void testRoundTripGeneric() throws SchemaException {
	// GIVEN
	PrismSchemaImpl schema = new PrismSchemaImpl(SCHEMA_NS, PrismTestUtil.getPrismContext());
	// Ordinary property
	schema.createPropertyDefinition("number1", DOMUtil.XSD_INT);
	
	// Property container
	PrismContainerDefinitionImpl containerDefinition = schema.createPropertyContainerDefinition("ContainerType");
	// ... in it ordinary property
	containerDefinition.createPropertyDefinition("login", DOMUtil.XSD_STRING);
	// ... and local property with a type from another schema
	containerDefinition.createPropertyDefinition("password", ProtectedStringType.COMPLEX_TYPE);
	// ... property reference
	containerDefinition.createPropertyDefinition(SchemaConstants.C_CREDENTIALS, CredentialsType.COMPLEX_TYPE);
	// ... read-only int property 
	PrismPropertyDefinition counterProperty = containerDefinition.createPropertyDefinition("counter", DOMUtil.XSD_INT);
	((PrismPropertyDefinitionImpl) counterProperty).setReadOnly();

	System.out.println("Generic schema before serializing to XSD: ");
	System.out.println(schema.debugDump());
	System.out.println();

	// WHEN
	
	Document xsd = schema.serializeToXsd();
	
	String stringXmlSchema = DOMUtil.serializeDOMToString(xsd);
	
	System.out.println("Generic schema after serializing to XSD: ");
	System.out.println(stringXmlSchema);
	System.out.println();
	
	Document parsedXsd = DOMUtil.parseDocument(stringXmlSchema);
	
	PrismSchema newSchema = PrismSchemaImpl.parse(DOMUtil.getFirstChildElement(parsedXsd), true, "serialized schema", PrismTestUtil.getPrismContext());

	System.out.println("Generic schema after parsing from XSD: ");
	System.out.println(newSchema.debugDump());
	System.out.println();
	
	// THEN

	PrismPropertyDefinition number1def = newSchema.findItemDefinitionByElementName(new QName(SCHEMA_NS,"number1"), PrismPropertyDefinition.class);
	assertEquals(new QName(SCHEMA_NS,"number1"),number1def.getName());
	assertEquals(DOMUtil.XSD_INT,number1def.getTypeName());
	
	PrismContainerDefinition newContainerDef = schema.findContainerDefinitionByType(new QName(SCHEMA_NS,"ContainerType"));
	assertEquals(new QName(SCHEMA_NS,"ContainerType"),newContainerDef.getTypeName());
	
	PrismPropertyDefinition loginDef = newContainerDef.findPropertyDefinition(new QName(SCHEMA_NS,"login"));
	assertEquals(new QName(SCHEMA_NS,"login"), loginDef.getName());
	assertEquals(DOMUtil.XSD_STRING, loginDef.getTypeName());
	assertTrue("Read flag is wrong",loginDef.canRead());
	assertTrue("Create flag is wrong",loginDef.canAdd());
	assertTrue("Update flag is wrong",loginDef.canModify());

	PrismPropertyDefinition passwdDef = newContainerDef.findPropertyDefinition(new QName(SCHEMA_NS,"password"));
	assertEquals(new QName(SCHEMA_NS,"password"), passwdDef.getName());
	assertEquals(ProtectedStringType.COMPLEX_TYPE, passwdDef.getTypeName());

	PrismPropertyDefinition credDef = newContainerDef.findPropertyDefinition(new QName(SchemaConstants.NS_C,"credentials"));
	assertEquals(new QName(SchemaConstants.NS_C,"credentials"), credDef.getName());
	assertEquals(new QName(SchemaConstants.NS_C,"CredentialsType"), credDef.getTypeName());

	PrismPropertyDefinition countDef = newContainerDef.findPropertyDefinition(new QName(SCHEMA_NS,"counter"));
	assertEquals(new QName(SCHEMA_NS,"counter"), countDef.getName());
	assertEquals(DOMUtil.XSD_INT, countDef.getTypeName());
	assertTrue("Read flag is wrong",countDef.canRead());
	assertFalse("Create flag is wrong",countDef.canAdd());
	assertFalse("Update flag is wrong",countDef.canModify());
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:73,代码来源:SchemaProcessorTest.java

示例8: testRoundTripResource

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
	public void testRoundTripResource() throws SchemaException {
		// GIVEN
		ResourceSchemaImpl schema = new ResourceSchemaImpl(SCHEMA_NS, PrismTestUtil.getPrismContext());
		
		// Property container
		ObjectClassComplexTypeDefinitionImpl containerDefinition = (ObjectClassComplexTypeDefinitionImpl) schema.createObjectClassDefinition("AccountObjectClass");
		containerDefinition.setKind(ShadowKindType.ACCOUNT);
		containerDefinition.setDefaultInAKind(true);
		containerDefinition.setNativeObjectClass("ACCOUNT");
		// ... in it ordinary attribute - an identifier
		ResourceAttributeDefinitionImpl xloginDef = containerDefinition.createAttributeDefinition("login", DOMUtil.XSD_STRING);
		containerDefinition.addPrimaryIdentifier(xloginDef);
		xloginDef.setNativeAttributeName("LOGIN");
		containerDefinition.setDisplayNameAttribute(xloginDef.getName());
		// ... and local property with a type from another schema
		ResourceAttributeDefinitionImpl xpasswdDef = containerDefinition.createAttributeDefinition("password", ProtectedStringType.COMPLEX_TYPE);
		xpasswdDef.setNativeAttributeName("PASSWORD");
		// ... property reference
		// TODO this is not a ResourceAttributeDefinition, it cannot be placed here!
		//containerDefinition.createAttributeDefinition(SchemaConstants.C_CREDENTIALS, SchemaConstants.C_CREDENTIALS_TYPE);
		// ... ignored attribute
		ResourceAttributeDefinitionImpl xSepDef = containerDefinition.createAttributeDefinition("sep", DOMUtil.XSD_STRING);
		xSepDef.setIgnored(true);

		System.out.println("Resource schema before serializing to XSD: ");
		System.out.println(schema.debugDump());
		System.out.println();

		// WHEN
		
		Document xsd = schema.serializeToXsd();
		
		String stringXmlSchema = DOMUtil.serializeDOMToString(xsd);
		
		System.out.println("Resource schema after serializing to XSD: ");
		System.out.println(stringXmlSchema);
		System.out.println();
		
		Document parsedXsd = DOMUtil.parseDocument(stringXmlSchema);
		
		ResourceSchema newSchema = ResourceSchemaImpl.parse(DOMUtil.getFirstChildElement(parsedXsd), "serialized schema", PrismTestUtil.getPrismContext());

		System.out.println("Resource schema after parsing from XSD: ");
		System.out.println(newSchema.debugDump());
		System.out.println();
		
		// THEN
			
		ObjectClassComplexTypeDefinition newObjectClassDef = newSchema.findObjectClassDefinition(new QName(SCHEMA_NS,"AccountObjectClass"));
		assertEquals(new QName(SCHEMA_NS,"AccountObjectClass"),newObjectClassDef.getTypeName());
		assertEquals(ShadowKindType.ACCOUNT, newObjectClassDef.getKind());
		assertTrue(newObjectClassDef.isDefaultInAKind());
		
		PrismPropertyDefinition loginDef = newObjectClassDef.findPropertyDefinition(new QName(SCHEMA_NS,"login"));
		assertEquals(new QName(SCHEMA_NS,"login"), loginDef.getName());
		assertEquals(DOMUtil.XSD_STRING, loginDef.getTypeName());
		assertFalse(loginDef.isIgnored());

		PrismPropertyDefinition passwdDef = newObjectClassDef.findPropertyDefinition(new QName(SCHEMA_NS,"password"));
		assertEquals(new QName(SCHEMA_NS,"password"), passwdDef.getName());
		assertEquals(ProtectedStringType.COMPLEX_TYPE, passwdDef.getTypeName());
		assertFalse(passwdDef.isIgnored());

//		PrismContainerDefinition credDef = newObjectClassDef.findContainerDefinition(new QName(SchemaConstants.NS_C,"credentials"));
//		assertEquals(new QName(SchemaConstants.NS_C,"credentials"), credDef.getName());
//		assertEquals(new QName(SchemaConstants.NS_C,"CredentialsType"), credDef.getTypeName());
//		assertFalse(credDef.isIgnored());
		
		PrismPropertyDefinition sepDef = newObjectClassDef.findPropertyDefinition(new QName(SCHEMA_NS,"sep"));
		assertEquals(new QName(SCHEMA_NS,"sep"), sepDef.getName());
		assertEquals(DOMUtil.XSD_STRING, sepDef.getTypeName());
		assertTrue(sepDef.isIgnored());
		
	}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:76,代码来源:SchemaProcessorTest.java

示例9: testFilterTypeUserNone

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
public void testFilterTypeUserNone() throws Exception {
	displayTestTitle("testFilterTypeUserNone");

       
	SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_TYPE_USER_NONE);
       
	ObjectQuery query = toObjectQuery(UserType.class, filterType);
	displayQuery(query);

	assertNotNull(query);

	ObjectFilter filter = query.getFilter();
	assertTrue("Filter is not of TYPE type", filter instanceof TypeFilter);
	
	ObjectFilter subFilter = ((TypeFilter) filter).getFilter();
	assertTrue("Filter is not of NONE type", subFilter instanceof NoneFilter);

	QueryType convertedQueryType = toQueryType(query);
	System.out.println("Re-converted query type");
	System.out.println(convertedQueryType.debugDump());

	Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext());
	LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump());

	
	System.out.println("Serialized filter (JAXB->DOM)");
	String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement);
	System.out.println(filterAsString);
	LOGGER.info(filterAsString);
	
	DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "type"));
       

	
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:37,代码来源:TestQueryConvertors.java


注:本文中的com.evolveum.midpoint.util.DOMUtil.serializeDOMToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。