2 * Copyright (c) 2013 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.flow.errors.rev131116.ErrorType;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotificationBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
18 * OF-1.0 errorMessage support
20 public class ErrorV10Translator extends AbstractErrorTranslator {
23 public ErrorType decodeErrorType(int typeArg) {
24 ErrorType type = ErrorType.forValue(typeArg);
25 switch (type.ordinal()) {
27 type = ErrorType.FlowModFailed;
30 type = ErrorType.PortModFailed;
33 type = ErrorType.QueueOpFailed;
42 * @return translated error message of general type (OF-1.0)
45 public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorMessage getGranularNodeErrors(ErrorMessage message, ErrorType errorType){
46 NodeErrorNotificationBuilder nodeErrBuilder = new NodeErrorNotificationBuilder();
47 nodeErrBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(message.getXid())));
48 nodeErrBuilder.setType(errorType);
49 nodeErrBuilder.setCode(message.getCode());
51 if (message.getData() != null) {
52 nodeErrBuilder.setData(new String(message.getData()));
54 return nodeErrBuilder.build();