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


Java DOMUtil.getChildElement方法代码示例

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


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

示例1: isCapabilityEnabled

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private static boolean isCapabilityEnabled(Element capability) throws SchemaException {
	if (capability == null) {
		return false;
	}
	ObjectFactory capabilitiesObjectFactory = new ObjectFactory();
	QName enabledElementName = capabilitiesObjectFactory.createEnabled(true).getName();
	Element enabledElement = DOMUtil.getChildElement(capability, enabledElementName);
	if (enabledElement == null) {
		return true;
	}
	Boolean enabled = XmlTypeConverter.convertValueElementAsScalar(enabledElement, Boolean.class);
	if (enabled == null) {
		return true;
	}
	return enabled;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:17,代码来源:CapabilityUtil.java

示例2: convertXmlEncToEncryptedDate

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private EncryptedDataType convertXmlEncToEncryptedDate(Element eEncryptedData) {
   	EncryptedDataType encryptedDataType = new EncryptedDataType();
   	Element eEncryptionMethod = DOMUtil.getChildElement(eEncryptedData, F_XML_ENC_ENCRYPTION_METHOD);
   	if (eEncryptionMethod != null) {
   		String algorithm = eEncryptionMethod.getAttribute(ATTRIBUTE_XML_ENC_ALGORITHM);
   		EncryptionMethodType encryptionMethodType = new EncryptionMethodType();
   		encryptionMethodType.setAlgorithm(algorithm);
		encryptedDataType.setEncryptionMethod(encryptionMethodType);
   	}
   	Element eKeyInfo = DOMUtil.getChildElement(eEncryptedData, F_XML_DSIG_KEY_INFO);
   	if (eKeyInfo != null) {
   		KeyInfoType keyInfoType = new KeyInfoType();
   		encryptedDataType.setKeyInfo(keyInfoType);
   		Element eKeyName = DOMUtil.getChildElement(eKeyInfo, F_XML_DSIG_KEY_NAME);
		if (eKeyName != null) {
			keyInfoType.setKeyName(eKeyName.getTextContent());
		}
   	}
   	Element eCipherData = DOMUtil.getChildElement(eEncryptedData, F_XML_ENC_CIPHER_DATA);
   	if (eCipherData != null) {
   		CipherDataType cipherDataType = new CipherDataType();
		encryptedDataType.setCipherData(cipherDataType);
		Element eCipherValue = DOMUtil.getChildElement(eCipherData, F_XML_ENC_CIPHER_VALUE);
		if (eCipherValue != null) {
			String cipherValue = eCipherValue.getTextContent();
			byte[] cipherValueBytes;
			try {
				cipherValueBytes = Base64.decode(cipherValue);
			} catch (Base64DecodingException e) {
				throw new IllegalArgumentException("Bad base64 encoding in CipherValue element: "+e.getMessage(),e);
			}
			cipherDataType.setCipherValue(cipherValueBytes);
		}
   	}
   	return encryptedDataType;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:37,代码来源:ProtectedDataType.java

示例3: parseWsdlResource

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
public static List<SchemaDescription> parseWsdlResource(final String resourcePath) throws SchemaException {
    List<SchemaDescription> schemaDescriptions = new ArrayList<>();

    InputStream inputStream = SchemaRegistry.class.getClassLoader().getResourceAsStream(resourcePath);
    if (inputStream == null) {
        throw new IllegalStateException("Cannot fetch system resource for schema " + resourcePath);
    }
    Node node;
    try {
        node = DOMUtil.parse(inputStream);
    } catch (IOException e) {
        throw new SchemaException("Cannot parse schema from system resource " + resourcePath, e);
    }
    Element rootElement = node instanceof Element ? (Element)node : DOMUtil.getFirstChildElement(node);
    QName rootElementQName = DOMUtil.getQName(rootElement);
    if (WSDLConstants.QNAME_DEFINITIONS.equals(rootElementQName)) {
        Element types = DOMUtil.getChildElement(rootElement, WSDLConstants.QNAME_TYPES);
        if (types == null) {
            LOGGER.warn("No <types> section in WSDL document in system resource " + resourcePath);
            return schemaDescriptions;
        }
        List<Element> schemaElements = DOMUtil.getChildElements(types, DOMUtil.XSD_SCHEMA_ELEMENT);
        if (schemaElements.isEmpty()) {
            LOGGER.warn("No schemas in <types> section in WSDL document in system resource " + resourcePath);
            return schemaDescriptions;
        }
        int number = 1;
        for (Element schemaElement : schemaElements) {
            SchemaDescription desc = new SchemaDescription("schema #" + (number++) + " in system resource " + resourcePath);
            desc.node = schemaElement;
            desc.fetchBasicInfoFromSchema();
            schemaDescriptions.add(desc);
            LOGGER.trace("Schema registered from {}", desc.getSourceDescription());
        }
        return schemaDescriptions;
    } else {
        throw new SchemaException("WSDL system resource "+resourcePath+" does not start with wsdl:definitions element");
    }
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:40,代码来源:SchemaDescription.java

示例4: testFilterUserNameJaxb

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

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

	assertNotNull(query);

	ObjectFilter filter = query.getFilter();
	PrismAsserts.assertEqualsFilter(filter, UserType.F_NAME, PolyStringType.COMPLEX_TYPE,
			new ItemPath(new QName(null,UserType.F_NAME.getLocalPart())));
	PrismAsserts.assertEqualsFilterValue((EqualFilter) filter, createPolyString("jack"));

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

	Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext());

	System.out.println("Serialized filter (JAXB->DOM)");
	System.out.println(DOMUtil.serializeDOMToString(filterClauseElement));
	
	DomAsserts.assertElementQName(filterClauseElement, EqualFilter.ELEMENT_NAME);
	DomAsserts.assertSubElements(filterClauseElement, 2);
	
	DomAsserts.assertSubElement(filterClauseElement, PrismConstants.Q_VALUE);
	Element valueElement = DOMUtil.getChildElement(filterClauseElement, PrismConstants.Q_VALUE);
	DomAsserts.assertTextContent(valueElement, "jack");
	
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:33,代码来源:TestQueryConvertors.java

示例5: assertResourceRum

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private void assertResourceRum(PrismObject<ResourceType> resource) throws SchemaException {
	resource.checkConsistence();
	resource.assertDefinitions("test");
	
	assertEquals("Wrong oid", RESOURCE_RUM_OID, resource.getOid());
	PrismAsserts.assertObjectDefinition(resource.getDefinition(), RESOURCE_QNAME, RESOURCE_TYPE_QNAME, ResourceType.class);
	PrismAsserts.assertParentConsistency(resource);
	
	assertPropertyValue(resource, "name", new PolyString("Rum Delivery System", "rum delivery system"));
	assertPropertyDefinition(resource, "name", PolyStringType.COMPLEX_TYPE, 0, 1);
	
	PrismProperty<SchemaDefinitionType> propSchema = resource.findProperty(ResourceType.F_SCHEMA);
	assertNotNull("No schema property in resource", propSchema);
	PrismPropertyDefinition<SchemaDefinitionType> propSchemaDef = propSchema.getDefinition();
	assertNotNull("No definition of schema property in resource", propSchemaDef);
	SchemaDefinitionType schemaDefinitionType = propSchema.getRealValue();
	assertNotNull("No value of schema property in resource", schemaDefinitionType);
	
	Element schemaElement = schemaDefinitionType.getSchema();
	assertNotNull("No schema element in schema property in resource", schemaElement);
	System.out.println("Resource schema:");
	System.out.println(DOMUtil.serializeDOMToString(schemaElement));
	assertEquals("Bad schema element name", DOMUtil.XSD_SCHEMA_ELEMENT, DOMUtil.getQName(schemaElement));
	Element complexTypeElement = DOMUtil.getChildElement(schemaElement, XSD_COMPLEX_TYPE_ELEMENT_NAME);
	assertNotNull("No complexType element in schema element in schema property in resource", complexTypeElement);
	String complexTypeName = complexTypeElement.getAttribute("name");
	assertEquals("Wrong name of complex type", "BarrelType", complexTypeName);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:29,代码来源:AbstractLexicalProcessorTest.java

示例6: stringify

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
/**
 * Converts whatever it gets to a string. But it does it in a sensitive way.
 * E.g. it tries to detect collections and returns the first element (if there is only one). 
 * Never returns null. Returns empty string instead. 
 */
public String stringify(Object whatever) {
	
	if (whatever == null) {
		return "";
	}
	
	if (whatever instanceof String) {
		return (String)whatever;
	}
	
	if (whatever instanceof PolyString) {
		return ((PolyString)whatever).getOrig();
	}

	if (whatever instanceof PolyStringType) {
		return ((PolyStringType)whatever).getOrig();
	}
	
	if (whatever instanceof Collection) {
		Collection collection = (Collection)whatever;
		if (collection.isEmpty()) {
			return "";
		}
		if (collection.size() > 1) {
			throw new IllegalArgumentException("Cannot stringify collection because it has "+collection.size()+" values");
		}
		whatever = collection.iterator().next();
	}
	
	Class<? extends Object> whateverClass = whatever.getClass();
	if (whateverClass.isArray()) {
		Object[] array = (Object[])whatever;
		if (array.length == 0) {
			return "";
		}
		if (array.length > 1) {
			throw new IllegalArgumentException("Cannot stringify array because it has "+array.length+" values");
		}
		whatever = array[0];
	}
	
	if (whatever == null) {
		return "";
	}
	
	if (whatever instanceof String) {
		return (String)whatever;
	}
	
	if (whatever instanceof PolyString) {
		return ((PolyString)whatever).getOrig();
	}

	if (whatever instanceof PolyStringType) {
		return ((PolyStringType)whatever).getOrig();
	}
	
	if (whatever instanceof Element) {
		Element element = (Element)whatever;
		Element origElement = DOMUtil.getChildElement(element, PolyString.F_ORIG);
		if (origElement != null) {
			// This is most likely a PolyStringType
			return origElement.getTextContent();
		} else {
			return element.getTextContent();
		}
	}
	
	if (whatever instanceof Node) {
		return ((Node)whatever).getTextContent();
	}

	return whatever.toString();
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:80,代码来源:BasicExpressionFunctions.java

示例7: testFilterUserAndJaxb

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

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

	assertNotNull(query);

	ObjectFilter filter = query.getFilter();
	PrismAsserts.assertAndFilter(filter, 2);
	
	ObjectFilter first = getFilterCondition(filter, 0);
	PrismAsserts.assertEqualsFilter(first, UserType.F_GIVEN_NAME, DOMUtil.XSD_STRING,
			new ItemPath(new QName(null,UserType.F_GIVEN_NAME.getLocalPart())));
	PrismAsserts.assertEqualsFilterValue((EqualFilter) first, "Jack");
	
	ObjectFilter second = getFilterCondition(filter, 1);
	PrismAsserts.assertEqualsFilter(second, UserType.F_LOCALITY, DOMUtil.XSD_STRING,
			new ItemPath(new QName(null,UserType.F_LOCALITY.getLocalPart())));
	PrismAsserts.assertEqualsFilterValue((EqualFilter) second, "Caribbean");

	QueryType convertedQueryType = toQueryType(query);
	System.out.println("Re-converted query type");
	System.out.println(convertedQueryType.debugDump());
	
	SearchFilterType convertedFilterType = convertedQueryType.getFilter();
	MapXNode xFilter = convertedFilterType.serializeToXNode();
	PrismAsserts.assertSize(xFilter, 1);
	PrismAsserts.assertSubnode(xFilter, AndFilter.ELEMENT_NAME, MapXNode.class);
	MapXNode xandmap = (MapXNode) xFilter.get(AndFilter.ELEMENT_NAME);
	PrismAsserts.assertSize(xandmap, 1);
	PrismAsserts.assertSubnode(xandmap, EqualFilter.ELEMENT_NAME, ListXNode.class);
	ListXNode xequalsList = (ListXNode) xandmap.get(EqualFilter.ELEMENT_NAME);
	PrismAsserts.assertSize(xequalsList, 2);
	
	Element filterClauseElement = convertedFilterType.getFilterClauseAsElement(getPrismContext());
	System.out.println("Serialized filter (JAXB->DOM)");
	System.out.println(DOMUtil.serializeDOMToString(filterClauseElement));
	
	DomAsserts.assertElementQName(filterClauseElement, AndFilter.ELEMENT_NAME);
	DomAsserts.assertSubElements(filterClauseElement, 2);
	
	Element firstSubelement = DOMUtil.getChildElement(filterClauseElement, 0);
	DomAsserts.assertElementQName(firstSubelement, EqualFilter.ELEMENT_NAME);
	Element firstValueElement = DOMUtil.getChildElement(firstSubelement, PrismConstants.Q_VALUE);
	DomAsserts.assertTextContent(firstValueElement, "Jack");
	
	Element secondSubelement = DOMUtil.getChildElement(filterClauseElement, 1);
	DomAsserts.assertElementQName(secondSubelement, EqualFilter.ELEMENT_NAME);
	Element secondValueElement = DOMUtil.getChildElement(secondSubelement, PrismConstants.Q_VALUE);
	DomAsserts.assertTextContent(secondValueElement, "Caribbean");
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:55,代码来源:TestQueryConvertors.java

示例8: testAccountFilter

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

	SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_FILE);
	ObjectQuery query = toObjectQuery(ShadowType.class, filterType);
	displayQuery(query);

	assertNotNull(query);

	ObjectFilter filter = query.getFilter();
	PrismAsserts.assertAndFilter(filter, 2);

	ObjectFilter first = getFilterCondition(filter, 0);
	PrismAsserts.assertEqualsFilter(first, ShadowType.F_FAILED_OPERATION_TYPE, FAILED_OPERATION_TYPE_QNAME,
			new ItemPath(ShadowType.F_FAILED_OPERATION_TYPE));
	PrismAsserts.assertEqualsFilterValue((EqualFilter) first, FailedOperationTypeType.ADD);

	ObjectFilter second = getFilterCondition(filter, 1);
	PrismAsserts.assertEqualsFilter(second, ShadowType.F_NAME, PolyStringType.COMPLEX_TYPE, new ItemPath(
			ShadowType.F_NAME));
	PrismAsserts.assertEqualsFilterValue((EqualFilter) second, createPolyString("someName"));

	QueryType convertedQueryType = toQueryType(query);
	System.out.println("Re-converted query type");
	System.out.println(convertedQueryType.debugDump());
	
	SearchFilterType convertedFilterType = convertedQueryType.getFilter();
	MapXNode xFilter = convertedFilterType.serializeToXNode();
	PrismAsserts.assertSize(xFilter, 1);
	PrismAsserts.assertSubnode(xFilter, AndFilter.ELEMENT_NAME, MapXNode.class);
	MapXNode xandmap = (MapXNode) xFilter.get(AndFilter.ELEMENT_NAME);
	PrismAsserts.assertSize(xandmap, 1);
	PrismAsserts.assertSubnode(xandmap, EqualFilter.ELEMENT_NAME, ListXNode.class);
	ListXNode xequalsList = (ListXNode) xandmap.get(EqualFilter.ELEMENT_NAME);
	PrismAsserts.assertSize(xequalsList, 2);
	
	Element filterClauseElement = convertedFilterType.getFilterClauseAsElement(getPrismContext());
	System.out.println("Serialized filter (JAXB->DOM)");
	System.out.println(DOMUtil.serializeDOMToString(filterClauseElement));
	
	DomAsserts.assertElementQName(filterClauseElement, AndFilter.ELEMENT_NAME);
	DomAsserts.assertSubElements(filterClauseElement, 2);
	
	Element firstSubelement = DOMUtil.getChildElement(filterClauseElement, 0);
	DomAsserts.assertElementQName(firstSubelement, EqualFilter.ELEMENT_NAME);
	Element firstValueElement = DOMUtil.getChildElement(firstSubelement, PrismConstants.Q_VALUE);
	DomAsserts.assertTextContent(firstValueElement, "add");
	
	Element secondSubelement = DOMUtil.getChildElement(filterClauseElement, 1);
	DomAsserts.assertElementQName(secondSubelement, EqualFilter.ELEMENT_NAME);
	Element secondValueElement = DOMUtil.getChildElement(secondSubelement, PrismConstants.Q_VALUE);
	DomAsserts.assertTextContent(secondValueElement, "someName");
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:55,代码来源:TestQueryConvertor.java


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