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;
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);