2 * Copyright (c) 2013, 2015 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
9 package org.opendaylight.openflowplugin.openflow.md.core.translator;
11 import java.math.BigInteger;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorType;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotificationBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
20 * OF-1.0 errorMessage support
22 public class ErrorV10Translator extends AbstractErrorTranslator {
25 public ErrorType decodeErrorType(int typeArg) {
26 ErrorType type = ErrorType.forValue(typeArg);
27 switch (type.ordinal()) {
29 type = ErrorType.FlowModFailed;
32 type = ErrorType.PortModFailed;
35 type = ErrorType.QueueOpFailed;
45 * @return translated error message of general type (OF-1.0)
48 public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorMessage getGranularNodeErrors(ErrorMessage message, ErrorType errorType, NodeRef node){
49 NodeErrorNotificationBuilder nodeErrBuilder = new NodeErrorNotificationBuilder();
50 nodeErrBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(message.getXid())));
51 nodeErrBuilder.setType(errorType);
52 nodeErrBuilder.setCode(message.getCode());
53 nodeErrBuilder.setNode(node);
55 if (message.getData() != null) {
56 nodeErrBuilder.setData(new String(message.getData()));
58 return nodeErrBuilder.build();