2 * Copyright (c) 2013-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;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
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.rev131103.TransactionId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
19 * OF-1.0 errorMessage support
21 public class ErrorV10Translator extends AbstractErrorTranslator {
24 public ErrorType decodeErrorType(int typeArg) {
25 ErrorType type = ErrorType.forValue(typeArg);
26 switch (type.ordinal()) {
28 type = ErrorType.FlowModFailed;
31 type = ErrorType.PortModFailed;
34 type = ErrorType.QueueOpFailed;
44 * @return translated error message of general type (OF-1.0)
47 public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorMessage getGranularNodeErrors(ErrorMessage message, ErrorType errorType, NodeRef node){
48 NodeErrorNotificationBuilder nodeErrBuilder = new NodeErrorNotificationBuilder();
49 nodeErrBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(message.getXid())));
50 nodeErrBuilder.setType(errorType);
51 nodeErrBuilder.setCode(message.getCode());
52 nodeErrBuilder.setNode(node);
54 if (message.getData() != null) {
55 nodeErrBuilder.setData(new String(message.getData()));
57 return nodeErrBuilder.build();