import org.checkerframework.checker.lock.qual.Holding;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.common.formatters.EventFormatter;
-import org.opendaylight.restconf.common.formatters.EventFormatterFactory;
import org.opendaylight.restconf.nb.rfc8040.NotificationQueryParams;
import org.opendaylight.restconf.nb.rfc8040.streams.StreamSessionHandler;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.serializer;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import static com.google.common.base.Verify.verifyNotNull;
import static java.util.Objects.requireNonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class AbstractWebsocketSerializer<T extends Exception> {
+abstract class AbstractWebsocketSerializer<T extends Exception> {
private static final Logger LOG = LoggerFactory.getLogger(AbstractWebsocketSerializer.class);
private final EffectiveModelContext context;
- protected AbstractWebsocketSerializer(final EffectiveModelContext context) {
+ AbstractWebsocketSerializer(final EffectiveModelContext context) {
this.context = requireNonNull(context);
}
}
}
- void serializeLeafNodesOnly(final Deque<PathArgument> path, final DataTreeCandidateNode candidate,
+ final void serializeLeafNodesOnly(final Deque<PathArgument> path, final DataTreeCandidateNode candidate,
final boolean skipData) throws T {
NormalizedNode node = null;
switch (candidate.getModificationType()) {
abstract void serializeOperation(DataTreeCandidateNode candidate) throws T;
- String convertPath(final Collection<PathArgument> path) {
+ static final String convertPath(final Collection<PathArgument> path) {
final StringBuilder pathBuilder = new StringBuilder();
for (PathArgument pathArgument : path) {
if (pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier) {
continue;
}
- pathBuilder.append("/");
+ pathBuilder.append('/');
pathBuilder.append(pathArgument.getNodeType().getNamespace().toString().replace(':', '-'));
- pathBuilder.append(":");
+ pathBuilder.append(':');
pathBuilder.append(pathArgument.getNodeType().getLocalName());
if (pathArgument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) {
((YangInstanceIdentifier.NodeIdentifierWithPredicates) pathArgument).entrySet();
for (Map.Entry<QName, Object> key : keys) {
pathBuilder.append(key.getKey().getNamespace().toString().replace(':', '-'));
- pathBuilder.append(":");
+ pathBuilder.append(':');
pathBuilder.append(key.getKey().getLocalName());
pathBuilder.append("='");
pathBuilder.append(key.getValue().toString());
- pathBuilder.append("'");
+ pathBuilder.append('\'');
}
- pathBuilder.append("]");
+ pathBuilder.append(']');
}
}
return pathBuilder.toString();
}
- String modificationTypeToOperation(final DataTreeCandidateNode candidate, final ModificationType modificationType) {
+ static final String modificationTypeToOperation(final DataTreeCandidateNode candidate,
+ final ModificationType modificationType) {
switch (modificationType) {
case UNMODIFIED:
// shouldn't ever happen since the root of a modification is only triggered by some event
case DISAPPEARED:
return "deleted";
default:
- LOG.error("DataTreeCandidate modification has unknown type: {}",
- candidate.getModificationType());
+ LOG.error("DataTreeCandidate modification has unknown type: {}", candidate.getModificationType());
throw new IllegalStateException("Unknown modification type");
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.formatters;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
-import static org.opendaylight.restconf.common.formatters.NotificationFormatter.XML_OUTPUT_FACTORY;
-import static org.opendaylight.restconf.common.formatters.XMLNotificationFormatter.DATA_CHANGE_EVENT_ELEMENT;
+import static org.opendaylight.restconf.nb.rfc8040.streams.listeners.NotificationFormatter.XML_OUTPUT_FACTORY;
+import static org.opendaylight.restconf.nb.rfc8040.streams.listeners.XMLNotificationFormatter.DATA_CHANGE_EVENT_ELEMENT;
-import com.google.common.annotations.Beta;
import java.io.IOException;
import java.time.Instant;
import java.util.Collection;
/**
* Base formatter for DataTreeCandidates which only handles exporting to a document for filter checking purpose.
*/
-@Beta
-public abstract class DataTreeCandidateFormatter extends EventFormatter<Collection<DataTreeCandidate>> {
- protected DataTreeCandidateFormatter() {
+abstract class DataTreeCandidateFormatter extends EventFormatter<Collection<DataTreeCandidate>> {
+ DataTreeCandidateFormatter() {
+
}
- public DataTreeCandidateFormatter(final String xpathFilter) throws XPathExpressionException {
+ DataTreeCandidateFormatter(final String xpathFilter) throws XPathExpressionException {
super(xpathFilter);
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.formatters;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import java.util.Collection;
import javax.xml.xpath.XPathExpressionException;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
-public interface DataTreeCandidateFormatterFactory extends EventFormatterFactory<Collection<DataTreeCandidate>> {
+interface DataTreeCandidateFormatterFactory extends EventFormatterFactory<Collection<DataTreeCandidate>> {
@Override
DataTreeCandidateFormatter getFormatter();
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.formatters;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import java.io.IOException;
import java.time.Instant;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.w3c.dom.Document;
-public abstract class EventFormatter<T> implements Immutable {
+abstract class EventFormatter<T> implements Immutable {
private static final XPathFactory XPF = XPathFactory.newInstance();
// FIXME: NETCONF-369: XPath operates without namespace context, therefore we need an namespace-unaware builder.
filter = xpath.compile(xpathFilter);
}
- public final Optional<String> eventData(final EffectiveModelContext schemaContext, final T input, final Instant now,
- boolean leafNodesOnly, boolean skipData)
+ final Optional<String> eventData(final EffectiveModelContext schemaContext, final T input, final Instant now,
+ final boolean leafNodesOnly, final boolean skipData)
throws Exception {
if (!filterMatches(schemaContext, input, now)) {
return Optional.empty();
throw new IllegalStateException("Failed to evaluate expression " + filter, e);
}
- return eval.booleanValue();
+ return eval;
}
/**
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.formatters;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import javax.xml.xpath.XPathExpressionException;
-public interface EventFormatterFactory<T> {
+interface EventFormatterFactory<T> {
EventFormatter<T> getFormatter();
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.formatters;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import static java.util.Objects.requireNonNull;
import java.time.Instant;
import java.util.Collection;
import javax.xml.xpath.XPathExpressionException;
-import org.opendaylight.restconf.common.serializer.JsonDataTreeCandidateSerializer;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.formatters;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import static java.util.Objects.requireNonNull;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-public final class JSONNotificationFormatter extends NotificationFormatter {
+final class JSONNotificationFormatter extends NotificationFormatter {
private final JSONCodecFactorySupplier codecSupplier;
private JSONNotificationFormatter(final JSONCodecFactorySupplier codecSupplier) {
this.codecSupplier = requireNonNull(codecSupplier);
}
- public static NotificationFormatterFactory createFactory(final JSONCodecFactorySupplier codecSupplier) {
+ static NotificationFormatterFactory createFactory(final JSONCodecFactorySupplier codecSupplier) {
requireNonNull(codecSupplier);
return new NotificationFormatterFactory() {
@Override
@Override
String createText(final EffectiveModelContext schemaContext, final DOMNotification input, final Instant now,
- boolean leafNodesOnly, boolean skipData)
+ final boolean leafNodesOnly, final boolean skipData)
throws IOException {
final Writer writer = new StringWriter();
final JsonWriter jsonWriter = new JsonWriter(writer).beginObject();
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.serializer;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import static java.util.Objects.requireNonNull;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
-public class JsonDataTreeCandidateSerializer extends AbstractWebsocketSerializer<IOException> {
+final class JsonDataTreeCandidateSerializer extends AbstractWebsocketSerializer<IOException> {
private final JSONCodecFactorySupplier codecSupplier;
private final JsonWriter jsonWriter;
- public JsonDataTreeCandidateSerializer(final EffectiveModelContext context,
+ JsonDataTreeCandidateSerializer(final EffectiveModelContext context,
final JSONCodecFactorySupplier codecSupplier, final JsonWriter jsonWriter) {
super(context);
this.codecSupplier = requireNonNull(codecSupplier);
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.restconf.common.formatters.DataTreeCandidateFormatterFactory;
-import org.opendaylight.restconf.common.formatters.JSONDataTreeCandidateFormatter;
-import org.opendaylight.restconf.common.formatters.XMLDataTreeCandidateFormatter;
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.formatters;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import java.io.IOException;
import java.time.Instant;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public abstract class NotificationFormatter extends EventFormatter<DOMNotification> {
- protected static final XMLOutputFactory XML_OUTPUT_FACTORY;
+abstract class NotificationFormatter extends EventFormatter<DOMNotification> {
+ static final XMLOutputFactory XML_OUTPUT_FACTORY;
static {
XML_OUTPUT_FACTORY = XMLOutputFactory.newFactory();
}
- public NotificationFormatter(final String xpathFilter) throws XPathExpressionException {
+ NotificationFormatter(final String xpathFilter) throws XPathExpressionException {
super(xpathFilter);
}
@Override
- void fillDocument(Document doc, EffectiveModelContext schemaContext, DOMNotification input) throws IOException {
+ final void fillDocument(final Document doc, final EffectiveModelContext schemaContext, final DOMNotification input)
+ throws IOException {
final Element notificationElement = doc.createElementNS("urn:ietf:params:xml:ns:netconf:notification:1.0",
"notification");
final Element eventTimeElement = doc.createElement("eventTime");
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.formatters;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import javax.xml.xpath.XPathExpressionException;
import org.opendaylight.mdsal.dom.api.DOMNotification;
-public interface NotificationFormatterFactory extends EventFormatterFactory<DOMNotification> {
+interface NotificationFormatterFactory extends EventFormatterFactory<DOMNotification> {
@Override
NotificationFormatter getFormatter();
import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
-import org.opendaylight.restconf.common.formatters.JSONNotificationFormatter;
-import org.opendaylight.restconf.common.formatters.NotificationFormatterFactory;
-import org.opendaylight.restconf.common.formatters.XMLNotificationFormatter;
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
/**
* {@link NotificationListenerAdapter} is responsible to track events on notifications.
*/
-public class NotificationListenerAdapter extends AbstractCommonSubscriber<Absolute, DOMNotification>
+public final class NotificationListenerAdapter extends AbstractCommonSubscriber<Absolute, DOMNotification>
implements DOMNotificationListener {
private static final Logger LOG = LoggerFactory.getLogger(NotificationListenerAdapter.class);
return path();
}
- public final synchronized void listen(final DOMNotificationService notificationService) {
+ public synchronized void listen(final DOMNotificationService notificationService) {
if (!isListening()) {
setRegistration(notificationService.registerNotificationListener(this, getSchemaPath()));
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.formatters;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
-import static org.opendaylight.restconf.common.formatters.NotificationFormatter.XML_OUTPUT_FACTORY;
-import static org.opendaylight.restconf.common.formatters.XMLNotificationFormatter.DATA_CHANGED_NAMESPACE;
-import static org.opendaylight.restconf.common.formatters.XMLNotificationFormatter.DATA_CHANGED_NOTIFICATION_ELEMENT;
-import static org.opendaylight.restconf.common.formatters.XMLNotificationFormatter.NOTIFICATION_ELEMENT;
-import static org.opendaylight.restconf.common.formatters.XMLNotificationFormatter.NOTIFICATION_NAMESPACE;
+import static org.opendaylight.restconf.nb.rfc8040.streams.listeners.NotificationFormatter.XML_OUTPUT_FACTORY;
+import static org.opendaylight.restconf.nb.rfc8040.streams.listeners.XMLNotificationFormatter.DATA_CHANGED_NAMESPACE;
+import static org.opendaylight.restconf.nb.rfc8040.streams.listeners.XMLNotificationFormatter.DATA_CHANGED_NOTIFICATION_ELEMENT;
+import static org.opendaylight.restconf.nb.rfc8040.streams.listeners.XMLNotificationFormatter.NOTIFICATION_ELEMENT;
+import static org.opendaylight.restconf.nb.rfc8040.streams.listeners.XMLNotificationFormatter.NOTIFICATION_NAMESPACE;
import java.io.IOException;
import java.io.StringWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.xpath.XPathExpressionException;
-import org.opendaylight.restconf.common.serializer.XmlDataTreeCandidateSerializer;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public final class XMLDataTreeCandidateFormatter extends DataTreeCandidateFormatter {
private static final XMLDataTreeCandidateFormatter INSTANCE = new XMLDataTreeCandidateFormatter();
- public static final DataTreeCandidateFormatterFactory FACTORY =
+ static final DataTreeCandidateFormatterFactory FACTORY =
new DataTreeCandidateFormatterFactory() {
@Override
public XMLDataTreeCandidateFormatter getFormatter(final String xpathFilter)
};
private XMLDataTreeCandidateFormatter() {
+
}
private XMLDataTreeCandidateFormatter(final String xpathFilter) throws XPathExpressionException {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.formatters;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import java.io.IOException;
import java.io.StringWriter;
import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-public class XMLNotificationFormatter extends NotificationFormatter {
+final class XMLNotificationFormatter extends NotificationFormatter {
private static final XMLNotificationFormatter INSTANCE = new XMLNotificationFormatter();
static final String NOTIFICATION_NAMESPACE = "urn:ietf:params:xml:ns:netconf:notification:1.0";
static final String DATA_CHANGED_NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote";
static final String DATA_CHANGED_NOTIFICATION_ELEMENT = "data-changed-notification";
- public static final String DATA_CHANGE_EVENT_ELEMENT = "data-change-event";
+ static final String DATA_CHANGE_EVENT_ELEMENT = "data-change-event";
- public static final NotificationFormatterFactory FACTORY = new NotificationFormatterFactory() {
+ static final NotificationFormatterFactory FACTORY = new NotificationFormatterFactory() {
@Override
public XMLNotificationFormatter getFormatter(final String xpathFilter) throws XPathExpressionException {
return new XMLNotificationFormatter(xpathFilter);
}
};
- public XMLNotificationFormatter() {
+ XMLNotificationFormatter() {
+
}
- public XMLNotificationFormatter(String xpathFilter) throws XPathExpressionException {
+ XMLNotificationFormatter(final String xpathFilter) throws XPathExpressionException {
super(xpathFilter);
}
@Override
- String createText(EffectiveModelContext schemaContext, DOMNotification input, Instant now,
- boolean leafNodesOnly, boolean skipData)
+ String createText(final EffectiveModelContext schemaContext, final DOMNotification input, final Instant now,
+ final boolean leafNodesOnly, final boolean skipData)
throws IOException {
final StringWriter writer = new StringWriter();
try {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.common.serializer;
+package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
import static java.util.Objects.requireNonNull;
-import static org.opendaylight.restconf.common.formatters.XMLNotificationFormatter.DATA_CHANGE_EVENT_ELEMENT;
+import static org.opendaylight.restconf.nb.rfc8040.streams.listeners.XMLNotificationFormatter.DATA_CHANGE_EVENT_ELEMENT;
import java.util.Collection;
import javax.xml.stream.XMLStreamException;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
-public class XmlDataTreeCandidateSerializer extends AbstractWebsocketSerializer<Exception> {
+final class XmlDataTreeCandidateSerializer extends AbstractWebsocketSerializer<Exception> {
private final XMLStreamWriter xmlWriter;
- public XmlDataTreeCandidateSerializer(final EffectiveModelContext context, final XMLStreamWriter xmlWriter) {
+ XmlDataTreeCandidateSerializer(final EffectiveModelContext context, final XMLStreamWriter xmlWriter) {
super(context);
this.xmlWriter = requireNonNull(xmlWriter);
}