We have headers as a non-final field with a leaking HashMap. As it turns
out, this is only used for stream listers, which can use ImmutableMap.
Cleanup constructors to express this, so we know what gets filled in.
Change-Id: I43f3b77c8c2a9640b6edbd815ce72bc3637819ba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
*/
package org.opendaylight.restconf.common.context;
*/
package org.opendaylight.restconf.common.context;
-import java.util.HashMap;
-import java.util.Map;
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableMap;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
public class NormalizedNodeContext {
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
public class NormalizedNodeContext {
private final InstanceIdentifierContext<? extends SchemaNode> context;
private final InstanceIdentifierContext<? extends SchemaNode> context;
+ private final ImmutableMap<String, Object> headers;
private final WriterParameters writerParameters;
private final NormalizedNode data;
private final WriterParameters writerParameters;
private final NormalizedNode data;
- private Map<String, Object> headers = new HashMap<>();
-
public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
- final NormalizedNode data, final WriterParameters writerParameters) {
+ final NormalizedNode data, final WriterParameters writerParameters,
+ final ImmutableMap<String, Object> headers) {
this.context = context;
this.data = data;
this.writerParameters = writerParameters;
this.context = context;
this.data = data;
this.writerParameters = writerParameters;
+ this.headers = requireNonNull(headers);
}
public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
}
public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
- final NormalizedNode data, final WriterParameters writerParameters, final Map<String, Object> headers) {
- this.context = context;
- this.data = data;
- this.writerParameters = writerParameters;
- this.headers = headers;
+ final NormalizedNode data, final WriterParameters writerParameters) {
+ this(context, data, writerParameters, ImmutableMap.of());
}
public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
final NormalizedNode data) {
}
public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
final NormalizedNode data) {
- this.context = context;
- this.data = data;
- // default writer parameters
- writerParameters = WriterParameters.EMPTY;
+ this(context, data, WriterParameters.EMPTY, ImmutableMap.of());
}
public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
}
public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
- final NormalizedNode data, final Map<String, Object> headers) {
- this.context = context;
- this.data = data;
- // default writer parameters
- writerParameters = WriterParameters.EMPTY;
- this.headers = headers;
+ final NormalizedNode data, final ImmutableMap<String, Object> headers) {
+ this(context, data, WriterParameters.EMPTY, headers);
}
public InstanceIdentifierContext<? extends SchemaNode> getInstanceIdentifierContext() {
}
public InstanceIdentifierContext<? extends SchemaNode> getInstanceIdentifierContext() {
*
* @return map of headers
*/
*
* @return map of headers
*/
- public Map<String, Object> getNewHeaders() {
+ public ImmutableMap<String, Object> getNewHeaders() {
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.FluentFuture;
public NormalizedNodeContext getModules(final UriInfo uriInfo) {
final MapNode allModuleMap = makeModuleMapNode(controllerContext.getAllModules());
public NormalizedNodeContext getModules(final UriInfo uriInfo) {
final MapNode allModuleMap = makeModuleMapNode(controllerContext.getAllModules());
- final EffectiveModelContext schemaContext = this.controllerContext.getGlobalSchema();
+ final EffectiveModelContext schemaContext = controllerContext.getGlobalSchema();
final Module restconfModule = getRestconfModule();
final Module restconfModule = getRestconfModule();
- final DataSchemaNode modulesSchemaNode = this.controllerContext.getRestconfModuleRestConfSchemaNode(
+ final DataSchemaNode modulesSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(
restconfModule, Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
checkState(modulesSchemaNode instanceof ContainerSchemaNode);
restconfModule, Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
checkState(modulesSchemaNode instanceof ContainerSchemaNode);
}
final InstanceIdentifierContext<?> mountPointIdentifier =
}
final InstanceIdentifierContext<?> mountPointIdentifier =
- this.controllerContext.toMountPointIdentifier(identifier);
+ controllerContext.toMountPointIdentifier(identifier);
final DOMMountPoint mountPoint = mountPointIdentifier.getMountPoint();
final MapNode mountPointModulesMap = makeModuleMapNode(controllerContext.getAllModules(mountPoint));
final Module restconfModule = getRestconfModule();
final DOMMountPoint mountPoint = mountPointIdentifier.getMountPoint();
final MapNode mountPointModulesMap = makeModuleMapNode(controllerContext.getAllModules(mountPoint));
final Module restconfModule = getRestconfModule();
- final DataSchemaNode modulesSchemaNode = this.controllerContext.getRestconfModuleRestConfSchemaNode(
+ final DataSchemaNode modulesSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(
restconfModule, Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
checkState(modulesSchemaNode instanceof ContainerSchemaNode);
restconfModule, Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
checkState(modulesSchemaNode instanceof ContainerSchemaNode);
return new NormalizedNodeContext(
new InstanceIdentifierContext<>(null, modulesSchemaNode, mountPoint,
return new NormalizedNodeContext(
new InstanceIdentifierContext<>(null, modulesSchemaNode, mountPoint,
- this.controllerContext.getGlobalSchema()),
+ controllerContext.getGlobalSchema()),
moduleContainerBuilder.build(), QueryParametersParser.parseWriterParameters(uriInfo));
}
moduleContainerBuilder.build(), QueryParametersParser.parseWriterParameters(uriInfo));
}
final EffectiveModelContext schemaContext;
if (identifier.contains(ControllerContext.MOUNT)) {
final InstanceIdentifierContext<?> mountPointIdentifier =
final EffectiveModelContext schemaContext;
if (identifier.contains(ControllerContext.MOUNT)) {
final InstanceIdentifierContext<?> mountPointIdentifier =
- this.controllerContext.toMountPointIdentifier(identifier);
+ controllerContext.toMountPointIdentifier(identifier);
mountPoint = mountPointIdentifier.getMountPoint();
mountPoint = mountPointIdentifier.getMountPoint();
- module = this.controllerContext.findModuleByNameAndRevision(mountPoint, nameRev.getKey(),
+ module = controllerContext.findModuleByNameAndRevision(mountPoint, nameRev.getKey(),
nameRev.getValue());
schemaContext = modelContext(mountPoint);
} else {
nameRev.getValue());
schemaContext = modelContext(mountPoint);
} else {
- module = this.controllerContext.findModuleByNameAndRevision(nameRev.getKey(), nameRev.getValue());
- schemaContext = this.controllerContext.getGlobalSchema();
+ module = controllerContext.findModuleByNameAndRevision(nameRev.getKey(), nameRev.getValue());
+ schemaContext = controllerContext.getGlobalSchema();
final Set<Module> modules = Collections.singleton(module);
final MapNode moduleMap = makeModuleMapNode(modules);
final Set<Module> modules = Collections.singleton(module);
final MapNode moduleMap = makeModuleMapNode(modules);
- final DataSchemaNode moduleSchemaNode = this.controllerContext
+ final DataSchemaNode moduleSchemaNode = controllerContext
.getRestconfModuleRestConfSchemaNode(restconfModule, Draft02.RestConfModule.MODULE_LIST_SCHEMA_NODE);
checkState(moduleSchemaNode instanceof ListSchemaNode);
.getRestconfModuleRestConfSchemaNode(restconfModule, Draft02.RestConfModule.MODULE_LIST_SCHEMA_NODE);
checkState(moduleSchemaNode instanceof ListSchemaNode);
@Override
@Deprecated
public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) {
@Override
@Deprecated
public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) {
- final EffectiveModelContext schemaContext = this.controllerContext.getGlobalSchema();
+ final EffectiveModelContext schemaContext = controllerContext.getGlobalSchema();
final Set<String> availableStreams = Notificator.getStreamNames();
final Module restconfModule = getRestconfModule();
final Set<String> availableStreams = Notificator.getStreamNames();
final Module restconfModule = getRestconfModule();
- final DataSchemaNode streamSchemaNode = this.controllerContext
+ final DataSchemaNode streamSchemaNode = controllerContext
.getRestconfModuleRestConfSchemaNode(restconfModule, Draft02.RestConfModule.STREAM_LIST_SCHEMA_NODE);
checkState(streamSchemaNode instanceof ListSchemaNode);
.getRestconfModuleRestConfSchemaNode(restconfModule, Draft02.RestConfModule.STREAM_LIST_SCHEMA_NODE);
checkState(streamSchemaNode instanceof ListSchemaNode);
listStreamsBuilder.withChild(toStreamEntryNode(streamName, streamSchemaNode));
}
listStreamsBuilder.withChild(toStreamEntryNode(streamName, streamSchemaNode));
}
- final DataSchemaNode streamsContainerSchemaNode = this.controllerContext.getRestconfModuleRestConfSchemaNode(
+ final DataSchemaNode streamsContainerSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(
restconfModule, Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
checkState(streamsContainerSchemaNode instanceof ContainerSchemaNode);
restconfModule, Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
checkState(streamsContainerSchemaNode instanceof ContainerSchemaNode);
}
final InstanceIdentifierContext<?> mountPointIdentifier =
}
final InstanceIdentifierContext<?> mountPointIdentifier =
- this.controllerContext.toMountPointIdentifier(identifier);
+ controllerContext.toMountPointIdentifier(identifier);
final DOMMountPoint mountPoint = mountPointIdentifier.getMountPoint();
return OperationsResourceUtils.contextForModelContext(modelContext(mountPoint), mountPoint);
}
private Module getRestconfModule() {
final DOMMountPoint mountPoint = mountPointIdentifier.getMountPoint();
return OperationsResourceUtils.contextForModelContext(modelContext(mountPoint), mountPoint);
}
private Module getRestconfModule() {
- final Module restconfModule = this.controllerContext.getRestconfModule();
+ final Module restconfModule = controllerContext.getRestconfModule();
if (restconfModule == null) {
LOG.debug("ietf-restconf module was not found.");
throw new RestconfDocumentedException("ietf-restconf module was not found.", ErrorType.APPLICATION,
if (restconfModule == null) {
LOG.debug("ietf-restconf module was not found.");
throw new RestconfDocumentedException("ietf-restconf module was not found.", ErrorType.APPLICATION,
throw new RestconfDocumentedException(msg, ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED);
}
} else {
throw new RestconfDocumentedException(msg, ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED);
}
} else {
- response = this.broker.invokeRpc(schema.getQName(), input);
+ response = broker.invokeRpc(schema.getQName(), input);
- schemaContext = this.controllerContext.getGlobalSchema();
+ schemaContext = controllerContext.getGlobalSchema();
}
final DOMRpcResult result = checkRpcResponse(response);
}
final DOMRpcResult result = checkRpcResponse(response);
final EffectiveModelContext schemaContext;
if (identifier.contains(ControllerContext.MOUNT)) {
// mounted RPC call - look up mount instance.
final EffectiveModelContext schemaContext;
if (identifier.contains(ControllerContext.MOUNT)) {
// mounted RPC call - look up mount instance.
- final InstanceIdentifierContext<?> mountPointId = this.controllerContext.toMountPointIdentifier(identifier);
+ final InstanceIdentifierContext<?> mountPointId = controllerContext.toMountPointIdentifier(identifier);
mountPoint = mountPointId.getMountPoint();
schemaContext = modelContext(mountPoint);
final int startOfRemoteRpcName =
mountPoint = mountPointId.getMountPoint();
schemaContext = modelContext(mountPoint);
final int startOfRemoteRpcName =
} else if (identifier.indexOf('/') == CHAR_NOT_FOUND) {
identifierEncoded = identifier;
mountPoint = null;
} else if (identifier.indexOf('/') == CHAR_NOT_FOUND) {
identifierEncoded = identifier;
mountPoint = null;
- schemaContext = this.controllerContext.getGlobalSchema();
+ schemaContext = controllerContext.getGlobalSchema();
} else {
LOG.debug("Identifier {} cannot contain slash character (/).", identifier);
throw new RestconfDocumentedException(String.format("Identifier %n%s%ncan\'t contain slash character (/).%n"
} else {
LOG.debug("Identifier {} cannot contain slash character (/).", identifier);
throw new RestconfDocumentedException(String.format("Identifier %n%s%ncan\'t contain slash character (/).%n"
final String identifierDecoded = ControllerContext.urlPathArgDecode(identifierEncoded);
final RpcDefinition rpc;
if (mountPoint == null) {
final String identifierDecoded = ControllerContext.urlPathArgDecode(identifierEncoded);
final RpcDefinition rpc;
if (mountPoint == null) {
- rpc = this.controllerContext.getRpcDefinition(identifierDecoded);
+ rpc = controllerContext.getRpcDefinition(identifierDecoded);
} else {
rpc = findRpc(modelContext(mountPoint), identifierDecoded);
}
} else {
rpc = findRpc(modelContext(mountPoint), identifierDecoded);
}
}
response = mountRpcServices.get().invokeRpc(rpc.getQName(), input);
} else {
}
response = mountRpcServices.get().invokeRpc(rpc.getQName(), input);
} else {
- response = this.broker.invokeRpc(rpc.getQName(), input);
+ response = broker.invokeRpc(rpc.getQName(), input);
}
final NormalizedNode result = checkRpcResponse(response).getResult();
}
final NormalizedNode result = checkRpcResponse(response).getResult();
NotificationOutputType outputType = null;
if (!pathIdentifier.isEmpty()) {
final String fullRestconfIdentifier =
NotificationOutputType outputType = null;
if (!pathIdentifier.isEmpty()) {
final String fullRestconfIdentifier =
- DATA_SUBSCR + this.controllerContext.toFullRestconfIdentifier(pathIdentifier, null);
+ DATA_SUBSCR + controllerContext.toFullRestconfIdentifier(pathIdentifier, null);
LogicalDatastoreType datastore =
parseEnumTypeParameter(value, LogicalDatastoreType.class, DATASTORE_PARAM_NAME);
LogicalDatastoreType datastore =
parseEnumTypeParameter(value, LogicalDatastoreType.class, DATASTORE_PARAM_NAME);
- final InstanceIdentifierContext<?> iiWithData = this.controllerContext.toInstanceIdentifier(identifier);
+ final InstanceIdentifierContext<?> iiWithData = controllerContext.toInstanceIdentifier(identifier);
final DOMMountPoint mountPoint = iiWithData.getMountPoint();
NormalizedNode data = null;
final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier();
if (mountPoint != null) {
final DOMMountPoint mountPoint = iiWithData.getMountPoint();
NormalizedNode data = null;
final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier();
if (mountPoint != null) {
- data = this.broker.readConfigurationData(mountPoint, normalizedII, withDefa);
+ data = broker.readConfigurationData(mountPoint, normalizedII, withDefa);
- data = this.broker.readConfigurationData(normalizedII, withDefa);
+ data = broker.readConfigurationData(normalizedII, withDefa);
}
if (data == null) {
throw dataMissing(identifier);
}
if (data == null) {
throw dataMissing(identifier);
@Override
public NormalizedNodeContext readOperationalData(final String identifier, final UriInfo uriInfo) {
@Override
public NormalizedNodeContext readOperationalData(final String identifier, final UriInfo uriInfo) {
- final InstanceIdentifierContext<?> iiWithData = this.controllerContext.toInstanceIdentifier(identifier);
+ final InstanceIdentifierContext<?> iiWithData = controllerContext.toInstanceIdentifier(identifier);
final DOMMountPoint mountPoint = iiWithData.getMountPoint();
NormalizedNode data = null;
final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier();
if (mountPoint != null) {
final DOMMountPoint mountPoint = iiWithData.getMountPoint();
NormalizedNode data = null;
final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier();
if (mountPoint != null) {
- data = this.broker.readOperationalData(mountPoint, normalizedII);
+ data = broker.readOperationalData(mountPoint, normalizedII);
- data = this.broker.readOperationalData(normalizedII);
+ data = broker.readOperationalData(normalizedII);
}
if (data == null) {
throw dataMissing(identifier);
}
if (data == null) {
throw dataMissing(identifier);
while (true) {
if (mountPoint != null) {
while (true) {
if (mountPoint != null) {
- result = this.broker.commitMountPointDataPut(mountPoint, normalizedII, payload.getData(), insert,
+ result = broker.commitMountPointDataPut(mountPoint, normalizedII, payload.getData(), insert,
- result = this.broker.commitConfigurationDataPut(this.controllerContext.getGlobalSchema(), normalizedII,
+ result = broker.commitConfigurationDataPut(controllerContext.getGlobalSchema(), normalizedII,
payload.getData(), insert, point);
}
payload.getData(), insert, point);
}
FluentFuture<? extends CommitInfo> future;
if (mountPoint != null) {
FluentFuture<? extends CommitInfo> future;
if (mountPoint != null) {
- future = this.broker.commitConfigurationDataPost(mountPoint, normalizedII, payload.getData(), insert,
+ future = broker.commitConfigurationDataPost(mountPoint, normalizedII, payload.getData(), insert,
- future = this.broker.commitConfigurationDataPost(this.controllerContext.getGlobalSchema(), normalizedII,
+ future = broker.commitConfigurationDataPost(controllerContext.getGlobalSchema(), normalizedII,
payload.getData(), insert, point);
}
payload.getData(), insert, point);
}
final UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
uriBuilder.path("config");
try {
final UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
uriBuilder.path("config");
try {
- uriBuilder.path(this.controllerContext.toFullRestconfIdentifier(normalizedII, mountPoint));
+ uriBuilder.path(controllerContext.toFullRestconfIdentifier(normalizedII, mountPoint));
} catch (final Exception e) {
LOG.info("Location for instance identifier {} was not created", normalizedII, e);
return null;
} catch (final Exception e) {
LOG.info("Location for instance identifier {} was not created", normalizedII, e);
return null;
@Override
public Response deleteConfigurationData(final String identifier) {
@Override
public Response deleteConfigurationData(final String identifier) {
- final InstanceIdentifierContext<?> iiWithData = this.controllerContext.toInstanceIdentifier(identifier);
+ final InstanceIdentifierContext<?> iiWithData = controllerContext.toInstanceIdentifier(identifier);
final DOMMountPoint mountPoint = iiWithData.getMountPoint();
final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier();
final FluentFuture<? extends CommitInfo> future;
if (mountPoint != null) {
final DOMMountPoint mountPoint = iiWithData.getMountPoint();
final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier();
final FluentFuture<? extends CommitInfo> future;
if (mountPoint != null) {
- future = this.broker.commitConfigurationDataDelete(mountPoint, normalizedII);
+ future = broker.commitConfigurationDataDelete(mountPoint, normalizedII);
- future = this.broker.commitConfigurationDataDelete(normalizedII);
+ future = broker.commitConfigurationDataDelete(normalizedII);
NodeIdentifier.create(QName.create("subscribe:to:notification", "2016-10-28", "location")));
// prepare new header with location
NodeIdentifier.create(QName.create("subscribe:to:notification", "2016-10-28", "location")));
// prepare new header with location
- final Map<String, Object> headers = new HashMap<>();
- headers.put("Location", response);
-
- return new NormalizedNodeContext(iid, builder.build(), headers);
+ return new NormalizedNodeContext(iid, builder.build(), ImmutableMap.of("Location", response));
}
final String msg = "Bad type of notification of sal-remote";
}
final String msg = "Bad type of notification of sal-remote";
}
for (final NotificationListenerAdapter listener : listeners) {
}
for (final NotificationListenerAdapter listener : listeners) {
- this.broker.registerToListenNotification(listener);
+ broker.registerToListenNotification(listener);
listener.setQueryParams(start, Optional.ofNullable(stop), Optional.ofNullable(filter), false, false);
}
listener.setQueryParams(start, Optional.ofNullable(stop), Optional.ofNullable(filter), false, false);
}
ErrorType.APPLICATION, ErrorTag.MISSING_ATTRIBUTE);
}
ErrorType.APPLICATION, ErrorTag.MISSING_ATTRIBUTE);
}
- this.broker.registerToListenDataChanges(datastore, scope, listener);
+ broker.registerToListenDataChanges(datastore, scope, listener);
final UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder();
final UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder();
- return this.broker.patchConfigurationDataWithinTransaction(context);
+ return broker.patchConfigurationDataWithinTransaction(context);
} catch (final Exception e) {
LOG.debug("Patch transaction failed", e);
throw new RestconfDocumentedException(e.getMessage(), e);
} catch (final Exception e) {
LOG.debug("Patch transaction failed", e);
throw new RestconfDocumentedException(e.getMessage(), e);
- return this.broker.patchConfigurationDataWithinTransaction(context);
+ return broker.patchConfigurationDataWithinTransaction(context);
} catch (final Exception e) {
LOG.debug("Patch transaction failed", e);
throw new RestconfDocumentedException(e.getMessage(), e);
} catch (final Exception e) {
LOG.debug("Patch transaction failed", e);
throw new RestconfDocumentedException(e.getMessage(), e);
private MapNode makeModuleMapNode(final Collection<? extends Module> modules) {
requireNonNull(modules);
final Module restconfModule = getRestconfModule();
private MapNode makeModuleMapNode(final Collection<? extends Module> modules) {
requireNonNull(modules);
final Module restconfModule = getRestconfModule();
- final DataSchemaNode moduleSchemaNode = this.controllerContext
+ final DataSchemaNode moduleSchemaNode = controllerContext
.getRestconfModuleRestConfSchemaNode(restconfModule, Draft02.RestConfModule.MODULE_LIST_SCHEMA_NODE);
checkState(moduleSchemaNode instanceof ListSchemaNode);
.getRestconfModuleRestConfSchemaNode(restconfModule, Draft02.RestConfModule.MODULE_LIST_SCHEMA_NODE);
checkState(moduleSchemaNode instanceof ListSchemaNode);
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Preconditions.checkState;
+import com.google.common.collect.ImmutableMap;
import java.net.URI;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.net.URI;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
-import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Optional;
import javax.ws.rs.Path;
import java.util.Map.Entry;
import java.util.Optional;
import javax.ws.rs.Path;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
public RestconfStreamsSubscriptionServiceImpl(final DOMDataBroker dataBroker,
final DOMNotificationService notificationService, final SchemaContextHandler schemaHandler,
final Configuration configuration) {
public RestconfStreamsSubscriptionServiceImpl(final DOMDataBroker dataBroker,
final DOMNotificationService notificationService, final SchemaContextHandler schemaHandler,
final Configuration configuration) {
- this.handlersHolder = new HandlersHolder(dataBroker, notificationService, schemaHandler);
+ handlersHolder = new HandlersHolder(dataBroker, notificationService, schemaHandler);
streamUtils = configuration.isUseSSE() ? SubscribeToStreamUtil.serverSentEvents()
: SubscribeToStreamUtil.webSockets();
}
streamUtils = configuration.isUseSSE() ? SubscribeToStreamUtil.serverSentEvents()
: SubscribeToStreamUtil.webSockets();
}
throw new RestconfDocumentedException(msg);
}
throw new RestconfDocumentedException(msg);
}
- // prepare new header with location
- final Map<String, Object> headers = new HashMap<>();
- headers.put("Location", response);
-
// prepare node with value of location
return new NormalizedNodeContext(prepareIIDSubsStreamOutput(handlersHolder.getSchemaHandler()),
// prepare node with value of location
return new NormalizedNodeContext(prepareIIDSubsStreamOutput(handlersHolder.getSchemaHandler()),
- ImmutableLeafNodeBuilder.create()
- .withNodeIdentifier(LOCATION_NODEID)
- .withValue(response.toString())
- .build(), headers);
+ ImmutableNodes.leafNode(LOCATION_NODEID, response.toString()), ImmutableMap.of("Location", response));
* @return the dataBroker
*/
public DOMDataBroker getDataBroker() {
* @return the dataBroker
*/
public DOMDataBroker getDataBroker() {
- return this.dataBroker;
* @return the notificationService
*/
public DOMNotificationService getNotificationServiceHandler() {
* @return the notificationService
*/
public DOMNotificationService getNotificationServiceHandler() {
- return this.notificationService;
+ return notificationService;
* @return the schemaHandler
*/
public SchemaContextHandler getSchemaHandler() {
* @return the schemaHandler
*/
public SchemaContextHandler getSchemaHandler() {
- return this.schemaHandler;