2 * ============LICENSE_START=======================================================
3 * dcaegen2-collectors-veshv
4 * ================================================================================
5 * Copyright (C) 2018 NOKIA
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dcae.collectors.veshv.domain
23 * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
27 sealed class WireFrameDecodingError(val message: String)
30 // Invalid frame errors
32 sealed class InvalidWireFrame(msg: String) : WireFrameDecodingError(msg)
34 class InvalidWireFrameMarker(actualMarker: Short) : InvalidWireFrame(
35 "Invalid start of frame. Expected 0x%02X, but was 0x%02X"
36 .format(WireFrameMessage.MARKER_BYTE, actualMarker)
39 class PayloadSizeExceeded(maxPayloadSizeBytes: Int) :
40 InvalidWireFrame("payload size exceeds the limit ($maxPayloadSizeBytes bytes)")
42 // Missing bytes errors
44 sealed class MissingWireFrameBytes(msg: String) : WireFrameDecodingError(msg)
46 object MissingWireFrameHeaderBytes : MissingWireFrameBytes("readable bytes < header size")
47 object MissingWireFramePayloadBytes : MissingWireFrameBytes("readable bytes < payload size")
48 object EmptyWireFrame : MissingWireFrameBytes("empty wire frame")
50 // WireFrameMessage validation exceptions
52 sealed class WireFrameMessageValidationError(val message: String)
54 class InvalidMajorVersion(actualVersion: Short) : WireFrameMessageValidationError(
55 "Invalid major version in wire frame header. " +
56 "Expected ${WireFrameMessage.SUPPORTED_VERSION_MAJOR} but was $actualVersion")
58 class UnsupportedPayloadContentType(actualType: Int) : WireFrameMessageValidationError(
59 "Invalid content type in wire frame header. " +
60 "Expected one of ${PayloadContentType.hexValues}, but was $actualType")
62 class NotMatchingPayloadSize(definedInHeader: Int, actual: Int) : WireFrameMessageValidationError(
63 "Payload size does not match one defined in wire frame header.\n" +
64 "Defined in header: $definedInHeader, but was: $actual")