diff options
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/main')
38 files changed, 676 insertions, 2338 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java index a763d503..1965ac90 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java @@ -17,6 +17,8 @@ package org.onap.ccsdk.apps.controllerblueprints.service;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import com.google.common.base.Preconditions;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -28,8 +30,6 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDict import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java new file mode 100644 index 00000000..ba27742a --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java @@ -0,0 +1,227 @@ +/*
+ * 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.
+ * 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.jetbrains.annotations.NotNull;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch;
+import org.onap.ccsdk.apps.controllerblueprints.service.load.BluePrintLoadConfiguration;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelContentRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelSearchRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.core.io.Resource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.codec.multipart.FilePart;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import reactor.core.publisher.Mono;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * BlueprintModelService.java Purpose: Provide Service Template Service processing BlueprintModelService
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+public class BlueprintModelService {
+
+ private static EELFLogger log = EELFManager.getInstance().getLogger(BlueprintModelService.class);
+
+ @Autowired
+ private BluePrintLoadConfiguration bluePrintLoadConfiguration;
+
+ @Autowired
+ private BluePrintCatalogService bluePrintCatalogService;
+
+ @Autowired
+ private BlueprintModelSearchRepository blueprintModelSearchRepository;
+
+ @Autowired
+ private BlueprintModelRepository blueprintModelRepository;
+
+ @Autowired
+ private BlueprintModelContentRepository blueprintModelContentRepository;
+
+ private static final String BLUEPRINT_MODEL_ID_FAILURE_MSG = "failed to get blueprint model id(%d) from repo";
+ private static final String BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG = "failed to get blueprint model by name(%d)" +
+ " and version(%d) from repo";
+
+ /**
+ * This is a saveBlueprintModel method
+ *
+ * @param filePart filePart
+ * @return Mono<BlueprintModelSearch>
+ * @throws BluePrintException BluePrintException
+ */
+ public Mono<BlueprintModelSearch> saveBlueprintModel(FilePart filePart) throws BluePrintException {
+ try {
+ Path cbaLocation = BluePrintFileUtils.Companion.getCbaStorageDirectory(bluePrintLoadConfiguration.blueprintArchivePath);
+ return BluePrintEnhancerUtils.Companion.saveCBAFile(filePart, cbaLocation).map(fileName -> {
+ String blueprintId = bluePrintCatalogService.uploadToDataBase(cbaLocation.resolve(fileName).toString(), false);
+ return blueprintModelSearchRepository.findById(blueprintId).get();
+ });
+
+ } catch (IOException | BluePrintException e) {
+ return Mono.error(new BluePrintException("Error uploading the CBA file in channel.", e));
+ }
+ }
+
+ /**
+ * This is a publishBlueprintModel method
+ *
+ * @param id id
+ * @return BlueprintModelSearch
+ * @throws BluePrintException BluePrintException
+ */
+ public BlueprintModelSearch publishBlueprintModel(String id) throws BluePrintException {
+ // TODO Implement publish Functionality
+ return null;
+ }
+
+ /**
+ * This is a searchBlueprintModels method
+ *
+ * @param tags tags
+ * @return List<BlueprintModelSearch>
+ */
+ public List<BlueprintModelSearch> searchBlueprintModels(String tags) {
+ return blueprintModelSearchRepository.findByTagsContainingIgnoreCase(tags);
+ }
+
+ /**
+ * This is a getBlueprintModelByNameAndVersion method
+ *
+ * @param name name
+ * @param version version
+ * @return BlueprintModelSearch
+ */
+ public BlueprintModelSearch getBlueprintModelByNameAndVersion(@NotNull String name, @NotNull String version) throws BluePrintException {
+ BlueprintModelSearch blueprintModelSearch;
+ Optional<BlueprintModelSearch> dbBlueprintModel = blueprintModelSearchRepository
+ .findByArtifactNameAndArtifactVersion(name, version);
+ if (dbBlueprintModel.isPresent()) {
+ blueprintModelSearch = dbBlueprintModel.get();
+ } else {
+ throw new BluePrintException(String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version));
+ }
+
+ return blueprintModelSearch;
+ }
+
+ /**
+ * This is a downloadBlueprintModelFile method to find the target file to download and return a file resource using MONO
+ *
+ * @param (id)
+ * @return ResponseEntity<Resource>
+ */
+ public ResponseEntity<Resource> downloadBlueprintModelFile(@NotNull String id) throws BluePrintException {
+ BlueprintModel blueprintModel;
+ try {
+ blueprintModel = getBlueprintModel(id);
+ } catch (BluePrintException e) {
+ throw new BluePrintException("Error uploading the CBA file in channel.", e);
+ }
+ String fileName = blueprintModel.getId() + ".zip";
+ byte[] file = blueprintModel.getBlueprintModelContent().getContent();
+ return ResponseEntity.ok()
+ .contentType(MediaType.parseMediaType("text/plain"))
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\"")
+ .body(new ByteArrayResource(file));
+ }
+
+ /**
+ * This is a getBlueprintModel method
+ *
+ * @param id id
+ * @return BlueprintModel
+ * @throws BluePrintException BluePrintException
+ */
+ private BlueprintModel getBlueprintModel(@NotNull String id) throws BluePrintException {
+ BlueprintModel blueprintModel;
+ Optional<BlueprintModel> dbBlueprintModel = blueprintModelRepository.findById(id);
+ if (dbBlueprintModel.isPresent()) {
+ blueprintModel = dbBlueprintModel.get();
+ } else {
+ throw new BluePrintException(String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id));
+ }
+
+ return blueprintModel;
+ }
+
+ /**
+ * This is a getBlueprintModelSearch method
+ *
+ * @param id id
+ * @return BlueprintModelSearch
+ * @throws BluePrintException BluePrintException
+ */
+ public BlueprintModelSearch getBlueprintModelSearch(@NotNull String id) throws BluePrintException {
+ BlueprintModelSearch blueprintModelSearch;
+ Optional<BlueprintModelSearch> dbBlueprintModel = blueprintModelSearchRepository.findById(id);
+ if (dbBlueprintModel.isPresent()) {
+ blueprintModelSearch = dbBlueprintModel.get();
+ } else {
+ throw new BluePrintException(String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id));
+ }
+
+ return blueprintModelSearch;
+ }
+
+ /**
+ * This is a deleteBlueprintModel method
+ *
+ * @param id id
+ * @throws BluePrintException BluePrintException
+ */
+ @Transactional
+ public void deleteBlueprintModel(@NotNull String id) throws BluePrintException {
+ Optional<BlueprintModel> dbBlueprintModel = blueprintModelRepository.findById(id);
+ if (dbBlueprintModel.isPresent()) {
+ blueprintModelContentRepository.deleteByBlueprintModel(dbBlueprintModel.get());
+ blueprintModelRepository.delete(dbBlueprintModel.get());
+ } else {
+ throw new BluePrintException(String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id));
+ }
+ }
+
+ /**
+ * This is a getAllBlueprintModel method to retrieve all the BlueprintModel in Database
+ *
+ * @return List<BlueprintModelSearch> list with the controller blueprint archives
+ */
+ public List<BlueprintModelSearch> getAllBlueprintModel() {
+ return blueprintModelSearchRepository.findAll();
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CBAContentService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CBAContentService.java deleted file mode 100755 index 66ef6a93..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CBAContentService.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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); - } - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementService.java deleted file mode 100755 index 2011172d..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementService.java +++ /dev/null @@ -1,128 +0,0 @@ -/*
- * 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.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.codec.multipart.FilePart;
-import org.springframework.stereotype.Service;
-import org.springframework.util.FileSystemUtils;
-import org.springframework.util.StringUtils;
-import reactor.core.publisher.Mono;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-/**
- * CbaFileManagementService.java Purpose: Provide Service processing CBA file management
- *
- * @author Steve Siani
- * @version 1.0
- */
-@Service
-public class CbaFileManagementService {
- private static EELFLogger log = EELFManager.getInstance().getLogger(CbaFileManagementService.class);
-
- @Value("${controllerblueprints.loadCbaExtension}")
- private String cbaExtension;
-
- private static final String CBA_FILE_NAME_PATTERN = "CBA_{0}_{1}";
-
-
- /**
- * cleanupSavedCBA: This method cleanup the Zip file and the unzip directory that was added.
- *
- * @param zipFileName zipFileName
- * @param cbaFileLocation cbaFileLocation
- * @return
- * @throws BluePrintException BluePrintException
- */
- public void cleanupSavedCBA(String zipFileName, Path cbaFileLocation) throws BluePrintException {
-
- String fileNameWithoutExtension = BluePrintFileUtils.Companion.stripFileExtension(zipFileName);
-
- //Delete the Zip file from the repository
- FileSystemUtils.deleteRecursively(BluePrintFileUtils.Companion.getBluePrintFile(zipFileName,cbaFileLocation));
-
- //Delete the CBA directory from the repository
- FileSystemUtils.deleteRecursively(BluePrintFileUtils.Companion.getBluePrintFile(fileNameWithoutExtension,cbaFileLocation));
- }
-
- /**
- * This is a saveCBAFile method
- * take a {@link FilePart}, transfer it to disk using a Flux of FilePart and return a {@link 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 {@link Mono} String representing the result of the operation
- * @throws (BluePrintException, IOException) BluePrintException, IOException
- */
- public Mono<String> saveCBAFile(FilePart filePart, Path targetDirectory) throws BluePrintException, IOException {
-
- // Normalize file name
- final String fileName = StringUtils.cleanPath(filePart.filename());
-
- // Check if the file's extension is "CBA"
- if(!StringUtils.getFilenameExtension(fileName).equals(cbaExtension)) {
- throw new BluePrintException("Invalid file extension required " + cbaExtension);
- }
-
- // Change file name to match a pattern
- String changedFileName = BluePrintFileUtils.Companion.getCBAGeneratedFileName(fileName, this.CBA_FILE_NAME_PATTERN);
-
- // Copy file to the target location (Replacing existing file with the same name)
- Path targetLocation = targetDirectory.resolve(changedFileName);
-
- // if a file with the same name already exists in a repository, delete and recreate it
- File file = new File(targetLocation.toString());
- if (file.exists())
- file.delete();
- file.createNewFile();
-
- return filePart.transferTo(file).thenReturn(changedFileName);
- }
-
- /**
- * Decompress the file into the cbaFileLocation parameter
- * @param zipFileName name of the zipped file
- * @param cbaFileLocation path in which the zipped file will get decompressed
- * @return String the path in which the file is decompressed
- * @throws BluePrintException Exception in the process
- */
- public String decompressCBAFile(final String zipFileName, Path cbaFileLocation) throws BluePrintException {
-
- File file = BluePrintFileUtils.Companion.getBluePrintFile(zipFileName, cbaFileLocation);
- try {
- Path directoryPath = Files.createDirectories(cbaFileLocation.resolve(BluePrintFileUtils.Companion.stripFileExtension(zipFileName)));
- BluePrintArchiveUtils.Companion.deCompress(file, directoryPath.toString());
- return directoryPath.toString();
-
- } catch (BluePrintProcessorException | IOException ex) {
- throw new BluePrintException(" Fail to decompress " + zipFileName, ex);
- }
-
- }
-
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaService.java deleted file mode 100755 index 7d616a76..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaService.java +++ /dev/null @@ -1,192 +0,0 @@ -/*
- * 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.jetbrains.annotations.NotNull;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.onap.ccsdk.apps.controllerblueprints.service.model.BlueprintModelResponse;
-import org.onap.ccsdk.apps.controllerblueprints.service.model.ItemCbaResponse;
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.CbaStateEnum;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.event.ApplicationReadyEvent;
-import org.springframework.context.event.EventListener;
-import org.springframework.core.io.ByteArrayResource;
-import org.springframework.core.io.Resource;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.http.codec.multipart.FilePart;
-import org.springframework.stereotype.Service;
-import reactor.core.publisher.Mono;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * CbaService.java Purpose: Provide Service Template Service processing CbaService
- *
- * @author Steve Siani
- * @version 1.0
- */
-
-@Service
-public class CbaService {
-
- private static EELFLogger log = EELFManager.getInstance().getLogger(CbaService.class);
-
- @Value("${controllerblueprints.blueprintArchivePath}")
- private String cbaArchivePath;
- private Path cbaLocation;
-
- @Autowired
- private CbaFileManagementService cbaFileManagementService;
-
- @Autowired
- private CbaToDatabaseService cbaToDatabaseService;
-
-
- /**
- * This method would be used by SpringBoot to initialize the cba location
- */
- @EventListener(ApplicationReadyEvent.class)
- private void initCbaService() {
- this.cbaLocation = BluePrintFileUtils.Companion.getCbaStorageDirectory(cbaArchivePath);
- log.info("CBA service Initiated...");
- }
-
- /**
- * This is a uploadCBAFile method
- * take a {@link FilePart}, transfer it to disk using WebFlux and return a {@link Mono} representing the result
- *
- * @param filePart - the request part containing the file to be saved
- * @return a {@link Mono< BlueprintModelResponse >} representing the result of the operation
- */
- public Mono<BlueprintModelResponse> uploadCBAFile(FilePart filePart) {
-
- try {
- return this.cbaFileManagementService.saveCBAFile(filePart, cbaLocation).map(fileName -> {
- ConfigModel configModel;
- BlueprintModelResponse blueprintModelResponse = null;
-
- try {
- String cbaDirectory = this.cbaFileManagementService.decompressCBAFile(fileName, cbaLocation);
- configModel = this.cbaToDatabaseService.storeBluePrints(cbaDirectory, fileName, cbaLocation.resolve(fileName));
- blueprintModelResponse = new BlueprintModelResponse(configModel.getId(), configModel.getArtifactName(), configModel.getArtifactVersion(), configModel.getArtifactDescription(), configModel.getConfigModelCBA().getCbaUUID());
- } catch (BluePrintException be) {
- Mono.error(new BluePrintException("Error loading CBA in database.", be));
- } finally {
- try {
- this.cbaFileManagementService.cleanupSavedCBA(fileName, cbaLocation);
- } catch (BluePrintException be) {
- Mono.error(new BluePrintException("Error while cleaning up.", be));
- }
- }
- return blueprintModelResponse;
- });
- } catch (IOException | BluePrintException e) {
- return Mono.error(new BluePrintException("Error uploading the CBA file in channel.", e));
- }
- }
-
- /**
- * This is a deleteCba method
- *
- * @param id id
- * @throws BluePrintException BluePrintException
- */
- public void deleteCBA(@NotNull Long id) throws BluePrintException {
- this.cbaToDatabaseService.deleteCBA(id);
- }
-
- /**
- * This is a downloadCBAFile method to find the target file to download and return a file ressource using MONO
- *
- * @param (id)
- * @return ResponseEntity<Resource>
- */
- public ResponseEntity<Resource> downloadCBAFile(@NotNull String id) {
- Optional<CbaContent> optionalContent = this.cbaToDatabaseService.findByUUID(id);
-
- CbaContent cbaContent = optionalContent.get();
-
- return ResponseEntity.ok()
- .contentType(MediaType.parseMediaType("text/plain"))
- .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + cbaContent.getCbaName() + "\"")
- .body(new ByteArrayResource(cbaContent.getCbaFile()));
- }
-
- /**
- * This is a findCBAByID method to find a CBA By the UUID
- *
- * @param (id)
- * @return ItemCbaResponse
- */
- public ItemCbaResponse findCBAByID(@NotNull String id) {
- ItemCbaResponse response = new ItemCbaResponse();
- Optional<CbaContent> optionalContent = this.cbaToDatabaseService.findByUUID(id);
-
- CbaContent cbaContent = optionalContent.get();
- response.setName(cbaContent.getCbaName());
- response.setState(cbaContent.getCbaState());
- response.setId(cbaContent.getCbaUUID());
- response.setVersion(cbaContent.getCbaVersion());
- response.setDescription(cbaContent.getCbaDescription());
- return response;
- }
-
- /**
- * This is a findAllCBA method to retrieve all the CBAs in Database
- *
- * @return List<ItemCbaResponse> list with the controller blueprint archives
- */
- public List<ItemCbaResponse> findAllCBA() {
- List<ItemCbaResponse> responseList = new ArrayList<>();
- List<CbaContent> cbaContents = this.cbaToDatabaseService.listCBAFiles();
-
- for(CbaContent content: cbaContents){
- ItemCbaResponse response = new ItemCbaResponse();
- response.setName(content.getCbaName());
- response.setState(content.getCbaState());
- response.setId(content.getCbaUUID());
- response.setVersion(content.getCbaVersion());
- response.setDescription(content.getCbaDescription());
-
- responseList.add(response);
- }
- return responseList;
- }
-
- /**
- * This is a findCBAByNameAndVersion method to find a CBA by Name and version
- *
- * @param (name, version)
- * @return
- * @throws BluePrintException BluePrintException
- */
- public ItemCbaResponse findCBAByNameAndVersion(@NotNull String name, @NotNull String version) throws BluePrintException {
- return null;
- }
-}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaToDatabaseService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaToDatabaseService.java deleted file mode 100755 index 34204202..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaToDatabaseService.java +++ /dev/null @@ -1,132 +0,0 @@ -/*
- * 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.apache.commons.collections.CollectionUtils;
-import org.jetbrains.annotations.NotNull;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelContentRepository;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.CbaStateEnum;
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * This class acts as a Rest Service that would store in the Database the Blueprints.
- * @author Ruben Chang
- */
-
-@Service
-public class CbaToDatabaseService {
-
- //Log used to trace the transactions using the EELFLogger class
- private static EELFLogger log = EELFManager.getInstance().getLogger(CbaToDatabaseService.class);
-
- @Autowired
- private ConfigModelRepository configModelRepository;
- @Autowired
- private ConfigModelContentRepository configModelContentRepository;
- @Autowired
- private ConfigModelCreateService configModelCreateService;
- @Autowired
- private CBAContentService cbaContentService;
-
- /**
- * This method will store the blueprints into the DB on the tables CONFIG_MODEL and CONFIG_MODEL_CONTENT
- * @param cbaArchiveToSave Path in which the components are stored
- * @return ConfigModel The Blueprint object stored in the DB
- */
- public ConfigModel storeBluePrints(String cbaDirectory, String cbaFileName, Path cbaArchiveToSave) throws BluePrintException {
- log.info("*************************** storeBluePrints **********************");
- ConfigModel configModel = null;
- CbaContent cbaContent;
- String version = "1.0";//TODO Read these information from metadata
- String description = "Initial description for CBA archive " + cbaFileName;//TODO
-
- List<String> serviceTemplateDirs = ConfigModelUtils.getBlueprintNames(cbaDirectory);
- if (CollectionUtils.isNotEmpty(serviceTemplateDirs)) {
- for (String fileName : serviceTemplateDirs) {
- try {
- String bluePrintPath = cbaDirectory.concat("/").concat(fileName);
- log.debug("***** Loading service template : {}", bluePrintPath);
- configModel = ConfigModelUtils.getConfigModel(bluePrintPath);
-
- configModel = this.configModelCreateService.saveConfigModel(configModel);
-
- log.info("Loaded service template successfully: {}", fileName);
- } catch (Exception e) {
- throw new BluePrintException("Load config model " + fileName + " error : "+e.getMessage());
- }
- }
- } else {
- throw new BluePrintException("Invalid structure. The unzipped file does not contains Blueprints");
- }
-
- byte[] file;
- try {
- file = Files.readAllBytes(cbaArchiveToSave);
- } catch (IOException e) {
- throw new BluePrintException("Fail to read the CBA to save in database.", e);
- }
-
- cbaContent = this.cbaContentService.saveCBAContent(cbaFileName, version, CbaStateEnum.DRAFT.getState(), description, file);
- configModel.setConfigModelCBA(cbaContent);
-
- return configModel;
- }
-
- /**
- * This is a deleteConfigModel method
- *
- * @param id id
- * @throws BluePrintException BluePrintException
- */
- public void deleteCBA(@NotNull Long id) throws BluePrintException {
- Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
-
- //TODO: Delete CBA and COnfigModel
-
- }
-
- /**
- * Get a list of the controller blueprint archives
- * @return List<CbaContent> List with the controller blueprint archives
- */
- public List<CbaContent> listCBAFiles() {
- return this.cbaContentService.getList();
- }
-
- /**
- * Find a Controller Blueprint Archive by UUID
- * @param uuID the User Identifier Controller Blueprint archive
- * @return Optional<CbaContent> the Controller Blueprint archive
- */
- public Optional<CbaContent> findByUUID(String uuID) {
- return this.cbaContentService.findByUUID(uuID);
- }
-}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java deleted file mode 100755 index f31a0ceb..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java +++ /dev/null @@ -1,330 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.common.base.Preconditions;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.jetbrains.annotations.NotNull;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConstants;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
-import org.springframework.stereotype.Service;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * ServiceTemplateCreateService.java Purpose: Provide Service Template Create Service processing
- * ServiceTemplateCreateService
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Deprecated
-@Service
-public class ConfigModelCreateService {
-
- private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelCreateService.class);
-
- private ConfigModelRepository configModelRepository;
-
- /**
- * This is a ConfigModelCreateService
- *
- * @param configModelRepository ConfigModelRepository
- */
- public ConfigModelCreateService(ConfigModelRepository configModelRepository) {
- this.configModelRepository = configModelRepository;
- }
-
- /**
- * This is a createInitialServiceTemplateContent method
- *
- * @param templateName templateName
- * @return String
- * @throws BluePrintException BluePrintException
- */
- public String createInitialServiceTemplateContent(String templateName) throws BluePrintException {
- String serviceTemplateContent = null;
- if (StringUtils.isNotBlank(templateName)) {
- try {
- serviceTemplateContent = IOUtils.toString(ConfigModelCreateService.class.getClassLoader()
- .getResourceAsStream("service_template/" + templateName + ".json"), Charset.defaultCharset());
- } catch (IOException e) {
- throw new BluePrintException(e.getMessage(), e);
- }
-
- }
- return serviceTemplateContent;
- }
-
- /**
- * This is a createInitialServiceTemplate method
- *
- * @param templateName templateName
- * @return ServiceTemplate
- * @throws BluePrintException BluePrintException
- */
- public ServiceTemplate createInitialServiceTemplate(String templateName) throws BluePrintException {
- ServiceTemplate serviceTemplate = null;
- if (StringUtils.isNotBlank(templateName)) {
- try {
- String serviceTemplateContent = IOUtils.toString(ConfigModelCreateService.class.getClassLoader()
- .getResourceAsStream("service_template/" + templateName + ".json"), Charset.defaultCharset());
- if (StringUtils.isNotBlank(serviceTemplateContent)) {
- serviceTemplate = JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
- }
- } catch (IOException e) {
- throw new BluePrintException(e.getMessage(), e);
- }
-
- }
- return serviceTemplate;
- }
-
- /**
- * This is a saveConfigModel method
- *
- * @param configModel configModel
- * @return ConfigModel
- * @throws BluePrintException BluePrintException
- */
- public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {
-
- if (configModel != null) {
- String artifactName = configModel.getArtifactName();
- String artifactVersion = configModel.getArtifactVersion();
- String author = configModel.getUpdatedBy();
- CbaContent configModelCBA = configModel.getConfigModelCBA();
-
- if (StringUtils.isBlank(author)) {
- throw new BluePrintException("Artifact Author is missing in the Service Template");
- }
-
- if (StringUtils.isBlank(artifactName)) {
- throw new BluePrintException("Artifact Name is missing in the Service Template");
- }
-
- if (StringUtils.isBlank(artifactVersion)) {
- throw new BluePrintException("Artifact Version is missing in the Service Template");
- }
- ConfigModel updateConfigModel;
-
- Optional<ConfigModel> dbConfigModelOptional = Optional.empty();
-
- if (configModel.getId() != null) {
- log.info("Searching for config model id : {}", configModel.getId());
- dbConfigModelOptional = configModelRepository.findById(configModel.getId());
- }
-
- if (!dbConfigModelOptional.isPresent()) {
- log.info("Searching for config model name :"
- + configModel.getArtifactName() + ", version " + configModel.getArtifactVersion());
- dbConfigModelOptional = configModelRepository.findByArtifactNameAndArtifactVersion(
- configModel.getArtifactName(), configModel.getArtifactVersion());
- }
-
- if (dbConfigModelOptional.isPresent()) {
- updateConfigModel = dbConfigModelOptional.get();
- log.info("Processing for config model id : {} with config model content count : {}"
- , updateConfigModel.getId(), updateConfigModel.getConfigModelContents().size());
- } else {
- ConfigModel tempConfigModel = new ConfigModel();
- tempConfigModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);
- tempConfigModel.setArtifactName(artifactName);
- tempConfigModel.setArtifactVersion(artifactVersion);
- tempConfigModel.setUpdatedBy(author);
- tempConfigModel.setPublished(ApplicationConstants.ACTIVE_N);
- tempConfigModel.setTags(artifactName);
- configModelRepository.saveAndFlush(tempConfigModel);
- updateConfigModel = tempConfigModel;
- }
-
- Long dbConfigModelId = updateConfigModel.getId();
-
- if (dbConfigModelId == null) {
- throw new BluePrintException("failed to get the initial saved config model id.");
- }
-
- log.info("Processing for config model id : {}", dbConfigModelId);
-
- deleteConfigModelContent(dbConfigModelId);
-
- addConfigModelContent(dbConfigModelId, configModel);
-
- // Populate Content model types
- updateConfigModel = updateConfigModel(dbConfigModelId, artifactName, artifactVersion, author, configModelCBA);
-
-
- return updateConfigModel;
- } else {
- throw new BluePrintException("Config model information is missing");
- }
-
- }
-
- private void deleteConfigModelContent(Long dbConfigModelId) {
- if (dbConfigModelId != null) {
- ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);
- if (CollectionUtils.isNotEmpty(dbConfigModel.getConfigModelContents())) {
- dbConfigModel.getConfigModelContents().clear();
- log.debug("Configuration Model content deleting : {}", dbConfigModel.getConfigModelContents());
- configModelRepository.saveAndFlush(dbConfigModel);
- }
-
- }
- }
-
- private void addConfigModelContent(Long dbConfigModelId, ConfigModel configModel) {
- if (dbConfigModelId != null && configModel != null
- && CollectionUtils.isNotEmpty(configModel.getConfigModelContents())) {
- ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);
- for (ConfigModelContent configModelContent : configModel.getConfigModelContents()) {
- if (configModelContent != null) {
- configModelContent.setId(null);
- configModelContent.setConfigModel(dbConfigModel);
- dbConfigModel.getConfigModelContents().add(configModelContent);
- log.debug("Configuration Model content adding : {}", configModelContent);
- }
- }
- configModelRepository.saveAndFlush(dbConfigModel);
- }
- }
-
- private ConfigModel updateConfigModel(Long dbConfigModelId, String artifactName, String artifactVersion,
- String author, CbaContent configModelCBA) throws BluePrintException {
-
- ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);
- // Populate tags from metadata
- String tags = getConfigModelTags(dbConfigModel);
- if (StringUtils.isBlank(tags)) {
- throw new BluePrintException("Failed to populate tags for the config model name " + artifactName);
- }
- dbConfigModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);
- dbConfigModel.setArtifactName(artifactName);
- dbConfigModel.setArtifactVersion(artifactVersion);
- dbConfigModel.setUpdatedBy(author);
- dbConfigModel.setPublished(ApplicationConstants.ACTIVE_N);
- dbConfigModel.setTags(tags);
- dbConfigModel.setConfigModelCBA(configModelCBA);
- configModelRepository.saveAndFlush(dbConfigModel);
- log.info("Config model ({}) saved successfully.", dbConfigModel.getId());
- return dbConfigModel;
- }
-
- private List<String> getValidContentTypes() {
- List<String> valids = new ArrayList<>();
- valids.add(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
- valids.add(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);
- return valids;
-
- }
-
- private String getConfigModelTags(ConfigModel configModel) throws BluePrintException {
- String tags = null;
- if (CollectionUtils.isNotEmpty(configModel.getConfigModelContents())) {
-
- for (ConfigModelContent configModelContent : configModel.getConfigModelContents()) {
- if (configModelContent != null && StringUtils.isNotBlank(configModelContent.getContentType())) {
-
- if (!getValidContentTypes().contains(configModelContent.getContentType())) {
- throw new BluePrintException(configModelContent.getContentType()
- + " is not a valid content type, It should be any one of this "
- + getValidContentTypes());
- }
-
- if (configModelContent.getContentType().equals(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON)) {
- ServiceTemplate serviceTemplate =
- JacksonUtils.readValue(configModelContent.getContent(), ServiceTemplate.class);
- Preconditions.checkNotNull(serviceTemplate, "failed to transform service template content");
- if (serviceTemplate.getMetadata() != null) {
- serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_AUTHOR,
- configModel.getUpdatedBy());
- serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_VERSION,
- configModel.getArtifactVersion());
- serviceTemplate.getMetadata().put(BluePrintConstants.METADATA_TEMPLATE_NAME,
- configModel.getArtifactName());
- }
- tags = String.valueOf(serviceTemplate.getMetadata());
- }
- }
- }
- }
- return tags;
- }
-
- /**
- * This is a publishConfigModel method
- *
- * @param id id
- * @return ConfigModel
- * @throws BluePrintException BluePrintException
- */
- public ConfigModel publishConfigModel(@NotNull Long id) throws BluePrintException {
- ConfigModel dbConfigModel = null;
- Optional<ConfigModel> dbConfigModelOptional = configModelRepository.findById(id);
- if (dbConfigModelOptional.isPresent()) {
- dbConfigModel = dbConfigModelOptional.get();
- List<ConfigModelContent> configModelContents = dbConfigModel.getConfigModelContents();
- if (configModelContents != null && !configModelContents.isEmpty()) {
- for (ConfigModelContent configModelContent : configModelContents) {
- if (configModelContent.getContentType()
- .equals(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON)) {
- ServiceTemplate serviceTemplate = JacksonUtils
- .readValue(configModelContent.getContent(), ServiceTemplate.class);
- if (serviceTemplate != null) {
- validateServiceTemplate(serviceTemplate);
- }
- }
- }
- }
- dbConfigModel.setPublished(ApplicationConstants.ACTIVE_Y);
- configModelRepository.save(dbConfigModel);
- log.info("Config model ({}) published successfully.", id);
- } else {
- throw new BluePrintException(String.format("Couldn't get Config model for id :(%s)", id));
- }
- return dbConfigModel;
- }
-
- /**
- * This is a validateServiceTemplate method
- *
- * @param serviceTemplate Service Template
- * @return ServiceTemplate
- * @throws BluePrintException BluePrintException
- */
- public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
- // FIXME("Plug right Validator")
- return serviceTemplate;
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java deleted file mode 100644 index b2fff26e..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java +++ /dev/null @@ -1,260 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.jetbrains.annotations.NotNull;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConstants;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelContentRepository;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * ConfigModelService.java Purpose: Provide Service Template Service processing ConfigModelService
- *
- * @author Brinda Santh
- * @version 1.0
- */
-
-@Service
-public class ConfigModelService {
-
- private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelService.class);
-
- private ConfigModelRepository configModelRepository;
- private ConfigModelContentRepository configModelContentRepository;
- private ConfigModelCreateService configModelCreateService;
- private static final String CONFIG_MODEL_ID_FAILURE_MSG= "failed to get config model id(%d) from repo";
-
- /**
- * This is a ConfigModelService constructor.
- *
- * @param configModelRepository configModelRepository
- * @param configModelContentRepository configModelContentRepository
- * @param configModelCreateService configModelCreateService
- */
- public ConfigModelService(ConfigModelRepository configModelRepository,
- ConfigModelContentRepository configModelContentRepository,
- ConfigModelCreateService configModelCreateService) {
- this.configModelRepository = configModelRepository;
- this.configModelContentRepository = configModelContentRepository;
- this.configModelCreateService = configModelCreateService;
- log.info("Config Model Service Initiated...");
- }
-
- /**
- * This is a getInitialConfigModel method
- *
- * @param templateName templateName
- * @return ConfigModel
- * @throws BluePrintException BluePrintException
- */
- public ConfigModel getInitialConfigModel(String templateName) throws BluePrintException {
- ConfigModel configModel = null;
- if (StringUtils.isNotBlank(templateName)) {
- configModel = new ConfigModel();
- configModel.setArtifactName(templateName);
- configModel.setArtifactType(ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL);
- configModel.setUpdatedBy("xxxxx@xxx.com");
- ConfigModelContent configModelContent = new ConfigModelContent();
- configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
- configModelContent.setName(templateName);
- String content = this.configModelCreateService.createInitialServiceTemplateContent(templateName);
- configModelContent.setContent(content);
-
- List<ConfigModelContent> configModelContents = new ArrayList<>();
- configModelContents.add(configModelContent);
-
- configModel.setConfigModelContents(configModelContents);
- }
- return configModel;
- }
-
- /**
- * This is a saveConfigModel method
- *
- * @param configModel configModel
- * @return ConfigModel
- * @throws BluePrintException BluePrintException
- */
- public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {
- return this.configModelCreateService.saveConfigModel(configModel);
- }
-
- /**
- * This is a publishConfigModel method
- *
- * @param id id
- * @return ConfigModel
- * @throws BluePrintException BluePrintException
- */
- public ConfigModel publishConfigModel(Long id) throws BluePrintException {
- return this.configModelCreateService.publishConfigModel(id);
- }
-
- /**
- * This is a searchConfigModels method
- *
- * @param tags tags
- * @return ConfigModel
- */
- public List<ConfigModel> searchConfigModels(String tags) {
- List<ConfigModel> models = configModelRepository.findByTagsContainingIgnoreCase(tags);
- if (models != null) {
- for (ConfigModel configModel : models) {
- configModel.setConfigModelContents(null);
- }
- }
- return models;
- }
-
- /**
- * This is a getConfigModelByNameAndVersion method
- *
- * @param name name
- * @param version version
- * @return ConfigModel
- */
- public ConfigModel getConfigModelByNameAndVersion(@NotNull String name, String version) throws BluePrintException {
- ConfigModel configModel;
- Optional<ConfigModel> dbConfigModel;
- if (StringUtils.isNotBlank(version)) {
- dbConfigModel = configModelRepository.findByArtifactNameAndArtifactVersion(name, version);
- } else {
- dbConfigModel = configModelRepository.findTopByArtifactNameOrderByArtifactVersionDesc(name);
- }
- if (dbConfigModel.isPresent()) {
- configModel = dbConfigModel.get();
- } else {
- throw new BluePrintException(String.format("failed to get config model name(%s), version(%s) from repo", name, version));
- }
- return configModel;
- }
-
- /**
- * This is a getConfigModel method
- *
- * @param id id
- * @return ConfigModel
- * @throws BluePrintException BluePrintException
- */
- public ConfigModel getConfigModel(@NotNull Long id) throws BluePrintException {
- ConfigModel configModel;
- Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
- if (dbConfigModel.isPresent()) {
- configModel = dbConfigModel.get();
- } else {
- throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));
- }
-
- return configModel;
- }
-
- /**
- * This method returns clone of the given model id, by masking the other unrelated fields
- *
- * @param id id
- * @return ConfigModel
- * @throws BluePrintException BluePrintException
- */
-
- public ConfigModel getCloneConfigModel(@NotNull Long id) throws BluePrintException {
-
- ConfigModel configModel;
- ConfigModel cloneConfigModel;
- Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
- if (dbConfigModel.isPresent()) {
- configModel = dbConfigModel.get();
- cloneConfigModel = configModel;
- cloneConfigModel.setUpdatedBy("xxxxx@xxx.com");
- cloneConfigModel.setArtifactName("XXXX");
- cloneConfigModel.setPublished("XXXX");
- cloneConfigModel.setPublished("XXXX");
- cloneConfigModel.setUpdatedBy("XXXX");
- cloneConfigModel.setId(null);
- cloneConfigModel.setTags(null);
- cloneConfigModel.setCreatedDate(new Date());
- List<ConfigModelContent> configModelContents = cloneConfigModel.getConfigModelContents();
-
- if (CollectionUtils.isNotEmpty(configModelContents)) {
- for (ConfigModelContent configModelContent : configModelContents) {
- if (configModelContent != null && StringUtils.isNotBlank(configModelContent.getContentType())) {
- configModelContent.setId(null);
- configModelContent.setCreationDate(new Date());
-
- if (ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON
- .equalsIgnoreCase(configModelContent.getContentType())) {
- ServiceTemplate serviceTemplate = JacksonUtils
- .readValue(configModelContent.getContent(), ServiceTemplate.class);
- if (serviceTemplate != null && serviceTemplate.getMetadata() != null) {
- serviceTemplate.getMetadata()
- .put(BluePrintConstants.METADATA_TEMPLATE_AUTHOR, "XXXX");
- serviceTemplate.getMetadata()
- .put(BluePrintConstants.METADATA_TEMPLATE_VERSION, "1.0.0");
- serviceTemplate.getMetadata()
- .put(BluePrintConstants.METADATA_TEMPLATE_NAME, "XXXXXX");
-
- configModelContent.setContent(JacksonUtils.getJson(serviceTemplate));
- }
- }
- }
-
- }
- }
- } else {
- throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));
- }
-
- return cloneConfigModel;
- }
-
- /**
- * This is a deleteConfigModel method
- *
- * @param id id
- * @throws BluePrintException BluePrintException
- */
-
- @Transactional
- public void deleteConfigModel(@NotNull Long id) throws BluePrintException {
- Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
- if (dbConfigModel.isPresent()) {
- configModelContentRepository.deleteByConfigModel(dbConfigModel.get());
- configModelRepository.delete(dbConfigModel.get());
- } else {
- throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));
- }
- }
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java index ff8b07a9..89af9e9a 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java @@ -16,6 +16,8 @@ package org.onap.ccsdk.apps.controllerblueprints.service;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import com.google.common.base.Preconditions;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
@@ -24,8 +26,6 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.service.common.SwaggerGenerator;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import java.util.HashMap;
import java.util.Map;
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java deleted file mode 100644 index 60a83f9b..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java +++ /dev/null @@ -1,131 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationService;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
-import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * ServiceTemplateService.java Purpose: Provide Service Template Create Service processing ServiceTemplateService
- *
- * @author Brinda Santh
- * @version 1.0
- */
-
-@Service
-public class ServiceTemplateService {
-
- private ResourceDictionaryRepository dataDictionaryRepository;
-
- private ConfigModelCreateService configModelCreateService;
- private ResourceAssignmentValidationService resourceAssignmentValidationService;
-
- /**
- * This is a SchemaGeneratorService constructor
- *
- * @param dataDictionaryRepository dataDictionaryRepository
- * @param configModelCreateService configModelCreateService
- * @param resourceAssignmentValidationService resourceAssignmentValidationService
- */
- public ServiceTemplateService(ResourceDictionaryRepository dataDictionaryRepository,
- ConfigModelCreateService configModelCreateService,
- ResourceAssignmentValidationService resourceAssignmentValidationService) {
- this.dataDictionaryRepository = dataDictionaryRepository;
- this.configModelCreateService = configModelCreateService;
- this.resourceAssignmentValidationService = resourceAssignmentValidationService;
- }
-
- /**
- * This is a validateServiceTemplate method
- *
- * @param serviceTemplate serviceTemplate
- * @return ServiceTemplate
- * @throws BluePrintException BluePrintException
- */
- public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
- return this.configModelCreateService.validateServiceTemplate(serviceTemplate);
- }
-
- /**
- * This is a enrichServiceTemplate method
- *
- * @param serviceTemplate serviceTemplate
- * @return ServiceTemplate
- */
- public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
- //FIXME("Connect New Enrichment service")
- return serviceTemplate;
- }
-
- /**
- * This is a autoMap method to map the template keys
- *
- * @param resourceAssignments resourceAssignments
- * @return AutoMapResponse
- * @throws BluePrintException BluePrintException
- */
- public AutoMapResponse autoMap(List<ResourceAssignment> resourceAssignments) throws BluePrintException {
- AutoResourceMappingService autoMappingService = new AutoResourceMappingService(dataDictionaryRepository);
- return autoMappingService.autoMap(resourceAssignments);
- }
-
- /**
- * This is a validateResourceAssignments method
- *
- * @param resourceAssignments resourceAssignments
- * @return List<ResourceAssignment>
- * @throws BluePrintException BluePrintException
- */
- public List<ResourceAssignment> validateResourceAssignments(List<ResourceAssignment> resourceAssignments)
- throws BluePrintException {
- resourceAssignmentValidationService.validate(resourceAssignments);
- return resourceAssignments;
- }
-
- /**
- * This is a generateResourceAssignments method
- *
- * @param templateContent templateContent
- * @return List<ResourceAssignment>
- */
- public List<ResourceAssignment> generateResourceAssignments(ConfigModelContent templateContent) {
- List<ResourceAssignment> resourceAssignments = new ArrayList<>();
- if (templateContent != null && StringUtils.isNotBlank(templateContent.getContent())) {
- Pattern p = Pattern.compile("(?<=\\$\\{)([^\\}]+)(?=\\})");
- Matcher m = p.matcher(templateContent.getContent());
- while (m.find()) {
- ResourceAssignment resourceAssignment = new ResourceAssignment();
- resourceAssignment.setName(m.group());
- resourceAssignments.add(resourceAssignment);
- }
- }
- return resourceAssignments;
- }
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModel.java index dea5757d..93954daa 100755 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModel.java @@ -1,5 +1,6 @@ /*
* 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.
@@ -17,7 +18,6 @@ package org.onap.ccsdk.apps.controllerblueprints.service.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonManagedReference;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Proxy;
import org.springframework.data.annotation.LastModifiedDate;
@@ -25,12 +25,10 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.*;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.List;
/**
- * ConfigModel.java Purpose: Provide Configuration Generator ConfigModel Entity
+ * BlueprintModel.java Purpose: Provide Configuration Generator BlueprintModel Entity
*
* @author Brinda Santh
* @version 1.0
@@ -40,12 +38,11 @@ import java.util.List; @Entity
@Table(name = "CONFIG_MODEL")
@Proxy(lazy=false)
-public class ConfigModel implements Serializable {
+public class BlueprintModel implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "config_model_id")
- private Long id;
+ private String id;
@Column(name = "service_uuid")
private String serviceUUID;
@@ -114,20 +111,14 @@ public class ConfigModel implements Serializable { @ApiModelProperty(required=true)
private String tags;
+ @OneToOne(mappedBy = "blueprintModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)
+ private BlueprintModelContent blueprintModelContent;
- @OneToMany(mappedBy = "configModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)
- @JsonManagedReference
- private List<ConfigModelContent> configModelContents = new ArrayList<>();
-
- @ManyToOne
- @JoinColumn(name = "cba_content_uuid")
- private CbaContent configModelCBA;
-
- public Long getId() {
+ public String getId() {
return id;
}
- public void setId(Long id) {
+ public void setId(String id) {
this.id = id;
}
@@ -283,20 +274,11 @@ public class ConfigModel implements Serializable { this.tags = tags;
}
- public List<ConfigModelContent> getConfigModelContents() {
- return configModelContents;
- }
-
- public void setConfigModelContents(List<ConfigModelContent> configModelContents) {
- this.configModelContents = configModelContents;
+ public BlueprintModelContent getBlueprintModelContent() {
+ return blueprintModelContent;
}
- public CbaContent getConfigModelCBA() {
- return configModelCBA;
- }
-
- public void setConfigModelCBA(CbaContent configModelCBA) {
- this.configModelCBA = configModelCBA;
+ public void setBlueprintModelContent(BlueprintModelContent blueprintModelContent) {
+ this.blueprintModelContent = blueprintModelContent;
}
-
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModelContent.java index 56135471..0bfa0f12 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModelContent.java @@ -1,5 +1,6 @@ /*
* 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.
@@ -16,13 +17,13 @@ package org.onap.ccsdk.apps.controllerblueprints.service.domain;
-import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
+import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
@@ -35,14 +36,13 @@ import java.util.Objects; @EntityListeners({AuditingEntityListener.class})
@Entity
@Table(name = "CONFIG_MODEL_CONTENT")
-public class ConfigModelContent {
+public class BlueprintModelContent implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "config_model_content_id")
- private Long id;
+ private String id;
@Column(name = "name", nullable = false)
@ApiModelProperty(required=true)
@@ -52,28 +52,24 @@ public class ConfigModelContent { @ApiModelProperty(required=true)
private String contentType;
-
- @ManyToOne
+ @OneToOne
@JoinColumn(name = "config_model_id")
- @JsonBackReference
- private ConfigModel configModel;
+ private BlueprintModel blueprintModel;
@Lob
@Column(name = "description")
private String description;
- @Deprecated
@Lob
@Column(name = "content", nullable = false)
@ApiModelProperty(required=true)
- private String content;
-
+ private byte[] content;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
@LastModifiedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updated_date")
- private Date creationDate;
+ private Date creationDate = new Date();
@Override
public String toString() {
@@ -89,12 +85,12 @@ public class ConfigModelContent { if (o == this) {
return true;
}
- if (!(o instanceof ConfigModelContent)) {
+ if (!(o instanceof BlueprintModelContent)) {
return false;
}
- ConfigModelContent configModelContent = (ConfigModelContent) o;
- return Objects.equals(id, configModelContent.id) && Objects.equals(name, configModelContent.name)
- && Objects.equals(contentType, configModelContent.contentType);
+ BlueprintModelContent blueprintModelContent = (BlueprintModelContent) o;
+ return Objects.equals(id, blueprintModelContent.id) && Objects.equals(name, blueprintModelContent.name)
+ && Objects.equals(contentType, blueprintModelContent.contentType);
}
@Override
@@ -102,12 +98,12 @@ public class ConfigModelContent { return Objects.hash(id, name, contentType);
}
- public Long getId() {
+ public String getId() {
return id;
}
- public void setId(Long id) {
+ public void setId(String id) {
this.id = id;
}
@@ -132,13 +128,13 @@ public class ConfigModelContent { }
- public ConfigModel getConfigModel() {
- return configModel;
+ public BlueprintModel getBlueprintModel() {
+ return blueprintModel;
}
- public void setConfigModel(ConfigModel configModel) {
- this.configModel = configModel;
+ public void setBlueprintModel(BlueprintModel blueprintModel) {
+ this.blueprintModel = blueprintModel;
}
@@ -152,12 +148,12 @@ public class ConfigModelContent { }
- public String getContent() {
+ public byte[] getContent() {
return content;
}
- public void setContent(String content) {
+ public void setContent(byte[] content) {
this.content = content;
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModelSearch.java index b6f0f001..8b51bce3 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelSearch.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/BlueprintModelSearch.java @@ -1,5 +1,6 @@ /*
* 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.
@@ -25,13 +26,12 @@ import java.util.Date; @Entity
@Table(name = "CONFIG_MODEL")
-public class ConfigModelSearch implements Serializable {
+public class BlueprintModelSearch implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "config_model_id")
- private Long id;
+ private String id;
@Column(name = "artifact_uuid")
private String artifactUUId;
@@ -68,11 +68,11 @@ public class ConfigModelSearch implements Serializable { @Column(name = "tags", nullable = false)
private String tags;
- public Long getId() {
+ public String getId() {
return id;
}
- public void setId(Long id) {
+ public void setId(String id) {
this.id = id;
}
@@ -159,7 +159,4 @@ public class ConfigModelSearch implements Serializable { public static long getSerialversionuid() {
return serialVersionUID;
}
-
-
-
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/CbaContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/CbaContent.java deleted file mode 100755 index 14ac6af1..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/CbaContent.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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; } - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java index 05f822d5..23d3a977 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java @@ -16,11 +16,11 @@ package org.onap.ccsdk.apps.controllerblueprints.service.domain;
-import javax.persistence.AttributeConverter;
-import javax.persistence.Converter;
-
import com.fasterxml.jackson.databind.JsonNode;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+
+import javax.persistence.AttributeConverter;
+import javax.persistence.Converter;
/**
* @author Brinda Santh
*/
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/BlueprintModelResponse.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/BlueprintModelResponse.java deleted file mode 100755 index 1b67ed82..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/BlueprintModelResponse.java +++ /dev/null @@ -1,78 +0,0 @@ -/*
- * 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.model;
-
-/**
- * BlueprintModelResponse.java Purpose: Model response for Upload CBA service
- *
- */
-public class BlueprintModelResponse {
- private Long id;
- private String name;
- private String version;
- private String description;
- private String cbaUUID;
-
- public BlueprintModelResponse(Long id, String name, String version, String description, String cbaUUID) {
- this.id = id;
- this.name = name;
- this.version = version;
- this.description = description;
- this.cbaUUID = cbaUUID;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getCbaUUID() {
- return cbaUUID;
- }
-
- public void setCbaUUID(String cbaUUID) {
- this.cbaUUID = cbaUUID;
- }
-}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/ItemCbaResponse.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/ItemCbaResponse.java deleted file mode 100755 index 0752df9b..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/ItemCbaResponse.java +++ /dev/null @@ -1,58 +0,0 @@ -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; - } - - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java new file mode 100644 index 00000000..7940c944 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java @@ -0,0 +1,102 @@ +/*
+ * 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.
+ * 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.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * BlueprintModelContentRepository.java Purpose: Provide BlueprintModelContentRepository of Repository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface BlueprintModelContentRepository extends JpaRepository<BlueprintModelContent, String> {
+
+ /**
+ * This is a findById method
+ *
+ * @param id id
+ * @return Optional<AsdcArtifacts>
+ */
+ @NotNull
+ Optional<BlueprintModelContent> findById(@NotNull String id);
+
+ /**
+ * This is a findTopByBlueprintModelAndContentType method
+ *
+ * @param blueprintModel blueprintModel
+ * @param contentType contentType
+ * @return Optional<BlueprintModelContent>
+ */
+ @SuppressWarnings("unused")
+ Optional<BlueprintModelContent> findTopByBlueprintModelAndContentType(BlueprintModel blueprintModel, String contentType);
+
+ /**
+ * This is a findByBlueprintModelAndContentType method
+ *
+ * @param blueprintModel blueprintModel
+ * @param contentType contentType
+ * @return Optional<BlueprintModelContent>
+ */
+ @SuppressWarnings("unused")
+ List<BlueprintModelContent> findByBlueprintModelAndContentType(BlueprintModel blueprintModel, String contentType);
+
+ /**
+ * This is a findByBlueprintModel method
+ *
+ * @param blueprintModel blueprintModel
+ * @return Optional<BlueprintModelContent>
+ */
+ @SuppressWarnings("unused")
+ List<BlueprintModelContent> findByBlueprintModel(BlueprintModel blueprintModel);
+
+ /**
+ * This is a findByBlueprintModelAndContentTypeAndName method
+ *
+ * @param blueprintModel blueprintModel
+ * @param contentType contentType
+ * @param name name
+ * @return Optional<BlueprintModelContent>
+ */
+ @SuppressWarnings("unused")
+ Optional<BlueprintModelContent> findByBlueprintModelAndContentTypeAndName(BlueprintModel blueprintModel,
+ String contentType, String name);
+
+ /**
+ * This is a deleteByMdeleteByBlueprintModelodelName method
+ *
+ * @param blueprintModel blueprintModel
+ */
+ void deleteByBlueprintModel(BlueprintModel blueprintModel);
+
+ /**
+ * This is a deleteById method
+ *
+ * @param id id
+ */
+ void deleteById(@NotNull String id);
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java index 0a60ab74..41316049 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelRepository.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java @@ -1,5 +1,6 @@ /*
* 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.
@@ -16,7 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.repository;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@@ -31,7 +32,7 @@ import java.util.Optional; * @version 1.0
*/
@Repository
-public interface ConfigModelRepository extends JpaRepository<ConfigModel, Long> {
+public interface BlueprintModelRepository extends JpaRepository<BlueprintModel, String> {
/**
* This is a findById method
*
@@ -39,7 +40,7 @@ public interface ConfigModelRepository extends JpaRepository<ConfigModel, Long> * @return Optional<AsdcArtifacts>
*/
@NotNull
- Optional<ConfigModel> findById(@NotNull Long id);
+ Optional<BlueprintModel> findById(@NotNull String id);
/**
* This is a findByArtifactNameAndArtifactVersion method
@@ -48,7 +49,7 @@ public interface ConfigModelRepository extends JpaRepository<ConfigModel, Long> * @param artifactVersion artifactVersion
* @return Optional<AsdcArtifacts>
*/
- Optional<ConfigModel> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);
+ Optional<BlueprintModel> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);
/**
* This is a findTopByArtifactNameOrderByArtifactIdDesc method
@@ -56,7 +57,7 @@ public interface ConfigModelRepository extends JpaRepository<ConfigModel, Long> * @param artifactName artifactName
* @return Optional<AsdcArtifacts>
*/
- Optional<ConfigModel> findTopByArtifactNameOrderByArtifactVersionDesc(String artifactName);
+ Optional<BlueprintModel> findTopByArtifactNameOrderByArtifactVersionDesc(String artifactName);
/**
* This is a findTopByArtifactName method
@@ -65,7 +66,7 @@ public interface ConfigModelRepository extends JpaRepository<ConfigModel, Long> * @return Optional<AsdcArtifacts>
*/
@SuppressWarnings("unused")
- List<ConfigModel> findTopByArtifactName(String artifactName);
+ List<BlueprintModel> findTopByArtifactName(String artifactName);
/**
* This is a findByTagsContainingIgnoreCase method
@@ -73,7 +74,7 @@ public interface ConfigModelRepository extends JpaRepository<ConfigModel, Long> * @param tags tags
* @return Optional<ModelType>
*/
- List<ConfigModel> findByTagsContainingIgnoreCase(String tags);
+ List<BlueprintModel> findByTagsContainingIgnoreCase(String tags);
/**
* This is a deleteByArtifactNameAndArtifactVersion method
@@ -90,6 +91,6 @@ public interface ConfigModelRepository extends JpaRepository<ConfigModel, Long> * @param id id
*/
@SuppressWarnings("unused")
- void deleteById(@NotNull Long id);
+ void deleteById(@NotNull String id);
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java new file mode 100644 index 00000000..ed863563 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java @@ -0,0 +1,69 @@ +/*
+ * 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.
+ * 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.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * BlueprintModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface BlueprintModelSearchRepository extends JpaRepository<BlueprintModelSearch, Long> {
+
+ /**
+ * This is a findById method
+ *
+ * @param id id
+ * @return Optional<BlueprintModelSearch>
+ */
+ @NotNull
+ Optional<BlueprintModelSearch> findById(@NotNull String id);
+
+ /**
+ * This is a findAll method
+ * @return List<BlueprintModelSearch>
+ */
+ @Override
+ List<BlueprintModelSearch> findAll();
+
+ /**
+ * This is a findByArtifactNameAndArtifactVersion method
+ *
+ * @param artifactName artifactName
+ * @param artifactVersion artifactVersion
+ * @return Optional<AsdcArtifacts>
+ */
+ Optional<BlueprintModelSearch> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<BlueprintModelSearch>
+ */
+ List<BlueprintModelSearch> findByTagsContainingIgnoreCase(String tags);
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/CBAContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/CBAContentRepository.java deleted file mode 100755 index 273a19d6..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/CBAContentRepository.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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); -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java deleted file mode 100644 index 81c26373..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java +++ /dev/null @@ -1,102 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.repository;
-
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-import javax.validation.constraints.NotNull;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * ConfigModelContentRepository.java Purpose: Provide ConfigModelContentRepository of Repository
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Deprecated
-@Repository
-public interface ConfigModelContentRepository extends JpaRepository<ConfigModelContent, Long> {
-
- /**
- * This is a findById method
- *
- * @param id id
- * @return Optional<AsdcArtifacts>
- */
- @NotNull
- Optional<ConfigModelContent> findById(@NotNull Long id);
-
- /**
- * This is a findTopByConfigModelAndContentType method
- *
- * @param configModel configModel
- * @param contentType contentType
- * @return Optional<ConfigModelContent>
- */
- @SuppressWarnings("unused")
- Optional<ConfigModelContent> findTopByConfigModelAndContentType(ConfigModel configModel, String contentType);
-
- /**
- * This is a findByConfigModelAndContentType method
- *
- * @param configModel configModel
- * @param contentType contentType
- * @return Optional<ConfigModelContent>
- */
- @SuppressWarnings("unused")
- List<ConfigModelContent> findByConfigModelAndContentType(ConfigModel configModel, String contentType);
-
- /**
- * This is a findByConfigModel method
- *
- * @param configModel configModel
- * @return Optional<ConfigModelContent>
- */
- @SuppressWarnings("unused")
- List<ConfigModelContent> findByConfigModel(ConfigModel configModel);
-
- /**
- * This is a findByConfigModelAndContentTypeAndName method
- *
- * @param configModel configModel
- * @param contentType contentType
- * @param name name
- * @return Optional<ConfigModelContent>
- */
- @SuppressWarnings("unused")
- Optional<ConfigModelContent> findByConfigModelAndContentTypeAndName(ConfigModel configModel,
- String contentType, String name);
-
- /**
- * This is a deleteByMdeleteByConfigModelodelName method
- *
- * @param configModel configModel
- */
- void deleteByConfigModel(ConfigModel configModel);
-
- /**
- * This is a deleteById method
- *
- * @param id id
- */
- void deleteById(@NotNull Long id);
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java deleted file mode 100644 index bafc3aa8..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelSearchRepository.java +++ /dev/null @@ -1,43 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.repository;
-
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelSearch;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-
-/**
- * ConfigModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Repository
-public interface ConfigModelSearchRepository extends JpaRepository<ConfigModelSearch, Long> {
-
-
- /**
- * This is a findByTagsContainingIgnoreCase method
- *
- * @param tags
- * @return Optional<ModelType>
- */
- List<ConfigModel> findByTagsContainingIgnoreCase(String tags);
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/BlueprintModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/BlueprintModelRest.java new file mode 100644 index 00000000..9d0b1e3e --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/BlueprintModelRest.java @@ -0,0 +1,90 @@ +/*
+ * 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.
+ * 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.rs;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.BlueprintModelService;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.Resource;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.codec.multipart.FilePart;
+import org.springframework.web.bind.annotation.*;
+import reactor.core.publisher.Mono;
+
+import java.util.List;
+
+/**
+ * {@inheritDoc}
+ */
+@RestController
+@RequestMapping(value = "/api/v1/blueprint-model")
+public class BlueprintModelRest {
+
+ @Autowired
+ private BlueprintModelService blueprintModelService;
+
+ @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+ public @ResponseBody
+ Mono<BlueprintModelSearch> saveBluePrint(@RequestPart("file") FilePart file) throws BluePrintException{
+ return blueprintModelService.saveBlueprintModel(file);
+ }
+
+ @DeleteMapping(path = "/{id}")
+ public void deleteBluePrint(@PathVariable(value = "id") String id) throws BluePrintException {
+ this.blueprintModelService.deleteBlueprintModel(id);
+ }
+
+ @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ BlueprintModelSearch getBluePrintByNameAndVersion(@PathVariable(value = "name") String name,
+ @PathVariable(value = "version") String version) throws BluePrintException {
+ return this.blueprintModelService.getBlueprintModelByNameAndVersion(name, version);
+ }
+
+ @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ BlueprintModelSearch getCBA(@PathVariable(value = "id") String id) throws BluePrintException {
+ return this.blueprintModelService.getBlueprintModelSearch(id);
+ }
+
+ @GetMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ List<BlueprintModelSearch> getAllCBA() {
+ return this.blueprintModelService.getAllBlueprintModel();
+ }
+
+ @GetMapping(path = "/download/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ ResponseEntity<Resource> downloadBluePrint(@PathVariable(value = "id") String id) throws BluePrintException {
+ return this.blueprintModelService.downloadBlueprintModelFile(id);
+ }
+
+ @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ BlueprintModelSearch publishBlueprintModel(@PathVariable(value = "id") String id) throws BluePrintException {
+ return this.blueprintModelService.publishBlueprintModel(id);
+ }
+
+ @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ List<BlueprintModelSearch> searchBlueprintModels(@PathVariable(value = "tags") String tags) {
+ return this.blueprintModelService.searchBlueprintModels(tags);
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/CbaRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/CbaRest.java deleted file mode 100755 index 4608b175..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/CbaRest.java +++ /dev/null @@ -1,84 +0,0 @@ -/*
- * 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.rs;
-
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.CbaService;
-import org.onap.ccsdk.apps.controllerblueprints.service.model.BlueprintModelResponse;
-import org.onap.ccsdk.apps.controllerblueprints.service.model.ItemCbaResponse;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.Resource;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.http.codec.multipart.FilePart;
-import org.springframework.http.codec.multipart.Part;
-import org.springframework.web.bind.annotation.*;
-import reactor.core.publisher.Flux;
-
-import java.util.List;
-
-/**
- * CbaRest.java Purpose: Provide a REST API to upload single and multiple CBA
- *
- * @author Steve Siani
- * @version 1.0
- */
-@RestController
-@RequestMapping(value = "/api/v1/cba")
-public class CbaRest {
-
- @Autowired
- private CbaService cbaService;
-
- @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
- public Flux<BlueprintModelResponse> uploadCBA(@RequestBody Flux<Part> parts) {
- return parts.filter(part -> part instanceof FilePart) // only retain file parts
- .ofType(FilePart.class) // convert the flux to FilePart
- .flatMap(filePart -> cbaService.uploadCBAFile(filePart)); // save each file and flatmap it to a flux of results
- }
-
- @DeleteMapping(path = "/{id}")
- public void deleteCBA(@PathVariable(value = "id") Long id) throws BluePrintException {
- this.cbaService.deleteCBA(id);
- }
-
- @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ItemCbaResponse getCBA(@PathVariable(value = "id") String id) {
- return this.cbaService.findCBAByID(id);
- }
-
- @GetMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- List<ItemCbaResponse> getAllCBA() {
- return this.cbaService.findAllCBA();
- }
-
- @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ItemCbaResponse getCBAByNameAndVersion(@PathVariable(value = "name") String name,
- @PathVariable(value = "version") String version) throws BluePrintException {
- return this.cbaService.findCBAByNameAndVersion(name, version);
- }
-
- @GetMapping(path = "/download/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ResponseEntity<Resource> downloadCBA(@PathVariable(value = "id") String id) {
- return this.cbaService.downloadCBAFile(id);
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java deleted file mode 100644 index b025b2ff..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java +++ /dev/null @@ -1,95 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * {@inheritDoc}
- */
-@Deprecated
-@RestController
-@RequestMapping(value = "/api/v1/config-model")
-public class ConfigModelRest {
-
- private ConfigModelService configModelService;
-
- /**
- * This is a ConfigModelRest constructor.
- *
- * @param configModelService Config Model Service
- */
- public ConfigModelRest(ConfigModelService configModelService) {
- this.configModelService = configModelService;
-
- }
-
- @GetMapping(path = "/initial/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException {
- return this.configModelService.getInitialConfigModel(name);
- }
-
- @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException {
- return this.configModelService.saveConfigModel(configModel);
- }
-
- @DeleteMapping(path = "/{id}")
- public void deleteConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
- this.configModelService.deleteConfigModel(id);
- }
-
- @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
- return this.configModelService.publishConfigModel(id);
- }
-
- @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
- return this.configModelService.getConfigModel(id);
- }
-
- @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name,
- @PathVariable(value = "version") String version) throws BluePrintException {
- return this.configModelService.getConfigModelByNameAndVersion(name, version);
- }
-
- @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) {
- return this.configModelService.searchConfigModels(tags);
- }
-
- @GetMapping(path = "/clone/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
- return this.configModelService.getCloneConfigModel(id);
- }
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java deleted file mode 100644 index 12ed0a57..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java +++ /dev/null @@ -1,73 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * {@inheritDoc}
- */
-@Deprecated
-//@RestController
-//@RequestMapping(value = "/api/v1/model-type")
-public class ModelTypeRest {
-
- private ModelTypeHandler modelTypeService;
-
- /**
- * This is a ModelTypeResourceImpl, used to save and get the model types stored in database
- *
- * @param modelTypeService Model Type Service
- */
- public ModelTypeRest(ModelTypeHandler modelTypeService) {
- this.modelTypeService = modelTypeService;
- }
-
- @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
- public ModelType getModelTypeByName(@PathVariable(value = "name") String name) {
- return modelTypeService.getModelTypeByName(name);
- }
-
- @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
- public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) {
- return modelTypeService.searchModelTypes(tags);
- }
-
- @GetMapping(path = "/by-definition/{definitionType}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) {
- return modelTypeService.getModelTypeByDefinitionType(definitionType);
- }
-
- @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException {
- return modelTypeService.saveModel(modelType);
- }
-
- @DeleteMapping(path = "/{name}")
- public void deleteModelTypeByName(@PathVariable(value = "name") String name) {
- modelTypeService.deleteByModelName(name);
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java deleted file mode 100644 index 4c34881a..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java +++ /dev/null @@ -1,82 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-
-
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
-import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * {@inheritDoc}
- */
-@Deprecated
-@RestController
-@RequestMapping(value = "/api/v1/service-template")
-public class ServiceTemplateRest {
-
- private ServiceTemplateService serviceTemplateService;
-
- /**
- * This is a ServiceTemplateRest constructor
- *
- * @param serviceTemplateService Service Template Service
- */
- public ServiceTemplateRest(ServiceTemplateService serviceTemplateService) {
- this.serviceTemplateService = serviceTemplateService;
- }
-
- @PostMapping(path = "/enrich", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ServiceTemplate enrichServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {
- return serviceTemplateService.enrichServiceTemplate(serviceTemplate);
- }
-
- @PostMapping(path = "/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ServiceTemplate validateServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {
- return serviceTemplateService.validateServiceTemplate(serviceTemplate);
- }
-
- @PostMapping(path = "/resource-assignment/auto-map", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- AutoMapResponse autoMap(@RequestBody List<ResourceAssignment> resourceAssignments) throws BluePrintException {
- return serviceTemplateService.autoMap(resourceAssignments);
- }
-
- @PostMapping(path = "/resource-assignment/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- List<ResourceAssignment> validateResourceAssignments(@RequestBody List<ResourceAssignment> resourceAssignments)
- throws BluePrintException {
- return serviceTemplateService.validateResourceAssignments(resourceAssignments);
- }
-
- @PostMapping(path = "/resource-assignment/generate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- List<ResourceAssignment> generateResourceAssignments(@RequestBody ConfigModelContent templateContent) {
- return serviceTemplateService.generateResourceAssignments(templateContent);
- }
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CbaStateEnum.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CbaStateEnum.java deleted file mode 100755 index 57785dd8..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CbaStateEnum.java +++ /dev/null @@ -1,15 +0,0 @@ -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; - } -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CloseCondition.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CloseCondition.java deleted file mode 100755 index d7b4aa93..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CloseCondition.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.onap.ccsdk.apps.controllerblueprints.service.utils;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class CloseCondition {
-
- AtomicInteger tasksSubmitted = new AtomicInteger(0);
- AtomicInteger tasksCompleted = new AtomicInteger(0);
- AtomicBoolean allTaskssubmitted = new AtomicBoolean(false);
-
- /**
- * notify all tasks have been subitted, determine of the file channel can be closed
- * @return true if the asynchronous file stream can be closed
- */
- public boolean canCloseOnComplete() {
- allTaskssubmitted.set(true);
- return tasksCompleted.get() == tasksSubmitted.get();
- }
-
- /**
- * notify a task has been submitted
- */
- public void onTaskSubmitted() {
- tasksSubmitted.incrementAndGet();
- }
-
- /**
- * notify a task has been completed
- * @return true if the asynchronous file stream can be closed
- */
- public boolean onTaskCompleted() {
- boolean allSubmittedClosed = tasksSubmitted.get() == tasksCompleted.incrementAndGet();
- return allSubmittedClosed && allTaskssubmitted.get();
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java deleted file mode 100644 index 96931014..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java +++ /dev/null @@ -1,128 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.utils;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.filefilter.DirectoryFileFilter;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-@Deprecated
-public class ConfigModelUtils {
-
- private ConfigModelUtils() {
-
- }
-
- private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelUtils.class);
-
- public static ConfigModel getConfigModel(String blueprintPath) throws Exception {
- Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "Blueprint Path is missing");
- ToscaMetaData toscaMetaData = BluePrintMetadataUtils.Companion.toscaMetaData(blueprintPath);
-
- Preconditions.checkNotNull(toscaMetaData, "failed to get Blueprint Metadata information");
- Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getEntityDefinitions()), "failed to get Blueprint Definition file");
- Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getCreatedBy()), "failed to get Blueprint created by");
- Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getToscaMetaFileVersion()), "failed to get Blueprint package version");
-
- String bluePrintName = FilenameUtils.getBaseName(toscaMetaData.getEntityDefinitions());
- Preconditions.checkArgument(StringUtils.isNotBlank(bluePrintName), "failed to get Blueprint Definition Name");
-
- // TODO - Update Rest of the Model
- ConfigModel configModel = new ConfigModel();
- configModel.setUpdatedBy(toscaMetaData.getCreatedBy());
- configModel.setArtifactName(bluePrintName);
- configModel.setArtifactVersion(toscaMetaData.getToscaMetaFileVersion());
- configModel.setTags(toscaMetaData.getTemplateTags());
- configModel.setArtifactType("SDNC_MODEL");
-
- String blueprintContent =
- getPathContent(blueprintPath + "/" + toscaMetaData.getEntityDefinitions());
-
- Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "failed to get Blueprint content");
-
- List<ConfigModelContent> configModelContents = new ArrayList<>();
- ConfigModelContent stConfigModelContent = new ConfigModelContent();
- stConfigModelContent.setName(configModel.getArtifactName());
- stConfigModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
- stConfigModelContent.setContent(blueprintContent);
- configModelContents.add(stConfigModelContent);
-
- String velocityDir = blueprintPath + "/Templates";
- List<File> velocityTemplateFiles = getFileOfExtension(velocityDir, new String[]{"vtl"});
-
- if (CollectionUtils.isNotEmpty(velocityTemplateFiles)) {
- for (File velocityTemplateFile : velocityTemplateFiles) {
- if (velocityTemplateFile != null) {
- String contentName = velocityTemplateFile.getName().replace(".vtl", "");
- ConfigModelContent velocityConfigModelContent = new ConfigModelContent();
- String velocityConfigContent = getPathContent(velocityTemplateFile);
- velocityConfigModelContent.setName(contentName);
- velocityConfigModelContent
- .setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);
- velocityConfigModelContent.setContent(velocityConfigContent);
- configModelContents.add(velocityConfigModelContent);
- log.info("Loaded blueprint template successfully: {}", velocityTemplateFile.getName());
- }
- }
- }
- configModel.setConfigModelContents(configModelContents);
-
- return configModel;
-
- }
-
- public static String getPathContent(String path) throws IOException {
- Preconditions.checkArgument(StringUtils.isNotBlank(path), "Path is missing");
- return FileUtils.readFileToString(new File(path), Charset.defaultCharset());
- }
-
- public static String getPathContent(File file) throws IOException {
- Preconditions.checkNotNull(file, "File is missing");
- return FileUtils.readFileToString(file, Charset.defaultCharset());
- }
-
- public static List<File> getFileOfExtension(String basePath, String[] extensions) {
- Preconditions.checkArgument(StringUtils.isNotBlank(basePath), "Path is missing");
- Preconditions.checkNotNull(extensions, "Extensions is missing");
- return (List<File>) FileUtils.listFiles(new File(basePath), extensions, true);
- }
-
- public static List<String> getBlueprintNames(String pathName) {
- File blueprintDir = new File(pathName);
- Preconditions.checkNotNull(blueprintDir, "failed to find the blueprint pathName file");
- String[] dirs = blueprintDir.list(DirectoryFileFilter.INSTANCE);
- Preconditions.checkNotNull(dirs, "failed to find the blueprint directories" + blueprintDir.getAbsolutePath());
- return Arrays.asList(dirs);
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java index c5e9e86f..6d02544e 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java @@ -29,8 +29,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationService;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl;
import java.util.HashMap;
import java.util.List;
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPolicyTypeEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPolicyTypeEnhancerImpl.kt index 7a9fbb67..80a84fcd 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPolicyTypeEnhancerImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPolicyTypeEnhancerImpl.kt @@ -16,7 +16,6 @@ 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 diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt index 07ee0a9b..d49bcdff 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt @@ -59,7 +59,7 @@ open class BluePrintCatalogLoadService(private val bluePrintCatalogService: Blue 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}") } diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt index 8cddbb4c..761dd25a 100644..100755 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt @@ -1,5 +1,6 @@ /* * 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. @@ -16,39 +17,59 @@ 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 } @@ -58,9 +79,57 @@ class BluePrintCatalogServiceImpl(private val bluePrintLoadConfiguration: BluePr 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 diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt index 801c22a1..2f18abfd 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt @@ -1,5 +1,6 @@ /* * 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. @@ -23,6 +24,13 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType 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 { @@ -57,5 +65,40 @@ 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) + } } } diff --git a/ms/controllerblueprints/modules/service/src/main/resources/sql/schema-local.sql b/ms/controllerblueprints/modules/service/src/main/resources/sql/schema-local.sql index 47e0cce7..ad5fdd05 100644 --- a/ms/controllerblueprints/modules/service/src/main/resources/sql/schema-local.sql +++ b/ms/controllerblueprints/modules/service/src/main/resources/sql/schema-local.sql @@ -7,7 +7,7 @@ -- table CONFIG_MODEL
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL (
- config_model_id INT(11) NOT NULL AUTO_INCREMENT,
+ config_model_id VARCHAR(100) NOT NULL,
service_uuid VARCHAR(50) NULL DEFAULT NULL,
distribution_id VARCHAR(50) NULL DEFAULT NULL,
service_name VARCHAR(255) NULL DEFAULT NULL,
@@ -36,7 +36,7 @@ CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL ( -- table CONFIG_MODEL_CONTENT
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL_CONTENT (
- config_model_content_id INT(11) NOT NULL AUTO_INCREMENT,
+ config_model_content_id VARCHAR(100) NOT NULL,
config_model_id INT NOT NULL,
name VARCHAR(100) NOT NULL,
content_type VARCHAR(50) NOT NULL,
diff --git a/ms/controllerblueprints/modules/service/src/main/resources/sql/schema.sql b/ms/controllerblueprints/modules/service/src/main/resources/sql/schema.sql index 9c38bec0..015b03b3 100644 --- a/ms/controllerblueprints/modules/service/src/main/resources/sql/schema.sql +++ b/ms/controllerblueprints/modules/service/src/main/resources/sql/schema.sql @@ -2,7 +2,7 @@ -- table CONFIG_MODEL
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL (
- config_model_id INT(11) NOT NULL AUTO_INCREMENT,
+ config_model_id VARCHAR(100) NOT NULL,
service_uuid VARCHAR(50) NULL DEFAULT NULL,
distribution_id VARCHAR(50) NULL DEFAULT NULL,
service_name VARCHAR(255) NULL DEFAULT NULL,
@@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL ( -- table CONFIG_MODEL_CONTENT
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL_CONTENT (
- config_model_content_id INT(11) NOT NULL AUTO_INCREMENT,
+ config_model_content_id VARCHAR(100) NOT NULL,
config_model_id INT NOT NULL,
name VARCHAR(100) NOT NULL,
content_type VARCHAR(50) NOT NULL,
|