From 5c416ebacf4baad25de6213661c3cdfff31c0482 Mon Sep 17 00:00:00 2001 From: Tibor Král Date: Tue, 14 May 2019 12:19:44 +0200 Subject: HC2VPP-381: Validation support for V3PO module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If288d97dce15bcc6924d4dd65c640a20920f094d Signed-off-by: Tibor Král --- .../v3po/interfaces/pbb/PbbRewriteCustomizer.java | 33 +++++----------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizer.java') diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizer.java index 13fccf7dd..86622663d 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizer.java @@ -16,8 +16,6 @@ package io.fd.hc2vpp.v3po.interfaces.pbb; -import static com.google.common.base.Preconditions.checkNotNull; - import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; import io.fd.hc2vpp.common.translate.util.MacTranslator; @@ -44,7 +42,7 @@ public class PbbRewriteCustomizer extends FutureJVppCustomizer public PbbRewriteCustomizer(@Nonnull final FutureJVppCore futureJVppCore, @Nonnull final NamingContext interfaceNamingContext) { super(futureJVppCore); - this.interfaceNamingContext = checkNotNull(interfaceNamingContext, "Interface naming context cannot be null"); + this.interfaceNamingContext = interfaceNamingContext; } @Override @@ -84,16 +82,16 @@ public class PbbRewriteCustomizer extends FutureJVppCustomizer private void setPbbRewrite(final InstanceIdentifier id, final PbbRewrite data, final WriteContext writeContext, final boolean disable) throws TimeoutException, VppBaseCallException { - final String interfaceName = checkNotNull(id.firstKeyOf(Interface.class), "Interface key not found").getName(); + final String interfaceName = id.firstKeyOf(Interface.class).getName(); final L2InterfacePbbTagRewrite request = new L2InterfacePbbTagRewrite(); //checking all attributes in preconditions(pbb-rewrite is subcontainer, so there can't be mandatory statements) request.swIfIndex = interfaceNamingContext.getIndex(interfaceName, writeContext.getMappingContext()); - request.bDmac = parseMac(verifiedDestinationAddress(data)); - request.bSmac = parseMac(verifiedSourceAddress(data)); - request.bVlanid = verifiedBVlanId(data); - request.iSid = verifiedISid(data); + request.bDmac = parseMac(data.getDestinationAddress().getValue()); + request.bSmac = parseMac(data.getSourceAddress().getValue()); + request.bVlanid = data.getBVlanTagVlanId().shortValue(); + request.iSid = data.getITagIsid().intValue(); request.vtrOp = verifiedOperation(data, disable); //not sure whats gonna happen to this attribute, so its left optional for now @@ -104,27 +102,10 @@ public class PbbRewriteCustomizer extends FutureJVppCustomizer getReply(getFutureJVpp().l2InterfacePbbTagRewrite(request).toCompletableFuture()); } - private String verifiedDestinationAddress(final PbbRewrite data) { - return checkNotNull(data.getDestinationAddress(), "Destination address cannot be null").getValue(); - } - - private String verifiedSourceAddress(final PbbRewrite data) { - return checkNotNull(data.getSourceAddress(), "Destination address cannot be null").getValue(); - } - - private short verifiedBVlanId(final PbbRewrite data) { - return checkNotNull(data.getBVlanTagVlanId(), "BVlan id cannot be null").shortValue(); - } - - private int verifiedISid(final PbbRewrite data) { - return checkNotNull(data.getITagIsid(), "ISid cannot be null").intValue(); - } - // if disabled ,then uses non-public allowed value 0, which is equal to operation disable private int verifiedOperation(final PbbRewrite data, final boolean disable) { - return disable ? OPERATION_DISABLE - : checkNotNull(data.getInterfaceOperation(), "Operation cannot be null").getIntValue(); + : data.getInterfaceOperation().getIntValue(); } } -- cgit 1.2.3-korg