return leafNodesOnly;
}
- /**
- * Checking query parameters on specific notification.
- *
- * @param xml data of notification
- * @param listener listener of notification
- * @return true if notification meets the requirements of query parameters,
- * false otherwise
- */
@SuppressWarnings("checkstyle:IllegalCatch")
- protected <T extends BaseListenerInterface> boolean checkQueryParams(final String xml, final T listener) {
- final Instant now = Instant.now();
+ <T extends BaseListenerInterface> boolean checkStartStop(final Instant now, final T listener) {
if (this.stop != null) {
- if ((this.start.compareTo(now) < 0) && (this.stop.compareTo(now) > 0)) {
- return checkFilter(xml);
+ if (this.start.compareTo(now) < 0 && this.stop.compareTo(now) > 0) {
+ return true;
}
if (this.stop.compareTo(now) < 0) {
try {
} else if (this.start != null) {
if (this.start.compareTo(now) < 0) {
this.start = null;
- return checkFilter(xml);
+ return true;
}
} else {
- return checkFilter(xml);
+ return true;
}
return false;
}
* @param xml data of notification
*/
@SuppressWarnings("checkstyle:IllegalCatch")
- private boolean checkFilter(final String xml) {
+ boolean checkFilter(final String xml) {
if (this.filter == null) {
return true;
}
import com.google.common.base.Preconditions;
import java.io.IOException;
+import java.time.Instant;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
@Override
public void onDataTreeChanged(@Nonnull final Collection<DataTreeCandidate> dataTreeCandidates) {
+ final Instant now = Instant.now();
+ if (!checkStartStop(now, this)) {
+ return;
+ }
+
final String xml = prepareXml(dataTreeCandidates);
- if (checkQueryParams(xml, this)) {
+ if (checkFilter(xml)) {
prepareAndPostData(xml);
}
}
@Override
public void onNotification(final DOMNotification notification) {
+ final Instant now = Instant.now();
+ if (!checkStartStop(now, this)) {
+ return;
+ }
+
final SchemaContext schemaContext = controllerContext.getGlobalSchema();
final String xml = prepareXml(schemaContext, notification);
- if (checkQueryParams(xml, this)) {
+ if (checkFilter(xml)) {
prepareAndPostData(outputType.equals("JSON") ? prepareJson(schemaContext, notification) : xml);
}
}
return leafNodesOnly;
}
- /**
- * Checking query parameters on specific notification.
- *
- * @param xml data of notification
- * @param listener listener of notification
- * @return true if notification meets the requirements of query parameters,
- * false otherwise
- */
@SuppressWarnings("checkstyle:IllegalCatch")
- protected <T extends BaseListenerInterface> boolean checkQueryParams(final String xml, final T listener) {
- final Instant now = Instant.now();
+ <T extends BaseListenerInterface> boolean checkStartStop(final Instant now, final T listener) {
if (this.stop != null) {
- if ((this.start.compareTo(now) < 0) && (this.stop.compareTo(now) > 0)) {
- return checkFilter(xml);
+ if (this.start.compareTo(now) < 0 && this.stop.compareTo(now) > 0) {
+ return true;
}
if (this.stop.compareTo(now) < 0) {
try {
} else if (this.start != null) {
if (this.start.compareTo(now) < 0) {
this.start = null;
- return checkFilter(xml);
+ return true;
}
} else {
- return checkFilter(xml);
+ return true;
}
return false;
}
* @param xml data of notification
*/
@SuppressWarnings("checkstyle:IllegalCatch")
- private boolean checkFilter(final String xml) {
+ boolean checkFilter(final String xml) {
if (this.filter == null) {
return true;
}
import com.google.common.base.Preconditions;
import java.io.IOException;
+import java.time.Instant;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
@Override
public void onDataTreeChanged(final Collection<DataTreeCandidate> dataTreeCandidates) {
+ final Instant now = Instant.now();
+ if (!checkStartStop(now, this)) {
+ return;
+ }
+
final String xml = prepareXml(dataTreeCandidates);
- if (checkQueryParams(xml, this)) {
+ if (checkFilter(xml)) {
prepareAndPostData(xml);
}
}
@Override
public void onNotification(final DOMNotification notification) {
+ final Instant now = Instant.now();
+ if (!checkStartStop(now, this)) {
+ return;
+ }
+
final SchemaContext schemaContext = schemaHandler.get();
final String xml = prepareXml(schemaContext, notification);
- if (checkQueryParams(xml, this)) {
+ if (checkFilter(xml)) {
prepareAndPostData(outputType.equals("JSON") ? prepareJson(schemaContext, notification) : xml);
}
}