X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2FNetconfMessageChunkDecoder.java;fp=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2FNetconfMessageChunkDecoder.java;h=0000000000000000000000000000000000000000;hp=77ef3861d2325d0e478ec058259487dfe5d9c756;hb=eac080120972a30ae37566fec20521286e87ef18;hpb=a06b268df0070f1b6502a83214b949852774fa58 diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageChunkDecoder.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageChunkDecoder.java deleted file mode 100644 index 77ef3861d2..0000000000 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageChunkDecoder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2013 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.controller.netconf.util.handler; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageDecoder; - -import java.util.List; - -import org.opendaylight.controller.netconf.api.NetconfDeserializerException; -import org.opendaylight.controller.netconf.util.messages.NetconfMessageConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Charsets; - -public class NetconfMessageChunkDecoder extends ByteToMessageDecoder { - private final static Logger logger = LoggerFactory.getLogger(NetconfMessageChunkDecoder.class); - - @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { - ByteBuf byteBufMsg = Unpooled.buffer(in.readableBytes()); - int chunkSize = -1; - boolean isParsed = false; - while (in.isReadable()) { - try { - if (!isParsed) { - chunkSize = readHeader(in); - isParsed = true; - } - if (chunkSize != -1 && isParsed) { - in.readBytes(byteBufMsg, chunkSize); - isParsed = false; - } else { - throw new NetconfDeserializerException("Unable to parse chunked data or header."); - } - } catch (Exception e) { - logger.error("Failed to decode chunked message.", e); - this.exceptionCaught(ctx, e); - } - } - out.add(byteBufMsg); - isParsed = false; - } - - private int readHeader(ByteBuf in) { - ByteBuf chunkSize = Unpooled.buffer(NetconfMessageConstants.MIN_HEADER_LENGTH, - NetconfMessageConstants.MAX_HEADER_LENGTH); - byte b = in.readByte(); - if (b != 10) - return -1; - b = in.readByte(); - if (b != 35) - return -1; - while ((b = in.readByte()) != 10) { - chunkSize.writeByte(b); - } - return Integer.parseInt(chunkSize.toString(Charsets.US_ASCII)); - } - -}