From 3365c01de8515e0ea7a0c26fbdfb296661bf6b92 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 4 Dec 2018 20:53:22 -0500 Subject: Add Netconf Executor Function module Change-Id: If264e63d4fc4305bc26dc6b249a462afefcbfe1e Issue-ID: CCSDK-790 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../resolution/ResourceResolutionComponent.kt | 35 +++++++++ .../resolution/ResourceResolutionConstants.kt | 24 ++++++ .../resolution/ResourceResolutionService.kt | 89 ++++++++++++++++++++++ .../DataBaseResourceAssignmentProcessor.kt | 37 +++++++++ .../DefaultResourceAssignmentProcessor.kt | 37 +++++++++ .../InputResourceAssignmentProcessor.kt | 37 +++++++++ .../SimpleRestResourceAssignmentProcessor.kt | 37 +++++++++ .../resolution/ResourceResolutionComponent.kt | 32 -------- .../resolution/ResourceResolutionConstants.kt | 25 ------ .../resolution/ResourceResolutionService.kt | 89 ---------------------- .../DataBaseResourceAssignmentProcessor.kt | 37 --------- .../DefaultResourceAssignmentProcessor.kt | 37 --------- .../processor/InputResourceAssignmentProcessor.kt | 37 --------- .../SimpleRestResourceAssignmentProcessor.kt | 37 --------- 14 files changed, 296 insertions(+), 294 deletions(-) create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt create mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt delete mode 100644 ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt new file mode 100644 index 00000000..32696c57 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt @@ -0,0 +1,35 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.apps.blueprintsprocessor.functions.resource.resolution + +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.annotation.Scope +import org.springframework.stereotype.Component + +@Component("component-resource-resolution") +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +open class ResourceResolutionComponent : AbstractComponentFunction() { + override fun process(executionRequest: ExecutionServiceInput) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt new file mode 100644 index 00000000..aea3313c --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt @@ -0,0 +1,24 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.apps.blueprintsprocessor.functions.resource.resolution + +class ResourceResolutionConstants { + companion object { + const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-" + } + +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt new file mode 100644 index 00000000..2b76b78a --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt @@ -0,0 +1,89 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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.apps.blueprintsprocessor.functions.resource.resolution + +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.ApplicationContext +import org.springframework.stereotype.Service + +/** + * ResourceResolutionService + * @author Brinda Santh + * 8/14/2018 + */ + +@Service +class ResourceResolutionService { + + + @Autowired + private lateinit var applicationContext: ApplicationContext + + fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput { + val resourceResolutionOutput = ResourceResolutionOutput() + resourceResolutionOutput.actionIdentifiers = resourceResolutionInput.actionIdentifiers + resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader + resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments + + process(resourceResolutionOutput.resourceAssignments) + + val status = Status() + status.code = 200 + status.message = "Success" + resourceResolutionOutput.status = status + + return resourceResolutionOutput + } + + fun registeredResourceSources(): List { + return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java) + .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) } + .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) } + } + + fun process(resourceAssignments: MutableList) { + + val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments) + + bulkSequenced.map { batchResourceAssignments -> + batchResourceAssignments.filter { it.name != "*" && it.name != "start" } + .map { resourceAssignment -> + val dictionarySource = resourceAssignment.dictionarySource + val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource) + + val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor + ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " + + "for resource assignment(${resourceAssignment.name})") + try { + // Invoke Apply Method + resourceAssignmentProcessor.apply(resourceAssignment) + } catch (e: RuntimeException) { + resourceAssignmentProcessor.recover(e, resourceAssignment) + throw BluePrintProcessorException(e) + } + } + } + } +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt new file mode 100644 index 00000000..80b2d0b7 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt @@ -0,0 +1,37 @@ +/* + * Copyright © 2018 IBM. + * Modifications Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.apps.blueprintsprocessor.functions.resource.resolutionprocessor + +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor +import org.springframework.stereotype.Service + +/** + * DataBaseResourceAssignmentProcessor + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-db") +open class DataBaseResourceAssignmentProcessor : ResourceAssignmentProcessor(){ + + override fun process(executionRequest: ResourceAssignment) { + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt new file mode 100644 index 00000000..05529254 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt @@ -0,0 +1,37 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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.apps.blueprintsprocessor.functions.resource.resolutionprocessor + +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor +import org.springframework.stereotype.Service + +/** + * DefaultResourceAssignmentProcessor + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-default") +open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() { + + override fun process(executionRequest: ResourceAssignment) { + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt new file mode 100644 index 00000000..73fd3a1f --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt @@ -0,0 +1,37 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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.apps.blueprintsprocessor.functions.resource.resolutionprocessor + +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor +import org.springframework.stereotype.Service + +/** + * InputResourceAssignmentProcessor + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-input") +open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() { + + override fun process(executionRequest: ResourceAssignment) { + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt new file mode 100644 index 00000000..64c8a1d3 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt @@ -0,0 +1,37 @@ +/* + * Copyright © 2018 IBM. + * Modifications Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.apps.blueprintsprocessor.functions.resource.resolutionprocessor + +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor +import org.springframework.stereotype.Service + +/** + * SimpleRestResourceAssignmentProcessor + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-mdsal") +open class SimpleRestResourceAssignmentProcessor : ResourceAssignmentProcessor() { + + override fun process(executionRequest: ResourceAssignment) { + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt deleted file mode 100644 index a485fa62..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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.apps.blueprintsprocessor.services.resolution - -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction -import org.springframework.stereotype.Component - -@Component("component-resource-resolution") -open class ResourceResolutionComponent : AbstractComponentFunction() { - override fun process(executionRequest: ExecutionServiceInput) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt deleted file mode 100644 index e234d056..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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.apps.blueprintsprocessor.services.resolution - -class ResourceResolutionConstants { - companion object { - const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-" - - } - -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt deleted file mode 100644 index 9e735cf0..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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.apps.blueprintsprocessor.services.resolution - -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.context.ApplicationContext -import org.springframework.stereotype.Service - -/** - * ResourceResolutionService - * @author Brinda Santh - * 8/14/2018 - */ - -@Service -class ResourceResolutionService { - - - @Autowired - private lateinit var applicationContext: ApplicationContext - - fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput { - val resourceResolutionOutput = ResourceResolutionOutput() - resourceResolutionOutput.actionIdentifiers = resourceResolutionInput.actionIdentifiers - resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader - resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments - - process(resourceResolutionOutput.resourceAssignments) - - val status = Status() - status.code = 200 - status.message = "Success" - resourceResolutionOutput.status = status - - return resourceResolutionOutput - } - - fun registeredResourceSources(): List { - return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java) - .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) } - .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) } - } - - fun process(resourceAssignments: MutableList) { - - val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments) - - bulkSequenced.map { batchResourceAssignments -> - batchResourceAssignments.filter { it.name != "*" && it.name != "start" } - .map { resourceAssignment -> - val dictionarySource = resourceAssignment.dictionarySource - val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource) - - val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor - ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " + - "for resource assignment(${resourceAssignment.name})") - try { - // Invoke Apply Method - resourceAssignmentProcessor.apply(resourceAssignment) - } catch (e: RuntimeException) { - resourceAssignmentProcessor.recover(e, resourceAssignment) - throw BluePrintProcessorException(e) - } - } - } - } -} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt deleted file mode 100644 index 66e43f1b..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2018 IBM. - * Modifications Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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.apps.blueprintsprocessor.services.resolution.processor - -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor -import org.springframework.stereotype.Service - -/** - * DataBaseResourceAssignmentProcessor - * - * @author Brinda Santh - */ -@Service("resource-assignment-processor-db") -open class DataBaseResourceAssignmentProcessor : ResourceAssignmentProcessor(){ - - override fun process(executionRequest: ResourceAssignment) { - } - - override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { - } -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt deleted file mode 100644 index e701e718..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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.apps.blueprintsprocessor.services.resolution.processor - -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor -import org.springframework.stereotype.Service - -/** - * DefaultResourceAssignmentProcessor - * - * @author Brinda Santh - */ -@Service("resource-assignment-processor-default") -open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() { - - override fun process(executionRequest: ResourceAssignment) { - } - - override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { - } -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt deleted file mode 100644 index 9e177d46..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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.apps.blueprintsprocessor.services.resolution.processor - -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor -import org.springframework.stereotype.Service - -/** - * InputResourceAssignmentProcessor - * - * @author Brinda Santh - */ -@Service("resource-assignment-processor-input") -open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() { - - override fun process(executionRequest: ResourceAssignment) { - } - - override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { - } -} \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt deleted file mode 100644 index e1b9a8ef..00000000 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2018 IBM. - * Modifications Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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.apps.blueprintsprocessor.services.resolution.processor - -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor -import org.springframework.stereotype.Service - -/** - * SimpleRestResourceAssignmentProcessor - * - * @author Brinda Santh - */ -@Service("resource-assignment-processor-mdsal") -open class SimpleRestResourceAssignmentProcessor : ResourceAssignmentProcessor() { - - override fun process(executionRequest: ResourceAssignment) { - } - - override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { - } -} \ No newline at end of file -- cgit 1.2.3-korg