import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.WorkFlowSpecRequest
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.WorkFlowSpecResponse
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.WorkFlowsResponse
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.load.BluePrintDatabaseLoadService
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.load.BlueprintDatabaseLoadService
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BlueprintEnhancerUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BlueprintLoadConfiguration
import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.cds.controllerblueprints.core.deleteNBDir
import org.onap.ccsdk.cds.controllerblueprints.core.httpProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintCatalogService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintEnhancerService
import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
-import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache
-import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BlueprintCompileCache
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext
import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintFileUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogCodes
*/
@Service
-open class BluePrintModelHandler(
- private val bluePrintDatabaseLoadService: BluePrintDatabaseLoadService,
- private val blueprintsProcessorCatalogService: BluePrintCatalogService,
- private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+open class BlueprintModelHandler(
+ private val bluePrintDatabaseLoadService: BlueprintDatabaseLoadService,
+ private val blueprintsProcessorCatalogService: BlueprintCatalogService,
+ private val bluePrintLoadConfiguration: BlueprintLoadConfiguration,
private val blueprintModelSearchRepository: BlueprintModelSearchRepository,
private val blueprintModelRepository: BlueprintModelRepository,
private val blueprintModelContentRepository: BlueprintModelContentRepository,
- private val bluePrintEnhancerService: BluePrintEnhancerService
+ private val bluePrintEnhancerService: BlueprintEnhancerService
) {
- private val log = logger(BluePrintModelHandler::class)
+ private val log = logger(BlueprintModelHandler::class)
open suspend fun bootstrapBlueprint(bootstrapRequest: BootstrapRequest) {
log.info(
bluePrintDatabaseLoadService.initResourceDictionary()
}
if (bootstrapRequest.loadCBA) {
- bluePrintDatabaseLoadService.initBluePrintCatalog()
+ bluePrintDatabaseLoadService.initBlueprintCatalog()
}
}
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open suspend fun prepareWorkFlowSpec(req: WorkFlowSpecRequest):
WorkFlowSpecResponse {
val basePath = blueprintsProcessorCatalogService.getFromDatabase(
)
log.info("blueprint base path $basePath")
- val blueprintContext = BluePrintMetadataUtils.getBluePrintContext(basePath.toString())
+ val blueprintContext = BlueprintMetadataUtils.getBlueprintContext(basePath.toString())
val workFlow = blueprintContext.workflowByName(req.workflowName)
val wfRes = WorkFlowSpecResponse()
return wfRes
}
- private fun addPropertyInfo(propName: String, prop: PropertyDefinition, ctx: BluePrintContext, res: WorkFlowSpecResponse) {
+ private fun addPropertyInfo(propName: String, prop: PropertyDefinition, ctx: BlueprintContext, res: WorkFlowSpecResponse) {
updatePropertyInfo(propName, prop, ctx, res)
addDataType(prop.type, ctx, res)
if (prop.entrySchema != null && prop.entrySchema!!.type != null) {
}
}
- private fun updatePropertyInfo(name: String, prop: PropertyDefinition, ctx: BluePrintContext, res: WorkFlowSpecResponse) {
+ private fun updatePropertyInfo(name: String, prop: PropertyDefinition, ctx: BlueprintContext, res: WorkFlowSpecResponse) {
if (prop.inputparam == null || prop.inputparam == false) {
var workflow = ctx.workflowByName(res.workFlowData.workFlowName)
for ((k, v) in workflow.steps!!) {
}
}
- private fun addDataType(name: String, ctx: BluePrintContext, res: WorkFlowSpecResponse) {
+ private fun addDataType(name: String, ctx: BlueprintContext, res: WorkFlowSpecResponse) {
var data = ctx.dataTypeByName(name)
if (data != null) {
res.dataTypes?.put(name, data)
}
}
- private fun addParentDataType(data: DataType, ctx: BluePrintContext, res: WorkFlowSpecResponse) {
+ private fun addParentDataType(data: DataType, ctx: BlueprintContext, res: WorkFlowSpecResponse) {
if (data.properties != null) {
for ((k, v) in data.properties!!) {
addPropertyInfo(k, v, ctx, res)
}
}
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open suspend fun getWorkflowNames(name: String, version: String): WorkFlowsResponse {
val basePath = blueprintsProcessorCatalogService.getFromDatabase(
name, version
res.blueprintName = name
res.version = version
- val blueprintContext = BluePrintMetadataUtils.getBluePrintContext(
+ val blueprintContext = BlueprintMetadataUtils.getBlueprintContext(
basePath.toString()
)
if (blueprintContext.workflows() != null) {
*
* @param filePart filePart
* @return Mono<BlueprintModelSearch>
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
</BlueprintModelSearch> */
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open suspend fun saveBlueprintModel(filePart: FilePart): BlueprintModelSearch {
try {
return upload(filePart, false)
* @param name name
* @param version version
* @return BlueprintModelSearch
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
*/
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open fun getBlueprintModelSearchByNameAndVersion(name: String, version: String): BlueprintModelSearch? {
return blueprintModelSearchRepository.findByArtifactNameAndArtifactVersion(name, version)
- /*?: throw BluePrintException(
+ /*?: throw BlueprintException(
ErrorCode.RESOURCE_NOT_FOUND.value,
String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version)
)*/
* @param name name
* @param version version
* @return ResponseEntity<Resource>
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
</Resource> */
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open fun downloadBlueprintModelFileByNameAndVersion(
name: String,
version: String
val archiveByteArray = download(name, version)
val fileName = "${name}_$version.zip"
return prepareResourceEntity(fileName, archiveByteArray)
- } catch (e: BluePrintProcessorException) {
+ } catch (e: BlueprintProcessorException) {
e.http(ErrorCatalogCodes.RESOURCE_NOT_FOUND)
val errorMsg = "Error while downloading the CBA file by Blueprint Name ($name) and Version ($version)."
throw e.updateErrorMessage(
* This is a downloadBlueprintModelFile method to find the target file to download and return a file resource
*
* @return ResponseEntity<Resource>
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
</Resource> */
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open fun downloadBlueprintModelFile(id: String): ResponseEntity<Resource> {
val blueprintModel: BlueprintModel
try {
blueprintModel = getBlueprintModel(id)
- } catch (e: BluePrintException) {
+ } catch (e: BlueprintException) {
throw httpProcessorException(
ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API,
"Error while downloading the CBA file: couldn't get blueprint modelby ID ($id)",
*
* @param id id
* @return BlueprintModel
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
*/
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open fun getBlueprintModel(id: String): BlueprintModel {
val blueprintModel: BlueprintModel
val dbBlueprintModel = blueprintModelRepository.findById(id)
* @param name name
* @param version version
* @return BlueprintModel
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
*/
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open fun getBlueprintModelByNameAndVersion(name: String, version: String): BlueprintModel {
val blueprintModel = blueprintModelRepository
.findByArtifactNameAndArtifactVersion(name, version)
*
* @param id id
* @return BlueprintModelSearch
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
*/
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open fun getBlueprintModelSearch(id: String): BlueprintModelSearch {
return blueprintModelSearchRepository.findById(id)
?: throw httpProcessorException(
}
/**
- * This is a searchBluePrintModelsByKeyWord method to retrieve specific BlueprintModel in Database
+ * This is a searchBlueprintModelsByKeyWord method to retrieve specific BlueprintModel in Database
* where keyword equals updatedBy or tags or artifcat name or artifcat version or artifact type
* @author Shaaban Ebrahim
* @param keyWord
*
* @return List<BlueprintModelSearch> list of the controller blueprint
</BlueprintModelSearch> */
- open fun searchBluePrintModelsByKeyWord(keyWord: String): List<BlueprintModelSearch> {
+ open fun searchBlueprintModelsByKeyWord(keyWord: String): List<BlueprintModelSearch> {
return blueprintModelSearchRepository.findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(
keyWord, keyWord, keyWord, keyWord, keyWord
)
}
/**
- * This is a searchBluePrintModelsByKeyWordPagebale method to retrieve specific BlueprintModel in Database
+ * This is a searchBlueprintModelsByKeyWordPagebale method to retrieve specific BlueprintModel in Database
* where keyword equals updatedBy or tags or artifcat name or artifcat version or artifact type and pageable
* @author Shaaban Ebrahim
* @param keyWord
*
* @return List<BlueprintModelSearch> list of the controller blueprint
</BlueprintModelSearch> */
- open fun searchBluePrintModelsByKeyWordPaged(keyWord: String, pageRequest: PageRequest): Page<BlueprintModelSearch> {
+ open fun searchBlueprintModelsByKeyWordPaged(keyWord: String, pageRequest: PageRequest): Page<BlueprintModelSearch> {
return blueprintModelSearchRepository.findByUpdatedByContainingIgnoreCaseOrTagsContainingIgnoreCaseOrArtifactNameContainingIgnoreCaseOrArtifactVersionContainingIgnoreCaseOrArtifactTypeContainingIgnoreCase(
keyWord,
keyWord,
* This is a deleteBlueprintModel method
*
* @param id id
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
*/
@Transactional
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open fun deleteBlueprintModel(id: String) {
val dbBlueprintModel = blueprintModelRepository.findById(id)
if (dbBlueprintModel.isPresent) {
*
* @param filePart filePart
* @return ResponseEntity<Resource>
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
*/
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open suspend fun enrichBlueprint(filePart: FilePart): ResponseEntity<Resource> {
try {
val enhancedByteArray = enrichBlueprintFileSource(filePart)
- return BluePrintEnhancerUtils.prepareResourceEntity("enhanced-cba.zip", enhancedByteArray)
- } catch (e: BluePrintProcessorException) {
+ return BlueprintEnhancerUtils.prepareResourceEntity("enhanced-cba.zip", enhancedByteArray)
+ } catch (e: BlueprintProcessorException) {
e.http(ErrorCatalogCodes.IO_FILE_INTERRUPT)
val errorMsg = "Error while enhancing the CBA package."
throw e.updateErrorMessage(
*
* @param filePart filePart
* @return BlueprintModelSearch
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
*/
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open suspend fun publishBlueprint(filePart: FilePart): BlueprintModelSearch {
try {
return upload(filePart, true)
- } catch (e: BluePrintProcessorException) {
+ } catch (e: BlueprintProcessorException) {
e.http(ErrorCatalogCodes.IO_FILE_INTERRUPT)
val errorMsg = "Error in Publishing CBA."
throw e.updateErrorMessage(
*
* @param filePart filePart
* @return BlueprintModelSearch
- * @throws BluePrintException BluePrintException
+ * @throws BlueprintException BlueprintException
*/
- @Throws(BluePrintException::class)
+ @Throws(BlueprintException::class)
open suspend fun enrichAndPublishBlueprint(filePart: FilePart): BlueprintModelSearch {
try {
val enhancedByteArray = enrichBlueprintFileSource(filePart)
return upload(enhancedByteArray, true)
- } catch (e: BluePrintProcessorException) {
+ } catch (e: BlueprintProcessorException) {
e.http(ErrorCatalogCodes.IO_FILE_INTERRUPT)
val errorMsg = "Error while enhancing and uploading the CBA package."
throw e.updateErrorMessage(
try {
val compressedFile = normalizedFile(blueprintArchive, "cba.zip")
when (fileSource) {
- is FilePart -> BluePrintEnhancerUtils.filePartAsFile(fileSource, compressedFile)
- is ByteArray -> BluePrintEnhancerUtils.byteArrayAsFile(fileSource, compressedFile)
+ is FilePart -> BlueprintEnhancerUtils.filePartAsFile(fileSource, compressedFile)
+ is ByteArray -> BlueprintEnhancerUtils.byteArrayAsFile(fileSource, compressedFile)
}
// Save the Copied file to Database
val blueprintId = blueprintsProcessorCatalogService.saveToDatabase(saveId, compressedFile, validate)
ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API,
String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId)
)
- } catch (e: BluePrintException) {
+ } catch (e: BlueprintException) {
e.http(ErrorCatalogCodes.IO_FILE_INTERRUPT)
val errorMsg = "Error in Upload CBA."
throw e.updateErrorMessage(
)
} finally {
// Clean blueprint script cache
- val cacheKey = BluePrintFileUtils
+ val cacheKey = BlueprintFileUtils
.compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, saveId))
- BluePrintCompileCache.cleanClassLoader(cacheKey)
+ BlueprintCompileCache.cleanClassLoader(cacheKey)
deleteNBDir(blueprintArchive)
deleteNBDir(blueprintWorking)
}
ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API,
"Error while downloading the CBA file: couldn't get model content"
)
- } catch (e: BluePrintException) {
+ } catch (e: BlueprintException) {
e.http(ErrorCatalogCodes.RESOURCE_NOT_FOUND)
val errorMsg = "Fail to get Blueprint Model content."
throw e.updateErrorMessage(
try {
when (fileSource) {
is FilePart ->
- BluePrintEnhancerUtils
+ BlueprintEnhancerUtils
.copyFilePartToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir)
is ByteArray ->
- BluePrintEnhancerUtils
+ BlueprintEnhancerUtils
.copyByteArrayToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir)
} // Enhance the Blue Prints
bluePrintEnhancerService.enhance(blueprintWorkingDir)
- return BluePrintEnhancerUtils.compressEnhanceDirAndReturnByteArray(blueprintWorkingDir, blueprintArchive)
- } catch (e: BluePrintException) {
+ return BlueprintEnhancerUtils.compressEnhanceDirAndReturnByteArray(blueprintWorkingDir, blueprintArchive)
+ } catch (e: BlueprintException) {
e.http(ErrorCatalogCodes.IO_FILE_INTERRUPT)
val errorMsg = "Fail Enriching the CBA."
throw e.updateErrorMessage(DesignerApiDomains.DESIGNER_API, errorMsg)
"Error while Enriching the CBA file.", e.errorCauseOrDefault()
)
} finally {
- BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir)
+ BlueprintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir)
}
}