X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=dom%2Fmdsal-dom-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fdom%2Fapi%2FDOMDataTreeCommitCohort.java;h=9760a8e7a30e6d56ae447a10dfcfba6119518a5b;hb=9e344b9902099daf029a8e9ea42727760b7b2a9e;hp=17b0344c6693c31f290072ed0c5b65d90ce2f9bb;hpb=80f8a6f25836bbe77d2ea2e13eb91ecb025e1a19;p=mdsal.git
diff --git a/dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMDataTreeCommitCohort.java b/dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMDataTreeCommitCohort.java
index 17b0344c66..9760a8e7a3 100644
--- a/dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMDataTreeCommitCohort.java
+++ b/dom/mdsal-dom-api/src/main/java/org/opendaylight/mdsal/dom/api/DOMDataTreeCommitCohort.java
@@ -7,23 +7,16 @@
*/
package org.opendaylight.mdsal.dom.api;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
-import com.google.common.collect.Iterables;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.common.api.DataValidationFailedException;
-import org.opendaylight.mdsal.common.api.MappingCheckedFuture;
import org.opendaylight.mdsal.common.api.PostCanCommitStep;
import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.slf4j.LoggerFactory;
/**
* Commit cohort participating in commit of data modification, which can validate data tree
@@ -62,51 +55,12 @@ import org.slf4j.LoggerFactory;
* Implementation may opt-out from receiving {@code preCommit()}, {@code commit()}, {@code abort()}
* callbacks by returning {@link PostCanCommitStep#NOOP}.
*
- *
* @author Tony Tkacik
*/
// TODO: Provide example and describe more usage patterns
@Beta
public interface DOMDataTreeCommitCohort {
- /**
- * DO NOT implement or invoke this method. It is deprecated in favor of
- * {@link #canCommit(Object, Collection, SchemaContext)} and only exists for backwards compatibility. The
- * default implementation returns {@link PostCanCommitStep#NOOP_SUCCESS_FUTURE} and is invoked by the
- * default implementation of {@link #canCommit(Object, Collection, SchemaContext)}.
- *
- * @deprecated Implement and invoke {@link #canCommit(Object, Collection, SchemaContext)} instead.
- */
- @Deprecated
- @Nonnull
- default CheckedFuture canCommit(@Nonnull final Object txId,
- @Nonnull final DOMDataTreeCandidate candidate, @Nonnull final SchemaContext ctx) {
- LoggerFactory.getLogger(getClass()).error(
- "The default implementation of DOMDataTreeCommitCohort#canCommit(Object, DOMDataTreeCandidate, "
- + "SchemaContext) was invoked on {}", getClass());
- return PostCanCommitStep.NOOP_SUCCESS_FUTURE;
- }
-
- /**
- * DO NOT implement or invoke this method. It is deprecated in favor of
- * {@link #canCommit(Object, SchemaContext, Collection)} which returns a {@link FluentFuture} instead of the
- * deprecated {@link CheckedFuture} which is scheduled for remkoval in a future guava release. The
- * default implementation calls {@link #canCommit(Object, SchemaContext, Collection)}.
- *
- * @deprecated Implement and invoke {@link #canCommit(Object, SchemaContext, Collection)} instead.
- */
- @Deprecated
- @Nonnull
- default CheckedFuture canCommit(@Nonnull final Object txId,
- @Nonnull final Collection candidates, @Nonnull final SchemaContext ctx) {
- LoggerFactory.getLogger(getClass()).error(
- "The default implementation of DOMDataTreeCommitCohort#canCommit(Object, Collection, "
- + "SchemaContext) was invoked on {}", getClass());
-
- return MappingCheckedFuture.create(canCommit(txId, ctx, candidates), new DataValidationFailedExceptionMapper(
- "canCommit", Iterables.getLast(candidates).getRootPath()));
- }
-
/**
* Validates the supplied data tree modifications and associates the cohort-specific steps with data broker
* transaction.
@@ -139,34 +93,18 @@ public interface DOMDataTreeCommitCohort {
* more specific subclasses of this exception to provide additional information about
* validation failure reason.
*/
- @Nonnull
- default FluentFuture canCommit(@Nonnull final Object txId,
- @Nonnull final SchemaContext ctx, @Nonnull final Collection candidates) {
- LoggerFactory.getLogger(getClass()).warn("DOMDataTreeCommitCohort implementation {} should override "
- + "canCommit(Object, SchemaContext, Collection)", getClass());
-
- // For backwards compatibility, the default implementation is to invoke the deprecated
- // canCommit(Object, DOMDataTreeCandidate, SchemaContext) method for each DOMDataTreeCandidate and return the
- // last PostCanCommitStep.
- List> futures = new ArrayList<>();
- for (DOMDataTreeCandidate candidate : candidates) {
- futures.add(canCommit(txId, candidate, ctx));
- }
-
- final ListenableFuture resultFuture = Futures.transform(Futures.allAsList(futures),
- input -> input.get(input.size() - 1), MoreExecutors.directExecutor());
- return FluentFuture.from(resultFuture);
- }
+ @NonNull FluentFuture canCommit(@NonNull Object txId,
+ @NonNull SchemaContext ctx, @NonNull Collection candidates);
/**
* An ExceptionMapper that translates an Exception to a DataValidationFailedException.
*/
class DataValidationFailedExceptionMapper extends ExceptionMapper {
- private final DOMDataTreeIdentifier failedTreeId;
+ private final @NonNull DOMDataTreeIdentifier failedTreeId;
public DataValidationFailedExceptionMapper(final String opName, final DOMDataTreeIdentifier failedTreeId) {
super(opName, DataValidationFailedException.class);
- this.failedTreeId = failedTreeId;
+ this.failedTreeId = requireNonNull(failedTreeId);
}
@Override