aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes/cds/Chart.yaml
AgeCommit message (Expand)AuthorFilesLines
2020-04-02Bump chart versionSylvain Desbureaux1-1/+1
2019-07-11Moving Helm Chart version for El AltoMike Elliott1-1/+1
2019-04-23Add command-processor chartAlexis de Talhouët1-1/+1
2019-03-04Add CDS as new chartSylvain Desbureaux1-0/+19
href='#n26'>26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
/*
 * Copyright © 2017-2018 AT&T Intellectual Property.
 * Modifications Copyright © 2018 - 2020 IBM, Bell Canada.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.onap.ccsdk.cds.controllerblueprints.core

import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogException
import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogExceptionFluent
import org.onap.ccsdk.cds.error.catalog.core.ErrorMessage

/**
 *
 *
 * @author Brinda Santh
 */
open class BluePrintProcessorException : ErrorCatalogException, ErrorCatalogExceptionFluent<BluePrintProcessorException> {

    constructor(message: String, cause: Throwable) : super(message, cause)
    constructor(message: String) : super(message)
    constructor(cause: Throwable) : super(cause)
    constructor(cause: Throwable, message: String, vararg args: Any?) : super(cause, message, args)
    constructor(code: Int, cause: Throwable) : super(code, cause)
    constructor(code: Int, message: String) : super(code, message)
    constructor(code: Int, message: String, cause: Throwable) : super(code, message, cause)

    override fun code(code: Int): BluePrintProcessorException {
        return this.updateCode(code)
    }

    override fun domain(domain: String): BluePrintProcessorException {
        return this.updateDomain(domain)
    }

    override fun action(action: String): BluePrintProcessorException {
        return this.updateAction(action)
    }

    override fun http(type: String): BluePrintProcessorException {
        return this.updateHttp(type)
    }

    override fun grpc(type: String): BluePrintProcessorException {
        return this.updateGrpc(type)
    }

    override fun payloadMessage(message: String): BluePrintProcessorException {
        return this.updatePayloadMessage(message)
    }

    override fun addErrorPayloadMessage(message: String): BluePrintProcessorException {
        return this.updateErrorPayloadMessage(message)
    }

    override fun addSubError(errorMessage: ErrorMessage): BluePrintProcessorException {
        return this.updateSubError(errorMessage)
    }
}

class BluePrintRetryException : RuntimeException {
    constructor(message: String, cause: Throwable) : super(message, cause)
    constructor(message: String) : super(message)
    constructor(cause: Throwable) : super(cause)
    constructor(cause: Throwable, message: String, vararg args: Any?) : super(format(message, *args), cause)
}

/** Extension Functions */

fun processorException(message: String): BluePrintProcessorException {
    return BluePrintProcessorException(message)
}

fun processorException(code: Int, message: String): BluePrintProcessorException {
    return processorException(message).code(code)
}

fun httpProcessorException(type: String, message: String): BluePrintProcessorException {
    return processorException(message).http(type)
}

fun grpcProcessorException(type: String, message: String): BluePrintProcessorException {
    return processorException(message).grpc(type)
}

fun httpProcessorException(type: String, domain: String, message: String): BluePrintProcessorException {
    val bluePrintProcessorException = processorException(message).http(type)
    return bluePrintProcessorException.addDomainAndErrorMessage(domain, message)
}

fun grpcProcessorException(type: String, domain: String, message: String): BluePrintProcessorException {
    val bluePrintProcessorException = processorException(message).grpc(type)
    return bluePrintProcessorException.addDomainAndErrorMessage(domain, message)
}

fun httpProcessorException(type: String, domain: String, message: String, cause: Throwable):
        BluePrintProcessorException {
    val bluePrintProcessorException = processorException(message).http(type)
    return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, cause)
}

fun grpcProcessorException(type: String, domain: String, message: String, cause: Throwable):
        BluePrintProcessorException {
    val bluePrintProcessorException = processorException(message).grpc(type)
    return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, cause)
}

fun BluePrintProcessorException.updateErrorMessage(domain: String, message: String, cause: Throwable):
        BluePrintProcessorException {
    return this.addDomainAndErrorMessage(domain, message, cause).domain(domain)
            .addErrorPayloadMessage(message)
            .payloadMessage(message)
}

fun BluePrintProcessorException.updateErrorMessage(domain: String, message: String): BluePrintProcessorException {
    return this.addDomainAndErrorMessage(domain, message).domain(domain)
            .addErrorPayloadMessage(message)
            .payloadMessage(message)
}

private fun BluePrintProcessorException.addDomainAndErrorMessage(
    domain: String,
    message: String,
    cause: Throwable = Throwable()
): BluePrintProcessorException {
    return this.addSubError(ErrorMessage(domain, message, cause.message
            ?: "")).domain(domain)
}