Merge "Bug 8873 - Bundle based reconciliation to enable bundling of messages"
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / translator / AbstractErrorTranslator.java
index ecb420ecd3a0db5fff40699ddb8f1059fdc4699a..a03c093b7c419d2d7172bdc536d3acc3cc95b6b7 100644 (file)
@@ -1,21 +1,23 @@
 /**
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013, 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
+
 package org.opendaylight.openflowplugin.openflow.md.core.translator;
 
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator;
-import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
-import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
+import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
+import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -23,11 +25,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * general support for errorMessage OF-API to MD-SAL translation 
+ * general support for errorMessage OF-API to MD-SAL translation
  */
 public abstract class AbstractErrorTranslator implements IMDMessageTranslator<OfHeader, List<DataObject>> {
 
-    protected static final Logger LOG = LoggerFactory.getLogger(AbstractErrorTranslator.class);
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractErrorTranslator.class);
 
     @Override
     public List<DataObject> translate(SwitchConnectionDistinguisher cookie, SessionContext sc, OfHeader msg) {
@@ -47,21 +49,24 @@ public abstract class AbstractErrorTranslator implements IMDMessageTranslator<Of
 
             // TODO -- Augmentation is not handled
             ErrorType type = decodeErrorType(message.getType());
-            
-            list.add(getGranularNodeErrors(message, type));
+            NodeRef node = new NodeRef(
+                InventoryDataServiceUtil.identifierFromDatapathId(
+                    sc.getFeatures().getDatapathId()));
+            list.add(getGranularNodeErrors(message, type, node));
             return list;
         } else {
             LOG.error("Message is not of Error Message ");
             return Collections.emptyList();
         }
     }
-    
+
     /**
-     * @param message
-     * @param errorType
-     * @return 
+     * @param message error message
+     * @param errorType error type
+     * @param node node ref
+     * @return error message
      */
-    protected abstract org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorMessage getGranularNodeErrors(ErrorMessage message, ErrorType errorType);
+    protected abstract org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorMessage getGranularNodeErrors(ErrorMessage message, ErrorType errorType, NodeRef node);
 
     /**
      * @param type error type in source message