MRI version bumpup for Aluminium
[netvirt.git] / elanmanager / api / src / main / java / org / opendaylight / netvirt / elanmanager / api / ElanHelper.java
index 9affa1f5fe6cde247a8b7db2cc9044bdcec569ad..ca8f97ef0cc83ec2f515bd92603798809e9767c8 100644 (file)
@@ -7,23 +7,24 @@
  */
 package org.opendaylight.netvirt.elanmanager.api;
 
-import java.math.BigInteger;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.genius.datastoreutils.ExpectedDataObjectNotFoundException;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
 import org.opendaylight.genius.mdsalutil.MetaDataUtil;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,16 +41,18 @@ public final class ElanHelper {
                 .child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).build();
     }
 
-    public static BigInteger getElanMetadataLabel(long elanTag) {
+    public static Uint64 getElanMetadataLabel(long elanTag) {
         return MetaDataUtil.getElanTagMetadata(elanTag);
     }
 
-    public static BigInteger getElanMetadataLabel(long elanTag, int lportTag) {
-        return getElanMetadataLabel(elanTag).or(MetaDataUtil.getLportTagMetaData(lportTag));
+    public static Uint64 getElanMetadataLabel(long elanTag, int lportTag) {
+        return Uint64.fromLongBits(getElanMetadataLabel(elanTag).longValue()
+                   | MetaDataUtil.getLportTagMetaData(lportTag).longValue());
     }
 
-    public static BigInteger getElanMetadataMask() {
-        return MetaDataUtil.METADATA_MASK_SERVICE.or(MetaDataUtil.METADATA_MASK_LPORT_TAG);
+    public static Uint64 getElanMetadataMask() {
+        return Uint64.fromLongBits(MetaDataUtil.METADATA_MASK_SERVICE.longValue()
+                   | MetaDataUtil.METADATA_MASK_LPORT_TAG.longValue());
     }
 
     public static List<String> getDpnInterfacesInElanInstance(DataBroker broker, String elanInstanceName) {
@@ -59,10 +62,10 @@ public final class ElanHelper {
             ElanDpnInterfacesList existingElanDpnInterfaces = SingleTransactionDataBroker.syncRead(broker,
                     LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId);
             if (existingElanDpnInterfaces != null) {
-                return existingElanDpnInterfaces.getDpnInterfaces().stream().flatMap(v -> v.getInterfaces().stream())
-                        .collect(Collectors.toList());
+                return new ArrayList<DpnInterfaces>(existingElanDpnInterfaces.getDpnInterfaces().values()).stream()
+                        .flatMap(v -> v.getInterfaces().stream()).collect(Collectors.toList());
             }
-        } catch (ReadFailedException e) {
+        } catch (ExpectedDataObjectNotFoundException e) {
             LOG.warn("Failed to read ElanDpnInterfacesList with error {}", e.getMessage());
         }
         return Collections.emptyList();