package org.opendaylight.netconf.sal.restconf.impl;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.CharMatcher;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveSchemaContext;
+import org.opendaylight.yangtools.yang.model.util.SimpleSchemaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
neededModules.forEach(imp -> fakeModules.add(new FakeImportedModule(imp)));
fakeModules.add(new FakeRestconfModule(neededModules, fakeCont));
- // FIXME: use a separate sublcass of AbstractSchemaContext
- final SchemaContext fakeSchemaCtx =
- EffectiveSchemaContext.resolveSchemaContext(ImmutableSet.copyOf(fakeModules));
+ final SchemaContext fakeSchemaCtx = SimpleSchemaContext.forModules(ImmutableSet.copyOf(fakeModules));
final InstanceIdentifierContext<ContainerSchemaNode> instanceIdentifierContext =
new InstanceIdentifierContext<>(null, fakeCont, mountPoint, fakeSchemaCtx);
return new NormalizedNodeContext(instanceIdentifierContext, containerBuilder.build());
try {
result.getFutureOfPutData().checkedGet();
return Response.status(result.getStatus()).build();
- } catch (TransactionCommitFailedException e) {
+ } catch (final TransactionCommitFailedException e) {
if (e instanceof OptimisticLockFailedException) {
if (--tries <= 0) {
LOG.debug("Got OptimisticLockFailedException on last try - failing " + identifier);
}
}
- private static void isEqualUriAndPayloadKeyValues(final Map<QName, Object> uriKeyValues, final MapEntryNode payload,
+ @VisibleForTesting
+ public static void isEqualUriAndPayloadKeyValues(final Map<QName, Object> uriKeyValues, final MapEntryNode payload,
final List<QName> keyDefinitions) {
final Map<QName, Object> mutableCopyUriKeyValues = Maps.newHashMap(uriKeyValues);
final Object dataKeyValue = payload.getIdentifier().getKeyValues().get(keyDefinition);
- if (!uriKeyValue.equals(dataKeyValue)) {
+ if (!Objects.deepEquals(uriKeyValue, dataKeyValue)) {
final String errMsg = "The value '" + uriKeyValue + "' for key '" + keyDefinition.getLocalName()
+ "' specified in the URI doesn't match the value '" + dataKeyValue
+ "' specified in the message body. ";
future.checkedGet();
} catch (final RestconfDocumentedException e) {
throw e;
- } catch (TransactionCommitFailedException e) {
+ } catch (final TransactionCommitFailedException e) {
LOG.info("Error creating data " + (uriInfo != null ? uriInfo.getPath() : ""), e);
throw new RestconfDocumentedException(e.getMessage(), e, e.getErrorList());
}
try {
future.checkedGet();
- } catch (TransactionCommitFailedException e) {
+ } catch (final TransactionCommitFailedException e) {
final Optional<Throwable> searchedException = Iterables.tryFind(Throwables.getCausalChain(e),
Predicates.instanceOf(ModifiedNodeDoesNotExistException.class));
if (searchedException.isPresent()) {
final TemporalAccessor p;
try {
p = FORMATTER.parse(value);
- } catch (DateTimeParseException e) {
+ } catch (final DateTimeParseException e) {
throw new RestconfDocumentedException("Cannot parse of value in date: " + value, e);
}
return Instant.from(p);
* @return {@link URI} of location
*/
private URI dataSubs(final String identifier, final UriInfo uriInfo, final Instant start, final Instant stop,
- final String filter, boolean leafNodesOnly) {
+ final String filter, final boolean leafNodesOnly) {
final String streamName = Notificator.createStreamNameFromUri(identifier);
if (Strings.isNullOrEmpty(streamName)) {
throw new RestconfDocumentedException("Stream name is empty.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);