Skip to content

Commit

Permalink
Do not throw exception if namespace is missing
Browse files Browse the repository at this point in the history
Just use .namespace() to return namespace, and if namespace is null, just use name.

JIRA: LIGHTY-298
Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
  • Loading branch information
Tobianas committed May 14, 2024
1 parent c5ae862 commit 7bbeb68
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.MissingNameSpaceException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.yangtools.yang.common.QName;
Expand Down Expand Up @@ -91,20 +90,14 @@ public static Optional<? extends NotificationDefinition> loadNotification(
* @return {@link QName} for input data or empty.
*/
public static Optional<QName> getRpcQName(final XmlElement xmlElement) {
String optionalNamespace = null;
try {
optionalNamespace = xmlElement.getNamespace();
} catch (MissingNameSpaceException e) {
throw new RuntimeException(e);
}
String namespace = xmlElement.namespace();
String name = xmlElement.getName();
if (Strings.isNullOrEmpty(name)) {
return Optional.empty();
}
String revision = null;
String namespace;
if (optionalNamespace != null) {
String[] split = optionalNamespace.split("\\?");
if (namespace != null) {
String[] split = namespace.split("\\?");
if (split.length > 1 && split[1].contains("revision=")) {
revision = split[1].replace("revision=", "");

Expand Down

0 comments on commit 7bbeb68

Please sign in to comment.