2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.core.translator;
10 import java.math.BigInteger;
11 import java.util.Collections;
12 import java.util.List;
14 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
15 import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
16 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper;
17 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
19 import org.opendaylight.yangtools.yang.binding.DataObject;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 import com.google.common.collect.Lists;
28 public class NotificationPlainTranslator implements IMDMessageTranslator<OfHeader, List<DataObject>> {
30 private static final Logger LOG = LoggerFactory
31 .getLogger(NotificationPlainTranslator.class);
34 public List<DataObject> translate(SwitchConnectionDistinguisher cookie,
35 SessionContext sc, OfHeader msg) {
36 List<DataObject> results = null;
38 if(msg instanceof NotificationQueueWrapper) {
39 NotificationQueueWrapper wrappedNotification = (NotificationQueueWrapper) msg;
40 BigInteger datapathId = sc.getFeatures().getDatapathId();
41 Short version = wrappedNotification.getVersion();
42 LOG.debug("NotificationQueueWrapper: version {} dataPathId {} notification {}", version, datapathId, wrappedNotification.getImplementedInterface());
43 results = Lists.newArrayList((DataObject) wrappedNotification.getNotification());
45 // TODO - Do something smarter than returning null if translation fails... what Exception should we throw here?
46 results = Collections.emptyList();