mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-05 04:06:49 +02:00
netconf RPC message parsing utils
Change-Id: I23d0d1a95bff3f193601eaa792e7574b7cc621de
This commit is contained in:
parent
725ed548d2
commit
d1c413ba8f
37
protocols/netconf/api/gen-rpc.sh
Executable file
37
protocols/netconf/api/gen-rpc.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Generate code from XML schema
|
||||
# it would be better to specify path to latest xjc (e.g., one with JDK9)
|
||||
XJC=${XJC:-xjc}
|
||||
$XJC -p org.onosproject.netconf.rpc -d src/main/java -no-header https://www.iana.org/assignments/xml-registry/schema/netconf.xsd
|
||||
|
||||
# Adding Copyright header + checkstyle ignore comment
|
||||
# patching javadoc syntax issue
|
||||
for s in src/main/java/org/onosproject/netconf/rpc/*.java ; do
|
||||
ed -s $s << EOF
|
||||
H
|
||||
0a
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
.
|
||||
w
|
||||
,g/</s|>|\>|
|
||||
.
|
||||
w
|
||||
EOF
|
||||
chmod 444 $s
|
||||
done
|
||||
@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.onosproject.netconf;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
|
||||
import org.onosproject.netconf.rpc.ErrorInfoType;
|
||||
import org.onosproject.netconf.rpc.ErrorSeverity;
|
||||
import org.onosproject.netconf.rpc.ErrorTag;
|
||||
import org.onosproject.netconf.rpc.ErrorType;
|
||||
import org.onosproject.netconf.rpc.RpcErrorType;
|
||||
import org.onosproject.netconf.rpc.RpcErrorType.ErrorMessage;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* Wrapper around {@link RpcErrorType} for ease of handling and logging.
|
||||
*
|
||||
* @see NetconfRpcParserUtil
|
||||
*/
|
||||
@Beta
|
||||
public class NetconfRpcError {
|
||||
|
||||
/**
|
||||
* Protocol mandated error-info: {@value}.
|
||||
*/
|
||||
public static final String BAD_ATTRIBUTE = "bad-attribute";
|
||||
/**
|
||||
* Protocol mandated error-info: {@value}.
|
||||
*/
|
||||
public static final String BAD_ELEMENT = "bad-element";
|
||||
/**
|
||||
* Protocol mandated error-info: {@value}.
|
||||
*/
|
||||
public static final String OK_ELEMENT = "ok-element";
|
||||
/**
|
||||
* Protocol mandated error-info: {@value}.
|
||||
*/
|
||||
public static final String ERR_ELEMENT = "err-element";
|
||||
/**
|
||||
* Protocol mandated error-info: {@value}.
|
||||
*/
|
||||
public static final String NOOP_ELEMENT = "noop-element";
|
||||
/**
|
||||
* Protocol mandated error-info: {@value}.
|
||||
*/
|
||||
public static final String BAD_NAMESPACE = "bad-namespace";
|
||||
|
||||
private final RpcErrorType msg;
|
||||
|
||||
|
||||
public static final NetconfRpcError wrap(RpcErrorType msg) {
|
||||
return new NetconfRpcError(msg);
|
||||
}
|
||||
|
||||
protected NetconfRpcError(RpcErrorType msg) {
|
||||
this.msg = checkNotNull(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns conceptual layer that the error occurred.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public ErrorType type() {
|
||||
return msg.getErrorType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a tag identifying the error condition.
|
||||
*
|
||||
* @return the tag
|
||||
*/
|
||||
public ErrorTag tag() {
|
||||
return msg.getErrorTag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns error severity.
|
||||
*
|
||||
* @return severity
|
||||
*/
|
||||
public ErrorSeverity severity() {
|
||||
return msg.getErrorSeverity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string identifying the data-model-specific
|
||||
* or implementation-specific error condition, if one exists.
|
||||
*
|
||||
* @return app tag
|
||||
*/
|
||||
public Optional<String> appTag() {
|
||||
return Optional.ofNullable(msg.getErrorAppTag());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns absolute XPath expression identifying the element path
|
||||
* to the node that is associated with the error being reported.
|
||||
*
|
||||
* @return XPath expression
|
||||
*/
|
||||
public Optional<String> path() {
|
||||
return Optional.ofNullable(msg.getErrorPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns human readable error message.
|
||||
*
|
||||
* @return message
|
||||
*/
|
||||
//@Nonnull
|
||||
public String message() {
|
||||
return Optional.ofNullable(msg.getErrorMessage())
|
||||
.map(ErrorMessage::getValue)
|
||||
.orElse("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns session-id in error-info if any.
|
||||
*
|
||||
* @return session-id
|
||||
*/
|
||||
public Optional<Long> infoSessionId() {
|
||||
return Optional.ofNullable(msg.getErrorInfo())
|
||||
.map(ErrorInfoType::getSessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns protocol-mandated contents if any.
|
||||
*
|
||||
* @return Map containing protocol-mandated contents
|
||||
* <p>
|
||||
* Possible Map keys:
|
||||
* {@link #BAD_ATTRIBUTE},
|
||||
* {@link #BAD_ELEMENT},
|
||||
* {@link #OK_ELEMENT},
|
||||
* {@link #ERR_ELEMENT},
|
||||
* {@link #NOOP_ELEMENT},
|
||||
* {@link #BAD_NAMESPACE}
|
||||
*/
|
||||
@Beta
|
||||
public Map<String, String> info() {
|
||||
return Optional.ofNullable(msg.getErrorInfo())
|
||||
.map(ErrorInfoType::getBadAttributeAndBadElementAndOkElement)
|
||||
.map(Collection::stream)
|
||||
.orElse(Stream.empty())
|
||||
.collect(Collectors.<JAXBElement<? extends Serializable>,
|
||||
String, String, Map<String, String>>
|
||||
toMap(elm -> elm.getName().getLocalPart(),
|
||||
elm -> String.valueOf(elm.getValue()),
|
||||
(v1, v2) -> v1,
|
||||
LinkedHashMap::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns any other elements if present.
|
||||
*
|
||||
* @return any other elements
|
||||
*/
|
||||
@Beta
|
||||
public List<Object> infoAny() {
|
||||
return Optional.ofNullable(msg.getErrorInfo())
|
||||
.map(ErrorInfoType::getAny)
|
||||
.orElse(ImmutableList.of());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns protocol- or data-model-specific error content.
|
||||
*
|
||||
* @return error info
|
||||
*/
|
||||
@Beta
|
||||
public Optional<ErrorInfoType> rawInfo() {
|
||||
return Optional.ofNullable(msg.getErrorInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("type", type())
|
||||
.add("tag", tag())
|
||||
.add("severity", severity())
|
||||
.add("appTag", appTag().orElse(null))
|
||||
.add("path", path().orElse(null))
|
||||
.add("message", Strings.emptyToNull(message()))
|
||||
.add("info-session-id", infoSessionId().orElse(null))
|
||||
.add("info", info())
|
||||
.omitNullValues()
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright 2017-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.onosproject.netconf;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* Represents class of errors related to NETCONF rpc messaging.
|
||||
*/
|
||||
@Beta
|
||||
public class NetconfRpcException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -5947975698207522820L;
|
||||
|
||||
private final List<NetconfRpcError> error;
|
||||
|
||||
/**
|
||||
* @param errors RPC error message body
|
||||
*/
|
||||
public NetconfRpcException(List<NetconfRpcError> errors) {
|
||||
super(getErrorMsg(errors));
|
||||
this.error = ImmutableList.copyOf(errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param errors RPC error message body
|
||||
* @param message describing the error
|
||||
*/
|
||||
public NetconfRpcException(List<NetconfRpcError> errors, String message) {
|
||||
super(message);
|
||||
this.error = ImmutableList.copyOf(errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param errors RPC error message body
|
||||
* @param cause of this exception
|
||||
*/
|
||||
public NetconfRpcException(List<NetconfRpcError> errors, Throwable cause) {
|
||||
super(getErrorMsg(errors), cause);
|
||||
this.error = ImmutableList.copyOf(errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param errors RPC error message body
|
||||
* @param message describing the error
|
||||
* @param cause of this exception
|
||||
*/
|
||||
public NetconfRpcException(List<NetconfRpcError> errors, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.error = ImmutableList.copyOf(errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves rpc-error details.
|
||||
*
|
||||
* @return the rpc-errors
|
||||
*/
|
||||
public List<NetconfRpcError> rpcErrors() {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " " + error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first non-empty error message or {@code ""}.
|
||||
* @param errors to fetch message from
|
||||
* @return first non-empty error message or {@code ""}
|
||||
*/
|
||||
private static String getErrorMsg(List<NetconfRpcError> errors) {
|
||||
return errors.stream()
|
||||
.map(NetconfRpcError::message)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.findFirst().orElse("");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.onosproject.netconf;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stax.StAXSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.onosproject.netconf.rpc.RpcErrorType;
|
||||
import org.slf4j.Logger;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.io.CharSource;
|
||||
import com.google.common.io.CharStreams;
|
||||
|
||||
@Beta
|
||||
public final class NetconfRpcParserUtil {
|
||||
|
||||
private static final Logger log = getLogger(NetconfRpcParserUtil.class);
|
||||
|
||||
/**
|
||||
* Parse first rpc-reply contained in the input.
|
||||
*
|
||||
* @param xml input
|
||||
* @return {@link NetconfRpcReply} or null on error
|
||||
*/
|
||||
public static NetconfRpcReply parseRpcReply(CharSequence xml) {
|
||||
XMLInputFactory xif = XMLInputFactory.newFactory();
|
||||
try {
|
||||
XMLStreamReader xsr = xif.createXMLStreamReader(CharSource.wrap(xml).openStream());
|
||||
return parseRpcReply(xsr);
|
||||
} catch (XMLStreamException | IOException e) {
|
||||
log.error("Exception thrown creating XMLStreamReader", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse first rpc-reply contained in the input.
|
||||
*
|
||||
* @param xsr input
|
||||
* @return {@link NetconfRpcReply} or null on error
|
||||
*/
|
||||
public static NetconfRpcReply parseRpcReply(XMLStreamReader xsr) {
|
||||
try {
|
||||
for ( ; xsr.hasNext(); xsr.next()) {
|
||||
if (xsr.isStartElement() &&
|
||||
xsr.getName().getLocalPart().equals("rpc-reply")) {
|
||||
|
||||
NetconfRpcReply.Builder builder = NetconfRpcReply.builder();
|
||||
String msgId = xsr.getAttributeValue(null, "message-id");
|
||||
builder.withMessageId(msgId);
|
||||
xsr.nextTag();
|
||||
|
||||
return parseRpcReplyBody(builder, xsr);
|
||||
}
|
||||
}
|
||||
} catch (XMLStreamException e) {
|
||||
log.error("Exception thrown parsing rpc-reply", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static NetconfRpcReply parseRpcReplyBody(NetconfRpcReply.Builder builder,
|
||||
XMLStreamReader xsr) {
|
||||
|
||||
try {
|
||||
for ( ; xsr.hasNext(); xsr.next()) {
|
||||
if (xsr.isStartElement()) {
|
||||
switch (xsr.getName().getLocalPart()) {
|
||||
case "ok":
|
||||
try {
|
||||
// skip to end of tag event
|
||||
xsr.getElementText();
|
||||
} catch (XMLStreamException e) {
|
||||
log.warn("Failed parsing ok", e);
|
||||
}
|
||||
// ok should be the only element
|
||||
return builder.buildOk();
|
||||
|
||||
case "rpc-error":
|
||||
try {
|
||||
JAXBContext context = JAXBContext.newInstance(RpcErrorType.class);
|
||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||
JAXBElement<RpcErrorType> error = unmarshaller.unmarshal(xsr, RpcErrorType.class);
|
||||
builder.addError(NetconfRpcError.wrap(error.getValue()));
|
||||
} catch (JAXBException e) {
|
||||
log.warn("Failed parsing rpc-error", e);
|
||||
}
|
||||
break;
|
||||
|
||||
default: // =rpc-response
|
||||
QName qName = xsr.getName();
|
||||
try {
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
Transformer t = tf.newTransformer();
|
||||
|
||||
t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
t.transform(new StAXSource(xsr),
|
||||
new StreamResult(CharStreams.asWriter(sb)));
|
||||
builder.addResponses(sb.toString());
|
||||
} catch (TransformerException e) {
|
||||
log.warn("Failed parsing {}", qName, e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (XMLStreamException e) {
|
||||
log.error("Exception thrown parsing rpc-reply body", e);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts XML object into a String.
|
||||
*
|
||||
* @param xml Object (e.g., DOM {@link Node})
|
||||
* @return String representation of {@code xml} or empty on error.
|
||||
*/
|
||||
@Beta
|
||||
public static String toString(Object xml) {
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
try {
|
||||
Transformer t = tf.newTransformer();
|
||||
t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
Source xmlSource = null;
|
||||
if (xml instanceof Node) {
|
||||
xmlSource = new DOMSource((Node) xml);
|
||||
} else if (xml instanceof XMLEventReader) {
|
||||
xmlSource = new StAXSource((XMLEventReader) xml);
|
||||
} else if (xml instanceof XMLStreamReader) {
|
||||
xmlSource = new StAXSource((XMLStreamReader) xml);
|
||||
} else {
|
||||
log.warn("Unknown XML object type: {}, {}", xml.getClass(), xml);
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
t.transform(xmlSource, new StreamResult(CharStreams.asWriter(sb)));
|
||||
return sb.toString();
|
||||
} catch (TransformerException | XMLStreamException e) {
|
||||
log.error("Exception thrown", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private NetconfRpcParserUtil() {}
|
||||
|
||||
}
|
||||
@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.onosproject.netconf;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Representation of rpc-reply.
|
||||
*
|
||||
* @see NetconfRpcParserUtil
|
||||
*/
|
||||
@Beta
|
||||
public class NetconfRpcReply {
|
||||
|
||||
private static final Logger log = getLogger(NetconfRpcReply.class);
|
||||
|
||||
public enum Type {
|
||||
OK,
|
||||
ERROR,
|
||||
RESPONSE
|
||||
}
|
||||
|
||||
private final Set<NetconfRpcReply.Type> replies;
|
||||
|
||||
private final String messageId;
|
||||
|
||||
// rpc-reply is ok or (0+ rpc-error and/or 0+ rpc-response)
|
||||
|
||||
private final List<NetconfRpcError> errors;
|
||||
private final List<String> responses;
|
||||
|
||||
protected NetconfRpcReply(NetconfRpcReply.Builder builder) {
|
||||
this.messageId = checkNotNull(builder.messageId);
|
||||
this.replies = ImmutableSet.copyOf(builder.replies);
|
||||
this.errors = ImmutableList.copyOf(builder.errors);
|
||||
this.responses = ImmutableList.copyOf(builder.responses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns message-id of this message.
|
||||
*
|
||||
* @return message-id
|
||||
*/
|
||||
//@Nonnull
|
||||
public String messageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if ok reply.
|
||||
*
|
||||
* @return true if ok reply.
|
||||
*/
|
||||
public boolean isOk() {
|
||||
return replies.contains(Type.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if reply contains rpc-error.
|
||||
*
|
||||
* @return true if reply contains rpc-error
|
||||
*/
|
||||
public boolean hasError() {
|
||||
return replies.contains(Type.ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of rpc-errors in rpc-reply.
|
||||
*
|
||||
* @return list of rpc-errors in rpc-reply.
|
||||
*/
|
||||
public List<NetconfRpcError> errors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of rpc responses in rpc-reply.
|
||||
*
|
||||
* @return list of rpc responses in rpc-reply.
|
||||
*/
|
||||
public List<String> responses() {
|
||||
return responses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("messageId", messageId)
|
||||
.add("replies", replies)
|
||||
.add("errors", errors)
|
||||
.add("responses", responses)
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates builder to build {@link NetconfRpcReply}.
|
||||
* @return created builder
|
||||
*/
|
||||
public static NetconfRpcReply.Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder to build {@link NetconfRpcReply}.
|
||||
*/
|
||||
public static final class Builder {
|
||||
private String messageId;
|
||||
private Set<NetconfRpcReply.Type> replies = EnumSet.noneOf(NetconfRpcReply.Type.class);
|
||||
private List<NetconfRpcError> errors = new ArrayList<>();
|
||||
private List<String> responses = new ArrayList<>();
|
||||
|
||||
private Builder() {}
|
||||
|
||||
/**
|
||||
* Builder method to set message-id.
|
||||
*
|
||||
* @param messageId field to set
|
||||
* @return builder
|
||||
*/
|
||||
public NetconfRpcReply.Builder withMessageId(String messageId) {
|
||||
this.messageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder method to adding error parameter.
|
||||
*
|
||||
* @param error field to add
|
||||
* @return builder
|
||||
*/
|
||||
public NetconfRpcReply.Builder addError(NetconfRpcError error) {
|
||||
this.replies.add(Type.ERROR);
|
||||
this.errors.add(error);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder method for adding response parameter.
|
||||
*
|
||||
* @param response field to add
|
||||
* @return builder
|
||||
*/
|
||||
public NetconfRpcReply.Builder addResponses(String response) {
|
||||
this.replies.add(Type.RESPONSE);
|
||||
this.responses.add(response);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds ok reply message.
|
||||
* @return ok
|
||||
*/
|
||||
public NetconfRpcReply buildOk() {
|
||||
if (!replies.isEmpty()) {
|
||||
log.warn("Unexpected item in replies area: {}", replies);
|
||||
}
|
||||
this.replies.add(Type.OK);
|
||||
return build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder method of the builder.
|
||||
*
|
||||
* @return built class
|
||||
*/
|
||||
public NetconfRpcReply build() {
|
||||
if (replies.isEmpty()) {
|
||||
log.warn("Empty rpc-reply?");
|
||||
}
|
||||
return new NetconfRpcReply(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for editOperationType.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p>
|
||||
* <pre>
|
||||
* <simpleType name="editOperationType">
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
* <enumeration value="merge"/>
|
||||
* <enumeration value="replace"/>
|
||||
* <enumeration value="create"/>
|
||||
* <enumeration value="delete"/>
|
||||
* <enumeration value="remove"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@XmlType(name = "editOperationType")
|
||||
@XmlEnum
|
||||
public enum EditOperationType {
|
||||
|
||||
@XmlEnumValue("merge")
|
||||
MERGE("merge"),
|
||||
@XmlEnumValue("replace")
|
||||
REPLACE("replace"),
|
||||
@XmlEnumValue("create")
|
||||
CREATE("create"),
|
||||
@XmlEnumValue("delete")
|
||||
DELETE("delete"),
|
||||
@XmlEnumValue("remove")
|
||||
REMOVE("remove");
|
||||
private final String value;
|
||||
|
||||
EditOperationType(String v) {
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static EditOperationType fromValue(String v) {
|
||||
for (EditOperationType c: EditOperationType.values()) {
|
||||
if (c.value.equals(v)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(v);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAnyElement;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
import javax.xml.bind.annotation.XmlElementRefs;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for errorInfoType complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="errorInfoType">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <choice>
|
||||
* <element name="session-id" type="{urn:ietf:params:xml:ns:netconf:base:1.0}SessionIdOrZero"/>
|
||||
* <sequence maxOccurs="unbounded" minOccurs="0">
|
||||
* <sequence>
|
||||
* <element name="bad-attribute" type="{http://www.w3.org/2001/XMLSchema}QName" minOccurs="0"/>
|
||||
* <element name="bad-element" type="{http://www.w3.org/2001/XMLSchema}QName" minOccurs="0"/>
|
||||
* <element name="ok-element" type="{http://www.w3.org/2001/XMLSchema}QName" minOccurs="0"/>
|
||||
* <element name="err-element" type="{http://www.w3.org/2001/XMLSchema}QName" minOccurs="0"/>
|
||||
* <element name="noop-element" type="{http://www.w3.org/2001/XMLSchema}QName" minOccurs="0"/>
|
||||
* <element name="bad-namespace" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </sequence>
|
||||
* </choice>
|
||||
* <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "errorInfoType", propOrder = {
|
||||
"sessionId",
|
||||
"badAttributeAndBadElementAndOkElement",
|
||||
"any"
|
||||
})
|
||||
public class ErrorInfoType {
|
||||
|
||||
@XmlElement(name = "session-id")
|
||||
@XmlSchemaType(name = "unsignedInt")
|
||||
protected Long sessionId;
|
||||
@XmlElementRefs({
|
||||
@XmlElementRef(name = "bad-attribute", namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", type = JAXBElement.class, required = false),
|
||||
@XmlElementRef(name = "bad-element", namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", type = JAXBElement.class, required = false),
|
||||
@XmlElementRef(name = "ok-element", namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", type = JAXBElement.class, required = false),
|
||||
@XmlElementRef(name = "err-element", namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", type = JAXBElement.class, required = false),
|
||||
@XmlElementRef(name = "noop-element", namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", type = JAXBElement.class, required = false),
|
||||
@XmlElementRef(name = "bad-namespace", namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", type = JAXBElement.class, required = false)
|
||||
})
|
||||
protected List<JAXBElement<? extends Serializable>> badAttributeAndBadElementAndOkElement;
|
||||
@XmlAnyElement(lax = true)
|
||||
protected List<Object> any;
|
||||
|
||||
/**
|
||||
* Gets the value of the sessionId property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Long }
|
||||
*
|
||||
*/
|
||||
public Long getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the sessionId property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Long }
|
||||
*
|
||||
*/
|
||||
public void setSessionId(Long value) {
|
||||
this.sessionId = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the badAttributeAndBadElementAndOkElement property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the badAttributeAndBadElementAndOkElement property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getBadAttributeAndBadElementAndOkElement().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
* {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
* {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
* {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
* {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
* {@link JAXBElement }{@code <}{@link String }{@code >}
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<JAXBElement<? extends Serializable>> getBadAttributeAndBadElementAndOkElement() {
|
||||
if (badAttributeAndBadElementAndOkElement == null) {
|
||||
badAttributeAndBadElementAndOkElement = new ArrayList<JAXBElement<? extends Serializable>>();
|
||||
}
|
||||
return this.badAttributeAndBadElementAndOkElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the any property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the any property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getAny().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link Element }
|
||||
* {@link Object }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<Object> getAny() {
|
||||
if (any == null) {
|
||||
any = new ArrayList<Object>();
|
||||
}
|
||||
return this.any;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for ErrorSeverity.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p>
|
||||
* <pre>
|
||||
* <simpleType name="ErrorSeverity">
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
* <enumeration value="error"/>
|
||||
* <enumeration value="warning"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@XmlType(name = "ErrorSeverity")
|
||||
@XmlEnum
|
||||
public enum ErrorSeverity {
|
||||
|
||||
@XmlEnumValue("error")
|
||||
ERROR("error"),
|
||||
@XmlEnumValue("warning")
|
||||
WARNING("warning");
|
||||
private final String value;
|
||||
|
||||
ErrorSeverity(String v) {
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ErrorSeverity fromValue(String v) {
|
||||
for (ErrorSeverity c: ErrorSeverity.values()) {
|
||||
if (c.value.equals(v)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(v);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for ErrorTag.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p>
|
||||
* <pre>
|
||||
* <simpleType name="ErrorTag">
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
* <enumeration value="in-use"/>
|
||||
* <enumeration value="invalid-value"/>
|
||||
* <enumeration value="too-big"/>
|
||||
* <enumeration value="missing-attribute"/>
|
||||
* <enumeration value="bad-attribute"/>
|
||||
* <enumeration value="unknown-attribute"/>
|
||||
* <enumeration value="missing-element"/>
|
||||
* <enumeration value="bad-element"/>
|
||||
* <enumeration value="unknown-element"/>
|
||||
* <enumeration value="unknown-namespace"/>
|
||||
* <enumeration value="access-denied"/>
|
||||
* <enumeration value="lock-denied"/>
|
||||
* <enumeration value="resource-denied"/>
|
||||
* <enumeration value="rollback-failed"/>
|
||||
* <enumeration value="data-exists"/>
|
||||
* <enumeration value="data-missing"/>
|
||||
* <enumeration value="operation-not-supported"/>
|
||||
* <enumeration value="operation-failed"/>
|
||||
* <enumeration value="partial-operation"/>
|
||||
* <enumeration value="malformed-message"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@XmlType(name = "ErrorTag")
|
||||
@XmlEnum
|
||||
public enum ErrorTag {
|
||||
|
||||
@XmlEnumValue("in-use")
|
||||
IN_USE("in-use"),
|
||||
@XmlEnumValue("invalid-value")
|
||||
INVALID_VALUE("invalid-value"),
|
||||
@XmlEnumValue("too-big")
|
||||
TOO_BIG("too-big"),
|
||||
@XmlEnumValue("missing-attribute")
|
||||
MISSING_ATTRIBUTE("missing-attribute"),
|
||||
@XmlEnumValue("bad-attribute")
|
||||
BAD_ATTRIBUTE("bad-attribute"),
|
||||
@XmlEnumValue("unknown-attribute")
|
||||
UNKNOWN_ATTRIBUTE("unknown-attribute"),
|
||||
@XmlEnumValue("missing-element")
|
||||
MISSING_ELEMENT("missing-element"),
|
||||
@XmlEnumValue("bad-element")
|
||||
BAD_ELEMENT("bad-element"),
|
||||
@XmlEnumValue("unknown-element")
|
||||
UNKNOWN_ELEMENT("unknown-element"),
|
||||
@XmlEnumValue("unknown-namespace")
|
||||
UNKNOWN_NAMESPACE("unknown-namespace"),
|
||||
@XmlEnumValue("access-denied")
|
||||
ACCESS_DENIED("access-denied"),
|
||||
@XmlEnumValue("lock-denied")
|
||||
LOCK_DENIED("lock-denied"),
|
||||
@XmlEnumValue("resource-denied")
|
||||
RESOURCE_DENIED("resource-denied"),
|
||||
@XmlEnumValue("rollback-failed")
|
||||
ROLLBACK_FAILED("rollback-failed"),
|
||||
@XmlEnumValue("data-exists")
|
||||
DATA_EXISTS("data-exists"),
|
||||
@XmlEnumValue("data-missing")
|
||||
DATA_MISSING("data-missing"),
|
||||
@XmlEnumValue("operation-not-supported")
|
||||
OPERATION_NOT_SUPPORTED("operation-not-supported"),
|
||||
@XmlEnumValue("operation-failed")
|
||||
OPERATION_FAILED("operation-failed"),
|
||||
@XmlEnumValue("partial-operation")
|
||||
PARTIAL_OPERATION("partial-operation"),
|
||||
@XmlEnumValue("malformed-message")
|
||||
MALFORMED_MESSAGE("malformed-message");
|
||||
private final String value;
|
||||
|
||||
ErrorTag(String v) {
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ErrorTag fromValue(String v) {
|
||||
for (ErrorTag c: ErrorTag.values()) {
|
||||
if (c.value.equals(v)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(v);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for ErrorType.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p>
|
||||
* <pre>
|
||||
* <simpleType name="ErrorType">
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
* <enumeration value="transport"/>
|
||||
* <enumeration value="rpc"/>
|
||||
* <enumeration value="protocol"/>
|
||||
* <enumeration value="application"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@XmlType(name = "ErrorType")
|
||||
@XmlEnum
|
||||
public enum ErrorType {
|
||||
|
||||
@XmlEnumValue("transport")
|
||||
TRANSPORT("transport"),
|
||||
@XmlEnumValue("rpc")
|
||||
RPC("rpc"),
|
||||
@XmlEnumValue("protocol")
|
||||
PROTOCOL("protocol"),
|
||||
@XmlEnumValue("application")
|
||||
APPLICATION("application");
|
||||
private final String value;
|
||||
|
||||
ErrorType(String v) {
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ErrorType fromValue(String v) {
|
||||
for (ErrorType c: ErrorType.values()) {
|
||||
if (c.value.equals(v)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(v);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for anonymous complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType>
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="capabilities">
|
||||
* <complexType>
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="capability" type="{http://www.w3.org/2001/XMLSchema}anyURI" maxOccurs="unbounded"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </element>
|
||||
* <element name="session-id" type="{urn:ietf:params:xml:ns:netconf:base:1.0}SessionId" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"capabilities",
|
||||
"sessionId"
|
||||
})
|
||||
@XmlRootElement(name = "hello")
|
||||
public class Hello {
|
||||
|
||||
@XmlElement(required = true)
|
||||
protected Hello.Capabilities capabilities;
|
||||
@XmlElement(name = "session-id")
|
||||
@XmlSchemaType(name = "unsignedInt")
|
||||
protected Long sessionId;
|
||||
|
||||
/**
|
||||
* Gets the value of the capabilities property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Hello.Capabilities }
|
||||
*
|
||||
*/
|
||||
public Hello.Capabilities getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the capabilities property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Hello.Capabilities }
|
||||
*
|
||||
*/
|
||||
public void setCapabilities(Hello.Capabilities value) {
|
||||
this.capabilities = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the sessionId property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Long }
|
||||
*
|
||||
*/
|
||||
public Long getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the sessionId property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Long }
|
||||
*
|
||||
*/
|
||||
public void setSessionId(Long value) {
|
||||
this.sessionId = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for anonymous complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType>
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="capability" type="{http://www.w3.org/2001/XMLSchema}anyURI" maxOccurs="unbounded"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"capability"
|
||||
})
|
||||
public static class Capabilities {
|
||||
|
||||
@XmlElement(required = true)
|
||||
@XmlSchemaType(name = "anyURI")
|
||||
protected List<String> capability;
|
||||
|
||||
/**
|
||||
* Gets the value of the capability property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the capability property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getCapability().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<String> getCapability() {
|
||||
if (capability == null) {
|
||||
capability = new ArrayList<String>();
|
||||
}
|
||||
return this.capability;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,277 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlElementDecl;
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* This object contains factory methods for each
|
||||
* Java content interface and Java element interface
|
||||
* generated in the org.onosproject.netconf.rpc package.
|
||||
* <p>An ObjectFactory allows you to programatically
|
||||
* construct new instances of the Java representation
|
||||
* for XML content. The Java representation of XML
|
||||
* content can consist of schema derived interfaces
|
||||
* and classes representing the binding of schema
|
||||
* type definitions, element declarations and model
|
||||
* groups. Factory methods for each of these are
|
||||
* provided in this class.
|
||||
*
|
||||
*/
|
||||
@XmlRegistry
|
||||
public class ObjectFactory {
|
||||
|
||||
private final static QName _Rpc_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "rpc");
|
||||
private final static QName _RpcReply_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "rpc-reply");
|
||||
private final static QName _RpcError_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "rpc-error");
|
||||
private final static QName _RpcOperation_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "rpcOperation");
|
||||
private final static QName _RpcResponse_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "rpcResponse");
|
||||
private final static QName _ErrorInfoTypeBadAttribute_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "bad-attribute");
|
||||
private final static QName _ErrorInfoTypeBadElement_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "bad-element");
|
||||
private final static QName _ErrorInfoTypeOkElement_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "ok-element");
|
||||
private final static QName _ErrorInfoTypeErrElement_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "err-element");
|
||||
private final static QName _ErrorInfoTypeNoopElement_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "noop-element");
|
||||
private final static QName _ErrorInfoTypeBadNamespace_QNAME = new QName("urn:ietf:params:xml:ns:netconf:base:1.0", "bad-namespace");
|
||||
|
||||
/**
|
||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.onosproject.netconf.rpc
|
||||
*
|
||||
*/
|
||||
public ObjectFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Hello }
|
||||
*
|
||||
*/
|
||||
public Hello createHello() {
|
||||
return new Hello();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link RpcErrorType }
|
||||
*
|
||||
*/
|
||||
public RpcErrorType createRpcErrorType() {
|
||||
return new RpcErrorType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link RpcType }
|
||||
*
|
||||
*/
|
||||
public RpcType createRpcType() {
|
||||
return new RpcType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link RpcReplyType }
|
||||
*
|
||||
*/
|
||||
public RpcReplyType createRpcReplyType() {
|
||||
return new RpcReplyType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link RpcOperationType }
|
||||
*
|
||||
*/
|
||||
public RpcOperationType createRpcOperationType() {
|
||||
return new RpcOperationType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link RpcResponseType }
|
||||
*
|
||||
*/
|
||||
public RpcResponseType createRpcResponseType() {
|
||||
return new RpcResponseType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Hello.Capabilities }
|
||||
*
|
||||
*/
|
||||
public Hello.Capabilities createHelloCapabilities() {
|
||||
return new Hello.Capabilities();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link ErrorInfoType }
|
||||
*
|
||||
*/
|
||||
public ErrorInfoType createErrorInfoType() {
|
||||
return new ErrorInfoType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link RpcErrorType.ErrorMessage }
|
||||
*
|
||||
*/
|
||||
public RpcErrorType.ErrorMessage createRpcErrorTypeErrorMessage() {
|
||||
return new RpcErrorType.ErrorMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link RpcType }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link RpcType }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "rpc")
|
||||
public JAXBElement<RpcType> createRpc(RpcType value) {
|
||||
return new JAXBElement<RpcType>(_Rpc_QNAME, RpcType.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link RpcReplyType }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link RpcReplyType }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "rpc-reply")
|
||||
public JAXBElement<RpcReplyType> createRpcReply(RpcReplyType value) {
|
||||
return new JAXBElement<RpcReplyType>(_RpcReply_QNAME, RpcReplyType.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link RpcErrorType }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link RpcErrorType }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "rpc-error")
|
||||
public JAXBElement<RpcErrorType> createRpcError(RpcErrorType value) {
|
||||
return new JAXBElement<RpcErrorType>(_RpcError_QNAME, RpcErrorType.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link RpcOperationType }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link RpcOperationType }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "rpcOperation")
|
||||
public JAXBElement<RpcOperationType> createRpcOperation(RpcOperationType value) {
|
||||
return new JAXBElement<RpcOperationType>(_RpcOperation_QNAME, RpcOperationType.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link RpcResponseType }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link RpcResponseType }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "rpcResponse")
|
||||
public JAXBElement<RpcResponseType> createRpcResponse(RpcResponseType value) {
|
||||
return new JAXBElement<RpcResponseType>(_RpcResponse_QNAME, RpcResponseType.class, null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "bad-attribute", scope = ErrorInfoType.class)
|
||||
public JAXBElement<QName> createErrorInfoTypeBadAttribute(QName value) {
|
||||
return new JAXBElement<QName>(_ErrorInfoTypeBadAttribute_QNAME, QName.class, ErrorInfoType.class, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "bad-element", scope = ErrorInfoType.class)
|
||||
public JAXBElement<QName> createErrorInfoTypeBadElement(QName value) {
|
||||
return new JAXBElement<QName>(_ErrorInfoTypeBadElement_QNAME, QName.class, ErrorInfoType.class, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "ok-element", scope = ErrorInfoType.class)
|
||||
public JAXBElement<QName> createErrorInfoTypeOkElement(QName value) {
|
||||
return new JAXBElement<QName>(_ErrorInfoTypeOkElement_QNAME, QName.class, ErrorInfoType.class, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "err-element", scope = ErrorInfoType.class)
|
||||
public JAXBElement<QName> createErrorInfoTypeErrElement(QName value) {
|
||||
return new JAXBElement<QName>(_ErrorInfoTypeErrElement_QNAME, QName.class, ErrorInfoType.class, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link QName }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "noop-element", scope = ErrorInfoType.class)
|
||||
public JAXBElement<QName> createErrorInfoTypeNoopElement(QName value) {
|
||||
return new JAXBElement<QName>(_ErrorInfoTypeNoopElement_QNAME, QName.class, ErrorInfoType.class, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
|
||||
*
|
||||
* @param value
|
||||
* Java instance representing xml element's value.
|
||||
* @return
|
||||
* the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
|
||||
*/
|
||||
@XmlElementDecl(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", name = "bad-namespace", scope = ErrorInfoType.class)
|
||||
public JAXBElement<String> createErrorInfoTypeBadNamespace(String value) {
|
||||
return new JAXBElement<String>(_ErrorInfoTypeBadNamespace_QNAME, String.class, ErrorInfoType.class, value);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,339 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for rpcErrorType complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="rpcErrorType">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="error-type" type="{urn:ietf:params:xml:ns:netconf:base:1.0}ErrorType"/>
|
||||
* <element name="error-tag" type="{urn:ietf:params:xml:ns:netconf:base:1.0}ErrorTag"/>
|
||||
* <element name="error-severity" type="{urn:ietf:params:xml:ns:netconf:base:1.0}ErrorSeverity"/>
|
||||
* <element name="error-app-tag" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* <element name="error-path" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* <element name="error-message" minOccurs="0">
|
||||
* <complexType>
|
||||
* <simpleContent>
|
||||
* <extension base="<http://www.w3.org/2001/XMLSchema>string">
|
||||
* <attribute ref="{http://www.w3.org/XML/1998/namespace}lang"/>
|
||||
* </extension>
|
||||
* </simpleContent>
|
||||
* </complexType>
|
||||
* </element>
|
||||
* <element name="error-info" type="{urn:ietf:params:xml:ns:netconf:base:1.0}errorInfoType" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "rpcErrorType", propOrder = {
|
||||
"errorType",
|
||||
"errorTag",
|
||||
"errorSeverity",
|
||||
"errorAppTag",
|
||||
"errorPath",
|
||||
"errorMessage",
|
||||
"errorInfo"
|
||||
})
|
||||
public class RpcErrorType {
|
||||
|
||||
@XmlElement(name = "error-type", required = true)
|
||||
@XmlSchemaType(name = "string")
|
||||
protected ErrorType errorType;
|
||||
@XmlElement(name = "error-tag", required = true)
|
||||
@XmlSchemaType(name = "string")
|
||||
protected ErrorTag errorTag;
|
||||
@XmlElement(name = "error-severity", required = true)
|
||||
@XmlSchemaType(name = "string")
|
||||
protected ErrorSeverity errorSeverity;
|
||||
@XmlElement(name = "error-app-tag")
|
||||
protected String errorAppTag;
|
||||
@XmlElement(name = "error-path")
|
||||
protected String errorPath;
|
||||
@XmlElement(name = "error-message")
|
||||
protected RpcErrorType.ErrorMessage errorMessage;
|
||||
@XmlElement(name = "error-info")
|
||||
protected ErrorInfoType errorInfo;
|
||||
|
||||
/**
|
||||
* Gets the value of the errorType property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link ErrorType }
|
||||
*
|
||||
*/
|
||||
public ErrorType getErrorType() {
|
||||
return errorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the errorType property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link ErrorType }
|
||||
*
|
||||
*/
|
||||
public void setErrorType(ErrorType value) {
|
||||
this.errorType = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the errorTag property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link ErrorTag }
|
||||
*
|
||||
*/
|
||||
public ErrorTag getErrorTag() {
|
||||
return errorTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the errorTag property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link ErrorTag }
|
||||
*
|
||||
*/
|
||||
public void setErrorTag(ErrorTag value) {
|
||||
this.errorTag = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the errorSeverity property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link ErrorSeverity }
|
||||
*
|
||||
*/
|
||||
public ErrorSeverity getErrorSeverity() {
|
||||
return errorSeverity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the errorSeverity property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link ErrorSeverity }
|
||||
*
|
||||
*/
|
||||
public void setErrorSeverity(ErrorSeverity value) {
|
||||
this.errorSeverity = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the errorAppTag property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getErrorAppTag() {
|
||||
return errorAppTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the errorAppTag property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setErrorAppTag(String value) {
|
||||
this.errorAppTag = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the errorPath property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getErrorPath() {
|
||||
return errorPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the errorPath property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setErrorPath(String value) {
|
||||
this.errorPath = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the errorMessage property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link RpcErrorType.ErrorMessage }
|
||||
*
|
||||
*/
|
||||
public RpcErrorType.ErrorMessage getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the errorMessage property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link RpcErrorType.ErrorMessage }
|
||||
*
|
||||
*/
|
||||
public void setErrorMessage(RpcErrorType.ErrorMessage value) {
|
||||
this.errorMessage = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the errorInfo property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link ErrorInfoType }
|
||||
*
|
||||
*/
|
||||
public ErrorInfoType getErrorInfo() {
|
||||
return errorInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the errorInfo property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link ErrorInfoType }
|
||||
*
|
||||
*/
|
||||
public void setErrorInfo(ErrorInfoType value) {
|
||||
this.errorInfo = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for anonymous complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType>
|
||||
* <simpleContent>
|
||||
* <extension base="<http://www.w3.org/2001/XMLSchema>string">
|
||||
* <attribute ref="{http://www.w3.org/XML/1998/namespace}lang"/>
|
||||
* </extension>
|
||||
* </simpleContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"value"
|
||||
})
|
||||
public static class ErrorMessage {
|
||||
|
||||
@XmlValue
|
||||
protected String value;
|
||||
@XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace")
|
||||
protected String lang;
|
||||
|
||||
/**
|
||||
* Gets the value of the value property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the value property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the lang property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getLang() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the lang property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setLang(String value) {
|
||||
this.lang = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for rpcOperationType complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="rpcOperationType">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "rpcOperationType")
|
||||
public class RpcOperationType {
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAnyAttribute;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for rpcReplyType complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="rpcReplyType">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <choice>
|
||||
* <element name="ok" type="{http://www.w3.org/2001/XMLSchema}anyType"/>
|
||||
* <sequence>
|
||||
* <element ref="{urn:ietf:params:xml:ns:netconf:base:1.0}rpc-error" maxOccurs="unbounded" minOccurs="0"/>
|
||||
* <element ref="{urn:ietf:params:xml:ns:netconf:base:1.0}rpcResponse" maxOccurs="unbounded" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </choice>
|
||||
* <attribute name="message-id" type="{urn:ietf:params:xml:ns:netconf:base:1.0}messageIdType" />
|
||||
* <anyAttribute processContents='lax'/>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "rpcReplyType", propOrder = {
|
||||
"ok",
|
||||
"rpcError",
|
||||
"rpcResponse"
|
||||
})
|
||||
public class RpcReplyType {
|
||||
|
||||
protected Object ok;
|
||||
@XmlElement(name = "rpc-error")
|
||||
protected List<RpcErrorType> rpcError;
|
||||
protected List<RpcResponseType> rpcResponse;
|
||||
@XmlAttribute(name = "message-id")
|
||||
protected String messageId;
|
||||
@XmlAnyAttribute
|
||||
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
|
||||
|
||||
/**
|
||||
* Gets the value of the ok property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Object }
|
||||
*
|
||||
*/
|
||||
public Object getOk() {
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the ok property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Object }
|
||||
*
|
||||
*/
|
||||
public void setOk(Object value) {
|
||||
this.ok = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the rpcError property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the rpcError property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getRpcError().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link RpcErrorType }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<RpcErrorType> getRpcError() {
|
||||
if (rpcError == null) {
|
||||
rpcError = new ArrayList<RpcErrorType>();
|
||||
}
|
||||
return this.rpcError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the rpcResponse property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the rpcResponse property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getRpcResponse().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link RpcResponseType }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<RpcResponseType> getRpcResponse() {
|
||||
if (rpcResponse == null) {
|
||||
rpcResponse = new ArrayList<RpcResponseType>();
|
||||
}
|
||||
return this.rpcResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the messageId property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the messageId property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setMessageId(String value) {
|
||||
this.messageId = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a map that contains attributes that aren't bound to any typed property on this class.
|
||||
*
|
||||
* <p>
|
||||
* the map is keyed by the name of the attribute and
|
||||
* the value is the string value of the attribute.
|
||||
*
|
||||
* the map returned by this method is live, and you can add new attribute
|
||||
* by updating the map directly. Because of this design, there's no setter.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* always non-null
|
||||
*/
|
||||
public Map<QName, String> getOtherAttributes() {
|
||||
return otherAttributes;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for rpcResponseType complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="rpcResponseType">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "rpcResponseType")
|
||||
public class RpcResponseType {
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
package org.onosproject.netconf.rpc;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAnyAttribute;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for rpcType complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="rpcType">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element ref="{urn:ietf:params:xml:ns:netconf:base:1.0}rpcOperation"/>
|
||||
* </sequence>
|
||||
* <attribute name="message-id" use="required" type="{urn:ietf:params:xml:ns:netconf:base:1.0}messageIdType" />
|
||||
* <anyAttribute processContents='lax'/>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "rpcType", propOrder = {
|
||||
"rpcOperation"
|
||||
})
|
||||
public class RpcType {
|
||||
|
||||
@XmlElement(required = true)
|
||||
protected RpcOperationType rpcOperation;
|
||||
@XmlAttribute(name = "message-id", required = true)
|
||||
protected String messageId;
|
||||
@XmlAnyAttribute
|
||||
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
|
||||
|
||||
/**
|
||||
* Gets the value of the rpcOperation property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link RpcOperationType }
|
||||
*
|
||||
*/
|
||||
public RpcOperationType getRpcOperation() {
|
||||
return rpcOperation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the rpcOperation property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link RpcOperationType }
|
||||
*
|
||||
*/
|
||||
public void setRpcOperation(RpcOperationType value) {
|
||||
this.rpcOperation = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the messageId property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the messageId property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setMessageId(String value) {
|
||||
this.messageId = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a map that contains attributes that aren't bound to any typed property on this class.
|
||||
*
|
||||
* <p>
|
||||
* the map is keyed by the name of the attribute and
|
||||
* the value is the string value of the attribute.
|
||||
*
|
||||
* the map returned by this method is live, and you can add new attribute
|
||||
* by updating the map directly. Because of this design, there's no setter.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* always non-null
|
||||
*/
|
||||
public Map<QName, String> getOtherAttributes() {
|
||||
return otherAttributes;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
// CHECKSTYLE:OFF
|
||||
@javax.xml.bind.annotation.XmlSchema(namespace = "urn:ietf:params:xml:ns:netconf:base:1.0", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
|
||||
package org.onosproject.netconf.rpc;
|
||||
@ -0,0 +1,328 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.onosproject.netconf;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.onosproject.netconf.rpc.ErrorSeverity;
|
||||
import org.onosproject.netconf.rpc.ErrorTag;
|
||||
import org.onosproject.netconf.rpc.ErrorType;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
public class NetconfRpcParserUtilTest {
|
||||
|
||||
static final String OK_DATA1 =
|
||||
"<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"3\">\n" +
|
||||
" <ok/>\n" +
|
||||
"</rpc-reply>\n";
|
||||
|
||||
static final String ERROR_XPATH1 =
|
||||
"/rpc/edit-config/config/oc-if:interfaces/oc-if:interface[oc-if:name='foo']/oc-if:config/oc-if:type";
|
||||
|
||||
static final String ERROR_DATA1 =
|
||||
"<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"4\">\n" +
|
||||
" <rpc-error>\n" +
|
||||
" <error-type>application</error-type>\n" +
|
||||
" <error-tag>invalid-value</error-tag>\n" +
|
||||
" <error-severity>error</error-severity>\n" +
|
||||
" <error-path xmlns:oc-if=\"http://openconfig.net/yang/interfaces\">\n" +
|
||||
" /rpc/edit-config/config/oc-if:interfaces/oc-if:interface[oc-if:name='foo']/oc-if:config/oc-if:type\n" +
|
||||
" </error-path>\n" +
|
||||
" <error-message xml:lang=\"en\">\"fastEther\" is not a valid value.</error-message>\n" +
|
||||
" <error-info>\n" +
|
||||
" <bad-element>type</bad-element>\n" +
|
||||
" <something>value</something>" +
|
||||
" </error-info>\n" +
|
||||
" </rpc-error>\n" +
|
||||
"</rpc-reply>";
|
||||
|
||||
static final String RESPONSE_BODY1 =
|
||||
"<data>\n" +
|
||||
" <interfaces xmlns=\"http://openconfig.net/yang/interfaces\">\n" +
|
||||
" <interface>\n" +
|
||||
" <name>foo</name>\n" +
|
||||
" <config>\n" +
|
||||
" <name>foo</name>\n" +
|
||||
" <type xmlns:ianaift=\"urn:ietf:params:xml:ns:yang:iana-if-type\">ianaift:fastEther</type>\n" +
|
||||
" </config>\n" +
|
||||
" </interface>\n" +
|
||||
" </interfaces>\n" +
|
||||
" <components xmlns=\"http://openconfig.net/yang/platform\">\n" +
|
||||
" <component>\n" +
|
||||
" <name>comp1</name>\n" +
|
||||
" <config>\n" +
|
||||
" <name>comp1</name>\n" +
|
||||
" </config>\n" +
|
||||
" </component>\n" +
|
||||
" <component>\n" +
|
||||
" <name>comp2</name>\n" +
|
||||
" <config>\n" +
|
||||
" <name>comp2</name>\n" +
|
||||
" </config>\n" +
|
||||
" </component>\n" +
|
||||
" </components>\n" +
|
||||
" <aaa xmlns=\"http://tail-f.com/ns/aaa/1.1\">\n" +
|
||||
" <authentication>\n" +
|
||||
" <users>\n" +
|
||||
" <user>\n" +
|
||||
" <name>admin</name>\n" +
|
||||
" <uid>9000</uid>\n" +
|
||||
" <gid>20</gid>\n" +
|
||||
" <password>$1$3iwdPGZ1$PBh0MaDjzSFf1jozKYJUI1</password>\n" +
|
||||
" <ssh_keydir>/var/confd/homes/admin/.ssh</ssh_keydir>\n" +
|
||||
" <homedir>/var/confd/homes/admin</homedir>\n" +
|
||||
" </user>\n" +
|
||||
" <user>\n" +
|
||||
" <name>oper</name>\n" +
|
||||
" <uid>9000</uid>\n" +
|
||||
" <gid>20</gid>\n" +
|
||||
" <password>$1$hJImrsyG$Ey294aLU/8wE.Y5vgjqzm/</password>\n" +
|
||||
" <ssh_keydir>/var/confd/homes/oper/.ssh</ssh_keydir>\n" +
|
||||
" <homedir>/var/confd/homes/oper</homedir>\n" +
|
||||
" </user>\n" +
|
||||
" <user>\n" +
|
||||
" <name>private</name>\n" +
|
||||
" <uid>9000</uid>\n" +
|
||||
" <gid>20</gid>\n" +
|
||||
" <password>$1$f85WqsO0$GdtqBqa0yAZXXm5sSCv/M/</password>\n" +
|
||||
" <ssh_keydir>/var/confd/homes/private/.ssh</ssh_keydir>\n" +
|
||||
" <homedir>/var/confd/homes/private</homedir>\n" +
|
||||
" </user>\n" +
|
||||
" <user>\n" +
|
||||
" <name>public</name>\n" +
|
||||
" <uid>9000</uid>\n" +
|
||||
" <gid>20</gid>\n" +
|
||||
" <password>$1$lYiRxyl.$0ofHPegBlwr7asbjz/a/Q.</password>\n" +
|
||||
" <ssh_keydir>/var/confd/homes/public/.ssh</ssh_keydir>\n" +
|
||||
" <homedir>/var/confd/homes/public</homedir>\n" +
|
||||
" </user>\n" +
|
||||
" </users>\n" +
|
||||
" </authentication>\n" +
|
||||
" <ios>\n" +
|
||||
" <level>\n" +
|
||||
" <nr>0</nr>\n" +
|
||||
" <prompt>\\h>\n" +
|
||||
" </prompt>\n" +
|
||||
" </level>\n" +
|
||||
" <level>\n" +
|
||||
" <nr>15</nr>\n" +
|
||||
" <prompt>\\h#\n" +
|
||||
" </prompt>\n" +
|
||||
" </level>\n" +
|
||||
" <privilege>\n" +
|
||||
" <mode>exec</mode>\n" +
|
||||
" <level>\n" +
|
||||
" <nr>0</nr>\n" +
|
||||
" <command>\n" +
|
||||
" <name>action</name>\n" +
|
||||
" </command>\n" +
|
||||
" <command>\n" +
|
||||
" <name>autowizard</name>\n" +
|
||||
" </command>\n" +
|
||||
" <command>\n" +
|
||||
" <name>enable</name>\n" +
|
||||
" </command>\n" +
|
||||
" <command>\n" +
|
||||
" <name>exit</name>\n" +
|
||||
" </command>\n" +
|
||||
" <command>\n" +
|
||||
" <name>help</name>\n" +
|
||||
" </command>\n" +
|
||||
" <command>\n" +
|
||||
" <name>startup</name>\n" +
|
||||
" </command>\n" +
|
||||
" </level>\n" +
|
||||
" <level>\n" +
|
||||
" <nr>15</nr>\n" +
|
||||
" <command>\n" +
|
||||
" <name>configure</name>\n" +
|
||||
" </command>\n" +
|
||||
" </level>\n" +
|
||||
" </privilege>\n" +
|
||||
" </ios>\n" +
|
||||
" </aaa>\n" +
|
||||
" <nacm xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-acm\">\n" +
|
||||
" <write-default>permit</write-default>\n" +
|
||||
" <groups>\n" +
|
||||
" <group>\n" +
|
||||
" <name>admin</name>\n" +
|
||||
" <user-name>admin</user-name>\n" +
|
||||
" <user-name>private</user-name>\n" +
|
||||
" </group>\n" +
|
||||
" <group>\n" +
|
||||
" <name>oper</name>\n" +
|
||||
" <user-name>oper</user-name>\n" +
|
||||
" <user-name>public</user-name>\n" +
|
||||
" </group>\n" +
|
||||
" </groups>\n" +
|
||||
" <rule-list>\n" +
|
||||
" <name>admin</name>\n" +
|
||||
" <group>admin</group>\n" +
|
||||
" <rule>\n" +
|
||||
" <name>any-access</name>\n" +
|
||||
" <action>permit</action>\n" +
|
||||
" </rule>\n" +
|
||||
" </rule-list>\n" +
|
||||
" <rule-list>\n" +
|
||||
" <name>any-group</name>\n" +
|
||||
" <group>*</group>\n" +
|
||||
" <rule>\n" +
|
||||
" <name>tailf-aaa-authentication</name>\n" +
|
||||
" <module-name>tailf-aaa</module-name>\n" +
|
||||
" <path>/aaa/authentication/users/user[name='$USER']</path>\n" +
|
||||
" <access-operations>read update</access-operations>\n" +
|
||||
" <action>permit</action>\n" +
|
||||
" </rule>\n" +
|
||||
" <rule>\n" +
|
||||
" <name>tailf-aaa-user</name>\n" +
|
||||
" <module-name>tailf-aaa</module-name>\n" +
|
||||
" <path>/user[name='$USER']</path>\n" +
|
||||
" <access-operations>create read update delete</access-operations>\n" +
|
||||
" <action>permit</action>\n" +
|
||||
" </rule>\n" +
|
||||
" <rule>\n" +
|
||||
" <name>tailf-webui-user</name>\n" +
|
||||
" <module-name>tailf-webui</module-name>\n" +
|
||||
" <path>/webui/data-stores/user-profile[username='$USER']</path>\n" +
|
||||
" <access-operations>create read update delete</access-operations>\n" +
|
||||
" <action>permit</action>\n" +
|
||||
" </rule>\n" +
|
||||
" </rule-list>\n" +
|
||||
" </nacm>\n" +
|
||||
" </data>";
|
||||
|
||||
static final String RESPONSE_DATA1 =
|
||||
"<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"5\">\n" +
|
||||
" " + RESPONSE_BODY1 + "\n" +
|
||||
"</rpc-reply>";
|
||||
|
||||
static final String ERROR_DATA2 =
|
||||
"<rpc-reply message-id=\"101\"\n" +
|
||||
" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"\n" +
|
||||
" xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
|
||||
" <rpc-error>\n" +
|
||||
" <error-type>application</error-type>\n" +
|
||||
" <error-tag>invalid-value</error-tag>\n" +
|
||||
" <error-severity>error</error-severity>\n" +
|
||||
" <error-path xmlns:t=\"http://example.com/schema/1.2/config\">\n" +
|
||||
" /t:top/t:interface[t:name=\"Ethernet0/0\"]/t:mtu\n" +
|
||||
" </error-path>\n" +
|
||||
" <error-message xml:lang=\"en\">\n" +
|
||||
" MTU value 25000 is not within range 256..9192\n" +
|
||||
" </error-message>\n" +
|
||||
" </rpc-error>\n" +
|
||||
" <rpc-error>\n" +
|
||||
" <error-type>application</error-type>" +
|
||||
" <error-tag>invalid-value</error-tag>\n" +
|
||||
" <error-severity>error</error-severity>\n" +
|
||||
" <error-path xmlns:t=\"http://example.com/schema/1.2/config\">\n" +
|
||||
" /t:top/t:interface[t:name=\"Ethernet1/0\"]/t:address/t:name\n" +
|
||||
" </error-path>\n" +
|
||||
" <error-message xml:lang=\"en\">\n" +
|
||||
" Invalid IP address for interface Ethernet1/0\n" +
|
||||
" </error-message>\n" +
|
||||
" </rpc-error>\n" +
|
||||
" </rpc-reply>";
|
||||
|
||||
|
||||
@Test
|
||||
public void testOkParse() {
|
||||
NetconfRpcReply ok = NetconfRpcParserUtil.parseRpcReply(OK_DATA1);
|
||||
assertThat(ok.isOk(), is(true));
|
||||
assertThat(ok.messageId(), is("3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorWithAnyParse() {
|
||||
|
||||
NetconfRpcReply reply = NetconfRpcParserUtil.parseRpcReply(ERROR_DATA1);
|
||||
|
||||
assertThat(reply.messageId(), is("4"));
|
||||
|
||||
List<NetconfRpcError> errs = reply.errors();
|
||||
assertThat(errs, hasSize(1));
|
||||
|
||||
NetconfRpcError err = errs.get(0);
|
||||
assertThat(err.type(), is(ErrorType.APPLICATION));
|
||||
assertThat(err.tag(), is(ErrorTag.INVALID_VALUE));
|
||||
assertThat(err.severity(), is(ErrorSeverity.ERROR));
|
||||
assertThat(err.path().isPresent(), is(true));
|
||||
assertThat(err.path().get().trim(), is(ERROR_XPATH1));
|
||||
assertThat(err.message(), is(notNullValue()));
|
||||
assertThat(err.message(), is("\"fastEther\" is not a valid value."));
|
||||
assertThat(err.info().get(NetconfRpcError.BAD_ELEMENT), is(endsWith("type")));
|
||||
assertThat(err.info().size(), is(1));
|
||||
assertThat(err.infoAny(), hasSize(1));
|
||||
assertThat(err.infoAny().get(0), is(instanceOf(Node.class)));
|
||||
assertThat(NetconfRpcParserUtil.toString(err.infoAny().get(0)),
|
||||
is(both(startsWith("<something")).and(endsWith("</something>"))));
|
||||
|
||||
assertThat(err.appTag().isPresent(), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorParse() {
|
||||
|
||||
NetconfRpcReply reply = NetconfRpcParserUtil.parseRpcReply(ERROR_DATA2);
|
||||
|
||||
assertThat(reply.messageId(), is("101"));
|
||||
|
||||
List<NetconfRpcError> errs = reply.errors();
|
||||
assertThat(errs, hasSize(2));
|
||||
|
||||
NetconfRpcError err1 = errs.get(0);
|
||||
assertThat(err1.type(), is(ErrorType.APPLICATION));
|
||||
assertThat(err1.tag(), is(ErrorTag.INVALID_VALUE));
|
||||
assertThat(err1.severity(), is(ErrorSeverity.ERROR));
|
||||
assertThat(err1.path().isPresent(), is(true));
|
||||
assertThat(err1.path().get().trim(), is("/t:top/t:interface[t:name=\"Ethernet0/0\"]/t:mtu"));
|
||||
assertThat(err1.message(), is(notNullValue()));
|
||||
assertThat(err1.message().trim(), is("MTU value 25000 is not within range 256..9192"));
|
||||
assertThat(err1.info().size(), is(0));
|
||||
assertThat(err1.infoAny(), hasSize(0));
|
||||
assertThat(err1.appTag().isPresent(), is(false));
|
||||
|
||||
NetconfRpcError err2 = errs.get(1);
|
||||
assertThat(err2.type(), is(ErrorType.APPLICATION));
|
||||
assertThat(err2.tag(), is(ErrorTag.INVALID_VALUE));
|
||||
assertThat(err2.severity(), is(ErrorSeverity.ERROR));
|
||||
assertThat(err2.path().isPresent(), is(true));
|
||||
assertThat(err2.path().get().trim(), is("/t:top/t:interface[t:name=\"Ethernet1/0\"]/t:address/t:name"));
|
||||
assertThat(err2.message(), is(notNullValue()));
|
||||
assertThat(err2.message().trim(), is("Invalid IP address for interface Ethernet1/0"));
|
||||
assertThat(err2.info().size(), is(0));
|
||||
assertThat(err2.infoAny(), hasSize(0));
|
||||
assertThat(err2.appTag().isPresent(), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetResponseParse() {
|
||||
NetconfRpcReply rep = NetconfRpcParserUtil.parseRpcReply(RESPONSE_DATA1);
|
||||
assertThat(rep.isOk(), is(false));
|
||||
assertThat(rep.messageId(), is("5"));
|
||||
|
||||
assertThat(rep.responses(), hasSize(1));
|
||||
assertThat(rep.responses().get(0),
|
||||
is(both(startsWith("<data")).and(endsWith("</data>"))));
|
||||
// Can't do below: response contains xmlns attribute for netconf base
|
||||
//assertThat(rep.responses().get(0), is(RESPONSE_BODY1));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user