本文整理了Java中org.opendaylight.controller.config.util.xml.XmlElement.getNamespace()
方法的一些代码示例,展示了XmlElement.getNamespace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlElement.getNamespace()
方法的具体详情如下:
包路径:org.opendaylight.controller.config.util.xml.XmlElement
类名称:XmlElement
方法名:getNamespace
暂无
代码示例来源:origin: org.opendaylight.controller/config-util
public void checkNamespace(String expectedNamespace) throws UnexpectedNamespaceException, MissingNameSpaceException {
if (!getNamespace().equals(expectedNamespace))
{
throw new UnexpectedNamespaceException(String.format("Unexpected namespace %s should be %s",
getNamespace(),
expectedNamespace),
DocumentedException.ErrorType.application,
DocumentedException.ErrorTag.operation_failed,
DocumentedException.ErrorSeverity.error);
}
}
代码示例来源:origin: org.opendaylight.controller/config-util
public XmlElement getOnlyChildElementWithSameNamespace(String childName) throws DocumentedException {
return getOnlyChildElement(childName, getNamespace());
}
代码示例来源:origin: org.opendaylight.controller/config-util
@Override
public boolean accept(Element e) {
try {
return XmlElement.fromDomElement(e).getNamespace().equals(namespace);
} catch (MissingNameSpaceException e1) {
return false;
}
}
代码示例来源:origin: org.opendaylight.controller/config-util
public List<XmlElement> getChildElementsWithSameNamespace(final String childName) throws MissingNameSpaceException {
List<XmlElement> children = getChildElementsWithinNamespace(getNamespace());
return Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
@Override
public boolean apply(XmlElement xmlElement) {
return xmlElement.getName().equals(childName);
}
}));
}
代码示例来源:origin: org.opendaylight.controller/config-util
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("XmlElement{");
sb.append("name='").append(getName()).append('\'');
if (element.getNamespaceURI() != null) {
try {
sb.append(", namespace='").append(getNamespace()).append('\'');
} catch (MissingNameSpaceException e) {
LOG.trace("Missing namespace for element.");
}
}
sb.append('}');
return sb.toString();
}
代码示例来源:origin: org.opendaylight.controller/config-util
public XmlElement getOnlyChildElementWithSameNamespace() throws DocumentedException {
XmlElement childElement = getOnlyChildElement();
childElement.checkNamespace(getNamespace());
return childElement;
}
代码示例来源:origin: org.opendaylight.netconf/netconf-util
public OperationNameAndNamespace(final Document message) throws DocumentedException {
XmlElement requestElement = null;
requestElement = getRequestElementWithCheck(message);
operationElement = requestElement.getOnlyChildElement();
operationName = operationElement.getName();
namespace = operationElement.getNamespace();
}
代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector
/**
* Recursively checks filter elements against the schema. Returns tree of nodes QNames as they appear in filter.
* @param element element to check
* @param parentNodeSchema parent node schema
* @param tree parent node tree
* @return tree
* @throws ValidationException if filter content is not valid
*/
private FilterTree validateNode(XmlElement element, DataSchemaNode parentNodeSchema, FilterTree tree) throws ValidationException {
final List<XmlElement> childElements = element.getChildElements();
for (XmlElement childElement : childElements) {
try {
final Deque<DataSchemaNode> path = findSchemaNodeByNameAndNamespace(parentNodeSchema, childElement.getName(), new URI(childElement.getNamespace()));
if (path.isEmpty()) {
throw new ValidationException(element, childElement);
}
FilterTree subtree = tree;
for (DataSchemaNode dataSchemaNode : path) {
subtree = subtree.addChild(dataSchemaNode);
}
final DataSchemaNode childSchema = path.getLast();
validateNode(childElement, childSchema, subtree);
} catch (URISyntaxException | MissingNameSpaceException e) {
throw new RuntimeException("Wrong namespace in element + " + childElement.toString());
}
}
return tree;
}
代码示例来源:origin: org.opendaylight.netconf/config-netconf-connector
final String netconfOperationNamespace;
try {
netconfOperationNamespace = operationElement.getNamespace();
} catch (DocumentedException e) {
LOG.debug("Cannot retrieve netconf operation namespace from message due to ", e);
代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector
@Override
protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) throws DocumentedException {
final Datastore targetDatastore = extractTargetParameter(operationElement);
if (targetDatastore == Datastore.running) {
throw new DocumentedException("edit-config on running datastore is not supported",
ErrorType.protocol,
ErrorTag.operation_not_supported,
ErrorSeverity.error);
}
final ModifyAction defaultAction = getDefaultOperation(operationElement);
final XmlElement configElement = getElement(operationElement, CONFIG_KEY);
for (XmlElement element : configElement.getChildElements()) {
final String ns = element.getNamespace();
final DataSchemaNode schemaNode = getSchemaNodeFromNamespace(ns, element).get();
final DataTreeChangeTracker changeTracker = new DataTreeChangeTracker(defaultAction);
final DomToNormalizedNodeParserFactory.BuildingStrategyProvider editOperationStrategyProvider = new EditOperationStrategyProvider(changeTracker);
parseIntoNormalizedNode(schemaNode, element, editOperationStrategyProvider);
executeOperations(changeTracker);
}
return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
}
代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector
/**
* Validates filter content against this validator schema context. If the filter is valid, method returns {@link YangInstanceIdentifier}
* of node which can be used as root for data selection.
* @param filterContent filter content
* @return YangInstanceIdentifier
* @throws DocumentedException if filter content is not valid
*/
public YangInstanceIdentifier validate(XmlElement filterContent) throws DocumentedException {
try {
final URI namespace = new URI(filterContent.getNamespace());
final Module module = schemaContext.getCurrentContext().findModuleByNamespaceAndRevision(namespace, null);
final DataSchemaNode schema = getRootDataSchemaNode(module, namespace, filterContent.getName());
final FilterTree filterTree = validateNode(filterContent, schema, new FilterTree(schema.getQName(), Type.OTHER));
return getFilterDataRoot(filterTree, YangInstanceIdentifier.builder());
} catch (DocumentedException e) {
throw e;
} catch (Exception e) {
throw new DocumentedException("Validation failed. Cause: " + e.getMessage(),
DocumentedException.ErrorType.application,
DocumentedException.ErrorTag.unknown_namespace,
DocumentedException.ErrorSeverity.error);
}
}
代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector
final String netconfOperationNamespace;
try {
netconfOperationNamespace = operationElement.getNamespace();
} catch (DocumentedException e) {
LOG.debug("Cannot retrieve netconf operation namespace from message due to ", e);
内容来源于网络,如有侵权,请联系作者删除!