**/blackDuckHub*\r
**/*.jsonld\r
**/.checkstyle\r
-**/.gitignore\r
+**/.gitignore
+
+**/*py.class
+**/.DS_Store\r
/**
* Upload the CBA Zip fle to data base and return the Database identifier
*/
- fun uploadToDataBase(file: String): String
+ fun uploadToDataBase(file: String, validate : Boolean): String
/**
* Download the CBA zip file from the data base and place it in a path and return the CBA zip absolute path
* Get the Blueprint from Data Base and Download it under working directory and return the path path
*/
fun prepareBluePrint(name: String, version: String): String
+
+ /**
+ * Get blueprint archive with zip file from Data Base
+ */
+ fun downloadFromDataBase(uuid: String, path: String): String
}
\ No newline at end of file
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
import org.apache.commons.io.IOUtils
+import org.apache.commons.io.filefilter.DirectoryFileFilter
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import reactor.core.publisher.zip
import java.io.*
import java.nio.charset.Charset
+import java.nio.file.Files
import java.util.zip.ZipFile
class BluePrintArchiveUtils {
val entry = enumeration.nextElement()
val destFilePath = File(targetPath, entry.name)
destFilePath.parentFile.mkdirs()
+
if (entry.isDirectory)
continue
+
val bufferedIs = BufferedInputStream(zip.getInputStream(entry))
bufferedIs.use {
destFilePath.outputStream().buffered(1024).use { bos ->
check(destinationDir.isDirectory && destinationDir.exists()) {
throw BluePrintProcessorException("failed to decompress blueprint(${zipFile.absolutePath}) to ($targetPath) ")
}
+
return destinationDir
}
+
+ /**
+ * Get the first item in directory
+ *
+ * @param zipFile
+ * @return string
+ */
+ fun getFirstItemInDirectory(dir: File): String {
+ return dir.walk().map { it.name }.elementAt(1)
+ }
}
}
\ No newline at end of file
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
val content = JacksonUtils.getContent("./../../../../components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py")
- val abstractComponentFunction = PythonExecutorUtils.getPythonComponent("/home/brindasanth/onap/apps/components/scripts/python/ccsdk_blueprints", pythonPath, content,
+ val abstractComponentFunction = PythonExecutorUtils.getPythonComponent("./../../../../components/scripts/python/ccsdk_blueprints", pythonPath, content,
"SampleBlueprintComponent", properties)
assertNotNull(abstractComponentFunction, "failed to get python component")
@Service
class BluePrintCatalogServiceImpl(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration) : BluePrintCatalogService {
- override fun uploadToDataBase(file: String): String {
+ override fun uploadToDataBase(file: String, validate : Boolean): String {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
.plus(name).plus(File.separator).plus(version)
}
+
+ override fun downloadFromDataBase(uuid: String, path: String): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
}
\ No newline at end of file
@Service
class MockBluePrintCatalogService : BluePrintCatalogService {
- override fun uploadToDataBase(file: String): String {
+ override fun uploadToDataBase(file: String, validate : Boolean): String {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
assertNotNull(version, "failed to get blueprint version")
return "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"
}
+
+ override fun downloadFromDataBase(uuid: String, path: String): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
}
\ No newline at end of file
package org.onap.ccsdk.apps.controllerblueprints;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMethod;
-
-import com.google.common.collect.Lists;
-
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.builders.ResponseMessageBuilder;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* SwaggerConfig
*
public void testConfigModel() {\r
HttpHeaders headers = new HttpHeaders();\r
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);\r
-// ResponseEntity<ConfigModel> entity = this.restTemplate\r
-// .exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);\r
+// ResponseEntity<BlueprintModel> entity = this.restTemplate\r
+// .exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),BlueprintModel.class);\r
// assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);\r
// Assert.assertNotNull("failed to get response Config model",entity.getBody());\r
}\r
public void testConfigModelFailure() {\r
HttpHeaders headers = new HttpHeaders();\r
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);\r
-// ResponseEntity<ConfigModel> entity = this.restTemplate\r
-// .exchange("/api/v1/config-model-not-found/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);\r
+// ResponseEntity<BlueprintModel> entity = this.restTemplate\r
+// .exchange("/api/v1/config-model-not-found/1", HttpMethod.GET, new HttpEntity<>(headers),BlueprintModel.class);\r
// assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);\r
// Assert.assertNotNull("failed to get response Config model",entity.getBody());\r
}\r
\r
package org.onap.ccsdk.apps.controllerblueprints.service;\r
\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
import com.google.common.base.Preconditions;\r
import org.apache.commons.collections.CollectionUtils;\r
import org.apache.commons.lang3.StringUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;\r
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
import org.springframework.stereotype.Service;\r
\r
import java.util.ArrayList;\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2019 Bell Canada.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.service;\r
+\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.load.BluePrintLoadConfiguration;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelContentRepository;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelRepository;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelSearchRepository;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.core.io.ByteArrayResource;\r
+import org.springframework.core.io.Resource;\r
+import org.springframework.http.HttpHeaders;\r
+import org.springframework.http.MediaType;\r
+import org.springframework.http.ResponseEntity;\r
+import org.springframework.http.codec.multipart.FilePart;\r
+import org.springframework.stereotype.Service;\r
+import org.springframework.transaction.annotation.Transactional;\r
+import reactor.core.publisher.Mono;\r
+\r
+import java.io.IOException;\r
+import java.nio.file.Path;\r
+import java.util.List;\r
+import java.util.Optional;\r
+\r
+/**\r
+ * BlueprintModelService.java Purpose: Provide Service Template Service processing BlueprintModelService\r
+ *\r
+ * @author Brinda Santh\r
+ * @version 1.0\r
+ */\r
+\r
+@Service\r
+public class BlueprintModelService {\r
+\r
+ private static EELFLogger log = EELFManager.getInstance().getLogger(BlueprintModelService.class);\r
+\r
+ @Autowired\r
+ private BluePrintLoadConfiguration bluePrintLoadConfiguration;\r
+\r
+ @Autowired\r
+ private BluePrintCatalogService bluePrintCatalogService;\r
+\r
+ @Autowired\r
+ private BlueprintModelSearchRepository blueprintModelSearchRepository;\r
+\r
+ @Autowired\r
+ private BlueprintModelRepository blueprintModelRepository;\r
+\r
+ @Autowired\r
+ private BlueprintModelContentRepository blueprintModelContentRepository;\r
+\r
+ private static final String BLUEPRINT_MODEL_ID_FAILURE_MSG = "failed to get blueprint model id(%d) from repo";\r
+ private static final String BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG = "failed to get blueprint model by name(%d)" +\r
+ " and version(%d) from repo";\r
+\r
+ /**\r
+ * This is a saveBlueprintModel method\r
+ *\r
+ * @param filePart filePart\r
+ * @return Mono<BlueprintModelSearch>\r
+ * @throws BluePrintException BluePrintException\r
+ */\r
+ public Mono<BlueprintModelSearch> saveBlueprintModel(FilePart filePart) throws BluePrintException {\r
+ try {\r
+ Path cbaLocation = BluePrintFileUtils.Companion.getCbaStorageDirectory(bluePrintLoadConfiguration.blueprintArchivePath);\r
+ return BluePrintEnhancerUtils.Companion.saveCBAFile(filePart, cbaLocation).map(fileName -> {\r
+ String blueprintId = bluePrintCatalogService.uploadToDataBase(cbaLocation.resolve(fileName).toString(), false);\r
+ return blueprintModelSearchRepository.findById(blueprintId).get();\r
+ });\r
+\r
+ } catch (IOException | BluePrintException e) {\r
+ return Mono.error(new BluePrintException("Error uploading the CBA file in channel.", e));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * This is a publishBlueprintModel method\r
+ *\r
+ * @param id id\r
+ * @return BlueprintModelSearch\r
+ * @throws BluePrintException BluePrintException\r
+ */\r
+ public BlueprintModelSearch publishBlueprintModel(String id) throws BluePrintException {\r
+ // TODO Implement publish Functionality\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * This is a searchBlueprintModels method\r
+ *\r
+ * @param tags tags\r
+ * @return List<BlueprintModelSearch>\r
+ */\r
+ public List<BlueprintModelSearch> searchBlueprintModels(String tags) {\r
+ return blueprintModelSearchRepository.findByTagsContainingIgnoreCase(tags);\r
+ }\r
+\r
+ /**\r
+ * This is a getBlueprintModelByNameAndVersion method\r
+ *\r
+ * @param name name\r
+ * @param version version\r
+ * @return BlueprintModelSearch\r
+ */\r
+ public BlueprintModelSearch getBlueprintModelByNameAndVersion(@NotNull String name, @NotNull String version) throws BluePrintException {\r
+ BlueprintModelSearch blueprintModelSearch;\r
+ Optional<BlueprintModelSearch> dbBlueprintModel = blueprintModelSearchRepository\r
+ .findByArtifactNameAndArtifactVersion(name, version);\r
+ if (dbBlueprintModel.isPresent()) {\r
+ blueprintModelSearch = dbBlueprintModel.get();\r
+ } else {\r
+ throw new BluePrintException(String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version));\r
+ }\r
+\r
+ return blueprintModelSearch;\r
+ }\r
+\r
+ /**\r
+ * This is a downloadBlueprintModelFile method to find the target file to download and return a file resource using MONO\r
+ *\r
+ * @param (id)\r
+ * @return ResponseEntity<Resource>\r
+ */\r
+ public ResponseEntity<Resource> downloadBlueprintModelFile(@NotNull String id) throws BluePrintException {\r
+ BlueprintModel blueprintModel;\r
+ try {\r
+ blueprintModel = getBlueprintModel(id);\r
+ } catch (BluePrintException e) {\r
+ throw new BluePrintException("Error uploading the CBA file in channel.", e);\r
+ }\r
+ String fileName = blueprintModel.getId() + ".zip";\r
+ byte[] file = blueprintModel.getBlueprintModelContent().getContent();\r
+ return ResponseEntity.ok()\r
+ .contentType(MediaType.parseMediaType("text/plain"))\r
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\"")\r
+ .body(new ByteArrayResource(file));\r
+ }\r
+\r
+ /**\r
+ * This is a getBlueprintModel method\r
+ *\r
+ * @param id id\r
+ * @return BlueprintModel\r
+ * @throws BluePrintException BluePrintException\r
+ */\r
+ private BlueprintModel getBlueprintModel(@NotNull String id) throws BluePrintException {\r
+ BlueprintModel blueprintModel;\r
+ Optional<BlueprintModel> dbBlueprintModel = blueprintModelRepository.findById(id);\r
+ if (dbBlueprintModel.isPresent()) {\r
+ blueprintModel = dbBlueprintModel.get();\r
+ } else {\r
+ throw new BluePrintException(String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id));\r
+ }\r
+\r
+ return blueprintModel;\r
+ }\r
+\r
+ /**\r
+ * This is a getBlueprintModelSearch method\r
+ *\r
+ * @param id id\r
+ * @return BlueprintModelSearch\r
+ * @throws BluePrintException BluePrintException\r
+ */\r
+ public BlueprintModelSearch getBlueprintModelSearch(@NotNull String id) throws BluePrintException {\r
+ BlueprintModelSearch blueprintModelSearch;\r
+ Optional<BlueprintModelSearch> dbBlueprintModel = blueprintModelSearchRepository.findById(id);\r
+ if (dbBlueprintModel.isPresent()) {\r
+ blueprintModelSearch = dbBlueprintModel.get();\r
+ } else {\r
+ throw new BluePrintException(String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id));\r
+ }\r
+\r
+ return blueprintModelSearch;\r
+ }\r
+\r
+ /**\r
+ * This is a deleteBlueprintModel method\r
+ *\r
+ * @param id id\r
+ * @throws BluePrintException BluePrintException\r
+ */\r
+ @Transactional\r
+ public void deleteBlueprintModel(@NotNull String id) throws BluePrintException {\r
+ Optional<BlueprintModel> dbBlueprintModel = blueprintModelRepository.findById(id);\r
+ if (dbBlueprintModel.isPresent()) {\r
+ blueprintModelContentRepository.deleteByBlueprintModel(dbBlueprintModel.get());\r
+ blueprintModelRepository.delete(dbBlueprintModel.get());\r
+ } else {\r
+ throw new BluePrintException(String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * This is a getAllBlueprintModel method to retrieve all the BlueprintModel in Database\r
+ *\r
+ * @return List<BlueprintModelSearch> list with the controller blueprint archives\r
+ */\r
+ public List<BlueprintModelSearch> getAllBlueprintModel() {\r
+ return blueprintModelSearchRepository.findAll();\r
+ }\r
+\r
+}\r
+++ /dev/null
-/*
- * Copyright © 2018 IBM 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.controllerblueprints.service;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.CBAContentRepository;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * CBAContentService.java Purpose: Provide CBAContent Template Service processing
- * CBAContentService
- *
- * @author Ruben Chang
- * @version 1.0
- */
-
-@Service
-public class CBAContentService {
-
- private static EELFLogger log = EELFManager.getInstance().getLogger(CBAContentService.class);
-
- private CBAContentRepository cbaContentRepository;
-
- /**
- * Constructor of the class
- * @param cbaContentRepository CRUD methods for entity CBAContentRepository
- */
- public CBAContentService(CBAContentRepository cbaContentRepository) {
- this.cbaContentRepository = cbaContentRepository;
- log.info("CBAContentRepository sucessfully instantiated");
- }
-
- /**
- * Save the CBAContent into the CBA_CONTENT table
- * @param cbaName The name of the file
- * @param cbaVersion version number of the CBA archive
- * @param cbaState int that would represent the state. Refer to the CbaStateEnum
- * @param cbaDescription Brief description that would help to identify and recognize the CBA archive
- * @param file the file
- * @return CbaContent the record saved into the table CBA_CONTENT
- */
- public CbaContent saveCBAContent(String cbaName, String cbaVersion, int cbaState, String cbaDescription, byte[] file){
- CbaContent cbaContent = new CbaContent();
- cbaContent.setCbaName(cbaName);
- cbaContent.setCbaVersion(cbaVersion);
- cbaContent.setCbaState(cbaState);
- cbaContent.setCbaDescription(cbaDescription);
- cbaContent.setCbaFile(file);
- cbaContentRepository.saveAndFlush(cbaContent);
- return cbaContent;
- }
-
- /**
- * Get the list of Controller Blueprint archives
- * @return List<CbaContent> list with the controller blueprint archives
- */
- public List<CbaContent> getList(){
- return cbaContentRepository.findAll();
- }
-
- /**
- * Get a single Controller Blueprint archive by uuID
- * @param uuID the userID controller blueprint identifier
- * @return Optional<CbaContent>
- */
- public Optional<CbaContent> findByUUID(String uuID) {
- return cbaContentRepository.findById(uuID);
- }
-
- /**
- * Method deleteCBAById: Delete a CBA in data base with it associated Blueprint Model
- * @param uuid the uuid that identify the CBA
- */
- public void deleteCBAById(String uuid) {
- cbaContentRepository.deleteById(uuid);
- }
-
-}
+++ /dev/null
-/*\r
- * Copyright © 2018 IBM Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;\r
-import org.springframework.beans.factory.annotation.Value;\r
-import org.springframework.http.codec.multipart.FilePart;\r
-import org.springframework.stereotype.Service;\r
-import org.springframework.util.FileSystemUtils;\r
-import org.springframework.util.StringUtils;\r
-import reactor.core.publisher.Mono;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.nio.file.Files;\r
-import java.nio.file.Path;\r
-\r
-/**\r
- * CbaFileManagementService.java Purpose: Provide Service processing CBA file management\r
- *\r
- * @author Steve Siani\r
- * @version 1.0\r
- */\r
-@Service\r
-public class CbaFileManagementService {\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(CbaFileManagementService.class);\r
-\r
- @Value("${controllerblueprints.loadCbaExtension}")\r
- private String cbaExtension;\r
-\r
- private static final String CBA_FILE_NAME_PATTERN = "CBA_{0}_{1}";\r
-\r
-\r
- /**\r
- * cleanupSavedCBA: This method cleanup the Zip file and the unzip directory that was added.\r
- *\r
- * @param zipFileName zipFileName\r
- * @param cbaFileLocation cbaFileLocation\r
- * @return\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public void cleanupSavedCBA(String zipFileName, Path cbaFileLocation) throws BluePrintException {\r
-\r
- String fileNameWithoutExtension = BluePrintFileUtils.Companion.stripFileExtension(zipFileName);\r
-\r
- //Delete the Zip file from the repository\r
- FileSystemUtils.deleteRecursively(BluePrintFileUtils.Companion.getBluePrintFile(zipFileName,cbaFileLocation));\r
-\r
- //Delete the CBA directory from the repository\r
- FileSystemUtils.deleteRecursively(BluePrintFileUtils.Companion.getBluePrintFile(fileNameWithoutExtension,cbaFileLocation));\r
- }\r
-\r
- /**\r
- * This is a saveCBAFile method\r
- * take a {@link FilePart}, transfer it to disk using a Flux of FilePart and return a {@link Mono} representing the CBA file name\r
- *\r
- * @param (filePart, targetDirectory) - the request part containing the file to be saved and the default directory where to save\r
- * @return a {@link Mono} String representing the result of the operation\r
- * @throws (BluePrintException, IOException) BluePrintException, IOException\r
- */\r
- public Mono<String> saveCBAFile(FilePart filePart, Path targetDirectory) throws BluePrintException, IOException {\r
-\r
- // Normalize file name\r
- final String fileName = StringUtils.cleanPath(filePart.filename());\r
-\r
- // Check if the file's extension is "CBA"\r
- if(!StringUtils.getFilenameExtension(fileName).equals(cbaExtension)) {\r
- throw new BluePrintException("Invalid file extension required " + cbaExtension);\r
- }\r
-\r
- // Change file name to match a pattern\r
- String changedFileName = BluePrintFileUtils.Companion.getCBAGeneratedFileName(fileName, this.CBA_FILE_NAME_PATTERN);\r
-\r
- // Copy file to the target location (Replacing existing file with the same name)\r
- Path targetLocation = targetDirectory.resolve(changedFileName);\r
-\r
- // if a file with the same name already exists in a repository, delete and recreate it\r
- File file = new File(targetLocation.toString());\r
- if (file.exists())\r
- file.delete();\r
- file.createNewFile();\r
-\r
- return filePart.transferTo(file).thenReturn(changedFileName);\r
- }\r
-\r
- /**\r
- * Decompress the file into the cbaFileLocation parameter\r
- * @param zipFileName name of the zipped file\r
- * @param cbaFileLocation path in which the zipped file will get decompressed\r
- * @return String the path in which the file is decompressed\r
- * @throws BluePrintException Exception in the process\r
- */\r
- public String decompressCBAFile(final String zipFileName, Path cbaFileLocation) throws BluePrintException {\r
-\r
- File file = BluePrintFileUtils.Companion.getBluePrintFile(zipFileName, cbaFileLocation);\r
- try {\r
- Path directoryPath = Files.createDirectories(cbaFileLocation.resolve(BluePrintFileUtils.Companion.stripFileExtension(zipFileName)));\r
- BluePrintArchiveUtils.Companion.deCompress(file, directoryPath.toString());\r
- return directoryPath.toString();\r
-\r
- } catch (BluePrintProcessorException | IOException ex) {\r
- throw new BluePrintException(" Fail to decompress " + zipFileName, ex);\r
- }\r
-\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright © 2018 IBM Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.jetbrains.annotations.NotNull;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.model.BlueprintModelResponse;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.model.ItemCbaResponse;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.CbaStateEnum;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.beans.factory.annotation.Value;\r
-import org.springframework.boot.context.event.ApplicationReadyEvent;\r
-import org.springframework.context.event.EventListener;\r
-import org.springframework.core.io.ByteArrayResource;\r
-import org.springframework.core.io.Resource;\r
-import org.springframework.http.HttpHeaders;\r
-import org.springframework.http.MediaType;\r
-import org.springframework.http.ResponseEntity;\r
-import org.springframework.http.codec.multipart.FilePart;\r
-import org.springframework.stereotype.Service;\r
-import reactor.core.publisher.Mono;\r
-import java.io.IOException;\r
-import java.nio.file.Path;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-/**\r
- * CbaService.java Purpose: Provide Service Template Service processing CbaService\r
- *\r
- * @author Steve Siani\r
- * @version 1.0\r
- */\r
-\r
-@Service\r
-public class CbaService {\r
-\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(CbaService.class);\r
-\r
- @Value("${controllerblueprints.blueprintArchivePath}")\r
- private String cbaArchivePath;\r
- private Path cbaLocation;\r
-\r
- @Autowired\r
- private CbaFileManagementService cbaFileManagementService;\r
-\r
- @Autowired\r
- private CbaToDatabaseService cbaToDatabaseService;\r
-\r
-\r
- /**\r
- * This method would be used by SpringBoot to initialize the cba location\r
- */\r
- @EventListener(ApplicationReadyEvent.class)\r
- private void initCbaService() {\r
- this.cbaLocation = BluePrintFileUtils.Companion.getCbaStorageDirectory(cbaArchivePath);\r
- log.info("CBA service Initiated...");\r
- }\r
-\r
- /**\r
- * This is a uploadCBAFile method\r
- * take a {@link FilePart}, transfer it to disk using WebFlux and return a {@link Mono} representing the result\r
- *\r
- * @param filePart - the request part containing the file to be saved\r
- * @return a {@link Mono< BlueprintModelResponse >} representing the result of the operation\r
- */\r
- public Mono<BlueprintModelResponse> uploadCBAFile(FilePart filePart) {\r
-\r
- try {\r
- return this.cbaFileManagementService.saveCBAFile(filePart, cbaLocation).map(fileName -> {\r
- ConfigModel configModel;\r
- BlueprintModelResponse blueprintModelResponse = null;\r
-\r
- try {\r
- String cbaDirectory = this.cbaFileManagementService.decompressCBAFile(fileName, cbaLocation);\r
- configModel = this.cbaToDatabaseService.storeBluePrints(cbaDirectory, fileName, cbaLocation.resolve(fileName));\r
- blueprintModelResponse = new BlueprintModelResponse(configModel.getId(), configModel.getArtifactName(), configModel.getArtifactVersion(), configModel.getArtifactDescription(), configModel.getConfigModelCBA().getCbaUUID());\r
- } catch (BluePrintException be) {\r
- Mono.error(new BluePrintException("Error loading CBA in database.", be));\r
- } finally {\r
- try {\r
- this.cbaFileManagementService.cleanupSavedCBA(fileName, cbaLocation);\r
- } catch (BluePrintException be) {\r
- Mono.error(new BluePrintException("Error while cleaning up.", be));\r
- }\r
- }\r
- return blueprintModelResponse;\r
- });\r
- } catch (IOException | BluePrintException e) {\r
- return Mono.error(new BluePrintException("Error uploading the CBA file in channel.", e));\r
- }\r
- }\r
-\r
- /**\r
- * This is a deleteCba method\r
- *\r
- * @param id id\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public void deleteCBA(@NotNull Long id) throws BluePrintException {\r
- this.cbaToDatabaseService.deleteCBA(id);\r
- }\r
-\r
- /**\r
- * This is a downloadCBAFile method to find the target file to download and return a file ressource using MONO\r
- *\r
- * @param (id)\r
- * @return ResponseEntity<Resource>\r
- */\r
- public ResponseEntity<Resource> downloadCBAFile(@NotNull String id) {\r
- Optional<CbaContent> optionalContent = this.cbaToDatabaseService.findByUUID(id);\r
-\r
- CbaContent cbaContent = optionalContent.get();\r
-\r
- return ResponseEntity.ok()\r
- .contentType(MediaType.parseMediaType("text/plain"))\r
- .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + cbaContent.getCbaName() + "\"")\r
- .body(new ByteArrayResource(cbaContent.getCbaFile()));\r
- }\r
-\r
- /**\r
- * This is a findCBAByID method to find a CBA By the UUID\r
- *\r
- * @param (id)\r
- * @return ItemCbaResponse\r
- */\r
- public ItemCbaResponse findCBAByID(@NotNull String id) {\r
- ItemCbaResponse response = new ItemCbaResponse();\r
- Optional<CbaContent> optionalContent = this.cbaToDatabaseService.findByUUID(id);\r
-\r
- CbaContent cbaContent = optionalContent.get();\r
- response.setName(cbaContent.getCbaName());\r
- response.setState(cbaContent.getCbaState());\r
- response.setId(cbaContent.getCbaUUID());\r
- response.setVersion(cbaContent.getCbaVersion());\r
- response.setDescription(cbaContent.getCbaDescription());\r
- return response;\r
- }\r
-\r
- /**\r
- * This is a findAllCBA method to retrieve all the CBAs in Database\r
- *\r
- * @return List<ItemCbaResponse> list with the controller blueprint archives\r
- */\r
- public List<ItemCbaResponse> findAllCBA() {\r
- List<ItemCbaResponse> responseList = new ArrayList<>();\r
- List<CbaContent> cbaContents = this.cbaToDatabaseService.listCBAFiles();\r
-\r
- for(CbaContent content: cbaContents){\r
- ItemCbaResponse response = new ItemCbaResponse();\r
- response.setName(content.getCbaName());\r
- response.setState(content.getCbaState());\r
- response.setId(content.getCbaUUID());\r
- response.setVersion(content.getCbaVersion());\r
- response.setDescription(content.getCbaDescription());\r
-\r
- responseList.add(response);\r
- }\r
- return responseList;\r
- }\r
-\r
- /**\r
- * This is a findCBAByNameAndVersion method to find a CBA by Name and version\r
- *\r
- * @param (name, version)\r
- * @return\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public ItemCbaResponse findCBAByNameAndVersion(@NotNull String name, @NotNull String version) throws BluePrintException {\r
- return null;\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-/*\r
- * Copyright © 2018 IBM Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.jetbrains.annotations.NotNull;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelContentRepository;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.CbaStateEnum;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.stereotype.Service;\r
-\r
-import java.io.IOException;\r
-import java.nio.file.Files;\r
-import java.nio.file.Path;\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-/**\r
- * This class acts as a Rest Service that would store in the Database the Blueprints.\r
- * @author Ruben Chang\r
- */\r
-\r
-@Service\r
-public class CbaToDatabaseService {\r
-\r
- //Log used to trace the transactions using the EELFLogger class\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(CbaToDatabaseService.class);\r
-\r
- @Autowired\r
- private ConfigModelRepository configModelRepository;\r
- @Autowired\r
- private ConfigModelContentRepository configModelContentRepository;\r
- @Autowired\r
- private ConfigModelCreateService configModelCreateService; \r
- @Autowired\r
- private CBAContentService cbaContentService;\r
-\r
- /**\r
- * This method will store the blueprints into the DB on the tables CONFIG_MODEL and CONFIG_MODEL_CONTENT\r
- * @param cbaArchiveToSave Path in which the components are stored\r
- * @return ConfigModel The Blueprint object stored in the DB\r
- */\r
- public ConfigModel storeBluePrints(String cbaDirectory, String cbaFileName, Path cbaArchiveToSave) throws BluePrintException {\r
- log.info("*************************** storeBluePrints **********************");\r
- ConfigModel configModel = null;\r
- CbaContent cbaContent;\r
- String version = "1.0";//TODO Read these information from metadata\r
- String description = "Initial description for CBA archive " + cbaFileName;//TODO\r
-\r
- List<String> serviceTemplateDirs = ConfigModelUtils.getBlueprintNames(cbaDirectory);\r
- if (CollectionUtils.isNotEmpty(serviceTemplateDirs)) {\r
- for (String fileName : serviceTemplateDirs) {\r
- try {\r
- String bluePrintPath = cbaDirectory.concat("/").concat(fileName);\r
- log.debug("***** Loading service template : {}", bluePrintPath);\r
- configModel = ConfigModelUtils.getConfigModel(bluePrintPath);\r
-\r
- configModel = this.configModelCreateService.saveConfigModel(configModel);\r
-\r
- log.info("Loaded service template successfully: {}", fileName);\r
- } catch (Exception e) {\r
- throw new BluePrintException("Load config model " + fileName + " error : "+e.getMessage());\r
- }\r
- }\r
- } else {\r
- throw new BluePrintException("Invalid structure. The unzipped file does not contains Blueprints");\r
- }\r
-\r
- byte[] file;\r
- try {\r
- file = Files.readAllBytes(cbaArchiveToSave);\r
- } catch (IOException e) {\r
- throw new BluePrintException("Fail to read the CBA to save in database.", e);\r
- }\r
-\r
- cbaContent = this.cbaContentService.saveCBAContent(cbaFileName, version, CbaStateEnum.DRAFT.getState(), description, file);\r
- configModel.setConfigModelCBA(cbaContent);\r
-\r
- return configModel;\r
- }\r
-\r
- /**\r
- * This is a deleteConfigModel method\r
- *\r
- * @param id id\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public void deleteCBA(@NotNull Long id) throws BluePrintException {\r
- Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);\r
-\r
- //TODO: Delete CBA and COnfigModel\r
-\r
- }\r
- \r
- /**\r
- * Get a list of the controller blueprint archives\r
- * @return List<CbaContent> List with the controller blueprint archives\r
- */\r
- public List<CbaContent> listCBAFiles() {\r
- return this.cbaContentService.getList();\r
- }\r
-\r
- /**\r
- * Find a Controller Blueprint Archive by UUID\r
- * @param uuID the User Identifier Controller Blueprint archive\r
- * @return Optional<CbaContent> the Controller Blueprint archive\r
- */\r
- public Optional<CbaContent> findByUUID(String uuID) {\r
- return this.cbaContentService.findByUUID(uuID);\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.google.common.base.Preconditions;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.io.IOUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.jetbrains.annotations.NotNull;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;\r
-import org.springframework.stereotype.Service;\r
-\r
-import java.io.IOException;\r
-import java.nio.charset.Charset;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-/**\r
- * ServiceTemplateCreateService.java Purpose: Provide Service Template Create Service processing\r
- * ServiceTemplateCreateService\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-@Deprecated\r
-@Service\r
-public class ConfigModelCreateService {\r
-\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelCreateService.class);\r
-\r
- private ConfigModelRepository configModelRepository;\r
-\r
- /**\r
- * This is a ConfigModelCreateService\r
- *\r
- * @param configModelRepository ConfigModelRepository\r
- */\r
- public ConfigModelCreateService(ConfigModelRepository configModelRepository) {\r
- this.configModelRepository = configModelRepository;\r
- }\r
-\r
- /**\r
- * This is a createInitialServiceTemplateContent method\r
- *\r
- * @param templateName templateName\r
- * @return String\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public String createInitialServiceTemplateContent(String templateName) throws BluePrintException {\r
- String serviceTemplateContent = null;\r
- if (StringUtils.isNotBlank(templateName)) {\r
- try {\r
- serviceTemplateContent = IOUtils.toString(ConfigModelCreateService.class.getClassLoader()\r
- .getResourceAsStream("service_template/" + templateName + ".json"), Charset.defaultCharset());\r
- } catch (IOException e) {\r
- throw new BluePrintException(e.getMessage(), e);\r
- }\r
-\r
- }\r
- return serviceTemplateContent;\r
- }\r
-\r
- /**\r
- * This is a createInitialServiceTemplate method\r
- *\r
- * @param templateName templateName\r
- * @return ServiceTemplate\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public ServiceTemplate createInitialServiceTemplate(String templateName) throws BluePrintException {\r
- ServiceTemplate serviceTemplate = null;\r
- if (StringUtils.isNotBlank(templateName)) {\r
- try {\r
- String serviceTemplateContent = IOUtils.toString(ConfigModelCreateService.class.getClassLoader()\r
- .getResourceAsStream("service_template/" + templateName + ".json"), Charset.defaultCharset());\r
- if (StringUtils.isNotBlank(serviceTemplateContent)) {\r
- serviceTemplate = JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);\r
- }\r
- } catch (IOException e) {\r
- throw new BluePrintException(e.getMessage(), e);\r
- }\r
-\r
- }\r
- return serviceTemplate;\r
- }\r
-\r
- /**\r
- * This is a saveConfigModel method\r
- *\r
- * @param configModel configModel\r
- * @return ConfigModel\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {\r
-\r
- if (configModel != null) {\r
- String artifactName = configModel.getArtifactName();\r
- String artifactVersion = configModel.getArtifactVersion();\r
- String author = configModel.getUpdatedBy();\r
- CbaContent configModelCBA = configModel.getConfigModelCBA();\r
-\r
- if (StringUtils.isBlank(author)) {\r
- throw new BluePrintException("Artifact Author is missing in the Service Template");\r
- }\r
-\r
- if (StringUtils.isBlank(artifactName)) {\r
- throw new BluePrintException("Artifact Name is missing in the Service Template");\r
- }\r
-\r
- if (StringUtils.isBlank(artifactVersion)) {\r
- throw new BluePrintException("Artifact Version is missing in the Service Template");\r
- }\r
- ConfigModel updateConfigModel;\r
-\r
- Optional<ConfigModel> dbConfigModelOptional = Optional.empty();\r
-\r
- if (configModel.getId() != null) {\r
- log.info("Searching for config model id : {}", configModel.getId());\r
- dbConfigModelOptional = configModelRepository.findById(configModel.getId());\r
- }\r
-\r
- if (!dbConfigModelOptional.isPresent()) {\r
- log.info("Searching for config model name :"\r
- + configModel.getArtifactName() + ", version " + configModel.getArtifactVersion());\r
- dbConfigModelOptional = configModelRepository.findByArtifactNameAndArtifactVersion(\r
- configModel.getArtifactName(), configModel.getArtifactVersion());\r
- }\r
-\r
- if (dbConfigModelOptional.isPresent()) {\r
- updateConfigModel = dbConfigModelOptional.get();\r
- log.info("Processing for config model id : {} with config model content count : {}"\r
- , updateConfigModel.getId(), updateConfigModel.getConfigModelContents().size());\r
- } else {\r
- ConfigModel tempConfigModel = new ConfigModel();\r
- tempConfigModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);\r
- tempConfigModel.setArtifactName(artifactName);\r
- tempConfigModel.setArtifactVersion(artifactVersion);\r
- tempConfigModel.setUpdatedBy(author);\r
- tempConfigModel.setPublished(ApplicationConstants.ACTIVE_N);\r
- tempConfigModel.setTags(artifactName);\r
- configModelRepository.saveAndFlush(tempConfigModel);\r
- updateConfigModel = tempConfigModel;\r
- }\r
-\r
- Long dbConfigModelId = updateConfigModel.getId();\r
-\r
- if (dbConfigModelId == null) {\r
- throw new BluePrintException("failed to get the initial saved config model id.");\r
- }\r
-\r
- log.info("Processing for config model id : {}", dbConfigModelId);\r
-\r
- deleteConfigModelContent(dbConfigModelId);\r
-\r
- addConfigModelContent(dbConfigModelId, configModel);\r
-\r
- // Populate Content model types\r
- updateConfigModel = updateConfigModel(dbConfigModelId, artifactName, artifactVersion, author, configModelCBA);\r
-\r
-\r
- return updateConfigModel;\r
- } else {\r
- throw new BluePrintException("Config model information is missing");\r
- }\r
-\r
- }\r
-\r
- private void deleteConfigModelContent(Long dbConfigModelId) {\r
- if (dbConfigModelId != null) {\r
- ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);\r
- if (CollectionUtils.isNotEmpty(dbConfigModel.getConfigModelContents())) {\r
- dbConfigModel.getConfigModelContents().clear();\r
- log.debug("Configuration Model content deleting : {}", dbConfigModel.getConfigModelContents());\r
- configModelRepository.saveAndFlush(dbConfigModel);\r
- }\r
-\r
- }\r
- }\r
-\r
- private void addConfigModelContent(Long dbConfigModelId, ConfigModel configModel) {\r
- if (dbConfigModelId != null && configModel != null\r
- && CollectionUtils.isNotEmpty(configModel.getConfigModelContents())) {\r
- ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);\r
- for (ConfigModelContent configModelContent : configModel.getConfigModelContents()) {\r
- if (configModelContent != null) {\r
- configModelContent.setId(null);\r
- configModelContent.setConfigModel(dbConfigModel);\r
- dbConfigModel.getConfigModelContents().add(configModelContent);\r
- log.debug("Configuration Model content adding : {}", configModelContent);\r
- }\r
- }\r
- configModelRepository.saveAndFlush(dbConfigModel);\r
- }\r
- }\r
-\r
- private ConfigModel updateConfigModel(Long dbConfigModelId, String artifactName, String artifactVersion,\r
- String author, CbaContent configModelCBA) throws BluePrintException {\r
-\r
- ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);\r
- // Populate tags from metadata\r
- String tags = getConfigModelTags(dbConfigModel);\r
- if (StringUtils.isBlank(tags)) {\r
- throw new BluePrintException("Failed to populate tags for the config model name " + artifactName);\r
- }\r
- dbConfigModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);\r
- dbConfigModel.setArtifactName(artifactName);\r
- dbConfigModel.setArtifactVersion(artifactVersion);\r
- dbConfigModel.setUpdatedBy(author);\r
- dbConfigModel.setPublished(ApplicationConstants.ACTIVE_N);\r
- dbConfigModel.setTags(tags);\r
- dbConfigModel.setConfigModelCBA(configModelCBA);\r
- configModelRepository.saveAndFlush(dbConfigModel);\r
- log.info("Config model ({}) saved successfully.", dbConfigModel.getId());\r
- return dbConfigModel;\r
- }\r
-\r
- private List<String> getValidContentTypes() {\r
- List<String> valids = new ArrayList<>();\r
- valids.add(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);\r
- valids.add(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);\r
- return valids;\r
-\r
- }\r
-\r
- private String getConfigModelTags(ConfigModel configModel) throws BluePrintException {\r
- String tags = null;\r
- if (CollectionUtils.isNotEmpty(configModel.getConfigModelContents())) {\r
-\r
- for (ConfigModelContent configModelContent : configModel.getConfigModelContents()) {\r
- if (configModelContent != null && StringUtils.isNotBlank(configModelContent.getContentType())) {\r
-\r
- if (!getValidContentTypes().contains(configModelContent.getContentType())) {\r
- throw new BluePrintException(configModelContent.getContentType()\r
- + " is not a valid content type, It should be any one of this "\r
- + getValidContentTypes());\r
- }\r
-\r
- if (configModelContent.getContentType().equals(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON)) {\r
- ServiceTemplate serviceTemplate =\r
- JacksonUtils.readValue(configModelContent.getContent(), ServiceTemplate.class);\r
- Preconditions.checkNotNull(serviceTemplate, "failed to transform service template content");\r
- if (serviceTemplate.getMetadata() != null) {\r
- serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_AUTHOR,\r
- configModel.getUpdatedBy());\r
- serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_VERSION,\r
- configModel.getArtifactVersion());\r
- serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_NAME,\r
- configModel.getArtifactName());\r
- }\r
- tags = String.valueOf(serviceTemplate.getMetadata());\r
- }\r
- }\r
- }\r
- }\r
- return tags;\r
- }\r
-\r
- /**\r
- * This is a publishConfigModel method\r
- *\r
- * @param id id\r
- * @return ConfigModel\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public ConfigModel publishConfigModel(@NotNull Long id) throws BluePrintException {\r
- ConfigModel dbConfigModel = null;\r
- Optional<ConfigModel> dbConfigModelOptional = configModelRepository.findById(id);\r
- if (dbConfigModelOptional.isPresent()) {\r
- dbConfigModel = dbConfigModelOptional.get();\r
- List<ConfigModelContent> configModelContents = dbConfigModel.getConfigModelContents();\r
- if (configModelContents != null && !configModelContents.isEmpty()) {\r
- for (ConfigModelContent configModelContent : configModelContents) {\r
- if (configModelContent.getContentType()\r
- .equals(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON)) {\r
- ServiceTemplate serviceTemplate = JacksonUtils\r
- .readValue(configModelContent.getContent(), ServiceTemplate.class);\r
- if (serviceTemplate != null) {\r
- validateServiceTemplate(serviceTemplate);\r
- }\r
- }\r
- }\r
- }\r
- dbConfigModel.setPublished(ApplicationConstants.ACTIVE_Y);\r
- configModelRepository.save(dbConfigModel);\r
- log.info("Config model ({}) published successfully.", id);\r
- } else {\r
- throw new BluePrintException(String.format("Couldn't get Config model for id :(%s)", id));\r
- }\r
- return dbConfigModel;\r
- }\r
-\r
- /**\r
- * This is a validateServiceTemplate method\r
- *\r
- * @param serviceTemplate Service Template\r
- * @return ServiceTemplate\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {\r
- // FIXME("Plug right Validator")\r
- return serviceTemplate;\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.jetbrains.annotations.NotNull;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelContentRepository;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.springframework.stereotype.Service;\r
-import org.springframework.transaction.annotation.Transactional;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-/**\r
- * ConfigModelService.java Purpose: Provide Service Template Service processing ConfigModelService\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-\r
-@Service\r
-public class ConfigModelService {\r
-\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelService.class);\r
-\r
- private ConfigModelRepository configModelRepository;\r
- private ConfigModelContentRepository configModelContentRepository;\r
- private ConfigModelCreateService configModelCreateService;\r
- private static final String CONFIG_MODEL_ID_FAILURE_MSG= "failed to get config model id(%d) from repo";\r
-\r
- /**\r
- * This is a ConfigModelService constructor.\r
- *\r
- * @param configModelRepository configModelRepository\r
- * @param configModelContentRepository configModelContentRepository\r
- * @param configModelCreateService configModelCreateService\r
- */\r
- public ConfigModelService(ConfigModelRepository configModelRepository,\r
- ConfigModelContentRepository configModelContentRepository,\r
- ConfigModelCreateService configModelCreateService) {\r
- this.configModelRepository = configModelRepository;\r
- this.configModelContentRepository = configModelContentRepository;\r
- this.configModelCreateService = configModelCreateService;\r
- log.info("Config Model Service Initiated...");\r
- }\r
-\r
- /**\r
- * This is a getInitialConfigModel method\r
- *\r
- * @param templateName templateName\r
- * @return ConfigModel\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public ConfigModel getInitialConfigModel(String templateName) throws BluePrintException {\r
- ConfigModel configModel = null;\r
- if (StringUtils.isNotBlank(templateName)) {\r
- configModel = new ConfigModel();\r
- configModel.setArtifactName(templateName);\r
- configModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);\r
- configModel.setUpdatedBy("xxxxx@xxx.com");\r
- ConfigModelContent configModelContent = new ConfigModelContent();\r
- configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);\r
- configModelContent.setName(templateName);\r
- String content = this.configModelCreateService.createInitialServiceTemplateContent(templateName);\r
- configModelContent.setContent(content);\r
-\r
- List<ConfigModelContent> configModelContents = new ArrayList<>();\r
- configModelContents.add(configModelContent);\r
-\r
- configModel.setConfigModelContents(configModelContents);\r
- }\r
- return configModel;\r
- }\r
-\r
- /**\r
- * This is a saveConfigModel method\r
- *\r
- * @param configModel configModel\r
- * @return ConfigModel\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {\r
- return this.configModelCreateService.saveConfigModel(configModel);\r
- }\r
-\r
- /**\r
- * This is a publishConfigModel method\r
- *\r
- * @param id id\r
- * @return ConfigModel\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public ConfigModel publishConfigModel(Long id) throws BluePrintException {\r
- return this.configModelCreateService.publishConfigModel(id);\r
- }\r
-\r
- /**\r
- * This is a searchConfigModels method\r
- *\r
- * @param tags tags\r
- * @return ConfigModel\r
- */\r
- public List<ConfigModel> searchConfigModels(String tags) {\r
- List<ConfigModel> models = configModelRepository.findByTagsContainingIgnoreCase(tags);\r
- if (models != null) {\r
- for (ConfigModel configModel : models) {\r
- configModel.setConfigModelContents(null);\r
- }\r
- }\r
- return models;\r
- }\r
-\r
- /**\r
- * This is a getConfigModelByNameAndVersion method\r
- *\r
- * @param name name\r
- * @param version version\r
- * @return ConfigModel\r
- */\r
- public ConfigModel getConfigModelByNameAndVersion(@NotNull String name, String version) throws BluePrintException {\r
- ConfigModel configModel;\r
- Optional<ConfigModel> dbConfigModel;\r
- if (StringUtils.isNotBlank(version)) {\r
- dbConfigModel = configModelRepository.findByArtifactNameAndArtifactVersion(name, version);\r
- } else {\r
- dbConfigModel = configModelRepository.findTopByArtifactNameOrderByArtifactVersionDesc(name);\r
- }\r
- if (dbConfigModel.isPresent()) {\r
- configModel = dbConfigModel.get();\r
- } else {\r
- throw new BluePrintException(String.format("failed to get config model name(%s), version(%s) from repo", name, version));\r
- }\r
- return configModel;\r
- }\r
-\r
- /**\r
- * This is a getConfigModel method\r
- *\r
- * @param id id\r
- * @return ConfigModel\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public ConfigModel getConfigModel(@NotNull Long id) throws BluePrintException {\r
- ConfigModel configModel;\r
- Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);\r
- if (dbConfigModel.isPresent()) {\r
- configModel = dbConfigModel.get();\r
- } else {\r
- throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));\r
- }\r
-\r
- return configModel;\r
- }\r
-\r
- /**\r
- * This method returns clone of the given model id, by masking the other unrelated fields\r
- *\r
- * @param id id\r
- * @return ConfigModel\r
- * @throws BluePrintException BluePrintException\r
- */\r
-\r
- public ConfigModel getCloneConfigModel(@NotNull Long id) throws BluePrintException {\r
-\r
- ConfigModel configModel;\r
- ConfigModel cloneConfigModel;\r
- Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);\r
- if (dbConfigModel.isPresent()) {\r
- configModel = dbConfigModel.get();\r
- cloneConfigModel = configModel;\r
- cloneConfigModel.setUpdatedBy("xxxxx@xxx.com");\r
- cloneConfigModel.setArtifactName("XXXX");\r
- cloneConfigModel.setPublished("XXXX");\r
- cloneConfigModel.setPublished("XXXX");\r
- cloneConfigModel.setUpdatedBy("XXXX");\r
- cloneConfigModel.setId(null);\r
- cloneConfigModel.setTags(null);\r
- cloneConfigModel.setCreatedDate(new Date());\r
- List<ConfigModelContent> configModelContents = cloneConfigModel.getConfigModelContents();\r
-\r
- if (CollectionUtils.isNotEmpty(configModelContents)) {\r
- for (ConfigModelContent configModelContent : configModelContents) {\r
- if (configModelContent != null && StringUtils.isNotBlank(configModelContent.getContentType())) {\r
- configModelContent.setId(null);\r
- configModelContent.setCreationDate(new Date());\r
-\r
- if (ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON\r
- .equalsIgnoreCase(configModelContent.getContentType())) {\r
- ServiceTemplate serviceTemplate = JacksonUtils\r
- .readValue(configModelContent.getContent(), ServiceTemplate.class);\r
- if (serviceTemplate != null && serviceTemplate.getMetadata() != null) {\r
- serviceTemplate.getMetadata()\r
- .put(BluePrintConstants.METADATA_TEMPLATE_AUTHOR, "XXXX");\r
- serviceTemplate.getMetadata()\r
- .put(BluePrintConstants.METADATA_TEMPLATE_VERSION, "1.0.0");\r
- serviceTemplate.getMetadata()\r
- .put(BluePrintConstants.METADATA_TEMPLATE_NAME, "XXXXXX");\r
-\r
- configModelContent.setContent(JacksonUtils.getJson(serviceTemplate));\r
- }\r
- }\r
- }\r
-\r
- }\r
- }\r
- } else {\r
- throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));\r
- }\r
-\r
- return cloneConfigModel;\r
- }\r
-\r
- /**\r
- * This is a deleteConfigModel method\r
- *\r
- * @param id id\r
- * @throws BluePrintException BluePrintException\r
- */\r
-\r
- @Transactional\r
- public void deleteConfigModel(@NotNull Long id) throws BluePrintException {\r
- Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);\r
- if (dbConfigModel.isPresent()) {\r
- configModelContentRepository.deleteByConfigModel(dbConfigModel.get());\r
- configModelRepository.delete(dbConfigModel.get());\r
- } else {\r
- throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));\r
- }\r
- }\r
-\r
-}\r
\r
package org.onap.ccsdk.apps.controllerblueprints.service;\r
\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
import com.google.common.base.Preconditions;\r
import org.apache.commons.collections.MapUtils;\r
import org.apache.commons.lang3.StringUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.service.common.SwaggerGenerator;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
\r
import java.util.HashMap;\r
import java.util.Map;\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationService;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;\r
-import org.springframework.stereotype.Service;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.regex.Matcher;\r
-import java.util.regex.Pattern;\r
-\r
-/**\r
- * ServiceTemplateService.java Purpose: Provide Service Template Create Service processing ServiceTemplateService\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-\r
-@Service\r
-public class ServiceTemplateService {\r
-\r
- private ResourceDictionaryRepository dataDictionaryRepository;\r
-\r
- private ConfigModelCreateService configModelCreateService;\r
- private ResourceAssignmentValidationService resourceAssignmentValidationService;\r
-\r
- /**\r
- * This is a SchemaGeneratorService constructor\r
- *\r
- * @param dataDictionaryRepository dataDictionaryRepository\r
- * @param configModelCreateService configModelCreateService\r
- * @param resourceAssignmentValidationService resourceAssignmentValidationService\r
- */\r
- public ServiceTemplateService(ResourceDictionaryRepository dataDictionaryRepository,\r
- ConfigModelCreateService configModelCreateService,\r
- ResourceAssignmentValidationService resourceAssignmentValidationService) {\r
- this.dataDictionaryRepository = dataDictionaryRepository;\r
- this.configModelCreateService = configModelCreateService;\r
- this.resourceAssignmentValidationService = resourceAssignmentValidationService;\r
- }\r
-\r
- /**\r
- * This is a validateServiceTemplate method\r
- *\r
- * @param serviceTemplate serviceTemplate\r
- * @return ServiceTemplate\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {\r
- return this.configModelCreateService.validateServiceTemplate(serviceTemplate);\r
- }\r
-\r
- /**\r
- * This is a enrichServiceTemplate method\r
- *\r
- * @param serviceTemplate serviceTemplate\r
- * @return ServiceTemplate\r
- */\r
- public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {\r
- //FIXME("Connect New Enrichment service")\r
- return serviceTemplate;\r
- }\r
-\r
- /**\r
- * This is a autoMap method to map the template keys\r
- *\r
- * @param resourceAssignments resourceAssignments\r
- * @return AutoMapResponse\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public AutoMapResponse autoMap(List<ResourceAssignment> resourceAssignments) throws BluePrintException {\r
- AutoResourceMappingService autoMappingService = new AutoResourceMappingService(dataDictionaryRepository);\r
- return autoMappingService.autoMap(resourceAssignments);\r
- }\r
-\r
- /**\r
- * This is a validateResourceAssignments method\r
- *\r
- * @param resourceAssignments resourceAssignments\r
- * @return List<ResourceAssignment>\r
- * @throws BluePrintException BluePrintException\r
- */\r
- public List<ResourceAssignment> validateResourceAssignments(List<ResourceAssignment> resourceAssignments)\r
- throws BluePrintException {\r
- resourceAssignmentValidationService.validate(resourceAssignments);\r
- return resourceAssignments;\r
- }\r
-\r
- /**\r
- * This is a generateResourceAssignments method\r
- *\r
- * @param templateContent templateContent\r
- * @return List<ResourceAssignment>\r
- */\r
- public List<ResourceAssignment> generateResourceAssignments(ConfigModelContent templateContent) {\r
- List<ResourceAssignment> resourceAssignments = new ArrayList<>();\r
- if (templateContent != null && StringUtils.isNotBlank(templateContent.getContent())) {\r
- Pattern p = Pattern.compile("(?<=\\$\\{)([^\\}]+)(?=\\})");\r
- Matcher m = p.matcher(templateContent.getContent());\r
- while (m.find()) {\r
- ResourceAssignment resourceAssignment = new ResourceAssignment();\r
- resourceAssignment.setName(m.group());\r
- resourceAssignments.add(resourceAssignment);\r
- }\r
- }\r
- return resourceAssignments;\r
- }\r
-\r
-}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2019 Bell Canada.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
package org.onap.ccsdk.apps.controllerblueprints.service.domain;\r
\r
import com.fasterxml.jackson.annotation.JsonFormat;\r
-import com.fasterxml.jackson.annotation.JsonManagedReference;\r
import io.swagger.annotations.ApiModelProperty;\r
import org.hibernate.annotations.Proxy;\r
import org.springframework.data.annotation.LastModifiedDate;\r
\r
import javax.persistence.*;\r
import java.io.Serializable;\r
-import java.util.ArrayList;\r
import java.util.Date;\r
-import java.util.List;\r
\r
/**\r
- * ConfigModel.java Purpose: Provide Configuration Generator ConfigModel Entity\r
+ * BlueprintModel.java Purpose: Provide Configuration Generator BlueprintModel Entity\r
*\r
* @author Brinda Santh\r
* @version 1.0\r
@Entity\r
@Table(name = "CONFIG_MODEL")\r
@Proxy(lazy=false)\r
-public class ConfigModel implements Serializable {\r
+public class BlueprintModel implements Serializable {\r
private static final long serialVersionUID = 1L;\r
@Id\r
- @GeneratedValue(strategy = GenerationType.IDENTITY)\r
@Column(name = "config_model_id")\r
- private Long id;\r
+ private String id;\r
\r
@Column(name = "service_uuid")\r
private String serviceUUID;\r
@ApiModelProperty(required=true)\r
private String tags;\r
\r
+ @OneToOne(mappedBy = "blueprintModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)\r
+ private BlueprintModelContent blueprintModelContent;\r
\r
- @OneToMany(mappedBy = "configModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)\r
- @JsonManagedReference\r
- private List<ConfigModelContent> configModelContents = new ArrayList<>();\r
-\r
- @ManyToOne\r
- @JoinColumn(name = "cba_content_uuid")\r
- private CbaContent configModelCBA;\r
-\r
- public Long getId() {\r
+ public String getId() {\r
return id;\r
}\r
\r
- public void setId(Long id) {\r
+ public void setId(String id) {\r
this.id = id;\r
}\r
\r
this.tags = tags;\r
}\r
\r
- public List<ConfigModelContent> getConfigModelContents() {\r
- return configModelContents;\r
- }\r
-\r
- public void setConfigModelContents(List<ConfigModelContent> configModelContents) {\r
- this.configModelContents = configModelContents;\r
+ public BlueprintModelContent getBlueprintModelContent() {\r
+ return blueprintModelContent;\r
}\r
\r
- public CbaContent getConfigModelCBA() {\r
- return configModelCBA;\r
- }\r
- \r
- public void setConfigModelCBA(CbaContent configModelCBA) {\r
- this.configModelCBA = configModelCBA;\r
+ public void setBlueprintModelContent(BlueprintModelContent blueprintModelContent) {\r
+ this.blueprintModelContent = blueprintModelContent;\r
}\r
-\r
}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2019 Bell Canada.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
package org.onap.ccsdk.apps.controllerblueprints.service.domain;\r
\r
-import com.fasterxml.jackson.annotation.JsonBackReference;\r
import com.fasterxml.jackson.annotation.JsonFormat;\r
import io.swagger.annotations.ApiModelProperty;\r
import org.springframework.data.annotation.LastModifiedDate;\r
import org.springframework.data.jpa.domain.support.AuditingEntityListener;\r
\r
import javax.persistence.*;\r
+import java.io.Serializable;\r
import java.util.Date;\r
import java.util.Objects;\r
\r
@EntityListeners({AuditingEntityListener.class})\r
@Entity\r
@Table(name = "CONFIG_MODEL_CONTENT")\r
-public class ConfigModelContent {\r
+public class BlueprintModelContent implements Serializable {\r
\r
private static final long serialVersionUID = 1L;\r
\r
@Id\r
- @GeneratedValue(strategy = GenerationType.IDENTITY)\r
@Column(name = "config_model_content_id")\r
- private Long id;\r
+ private String id;\r
\r
@Column(name = "name", nullable = false)\r
@ApiModelProperty(required=true)\r
@ApiModelProperty(required=true)\r
private String contentType;\r
\r
-\r
- @ManyToOne\r
+ @OneToOne\r
@JoinColumn(name = "config_model_id")\r
- @JsonBackReference\r
- private ConfigModel configModel;\r
+ private BlueprintModel blueprintModel;\r
\r
@Lob\r
@Column(name = "description")\r
private String description;\r
\r
- @Deprecated\r
@Lob\r
@Column(name = "content", nullable = false)\r
@ApiModelProperty(required=true)\r
- private String content;\r
-\r
+ private byte[] content;\r
\r
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")\r
@LastModifiedDate\r
@Temporal(TemporalType.TIMESTAMP)\r
@Column(name = "updated_date")\r
- private Date creationDate;\r
+ private Date creationDate = new Date();\r
\r
@Override\r
public String toString() {\r
if (o == this) {\r
return true;\r
}\r
- if (!(o instanceof ConfigModelContent)) {\r
+ if (!(o instanceof BlueprintModelContent)) {\r
return false;\r
}\r
- ConfigModelContent configModelContent = (ConfigModelContent) o;\r
- return Objects.equals(id, configModelContent.id) && Objects.equals(name, configModelContent.name)\r
- && Objects.equals(contentType, configModelContent.contentType);\r
+ BlueprintModelContent blueprintModelContent = (BlueprintModelContent) o;\r
+ return Objects.equals(id, blueprintModelContent.id) && Objects.equals(name, blueprintModelContent.name)\r
+ && Objects.equals(contentType, blueprintModelContent.contentType);\r
}\r
\r
@Override\r
return Objects.hash(id, name, contentType);\r
}\r
\r
- public Long getId() {\r
+ public String getId() {\r
return id;\r
}\r
\r
\r
- public void setId(Long id) {\r
+ public void setId(String id) {\r
this.id = id;\r
}\r
\r
}\r
\r
\r
- public ConfigModel getConfigModel() {\r
- return configModel;\r
+ public BlueprintModel getBlueprintModel() {\r
+ return blueprintModel;\r
}\r
\r
\r
- public void setConfigModel(ConfigModel configModel) {\r
- this.configModel = configModel;\r
+ public void setBlueprintModel(BlueprintModel blueprintModel) {\r
+ this.blueprintModel = blueprintModel;\r
}\r
\r
\r
}\r
\r
\r
- public String getContent() {\r
+ public byte[] getContent() {\r
return content;\r
}\r
\r
\r
- public void setContent(String content) {\r
+ public void setContent(byte[] content) {\r
this.content = content;\r
}\r
\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2019 Bell Canada.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
@Entity\r
@Table(name = "CONFIG_MODEL")\r
-public class ConfigModelSearch implements Serializable {\r
+public class BlueprintModelSearch implements Serializable {\r
private static final long serialVersionUID = 1L;\r
\r
@Id\r
- @GeneratedValue(strategy = GenerationType.IDENTITY)\r
@Column(name = "config_model_id")\r
- private Long id;\r
+ private String id;\r
\r
@Column(name = "artifact_uuid")\r
private String artifactUUId;\r
@Column(name = "tags", nullable = false)\r
private String tags;\r
\r
- public Long getId() {\r
+ public String getId() {\r
return id;\r
}\r
\r
- public void setId(Long id) {\r
+ public void setId(String id) {\r
this.id = id;\r
}\r
\r
public static long getSerialversionuid() {\r
return serialVersionUID;\r
}\r
-\r
-\r
-\r
}\r
+++ /dev/null
-/*
- * Copyright © 2018 IBM 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.controllerblueprints.service.domain;
-
-import com.fasterxml.jackson.annotation.JsonManagedReference;
-import org.hibernate.annotations.Proxy;
-import org.springframework.data.jpa.domain.support.AuditingEntityListener;
-
-import javax.persistence.*;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-/**
- * CbaContent.java Purpose: Provide Configuration Generator for CbaContent Entity
- *
- * @author Ruben Chang
- * @version 1.0
- */
-
-@EntityListeners({AuditingEntityListener.class})
-@Entity
-@Table(name = "CBA_CONTENT")
-@Proxy(lazy=false)
-public class CbaContent implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public CbaContent() {
- this.cbaUUID = UUID.randomUUID().toString();
- }
-
- @Id
- @Column(name = "cba_uuid", nullable = false)
- private String cbaUUID;
-
- @Lob
- @Column(name = "cba_file")
- private byte[] cbaFile;
-
- @Column(name = "cba_name")
- private String cbaName;
-
- @Column(name = "cba_version")
- private String cbaVersion;
-
- @Column(name = "cba_state")
- private int cbaState;
-
- @Column(name="cba_description")
- private String cbaDescription;
-
- @OneToMany(mappedBy = "configModelCBA", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)
- @JsonManagedReference
- private List<ConfigModel> models = new ArrayList<>();
-
- public String getCbaUUID() {
- return cbaUUID;
- }
-
- public void setCbaUUID(String cbaUUID) {
- this.cbaUUID = cbaUUID;
- }
-
- public String getCbaName() {
- return cbaName;
- }
-
- public void setCbaName(String cbaName) {
- this.cbaName = cbaName;
- }
-
- public String getCbaVersion() {
- return cbaVersion;
- }
-
- public void setCbaVersion(String cbaVersion) {
- this.cbaVersion = cbaVersion;
- }
-
- public List<ConfigModel> getModels() {
- return models;
- }
-
- public void setModels(List<ConfigModel> models) { this.models = models; }
-
- public int getCbaState() { return cbaState; }
-
- public void setCbaState(int cbaState) { this.cbaState = cbaState; }
-
- public String getCbaDescription() { return cbaDescription; }
-
- public void setCbaDescription(String cbaDescription) { this.cbaDescription = cbaDescription; }
-
- public byte[] getCbaFile() { return cbaFile; }
-
- public void setCbaFile(byte[] cbaFile) { this.cbaFile = cbaFile; }
-
-}
\r
package org.onap.ccsdk.apps.controllerblueprints.service.domain;\r
\r
-import javax.persistence.AttributeConverter;\r
-import javax.persistence.Converter;\r
-\r
import com.fasterxml.jackson.databind.JsonNode;\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
+\r
+import javax.persistence.AttributeConverter;\r
+import javax.persistence.Converter;\r
/**\r
* @author Brinda Santh\r
*/\r
+++ /dev/null
-/*\r
- * Copyright © 2018 IBM Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.model;\r
-\r
-/**\r
- * BlueprintModelResponse.java Purpose: Model response for Upload CBA service\r
- *\r
- */\r
-public class BlueprintModelResponse {\r
- private Long id;\r
- private String name;\r
- private String version;\r
- private String description;\r
- private String cbaUUID;\r
-\r
- public BlueprintModelResponse(Long id, String name, String version, String description, String cbaUUID) {\r
- this.id = id;\r
- this.name = name;\r
- this.version = version;\r
- this.description = description;\r
- this.cbaUUID = cbaUUID;\r
- }\r
-\r
- public Long getId() {\r
- return id;\r
- }\r
-\r
- public void setId(Long id) {\r
- this.id = id;\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
-\r
- public String getVersion() {\r
- return version;\r
- }\r
-\r
- public void setVersion(String version) {\r
- this.version = version;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getCbaUUID() {\r
- return cbaUUID;\r
- }\r
-\r
- public void setCbaUUID(String cbaUUID) {\r
- this.cbaUUID = cbaUUID;\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package org.onap.ccsdk.apps.controllerblueprints.service.model;
-
-/**
- * CLass that would represent the response for the GET methods on the CBAService class
- */
-public class ItemCbaResponse {
-
- private String id;
- private String description;
- private String name;
- private int state;
- private String version;
-
- public ItemCbaResponse() {
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getState() {
- return state;
- }
-
- public void setState(int state) {
- this.state = state;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
-
-}
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2019 Bell Canada.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.service.repository;\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent;\r
+import org.springframework.data.jpa.repository.JpaRepository;\r
+import org.springframework.stereotype.Repository;\r
+\r
+import javax.validation.constraints.NotNull;\r
+import java.util.List;\r
+import java.util.Optional;\r
+\r
+/**\r
+ * BlueprintModelContentRepository.java Purpose: Provide BlueprintModelContentRepository of Repository\r
+ *\r
+ * @author Brinda Santh\r
+ * @version 1.0\r
+ */\r
+@Repository\r
+public interface BlueprintModelContentRepository extends JpaRepository<BlueprintModelContent, String> {\r
+\r
+ /**\r
+ * This is a findById method\r
+ * \r
+ * @param id id\r
+ * @return Optional<AsdcArtifacts>\r
+ */\r
+ @NotNull\r
+ Optional<BlueprintModelContent> findById(@NotNull String id);\r
+\r
+ /**\r
+ * This is a findTopByBlueprintModelAndContentType method\r
+ * \r
+ * @param blueprintModel blueprintModel\r
+ * @param contentType contentType\r
+ * @return Optional<BlueprintModelContent>\r
+ */\r
+ @SuppressWarnings("unused")\r
+ Optional<BlueprintModelContent> findTopByBlueprintModelAndContentType(BlueprintModel blueprintModel, String contentType);\r
+\r
+ /**\r
+ * This is a findByBlueprintModelAndContentType method\r
+ * \r
+ * @param blueprintModel blueprintModel\r
+ * @param contentType contentType\r
+ * @return Optional<BlueprintModelContent>\r
+ */\r
+ @SuppressWarnings("unused")\r
+ List<BlueprintModelContent> findByBlueprintModelAndContentType(BlueprintModel blueprintModel, String contentType);\r
+\r
+ /**\r
+ * This is a findByBlueprintModel method\r
+ * \r
+ * @param blueprintModel blueprintModel\r
+ * @return Optional<BlueprintModelContent>\r
+ */\r
+ @SuppressWarnings("unused")\r
+ List<BlueprintModelContent> findByBlueprintModel(BlueprintModel blueprintModel);\r
+\r
+ /**\r
+ * This is a findByBlueprintModelAndContentTypeAndName method\r
+ * \r
+ * @param blueprintModel blueprintModel\r
+ * @param contentType contentType\r
+ * @param name name\r
+ * @return Optional<BlueprintModelContent>\r
+ */\r
+ @SuppressWarnings("unused")\r
+ Optional<BlueprintModelContent> findByBlueprintModelAndContentTypeAndName(BlueprintModel blueprintModel,\r
+ String contentType, String name);\r
+\r
+ /**\r
+ * This is a deleteByMdeleteByBlueprintModelodelName method\r
+ * \r
+ * @param blueprintModel blueprintModel\r
+ */\r
+ void deleteByBlueprintModel(BlueprintModel blueprintModel);\r
+\r
+ /**\r
+ * This is a deleteById method\r
+ * \r
+ * @param id id\r
+ */\r
+ void deleteById(@NotNull String id);\r
+\r
+}\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2019 Bell Canada.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
package org.onap.ccsdk.apps.controllerblueprints.service.repository;\r
\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel;\r
import org.springframework.data.jpa.repository.JpaRepository;\r
import org.springframework.stereotype.Repository;\r
\r
* @version 1.0\r
*/\r
@Repository\r
-public interface ConfigModelRepository extends JpaRepository<ConfigModel, Long> {\r
+public interface BlueprintModelRepository extends JpaRepository<BlueprintModel, String> {\r
/**\r
* This is a findById method\r
* \r
* @return Optional<AsdcArtifacts>\r
*/\r
@NotNull\r
- Optional<ConfigModel> findById(@NotNull Long id);\r
+ Optional<BlueprintModel> findById(@NotNull String id);\r
\r
/**\r
* This is a findByArtifactNameAndArtifactVersion method\r
* @param artifactVersion artifactVersion\r
* @return Optional<AsdcArtifacts>\r
*/\r
- Optional<ConfigModel> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);\r
+ Optional<BlueprintModel> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);\r
\r
/**\r
* This is a findTopByArtifactNameOrderByArtifactIdDesc method\r
* @param artifactName artifactName\r
* @return Optional<AsdcArtifacts>\r
*/\r
- Optional<ConfigModel> findTopByArtifactNameOrderByArtifactVersionDesc(String artifactName);\r
+ Optional<BlueprintModel> findTopByArtifactNameOrderByArtifactVersionDesc(String artifactName);\r
\r
/**\r
* This is a findTopByArtifactName method\r
* @return Optional<AsdcArtifacts>\r
*/\r
@SuppressWarnings("unused")\r
- List<ConfigModel> findTopByArtifactName(String artifactName);\r
+ List<BlueprintModel> findTopByArtifactName(String artifactName);\r
\r
/**\r
* This is a findByTagsContainingIgnoreCase method\r
* @param tags tags\r
* @return Optional<ModelType>\r
*/\r
- List<ConfigModel> findByTagsContainingIgnoreCase(String tags);\r
+ List<BlueprintModel> findByTagsContainingIgnoreCase(String tags);\r
\r
/**\r
* This is a deleteByArtifactNameAndArtifactVersion method\r
* @param id id\r
*/\r
@SuppressWarnings("unused")\r
- void deleteById(@NotNull Long id);\r
+ void deleteById(@NotNull String id);\r
\r
}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2019 Bell Canada.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.service.repository;\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch;\r
+import org.springframework.data.jpa.repository.JpaRepository;\r
+import org.springframework.stereotype.Repository;\r
+\r
+import javax.validation.constraints.NotNull;\r
+import java.util.List;\r
+import java.util.Optional;\r
+\r
+/**\r
+ * BlueprintModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository\r
+ *\r
+ * @author Brinda Santh\r
+ * @version 1.0\r
+ */\r
+@Repository\r
+public interface BlueprintModelSearchRepository extends JpaRepository<BlueprintModelSearch, Long> {\r
+\r
+ /**\r
+ * This is a findById method\r
+ *\r
+ * @param id id\r
+ * @return Optional<BlueprintModelSearch>\r
+ */\r
+ @NotNull\r
+ Optional<BlueprintModelSearch> findById(@NotNull String id);\r
+\r
+ /**\r
+ * This is a findAll method\r
+ * @return List<BlueprintModelSearch>\r
+ */\r
+ @Override\r
+ List<BlueprintModelSearch> findAll();\r
+\r
+ /**\r
+ * This is a findByArtifactNameAndArtifactVersion method\r
+ *\r
+ * @param artifactName artifactName\r
+ * @param artifactVersion artifactVersion\r
+ * @return Optional<AsdcArtifacts>\r
+ */\r
+ Optional<BlueprintModelSearch> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);\r
+\r
+ /**\r
+ * This is a findByTagsContainingIgnoreCase method\r
+ * \r
+ * @param tags\r
+ * @return Optional<BlueprintModelSearch>\r
+ */\r
+ List<BlueprintModelSearch> findByTagsContainingIgnoreCase(String tags);\r
+}\r
+++ /dev/null
-/*
- * Copyright © 2018 IBM 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.controllerblueprints.service.repository;
-
-import org.jetbrains.annotations.NotNull;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * CBAContentRepository.java Purpose: Provide Configuration Generator CRUD methods for CBAContent table
- *
- * @author Ruben Chang
- * @version 1.0
- */
-@Repository
-public interface CBAContentRepository extends JpaRepository<CbaContent, String> {
-
- /**
- * This is a findAll method
- * @return List<CbaContent>
- */
- @Override
- List<CbaContent> findAll();
-
- /**
- * Returns a CbaContent based on the cbaUUID
- * @param cbaUUID the CbaUUID
- * @return Optional<CbaContent>
- */
- @Override
- @NotNull
- Optional<CbaContent> findById(@NotNull String cbaUUID);
-
- /**
- * This is a deleteById methid
- * @param cbaUUID the user ID for a particular CBAFile
- */
- @Override
- void deleteById(@NotNull String cbaUUID);
-}
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.repository;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
-import org.springframework.data.jpa.repository.JpaRepository;\r
-import org.springframework.stereotype.Repository;\r
-\r
-import javax.validation.constraints.NotNull;\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-/**\r
- * ConfigModelContentRepository.java Purpose: Provide ConfigModelContentRepository of Repository\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-@Deprecated\r
-@Repository\r
-public interface ConfigModelContentRepository extends JpaRepository<ConfigModelContent, Long> {\r
-\r
- /**\r
- * This is a findById method\r
- * \r
- * @param id id\r
- * @return Optional<AsdcArtifacts>\r
- */\r
- @NotNull\r
- Optional<ConfigModelContent> findById(@NotNull Long id);\r
-\r
- /**\r
- * This is a findTopByConfigModelAndContentType method\r
- * \r
- * @param configModel configModel\r
- * @param contentType contentType\r
- * @return Optional<ConfigModelContent>\r
- */\r
- @SuppressWarnings("unused")\r
- Optional<ConfigModelContent> findTopByConfigModelAndContentType(ConfigModel configModel, String contentType);\r
-\r
- /**\r
- * This is a findByConfigModelAndContentType method\r
- * \r
- * @param configModel configModel\r
- * @param contentType contentType\r
- * @return Optional<ConfigModelContent>\r
- */\r
- @SuppressWarnings("unused")\r
- List<ConfigModelContent> findByConfigModelAndContentType(ConfigModel configModel, String contentType);\r
-\r
- /**\r
- * This is a findByConfigModel method\r
- * \r
- * @param configModel configModel\r
- * @return Optional<ConfigModelContent>\r
- */\r
- @SuppressWarnings("unused")\r
- List<ConfigModelContent> findByConfigModel(ConfigModel configModel);\r
-\r
- /**\r
- * This is a findByConfigModelAndContentTypeAndName method\r
- * \r
- * @param configModel configModel\r
- * @param contentType contentType\r
- * @param name name\r
- * @return Optional<ConfigModelContent>\r
- */\r
- @SuppressWarnings("unused")\r
- Optional<ConfigModelContent> findByConfigModelAndContentTypeAndName(ConfigModel configModel,\r
- String contentType, String name);\r
-\r
- /**\r
- * This is a deleteByMdeleteByConfigModelodelName method\r
- * \r
- * @param configModel configModel\r
- */\r
- void deleteByConfigModel(ConfigModel configModel);\r
-\r
- /**\r
- * This is a deleteById method\r
- * \r
- * @param id id\r
- */\r
- void deleteById(@NotNull Long id);\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.repository;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelSearch;\r
-import org.springframework.data.jpa.repository.JpaRepository;\r
-import org.springframework.stereotype.Repository;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * ConfigModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-@Repository\r
-public interface ConfigModelSearchRepository extends JpaRepository<ConfigModelSearch, Long> {\r
-\r
-\r
- /**\r
- * This is a findByTagsContainingIgnoreCase method\r
- * \r
- * @param tags\r
- * @return Optional<ModelType>\r
- */\r
- List<ConfigModel> findByTagsContainingIgnoreCase(String tags);\r
-}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2019 Bell Canada.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.BlueprintModelService;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.core.io.Resource;\r
+import org.springframework.http.MediaType;\r
+import org.springframework.http.ResponseEntity;\r
+import org.springframework.http.codec.multipart.FilePart;\r
+import org.springframework.web.bind.annotation.*;\r
+import reactor.core.publisher.Mono;\r
+\r
+import java.util.List;\r
+\r
+/**\r
+ * {@inheritDoc}\r
+ */\r
+@RestController\r
+@RequestMapping(value = "/api/v1/blueprint-model")\r
+public class BlueprintModelRest {\r
+\r
+ @Autowired\r
+ private BlueprintModelService blueprintModelService;\r
+\r
+ @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)\r
+ public @ResponseBody\r
+ Mono<BlueprintModelSearch> saveBluePrint(@RequestPart("file") FilePart file) throws BluePrintException{\r
+ return blueprintModelService.saveBlueprintModel(file);\r
+ }\r
+\r
+ @DeleteMapping(path = "/{id}")\r
+ public void deleteBluePrint(@PathVariable(value = "id") String id) throws BluePrintException {\r
+ this.blueprintModelService.deleteBlueprintModel(id);\r
+ }\r
+\r
+ @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+ public @ResponseBody\r
+ BlueprintModelSearch getBluePrintByNameAndVersion(@PathVariable(value = "name") String name,\r
+ @PathVariable(value = "version") String version) throws BluePrintException {\r
+ return this.blueprintModelService.getBlueprintModelByNameAndVersion(name, version);\r
+ }\r
+\r
+ @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+ public @ResponseBody\r
+ BlueprintModelSearch getCBA(@PathVariable(value = "id") String id) throws BluePrintException {\r
+ return this.blueprintModelService.getBlueprintModelSearch(id);\r
+ }\r
+\r
+ @GetMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE)\r
+ public @ResponseBody\r
+ List<BlueprintModelSearch> getAllCBA() {\r
+ return this.blueprintModelService.getAllBlueprintModel();\r
+ }\r
+\r
+ @GetMapping(path = "/download/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+ public @ResponseBody\r
+ ResponseEntity<Resource> downloadBluePrint(@PathVariable(value = "id") String id) throws BluePrintException {\r
+ return this.blueprintModelService.downloadBlueprintModelFile(id);\r
+ }\r
+\r
+ @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+ public @ResponseBody\r
+ BlueprintModelSearch publishBlueprintModel(@PathVariable(value = "id") String id) throws BluePrintException {\r
+ return this.blueprintModelService.publishBlueprintModel(id);\r
+ }\r
+\r
+ @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+ public @ResponseBody\r
+ List<BlueprintModelSearch> searchBlueprintModels(@PathVariable(value = "tags") String tags) {\r
+ return this.blueprintModelService.searchBlueprintModels(tags);\r
+ }\r
+}\r
+++ /dev/null
-/*\r
- * Copyright © 2018 IBM Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.CbaService;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.model.BlueprintModelResponse;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.model.ItemCbaResponse;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.core.io.Resource;\r
-import org.springframework.http.MediaType;\r
-import org.springframework.http.ResponseEntity;\r
-import org.springframework.http.codec.multipart.FilePart;\r
-import org.springframework.http.codec.multipart.Part;\r
-import org.springframework.web.bind.annotation.*;\r
-import reactor.core.publisher.Flux;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * CbaRest.java Purpose: Provide a REST API to upload single and multiple CBA\r
- *\r
- * @author Steve Siani\r
- * @version 1.0\r
- */\r
-@RestController\r
-@RequestMapping(value = "/api/v1/cba")\r
-public class CbaRest {\r
-\r
- @Autowired\r
- private CbaService cbaService;\r
-\r
- @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)\r
- public Flux<BlueprintModelResponse> uploadCBA(@RequestBody Flux<Part> parts) {\r
- return parts.filter(part -> part instanceof FilePart) // only retain file parts\r
- .ofType(FilePart.class) // convert the flux to FilePart\r
- .flatMap(filePart -> cbaService.uploadCBAFile(filePart)); // save each file and flatmap it to a flux of results\r
- }\r
-\r
- @DeleteMapping(path = "/{id}")\r
- public void deleteCBA(@PathVariable(value = "id") Long id) throws BluePrintException {\r
- this.cbaService.deleteCBA(id);\r
- }\r
-\r
- @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ItemCbaResponse getCBA(@PathVariable(value = "id") String id) {\r
- return this.cbaService.findCBAByID(id);\r
- }\r
-\r
- @GetMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- List<ItemCbaResponse> getAllCBA() {\r
- return this.cbaService.findAllCBA();\r
- }\r
-\r
- @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ItemCbaResponse getCBAByNameAndVersion(@PathVariable(value = "name") String name,\r
- @PathVariable(value = "version") String version) throws BluePrintException {\r
- return this.cbaService.findCBAByNameAndVersion(name, version);\r
- }\r
-\r
- @GetMapping(path = "/download/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ResponseEntity<Resource> downloadCBA(@PathVariable(value = "id") String id) {\r
- return this.cbaService.downloadCBAFile(id);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
-import org.springframework.http.MediaType;\r
-import org.springframework.web.bind.annotation.*;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * {@inheritDoc}\r
- */\r
-@Deprecated\r
-@RestController\r
-@RequestMapping(value = "/api/v1/config-model")\r
-public class ConfigModelRest {\r
-\r
- private ConfigModelService configModelService;\r
-\r
- /**\r
- * This is a ConfigModelRest constructor.\r
- *\r
- * @param configModelService Config Model Service\r
- */\r
- public ConfigModelRest(ConfigModelService configModelService) {\r
- this.configModelService = configModelService;\r
-\r
- }\r
-\r
- @GetMapping(path = "/initial/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException {\r
- return this.configModelService.getInitialConfigModel(name);\r
- }\r
-\r
- @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException {\r
- return this.configModelService.saveConfigModel(configModel);\r
- }\r
-\r
- @DeleteMapping(path = "/{id}")\r
- public void deleteConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
- this.configModelService.deleteConfigModel(id);\r
- }\r
-\r
- @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
- return this.configModelService.publishConfigModel(id);\r
- }\r
-\r
- @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
- return this.configModelService.getConfigModel(id);\r
- }\r
-\r
- @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name,\r
- @PathVariable(value = "version") String version) throws BluePrintException {\r
- return this.configModelService.getConfigModelByNameAndVersion(name, version);\r
- }\r
-\r
- @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) {\r
- return this.configModelService.searchConfigModels(tags);\r
- }\r
-\r
- @GetMapping(path = "/clone/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
- return this.configModelService.getCloneConfigModel(id);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler;\r
-import org.springframework.http.MediaType;\r
-import org.springframework.web.bind.annotation.*;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * {@inheritDoc}\r
- */\r
-@Deprecated\r
-//@RestController\r
-//@RequestMapping(value = "/api/v1/model-type")\r
-public class ModelTypeRest {\r
-\r
- private ModelTypeHandler modelTypeService;\r
-\r
- /**\r
- * This is a ModelTypeResourceImpl, used to save and get the model types stored in database\r
- *\r
- * @param modelTypeService Model Type Service\r
- */\r
- public ModelTypeRest(ModelTypeHandler modelTypeService) {\r
- this.modelTypeService = modelTypeService;\r
- }\r
-\r
- @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public ModelType getModelTypeByName(@PathVariable(value = "name") String name) {\r
- return modelTypeService.getModelTypeByName(name);\r
- }\r
-\r
- @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) {\r
- return modelTypeService.searchModelTypes(tags);\r
- }\r
-\r
- @GetMapping(path = "/by-definition/{definitionType}", produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) {\r
- return modelTypeService.getModelTypeByDefinitionType(definitionType);\r
- }\r
-\r
- @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException {\r
- return modelTypeService.saveModel(modelType);\r
- }\r
-\r
- @DeleteMapping(path = "/{name}")\r
- public void deleteModelTypeByName(@PathVariable(value = "name") String name) {\r
- modelTypeService.deleteByModelName(name);\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
-\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;\r
-import org.springframework.http.MediaType;\r
-import org.springframework.web.bind.annotation.*;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * {@inheritDoc}\r
- */\r
-@Deprecated\r
-@RestController\r
-@RequestMapping(value = "/api/v1/service-template")\r
-public class ServiceTemplateRest {\r
-\r
- private ServiceTemplateService serviceTemplateService;\r
-\r
- /**\r
- * This is a ServiceTemplateRest constructor\r
- *\r
- * @param serviceTemplateService Service Template Service\r
- */\r
- public ServiceTemplateRest(ServiceTemplateService serviceTemplateService) {\r
- this.serviceTemplateService = serviceTemplateService;\r
- }\r
-\r
- @PostMapping(path = "/enrich", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ServiceTemplate enrichServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {\r
- return serviceTemplateService.enrichServiceTemplate(serviceTemplate);\r
- }\r
-\r
- @PostMapping(path = "/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- ServiceTemplate validateServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {\r
- return serviceTemplateService.validateServiceTemplate(serviceTemplate);\r
- }\r
-\r
- @PostMapping(path = "/resource-assignment/auto-map", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- AutoMapResponse autoMap(@RequestBody List<ResourceAssignment> resourceAssignments) throws BluePrintException {\r
- return serviceTemplateService.autoMap(resourceAssignments);\r
- }\r
-\r
- @PostMapping(path = "/resource-assignment/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- List<ResourceAssignment> validateResourceAssignments(@RequestBody List<ResourceAssignment> resourceAssignments)\r
- throws BluePrintException {\r
- return serviceTemplateService.validateResourceAssignments(resourceAssignments);\r
- }\r
-\r
- @PostMapping(path = "/resource-assignment/generate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- List<ResourceAssignment> generateResourceAssignments(@RequestBody ConfigModelContent templateContent) {\r
- return serviceTemplateService.generateResourceAssignments(templateContent);\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.onap.ccsdk.apps.controllerblueprints.service.utils;
-
-public enum CbaStateEnum {
-
- DRAFT(0), VALIDATED(1), APPROVED(2);
- int state;
-
- CbaStateEnum(int state) {
- this.state = state;
- }
-
- public int getState() {
- return state;
- }
-}
+++ /dev/null
-package org.onap.ccsdk.apps.controllerblueprints.service.utils;\r
-\r
-import java.util.concurrent.atomic.AtomicBoolean;\r
-import java.util.concurrent.atomic.AtomicInteger;\r
-\r
-public class CloseCondition {\r
-\r
- AtomicInteger tasksSubmitted = new AtomicInteger(0);\r
- AtomicInteger tasksCompleted = new AtomicInteger(0);\r
- AtomicBoolean allTaskssubmitted = new AtomicBoolean(false);\r
-\r
- /**\r
- * notify all tasks have been subitted, determine of the file channel can be closed\r
- * @return true if the asynchronous file stream can be closed\r
- */\r
- public boolean canCloseOnComplete() {\r
- allTaskssubmitted.set(true);\r
- return tasksCompleted.get() == tasksSubmitted.get();\r
- }\r
-\r
- /**\r
- * notify a task has been submitted\r
- */\r
- public void onTaskSubmitted() {\r
- tasksSubmitted.incrementAndGet();\r
- }\r
-\r
- /**\r
- * notify a task has been completed\r
- * @return true if the asynchronous file stream can be closed\r
- */\r
- public boolean onTaskCompleted() {\r
- boolean allSubmittedClosed = tasksSubmitted.get() == tasksCompleted.incrementAndGet();\r
- return allSubmittedClosed && allTaskssubmitted.get();\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.utils;\r
-\r
-import com.google.common.base.Preconditions;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.io.FileUtils;\r
-import org.apache.commons.io.FilenameUtils;\r
-import org.apache.commons.io.filefilter.DirectoryFileFilter;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.nio.charset.Charset;\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-@Deprecated\r
-public class ConfigModelUtils {\r
-\r
- private ConfigModelUtils() {\r
-\r
- }\r
-\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelUtils.class);\r
-\r
- public static ConfigModel getConfigModel(String blueprintPath) throws Exception {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "Blueprint Path is missing");\r
- ToscaMetaData toscaMetaData = BluePrintMetadataUtils.Companion.toscaMetaData(blueprintPath);\r
-\r
- Preconditions.checkNotNull(toscaMetaData, "failed to get Blueprint Metadata information");\r
- Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getEntityDefinitions()), "failed to get Blueprint Definition file");\r
- Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getCreatedBy()), "failed to get Blueprint created by");\r
- Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getToscaMetaFileVersion()), "failed to get Blueprint package version");\r
-\r
- String bluePrintName = FilenameUtils.getBaseName(toscaMetaData.getEntityDefinitions());\r
- Preconditions.checkArgument(StringUtils.isNotBlank(bluePrintName), "failed to get Blueprint Definition Name");\r
-\r
- // TODO - Update Rest of the Model\r
- ConfigModel configModel = new ConfigModel();\r
- configModel.setUpdatedBy(toscaMetaData.getCreatedBy());\r
- configModel.setArtifactName(bluePrintName);\r
- configModel.setArtifactVersion(toscaMetaData.getToscaMetaFileVersion());\r
- configModel.setTags(toscaMetaData.getTemplateTags());\r
- configModel.setArtifactType("SDNC_MODEL");\r
-\r
- String blueprintContent =\r
- getPathContent(blueprintPath + "/" + toscaMetaData.getEntityDefinitions());\r
-\r
- Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "failed to get Blueprint content");\r
-\r
- List<ConfigModelContent> configModelContents = new ArrayList<>();\r
- ConfigModelContent stConfigModelContent = new ConfigModelContent();\r
- stConfigModelContent.setName(configModel.getArtifactName());\r
- stConfigModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);\r
- stConfigModelContent.setContent(blueprintContent);\r
- configModelContents.add(stConfigModelContent);\r
-\r
- String velocityDir = blueprintPath + "/Templates";\r
- List<File> velocityTemplateFiles = getFileOfExtension(velocityDir, new String[]{"vtl"});\r
-\r
- if (CollectionUtils.isNotEmpty(velocityTemplateFiles)) {\r
- for (File velocityTemplateFile : velocityTemplateFiles) {\r
- if (velocityTemplateFile != null) {\r
- String contentName = velocityTemplateFile.getName().replace(".vtl", "");\r
- ConfigModelContent velocityConfigModelContent = new ConfigModelContent();\r
- String velocityConfigContent = getPathContent(velocityTemplateFile);\r
- velocityConfigModelContent.setName(contentName);\r
- velocityConfigModelContent\r
- .setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);\r
- velocityConfigModelContent.setContent(velocityConfigContent);\r
- configModelContents.add(velocityConfigModelContent);\r
- log.info("Loaded blueprint template successfully: {}", velocityTemplateFile.getName());\r
- }\r
- }\r
- }\r
- configModel.setConfigModelContents(configModelContents);\r
-\r
- return configModel;\r
-\r
- }\r
-\r
- public static String getPathContent(String path) throws IOException {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(path), "Path is missing");\r
- return FileUtils.readFileToString(new File(path), Charset.defaultCharset());\r
- }\r
-\r
- public static String getPathContent(File file) throws IOException {\r
- Preconditions.checkNotNull(file, "File is missing");\r
- return FileUtils.readFileToString(file, Charset.defaultCharset());\r
- }\r
-\r
- public static List<File> getFileOfExtension(String basePath, String[] extensions) {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(basePath), "Path is missing");\r
- Preconditions.checkNotNull(extensions, "Extensions is missing");\r
- return (List<File>) FileUtils.listFiles(new File(basePath), extensions, true);\r
- }\r
-\r
- public static List<String> getBlueprintNames(String pathName) {\r
- File blueprintDir = new File(pathName);\r
- Preconditions.checkNotNull(blueprintDir, "failed to find the blueprint pathName file");\r
- String[] dirs = blueprintDir.list(DirectoryFileFilter.INSTANCE);\r
- Preconditions.checkNotNull(dirs, "failed to find the blueprint directories" + blueprintDir.getAbsolutePath());\r
- return Arrays.asList(dirs);\r
- }\r
-}\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService;\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationService;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl;\r
\r
import java.util.HashMap;\r
import java.util.List;\r
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.PolicyType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPolicyTypeEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
open fun loadBluePrintModelCatalog(errorBuilder: StrBuilder, file: File) {
try {
- bluePrintCatalogService.uploadToDataBase(file.absolutePath)
+ bluePrintCatalogService.uploadToDataBase(file.absolutePath, true)
} catch (e: Exception) {
errorBuilder.appendln("Couldn't load DataType(${file.name}: ${e.message}")
}
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.ccsdk.apps.controllerblueprints.service.load
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConstants
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelContentRepository
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelRepository
import org.springframework.stereotype.Service
import java.io.File
-import java.util.*
+import java.nio.file.Files
@Service
class BluePrintCatalogServiceImpl(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
- private val bluePrintValidatorService: BluePrintValidatorService) : BluePrintCatalogService {
+ private val bluePrintValidatorService: BluePrintValidatorService,
+ private val blueprintModelContentRepository: BlueprintModelContentRepository,
+ private val blueprintModelRepository: BlueprintModelRepository) : BluePrintCatalogService {
- override fun uploadToDataBase(file: String): String {
- val id = UUID.randomUUID().toString()
+ override fun uploadToDataBase(file: String, validate: Boolean): String {
+ // The file name provided here is unique as we transform to UUID before storing
val blueprintFile = File(file)
+ val fileName = blueprintFile.name
+ val id = BluePrintFileUtils.stripFileExtension(fileName)
// If the file is directory
if (blueprintFile.isDirectory) {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(id, blueprintFile.absolutePath)
- val valid = bluePrintValidatorService.validateBluePrints(bluePrintRuntimeService)
- if (valid) {
- val zipFile = File("${bluePrintLoadConfiguration.blueprintArchivePath}/${id}.zip")
- // zip the directory
- BluePrintArchiveUtils.compress(blueprintFile, zipFile, true)
-
- // TODO(Upload to the Data Base)
-
- // After Upload to Database delete the zip file
- zipFile.deleteOnExit()
- }
+
+ val zipFile = File("${bluePrintLoadConfiguration.blueprintArchivePath}/$fileName")
+ // zip the directory
+ BluePrintArchiveUtils.compress(blueprintFile, zipFile, true)
+
+ // Upload to the Data Base
+ saveToDataBase(blueprintFile, id, zipFile)
+
+ // After Upload to Database delete the zip file
+ zipFile.delete()
+
} else {
// If the file is ZIP
- // TODO(Upload to the Data Base)
+ // unzip the CBA file to validate before store in database
+ val targetDir = "${bluePrintLoadConfiguration.blueprintDeployPath}/$id/"
+ val extractedDirectory = BluePrintArchiveUtils.deCompress(blueprintFile, targetDir)
+
+ // Upload to the Data Base
+ saveToDataBase(extractedDirectory, id, blueprintFile)
+
+ // After Upload to Database delete the zip file
+ blueprintFile.delete()
+ extractedDirectory.delete()
}
+
return id
}
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
+ override fun downloadFromDataBase(uuid: String, path: String): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
override fun prepareBluePrint(name: String, version: String): String {
val preparedPath = "${bluePrintLoadConfiguration.blueprintDeployPath}/$name/$version"
downloadFromDataBase(name, version, preparedPath)
return preparedPath
}
+
+ private fun saveToDataBase(extractedDirectory: File, id: String, archiveFile: File, checkValidity: Boolean? = false) {
+ // Upload to the Data Base
+ //val id = "save-$uuid"
+ var valid = false
+ val firstItem = BluePrintArchiveUtils.getFirstItemInDirectory(extractedDirectory)
+ val blueprintBaseDirectory = extractedDirectory.absolutePath + "/" + firstItem
+ // Validate Blueprint
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(id, blueprintBaseDirectory)
+
+ // Check Validity of blueprint
+ if (checkValidity!!) {
+ valid = bluePrintValidatorService.validateBluePrints(bluePrintRuntimeService)
+ }
+
+ if ((valid && checkValidity!!) || (!valid && !checkValidity!!)) {
+ val metaData = bluePrintRuntimeService.bluePrintContext().metadata!!
+ // FIXME("Check Duplicate for Artifact Name and Artifact Version")
+ val blueprintModel = BlueprintModel()
+ blueprintModel.id = id
+ blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL
+ blueprintModel.published = ApplicationConstants.ACTIVE_N
+ blueprintModel.artifactName = metaData[BluePrintConstants.METADATA_TEMPLATE_NAME]
+ blueprintModel.artifactVersion = metaData[BluePrintConstants.METADATA_TEMPLATE_VERSION]
+ blueprintModel.updatedBy = metaData[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]
+ blueprintModel.tags = metaData[BluePrintConstants.METADATA_TEMPLATE_TAGS]
+ blueprintModel.artifactDescription = "Controller Blueprint for ${blueprintModel.artifactName}:${blueprintModel.artifactVersion}"
+
+ val blueprintModelContent = BlueprintModelContent()
+ blueprintModelContent.id = id // For quick access both id's are same.always have one to one mapping.
+ blueprintModelContent.contentType = "CBA_ZIP"
+ blueprintModelContent.name = "${blueprintModel.artifactName}:${blueprintModel.artifactVersion}"
+ blueprintModelContent.description = "(${blueprintModel.artifactName}:${blueprintModel.artifactVersion} CBA Zip Content"
+ blueprintModelContent.content = Files.readAllBytes(archiveFile.toPath())
+
+ // Set the Blueprint Model into blueprintModelContent
+ blueprintModelContent.blueprintModel = blueprintModel
+
+ // Set the Blueprint Model Content into blueprintModel
+ blueprintModel.blueprintModelContent = blueprintModelContent
+
+ blueprintModelRepository.saveAndFlush(blueprintModel)
+ }
+ }
}
\ No newline at end of file
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.springframework.http.codec.multipart.FilePart
+import org.springframework.util.StringUtils
+import reactor.core.publisher.Mono
+import java.io.File
+import java.io.IOException
+import java.nio.file.Path
+import java.util.*
class BluePrintEnhancerUtils {
bluePrintContext.serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
return artifactType
}
+
+ /**
+ * This is a saveCBAFile method
+ * take a [FilePart], transfer it to disk using a Flux of FilePart and return a [Mono] representing the CBA file name
+ *
+ * @param (filePart, targetDirectory) - the request part containing the file to be saved and the default directory where to save
+ * @return a [Mono] String representing the result of the operation
+ * @throws (BluePrintException, IOException) BluePrintException, IOException
+ */
+ @Throws(BluePrintException::class, IOException::class)
+ fun saveCBAFile(filePart: FilePart, targetDirectory: Path): Mono<String> {
+
+ // Normalize file name
+ val fileName = StringUtils.cleanPath(filePart.filename())
+
+ // Check if the file's extension is "CBA"
+ if (StringUtils.getFilenameExtension(fileName) != "zip") {
+ throw BluePrintException("Invalid file extension required ZIP")
+ }
+
+ // Change file name to match a pattern
+ val changedFileName = UUID.randomUUID().toString() + ".zip"
+ //String changedFileName = BluePrintFileUtils.Companion.getCBAGeneratedFileName(fileName, this.CBA_FILE_NAME_PATTERN);
+
+ // Copy file to the target location (Replacing existing file with the same name)
+ val targetLocation = targetDirectory.resolve(changedFileName)
+
+ // if a file with the same name already exists in a repository, delete and recreate it
+ val file = File(targetLocation.toString())
+ if (file.exists())
+ file.delete()
+ file.createNewFile()
+
+ return filePart.transferTo(file).thenReturn(changedFileName)
+ }
}
}
-- table CONFIG_MODEL\r
-- -----------------------------------------------------\r
CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL (\r
- config_model_id INT(11) NOT NULL AUTO_INCREMENT,\r
+ config_model_id VARCHAR(100) NOT NULL,\r
service_uuid VARCHAR(50) NULL DEFAULT NULL,\r
distribution_id VARCHAR(50) NULL DEFAULT NULL,\r
service_name VARCHAR(255) NULL DEFAULT NULL,\r
-- table CONFIG_MODEL_CONTENT\r
-- -----------------------------------------------------\r
CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL_CONTENT (\r
- config_model_content_id INT(11) NOT NULL AUTO_INCREMENT, \r
+ config_model_content_id VARCHAR(100) NOT NULL,\r
config_model_id INT NOT NULL,\r
name VARCHAR(100) NOT NULL,\r
content_type VARCHAR(50) NOT NULL,\r
-- table CONFIG_MODEL\r
-- -----------------------------------------------------\r
CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL (\r
- config_model_id INT(11) NOT NULL AUTO_INCREMENT,\r
+ config_model_id VARCHAR(100) NOT NULL,\r
service_uuid VARCHAR(50) NULL DEFAULT NULL,\r
distribution_id VARCHAR(50) NULL DEFAULT NULL,\r
service_name VARCHAR(255) NULL DEFAULT NULL,\r
-- table CONFIG_MODEL_CONTENT\r
-- -----------------------------------------------------\r
CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL_CONTENT (\r
- config_model_content_id INT(11) NOT NULL AUTO_INCREMENT, \r
+ config_model_content_id VARCHAR(100) NOT NULL,\r
config_model_id INT NOT NULL,\r
name VARCHAR(100) NOT NULL,\r
content_type VARCHAR(50) NOT NULL,\r
package org.onap.ccsdk.apps.controllerblueprints.service;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import java.lang.System;
-import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelContentRepository;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
+import org.springframework.beans.factory.annotation.Autowired;
-public class ConfigModelServiceTest {
- private ConfigModelService configModelService;
+public class BlueprintModelServiceTest {
+ @Autowired
+ private BlueprintModelService blueprintModelService;
- @Test(expected = NullPointerException.class)
+ @Test
public void testGetInitialConfigModel() throws BluePrintException {
- Assert.assertEquals(null, configModelService.getInitialConfigModel(""));
}
}
+++ /dev/null
-/*\r
- * Copyright © 2018 IBM Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-import org.junit.*;\r
-import org.junit.runner.RunWith;\r
-import org.onap.ccsdk.apps.controllerblueprints.TestApplication;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.beans.factory.annotation.Value;\r
-import org.springframework.boot.test.context.SpringBootTest;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringRunner;\r
-import org.springframework.util.FileSystemUtils;\r
-import java.nio.file.Path;\r
-\r
-\r
-/**\r
- * CbaFileManagementServiceTest.java Purpose: Test the decompressing method of CbaCompressionService\r
- *\r
- * @author Vinal Patel\r
- * @version 1.0\r
- */\r
-\r
-@RunWith(SpringRunner.class)\r
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)\r
-@ContextConfiguration(classes = {TestApplication.class})\r
-public class CbaFileManagementServiceTest {\r
-\r
- @Value("${controllerblueprints.loadBlueprintsExamplesPath}")\r
- private String cbaPath;\r
- private String zipfile;\r
- private String directorypath;\r
- private Path zipfilepath;\r
-\r
- @Autowired\r
- CbaFileManagementService cbaCompressionService;\r
-\r
-\r
- /**\r
- *\r
- */\r
- @Before\r
- public void setUp() {\r
- try {\r
- zipfilepath = BluePrintFileUtils.Companion.getCbaStorageDirectory(cbaPath);\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- zipfile = "CBA_Zip_Test.zip";\r
- directorypath = zipfilepath.resolve(zipfile.substring(0,zipfile.lastIndexOf("."))).toAbsolutePath().toString();\r
- }\r
- @After\r
- public void clenup() throws BluePrintException {\r
-\r
- try {\r
- //Delete the Zip file from the repository\r
- FileSystemUtils.deleteRecursively(BluePrintFileUtils.Companion.getBluePrintFile(directorypath, zipfilepath));\r
- }\r
- catch (Exception ex){\r
- throw new BluePrintException("Fail while cleaning up CBA saved!", ex);\r
- }\r
- }\r
-\r
- /**\r
- * @throws BluePrintException\r
- * Test will get success if it is able to decompress CBA file and returns the folder path\r
- */\r
- @Test\r
- public void testDecompressCBAFile_success() throws BluePrintException {\r
- Assert.assertEquals(directorypath,cbaCompressionService.decompressCBAFile(zipfile,zipfilepath));\r
- }\r
-\r
-}\r
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.junit.*;
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
\r
package org.onap.ccsdk.apps.controllerblueprints.service.common;\r
\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
import org.apache.commons.io.FileUtils;\r
import org.junit.Assert;\r
import org.junit.FixMethodOrder;\r
import org.junit.Test;\r
import org.junit.runners.MethodSorters;\r
import org.onap.ccsdk.apps.controllerblueprints.service.SchemaGeneratorService;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
\r
import java.io.File;\r
import java.nio.charset.Charset;\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
-\r
-import org.junit.*;\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.MethodSorters;\r
-import org.onap.ccsdk.apps.controllerblueprints.TestApplication;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.boot.test.context.SpringBootTest;\r
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringRunner;\r
-\r
-import java.util.List;\r
-\r
-@RunWith(SpringRunner.class)\r
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)\r
-@ContextConfiguration(classes = {TestApplication.class})\r
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
-public class ConfigModelRestTest {\r
-\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelRestTest.class);\r
-\r
- @Autowired\r
- ConfigModelRest configModelRest;\r
-\r
- ConfigModel configModel;\r
-\r
- String name = "vrr-test";\r
- String version = "1.0.0";\r
-\r
- @Before\r
- public void setUp() {\r
-\r
- }\r
-\r
-\r
- @After\r
- public void tearDown() {\r
- }\r
-\r
-\r
- @Test\r
- public void test01getInitialConfigModel() throws Exception {\r
- log.info("** test01getInitialConfigModel *****************");\r
-\r
- String name = "default_netconf";\r
- ConfigModel configModel = configModelRest.getInitialConfigModel(name);\r
- Assert.assertNotNull("Failed to get Initial Config Model , Return object is Null", configModel);\r
- Assert.assertNotNull("Failed to get Service Template Content ", configModel.getConfigModelContents());\r
- }\r
-\r
-\r
- @Deprecated\r
- @Test\r
- public void test02SaveServiceTemplate() throws Exception {\r
- log.info("************************ test02SaveServiceTemplate ******************");\r
-\r
-\r
- configModel = ConfigModelUtils.getConfigModel("load/blueprints/vrr-test");\r
-\r
- configModel = configModelRest.saveConfigModel(configModel);\r
- Assert.assertNotNull("Failed to ConfigModel, Return object is Null", configModel);\r
- Assert.assertNotNull("Failed to ConfigModel Id , Return ID object is Null", configModel.getId());\r
- Assert.assertNotNull("Failed to ConfigModel Content, Return object is Null",\r
- configModel.getConfigModelContents());\r
- Assert.assertEquals("Failed in validation of ConfigModel Content count,", 3,\r
- configModel.getConfigModelContents().size());\r
-\r
- ConfigModel dbconfigModel = configModelRest.getConfigModel(configModel.getId());\r
-\r
- log.info("************************ test02SaveServiceTemplate-2 ******************");\r
-\r
- dbconfigModel.getConfigModelContents().remove(2);\r
- dbconfigModel = configModelRest.saveConfigModel(dbconfigModel);\r
- log.info("Saved Config Model " + configModel.getId());\r
- Assert.assertNotNull("Failed to ConfigModel, Return object is Null", dbconfigModel);\r
- Assert.assertNotNull("Failed to ConfigModel Id ", dbconfigModel.getId());\r
- Assert.assertNotNull("Failed to ConfigModel Content",\r
- dbconfigModel.getConfigModelContents());\r
- Assert.assertEquals("Failed to Remove the ConfigModel Content,", 2,\r
- dbconfigModel.getConfigModelContents().size());\r
-\r
-\r
- }\r
-\r
-\r
- @Test\r
- public void test03PublishServiceTemplate() throws Exception {\r
- log.info("** test03PublishServiceTemplate *****************");\r
-\r
- ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);\r
- log.info("Publishing Config Model " + configModel.getId());\r
- configModel = configModelRest.publishConfigModel(configModel.getId());\r
- Assert.assertNotNull("Failed to ConfigModel, Return object is Null", configModel);\r
- Assert.assertNotNull("Failed to ConfigModel Id ", configModel.getId());\r
- Assert.assertNotNull("Failed to ConfigModel Content", configModel.getConfigModelContents());\r
- Assert.assertEquals("Failed to update the publish indicator", "Y", configModel.getPublished());\r
- }\r
-\r
-\r
- @Deprecated\r
- @Test\r
- public void test04GetConfigModel() throws Exception {\r
- log.info("** test04GetConfigModel *****************");\r
-\r
- ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);\r
- Assert.assertNotNull("Failed to get ConfigModel for the Name (" + configModel.getArtifactName() + ") and ("\r
- + configModel.getArtifactVersion() + ")", configModel);\r
- Assert.assertNotNull("Failed to get ConfigModel Id", configModel.getId());\r
-\r
- configModel = configModelRest.getConfigModel(configModel.getId());\r
- Assert.assertNotNull("Failed to get ConfigModel for the Id (" + configModel.getId() + ") ", configModel);\r
-\r
- }\r
-\r
- @Deprecated\r
- @Test\r
- public void test05GetCloneConfigModel() throws Exception {\r
- log.info("** test05GetCloneConfigModel *****************");\r
-\r
- ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);\r
-\r
- Assert.assertNotNull("Failed to get ConfigModel for the Name (" + configModel.getArtifactName() + ") and ("\r
- + configModel.getArtifactVersion() + ")", configModel);\r
- Assert.assertNotNull("Failed to get ConfigModel Id", configModel.getId());\r
-\r
- configModel = configModelRest.getCloneConfigModel(configModel.getId());\r
- Assert.assertNotNull("Failed to get ConfigModel for the Id (" + configModel.getId() + ") ", configModel);\r
- }\r
-\r
-\r
- @Test\r
- public void test07SearchConfigModels() throws Exception {\r
- log.info("** test07SearchConfigModels *****************");\r
-\r
- List<ConfigModel> configModels = configModelRest.searchConfigModels("vrr-test");\r
- Assert.assertNotNull("Failed to search ConfigModel", configModels);\r
- Assert.assertTrue("Failed to search ConfigModel with count", configModels.size() > 0);\r
- // update the ServiceModelContent\r
- }\r
-\r
-\r
- @Test\r
- public void test08DeleteConfigModels() throws Exception {\r
- log.info("** test08DeleteConfigModels *****************");\r
-\r
- ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);\r
- configModelRest.deleteConfigModel(configModel.getId());\r
-\r
- }\r
-\r
-\r
-}\r
\r
import com.att.eelf.configuration.EELFLogger;\r
import com.att.eelf.configuration.EELFManager;\r
-import org.junit.*;\r
+import org.junit.Assert;\r
+import org.junit.FixMethodOrder;\r
+import org.junit.Test;\r
import org.junit.runner.RunWith;\r
import org.junit.runners.MethodSorters;\r
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
-\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.apache.commons.io.IOUtils;\r
-import org.junit.Assert;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-\r
-import java.nio.charset.Charset;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-@Deprecated\r
-//@RunWith(SpringRunner.class)\r
-//@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"})\r
-//@ContextConfiguration(classes = {TestApplication.class})\r
-//@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
-public class ResourceDictionaryRestTest {\r
-\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryRestTest.class);\r
-\r
- @Autowired\r
- protected ResourceDictionaryRest resourceDictionaryRest;\r
-\r
- //@Test\r
- public void test01SaveDataDictionary() throws Exception {\r
- String definition = IOUtils.toString(\r
- getClass().getClassLoader().getResourceAsStream("resourcedictionary/default_definition.json"),\r
- Charset.defaultCharset());\r
-\r
- ResourceDictionary dataDictionary = new ResourceDictionary();\r
- dataDictionary.setName("test-name");\r
- dataDictionary.setDefinition(JacksonUtils.readValue(definition, ResourceDefinition.class));\r
- dataDictionary.setDataType("string");\r
- dataDictionary.setDescription("Sample Resource Mapping");\r
- dataDictionary.setTags("test, ipaddress");\r
- dataDictionary.setUpdatedBy("xxxxxx@xxx.com");\r
-\r
- dataDictionary = resourceDictionaryRest.saveResourceDictionary(dataDictionary);\r
-\r
- Assert.assertNotNull("Failed to get Saved Resource Dictionary", dataDictionary);\r
- Assert.assertNotNull("Failed to get Saved Resource Dictionary, Id", dataDictionary.getName());\r
-\r
- ResourceDictionary dbDataDictionary =\r
- resourceDictionaryRest.getResourceDictionaryByName(dataDictionary.getName());\r
- Assert.assertNotNull("Failed to query Resource Dictionary for ID (" + dataDictionary.getName() + ")",\r
- dbDataDictionary);\r
- Assert.assertNotNull("Failed to query Resource Dictionary definition for ID (" + dataDictionary.getName() + ")",\r
- dbDataDictionary.getDefinition());\r
-\r
- log.trace("Saved Dictionary " + dbDataDictionary.getDefinition());\r
-\r
- }\r
-\r
- //@Test\r
- public void test02GetDataDictionary() throws Exception {\r
-\r
- ResourceDictionary dbResourceDictionary = resourceDictionaryRest.getResourceDictionaryByName("test-name");\r
- Assert.assertNotNull("Failed to query Resource Dictionary by Name", dbResourceDictionary);\r
-\r
- String tags = "ipaddress";\r
-\r
- List<ResourceDictionary> dbResourceDictionaries = resourceDictionaryRest.searchResourceDictionaryByTags(tags);\r
- Assert.assertNotNull("Failed to search ResourceDictionary by tags", dbResourceDictionaries);\r
- Assert.assertTrue("Failed to search searchResourceDictionaryByTags by tags by count",\r
- dbResourceDictionaries.size() > 0);\r
-\r
- List<String> names = new ArrayList<>();\r
- names.add("test-name");\r
- dbResourceDictionaries = resourceDictionaryRest.searchResourceDictionaryByNames(names);\r
- Assert.assertNotNull("Failed to search ResourceDictionary by Names", dbResourceDictionaries);\r
- Assert.assertTrue("Failed to search searchResourceDictionaryByNames by tags by count",\r
- dbResourceDictionaries.size() > 0);\r
-\r
- }\r
-\r
- //@Test\r
- public void test03GetResourceSourceMapping() {\r
- ResourceSourceMapping resourceSourceMapping = resourceDictionaryRest.getResourceSourceMapping();\r
- org.springframework.util.Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping");\r
- org.springframework.util.Assert.notNull(resourceSourceMapping.getResourceSourceMappings(), "Failed to get resource source mappings");\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
-\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.io.FileUtils;\r
-import org.junit.Assert;\r
-import org.junit.FixMethodOrder;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.junit.runners.MethodSorters;\r
-import org.onap.ccsdk.apps.controllerblueprints.TestApplication;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.boot.test.context.SpringBootTest;\r
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringRunner;\r
-\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.List;\r
-\r
-@Deprecated\r
-@RunWith(SpringRunner.class)\r
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"})\r
-@ContextConfiguration(classes = {TestApplication.class})\r
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
-public class ServiceTemplateRestTest {\r
-\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateRestTest.class);\r
- @Autowired\r
- ModelTypeController modelTypeRest;\r
-\r
- @Autowired\r
- private ServiceTemplateRest serviceTemplateRest;\r
-\r
- //@Test FIXME("Enable once Complete Enhancement Service Implemented")\r
- public void test02EnrichServiceTemplate() throws Exception {\r
- log.info("*********** test02EnrichServiceTemplate ***********************");\r
- String file = "src/test/resources/enhance/enhance-template.json";\r
-\r
- String serviceTemplateContent = FileUtils.readFileToString(new File(file), Charset.defaultCharset());\r
-\r
- ServiceTemplate serviceTemplate = JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);\r
-\r
- serviceTemplate = serviceTemplateRest.enrichServiceTemplate(serviceTemplate);\r
-\r
- String enhancedFile = "src/test/resources/enhance/enhanced-template.json";\r
-\r
- FileUtils.write(new File(enhancedFile),\r
- JacksonUtils.getJson(serviceTemplate, true), Charset.defaultCharset());\r
-\r
- Assert.assertNotNull("Failed to get Enriched Blueprints, Return object is Null", serviceTemplate);\r
- Assert.assertNotNull("Failed to get Enriched Blueprints Data Type, Return object is Null",\r
- serviceTemplate.getDataTypes());\r
- Assert.assertNotNull("Failed to get Enriched Blueprints Node Type, Return object is Null",\r
- serviceTemplate.getNodeTypes());\r
- log.trace("Enriched Service Template :\n" + JacksonUtils.getJson(serviceTemplate, true));\r
- }\r
-\r
- //@Test FIXME("Enable once Complete Enhancement Service Implemented")\r
- public void test03ValidateServiceTemplate() throws Exception {\r
- log.info("*********** test03ValidateServiceTemplate *******************************************");\r
- String enhancedFile = "src/test/resources/enhance/enhanced-template.json";\r
- String serviceTemplateContent = FileUtils.readFileToString(new File(enhancedFile), Charset.defaultCharset());\r
-\r
- ServiceTemplate serviceTemplate =\r
- JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);\r
-\r
- serviceTemplate = serviceTemplateRest.validateServiceTemplate(serviceTemplate);\r
-\r
- Assert.assertNotNull("Failed to validate Service Template, Return object is Null", serviceTemplate);\r
- Assert.assertNotNull("Failed to get Service Template Data Type, Return object is Null",\r
- serviceTemplate.getDataTypes());\r
- Assert.assertNotNull("Failed to get Service Template Node Type, Return object is Null",\r
- serviceTemplate.getNodeTypes());\r
-\r
- log.trace("Validated Service Template :\n" + JacksonUtils.getJson(serviceTemplate, true));\r
-\r
- }\r
-\r
-\r
- @Test\r
- public void test04GenerateResourceAssignments() throws Exception {\r
- log.info("*********** test04GenerateResourceAssignments *******************************************");\r
- ConfigModelContent baseConfigConfigModelContent = new ConfigModelContent();\r
- String baseConfigContent = FileUtils.readFileToString(new File("load/blueprints/vrr-test/Templates/base-config-template.vtl")\r
- , Charset.defaultCharset());\r
- baseConfigConfigModelContent.setName("base-config-template");\r
- baseConfigConfigModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);\r
- baseConfigConfigModelContent.setContent(baseConfigContent);\r
-\r
- List<ResourceAssignment> resourceAssignments =\r
- serviceTemplateRest.generateResourceAssignments(baseConfigConfigModelContent);\r
-\r
- Assert.assertNotNull("Failed to get ResourceAssignments, Return object is Null", resourceAssignments);\r
- Assert.assertTrue("Failed to get ResourceAssignments count", resourceAssignments.size() > 0);\r
-\r
- log.trace("Validated Service Template :\n" + JacksonUtils.getJson(resourceAssignments, true));\r
-\r
-\r
- }\r
-\r
- //@Test\r
- public void test05AutoMap() throws Exception {\r
- log.info("*********** test05AutoMap *******************************************");\r
-\r
- String resourceAssignmentContent = FileUtils.readFileToString(\r
- new File("src/test/resources/resourcedictionary/automap.json"), Charset.defaultCharset());\r
- List<ResourceAssignment> batchResourceAssignment =\r
- JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class);\r
- AutoMapResponse autoMapResponse = serviceTemplateRest.autoMap(batchResourceAssignment);\r
-\r
- Assert.assertNotNull("Failed to get ResourceAssignments, Return object is Null",\r
- autoMapResponse.getResourceAssignments());\r
- Assert.assertNotNull("Failed to get Data Dictionary from ResourceAssignments",\r
- autoMapResponse.getDataDictionaries());\r
- Assert.assertTrue("Failed to get ResourceAssignments count",\r
- CollectionUtils.isNotEmpty(autoMapResponse.getDataDictionaries()));\r
-\r
- List<ResourceAssignment> autoMappedResourceAssignment = autoMapResponse.getResourceAssignments();\r
- autoMappedResourceAssignment.forEach(resourceAssignment -> {\r
- if ("sample-db-source".equals(resourceAssignment.getName())) {\r
- Assert.assertEquals("Failed to assign default first source", "db",\r
- resourceAssignment.getDictionarySource());\r
- }\r
- });\r
-\r
- }\r
-\r
-\r
-}\r
package org.onap.ccsdk.apps.controllerblueprints.service.validator;
-import static org.junit.Assert.*;
-
-import org.junit.*;
-import org.onap.ccsdk.apps.controllerblueprints.service.validator.ModelTypeValidator;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-
import com.fasterxml.jackson.databind.JsonNode;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
public class ModelTypeValidatorTest {