package org.onap.ccsdk.cds.blueprintsprocessor.grpc.service
import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertiesService
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BasicAuthGrpcClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GRPCLibConstants
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GrpcClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TLSAuthGrpcServerProperties
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcServerProperties
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.returnNullIfMissing
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.stereotype.Service
@Service(GRPCLibConstants.SERVICE_BLUEPRINT_GRPC_LIB_PROPERTY)
-open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesService: BluePrintPropertiesService) {
+open class BlueprintGrpcLibPropertyService(private var bluePrintPropertiesService: BlueprintPropertiesService) {
- fun blueprintGrpcServerService(jsonNode: JsonNode): BluePrintGrpcServerService {
+ fun blueprintGrpcServerService(jsonNode: JsonNode): BlueprintGrpcServerService {
val grpcServerProperties = grpcServerProperties(jsonNode)
return blueprintGrpcServerService(grpcServerProperties)
}
- fun blueprintGrpcServerService(selector: String): BluePrintGrpcServerService {
+ fun blueprintGrpcServerService(selector: String): BlueprintGrpcServerService {
val prefix = "${GRPCLibConstants.PROPERTY_GRPC_SERVER_PREFIX}$selector"
val grpcServerProperties = grpcServerProperties(prefix)
return blueprintGrpcServerService(grpcServerProperties)
JacksonUtils.readValue(jsonNode, TLSAuthGrpcServerProperties::class.java)!!
}
else -> {
- throw BluePrintProcessorException("Grpc type($type) not supported")
+ throw BlueprintProcessorException("Grpc type($type) not supported")
}
}
}
tlsAuthGrpcServerProperties(prefix)
}
else -> {
- throw BluePrintProcessorException("Grpc type($type) not supported")
+ throw BlueprintProcessorException("Grpc type($type) not supported")
}
}
}
}
private fun blueprintGrpcServerService(grpcServerProperties: GrpcServerProperties):
- BluePrintGrpcServerService {
+ BlueprintGrpcServerService {
when (grpcServerProperties) {
is TLSAuthGrpcServerProperties -> {
return TLSAuthGrpcServerService(grpcServerProperties)
}
else -> {
- throw BluePrintProcessorException("couldn't get grpc client service for properties $grpcServerProperties")
+ throw BlueprintProcessorException("couldn't get grpc client service for properties $grpcServerProperties")
}
}
}
/** GRPC Client Lib Property Service */
- fun blueprintGrpcClientService(jsonNode: JsonNode): BluePrintGrpcClientService {
+ fun blueprintGrpcClientService(jsonNode: JsonNode): BlueprintGrpcClientService {
val restClientProperties = grpcClientProperties(jsonNode)
return blueprintGrpcClientService(restClientProperties)
}
- fun blueprintGrpcClientService(selector: String): BluePrintGrpcClientService {
+ fun blueprintGrpcClientService(selector: String): BlueprintGrpcClientService {
val prefix = "${GRPCLibConstants.PROPERTY_GRPC_CLIENT_PREFIX}$selector"
val restClientProperties = grpcClientProperties(prefix)
return blueprintGrpcClientService(restClientProperties)
fun grpcClientProperties(jsonNode: JsonNode): GrpcClientProperties {
val type = jsonNode.get("type").returnNullIfMissing()?.textValue()
- ?: BluePrintProcessorException("missing type property")
+ ?: BlueprintProcessorException("missing type property")
return when (type) {
GRPCLibConstants.TYPE_TOKEN_AUTH -> {
JacksonUtils.readValue(jsonNode, TokenAuthGrpcClientProperties::class.java)!!
JacksonUtils.readValue(jsonNode, BasicAuthGrpcClientProperties::class.java)!!
}
else -> {
- throw BluePrintProcessorException("Grpc type($type) not supported")
+ throw BlueprintProcessorException("Grpc type($type) not supported")
}
}
}
basicAuthGrpcClientProperties(prefix)
}
else -> {
- throw BluePrintProcessorException("Grpc type($type) not supported")
+ throw BlueprintProcessorException("Grpc type($type) not supported")
}
}
}
fun blueprintGrpcClientService(grpcClientProperties: GrpcClientProperties):
- BluePrintGrpcClientService {
+ BlueprintGrpcClientService {
return when (grpcClientProperties) {
is TokenAuthGrpcClientProperties -> {
TokenAuthGrpcClientService(grpcClientProperties)
BasicAuthGrpcClientService(grpcClientProperties)
}
else -> {
- throw BluePrintProcessorException("couldn't get grpc service for type(${grpcClientProperties.type})")
+ throw BlueprintProcessorException("couldn't get grpc service for type(${grpcClientProperties.type})")
}
}
}