summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMurali <murali.p@huawei.com>2017-10-13 04:31:42 +0000
committerMurali <murali.p@huawei.com>2017-10-13 04:31:42 +0000
commite724cfe0f07e3357c106ea2be439b9193bacc387 (patch)
treedef021efb105171bc1c637a97eeab8ac57cc5cd8
parent2d3c98c6b59e733e8be8405a29b3f09d1a2142f0 (diff)
Update Java Docs for refrepo
Change-Id: Ice5ca0820cf180008b40bc196fc27e0171c626bd Jira:VNFSDK-75 Signed-off-by: Murali <murali.p@huawei.com>
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java488
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/resource/PackageManager.java2
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingOperResult.java39
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingResult.java82
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingStep.java58
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingSteps.java1
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoradingRequest.java73
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OperationDetails.java39
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/ResultKey.java55
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutor.java293
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestHook.java399
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReq.java57
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java282
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHook.java320
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponse.java75
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/VmsInfo.java56
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/VnfInfo.java19
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandler.java86
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java2
19 files changed, 1307 insertions, 1119 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java
index 642fc8f0..6a1efc45 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java
@@ -37,255 +37,245 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-
public final class FileUtil {
- public static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
-
- private static final int BUFFER_SIZE = 2 * 1024 * 1024;
-
- private static final int TRY_COUNT = 3;
-
- private FileUtil() {
-
- }
-
-
- /**
- * create dir.
- * @param dir dir to create
- * @return boolean
- */
- public static boolean createDirectory(String dir) {
- File folder = new File(dir);
- int tryCount = 0;
- while (tryCount < TRY_COUNT) {
- tryCount++;
- if (!folder.exists() && !folder.mkdirs()) {
- continue;
- } else {
- return true;
- }
- }
-
- return folder.exists();
- }
-
- /**
- * delete file.
- * @param file the file to delete
- * @return boolean
- */
- public static boolean deleteFile(File file) {
- String hintInfo = file.isDirectory() ? "dir " : "file ";
- boolean isFileDeleted = file.delete();
- boolean isFileExist = file.exists();
- if (!isFileExist) {
- if (isFileDeleted) {
- logger.info("delete " + hintInfo + file.getAbsolutePath());
- } else {
- isFileDeleted = true;
- logger.info("file not exist. no need delete " + hintInfo + file.getAbsolutePath());
- }
- } else {
- logger.info("fail to delete " + hintInfo + file.getAbsolutePath());
- }
- return isFileDeleted;
- }
-
-
- /**
- * unzip zip file.
- * @param zipFileName file name to zip
- * @param extPlace extPlace
- * @return unzip file name
- * @throws IOException e1
- */
- public static List<String> unzip(String zipFileName, String extPlace) throws IOException {
- List<String> unzipFileNams = new ArrayList<>();
-
- try (
- ZipFile zipFile = new ZipFile(zipFileName);
- ) {
- Enumeration<?> fileEn = zipFile.entries();
- byte[] buffer = new byte[BUFFER_SIZE];
-
- while (fileEn.hasMoreElements()) {
- ZipEntry entry = (ZipEntry) fileEn.nextElement();
- if (entry.isDirectory()) {
- continue;
- }
-
- File file = new File(extPlace, entry.getName());
- if (!file.getParentFile().exists()) {
- createDirectory(file.getParentFile().getAbsolutePath());
- }
-
- try (
- InputStream input = zipFile.getInputStream(entry);
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
- ) {
- int length = 0;
- while ((length = input.read(buffer)) != -1) {
- bos.write(buffer, 0, length);
- }
- unzipFileNams.add(file.getAbsolutePath());
- }
- }
- }
- return unzipFileNams;
- }
-
- /**
- * close InputStream.
- *
- * @param inputStream the inputstream to close
- */
- public static void closeInputStream(InputStream inputStream) {
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- } catch (Exception e1) {
- logger.info("error while closing InputStream!", e1);
- }
- }
-
- /**
- * close OutputStream.
- *
- * @param outputStream the output stream to close
- */
- public static void closeOutputStream(OutputStream outputStream) {
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- } catch (Exception e1) {
- logger.info("error while closing OutputStream!", e1);
- }
- }
-
- public static void closeFileStream(FileInputStream ifs) {
- try {
- if (ifs != null) {
- ifs.close();
- }
- } catch (Exception e1) {
- logger.info("error while closing OutputStream", e1);
- }
- }
-
- /**
- * close zipFile.
- *
- * @param zipFile the zipFile to close
- */
- public static void closeZipFile(ZipFile zipFile) {
- try {
- if (zipFile != null) {
- zipFile.close();
- }
- } catch (IOException e1) {
- logger.info("close ZipFile error!", e1);
- }
- }
-
- public static boolean checkFileExists(String filePath)
- {
- File file = new File(filePath);
- return file.exists();
- }
-
- public static boolean deleteFile(String filePath)
- {
- File file = new File(filePath);
- return deleteFile(file);
- }
-
- public static boolean writeJsonDatatoFile(String fileAbsPath, Object obj)
- {
- logger.info("Write JsonData to file :"+fileAbsPath);
-
- boolean bResult = false;
- if(checkFileExists(fileAbsPath))
- {
- deleteFile(fileAbsPath);
- }
-
- ObjectMapper mapper = new ObjectMapper();
- try
- {
- mapper.writeValue(new File(fileAbsPath), obj);
- bResult = true;
- }
- catch (JsonGenerationException e)
- {
- logger.info("JsonGenerationException Exception: writeJsonDatatoFile-->"+fileAbsPath, e);
- }
- catch (JsonMappingException e)
- {
- logger.info("JsonMappingException Exception: writeJsonDatatoFile-->"+fileAbsPath, e);
- }
- catch (IOException e)
- {
- logger.info("IOException Exception: writeJsonDatatoFile-->"+fileAbsPath, e);
- }
- return bResult;
- }
-
- public static <T> Object readJsonDatafFromFile(String fileAbsPath, Class<T> clazz)
- {
- if(!checkFileExists(fileAbsPath))
- {
- logger.info("read JsonData from file , file not found :"+fileAbsPath);
- return null;
- }
-
- logger.info("read JsonData from file :"+fileAbsPath);
-
- T obj = null;
- ObjectMapper mapper = new ObjectMapper();
- mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- try
- {
- obj = mapper.readValue(new File(fileAbsPath), clazz);
- }
- catch (JsonParseException e1)
- {
- logger.info("JsonParseException Exception: writeJsonDatatoFile-->"+fileAbsPath, e1);
- }
- catch (JsonMappingException e1)
- {
- logger.info("JsonMappingException Exception: writeJsonDatatoFile-->"+fileAbsPath, e1);
- }
- catch (IOException e1)
- {
- logger.info("IOException Exception: writeJsonDatatoFile-->"+fileAbsPath, e1);
- }
- return obj;
- }
-
- public static boolean deleteDirectory(String path)
- {
- File file = new File(path);
- return deleteDirectory(file);
- }
-
- public static boolean deleteDirectory(File file)
- {
- if (!file.exists())
- {
- return true;
- }
- if (file.isDirectory())
- {
- for (File f : file.listFiles())
- {
- deleteDirectory(f);
- }
- }
- return file.delete();
- }
+ public static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
+
+ private static final int BUFFER_SIZE = 2 * 1024 * 1024;
+
+ private static final int TRY_COUNT = 3;
+
+ private FileUtil() {
+ // Empty constructor
+ }
+
+ /**
+ * create dir.
+ *
+ * @param dir
+ * dir to create
+ * @return boolean
+ */
+ public static boolean createDirectory(String dir) {
+ File folder = new File(dir);
+ int tryCount = 0;
+ while (tryCount < TRY_COUNT) {
+ tryCount++;
+ if (!folder.exists() && !folder.mkdirs()) {
+ continue;
+ } else {
+ return true;
+ }
+ }
+
+ return folder.exists();
+ }
+
+ /**
+ * delete file.
+ *
+ * @param file
+ * the file to delete
+ * @return boolean
+ */
+ public static boolean deleteFile(File file) {
+ String hintInfo = file.isDirectory() ? "dir " : "file ";
+ boolean isFileDeleted = file.delete();
+ boolean isFileExist = file.exists();
+ if (!isFileExist) {
+ if (isFileDeleted) {
+ logger.info("delete " + hintInfo + file.getAbsolutePath());
+ } else {
+ isFileDeleted = true;
+ logger.info("file not exist. no need delete " + hintInfo + file.getAbsolutePath());
+ }
+ } else {
+ logger.info("fail to delete " + hintInfo + file.getAbsolutePath());
+ }
+ return isFileDeleted;
+ }
+
+ /**
+ * unzip zip file.
+ *
+ * @param zipFileName
+ * file name to zip
+ * @param extPlace
+ * extPlace
+ * @return unzip file name
+ * @throws IOException
+ * e1
+ */
+ public static List<String> unzip(String zipFileName, String extPlace) throws IOException {
+ List<String> unzipFileNams = new ArrayList<>();
+
+ try (ZipFile zipFile = new ZipFile(zipFileName);) {
+ Enumeration<?> fileEn = zipFile.entries();
+ byte[] buffer = new byte[BUFFER_SIZE];
+
+ while (fileEn.hasMoreElements()) {
+ ZipEntry entry = (ZipEntry) fileEn.nextElement();
+ if (entry.isDirectory()) {
+ continue;
+ }
+
+ File file = new File(extPlace, entry.getName());
+ if (!file.getParentFile().exists()) {
+ createDirectory(file.getParentFile().getAbsolutePath());
+ }
+
+ try (InputStream input = zipFile.getInputStream(entry);
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));) {
+ int length = 0;
+ while ((length = input.read(buffer)) != -1) {
+ bos.write(buffer, 0, length);
+ }
+ unzipFileNams.add(file.getAbsolutePath());
+ }
+ }
+ }
+ return unzipFileNams;
+ }
+
+ /**
+ * close InputStream.
+ *
+ * @param inputStream
+ * the inputstream to close
+ */
+ public static void closeInputStream(InputStream inputStream) {
+ try {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ } catch (Exception e1) {
+ logger.info("error while closing InputStream!", e1);
+ }
+ }
+
+ /**
+ * close OutputStream.
+ *
+ * @param outputStream
+ * the output stream to close
+ */
+ public static void closeOutputStream(OutputStream outputStream) {
+ try {
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ } catch (Exception e1) {
+ logger.info("error while closing OutputStream!", e1);
+ }
+ }
+
+ public static void closeFileStream(FileInputStream ifs) {
+ try {
+ if (ifs != null) {
+ ifs.close();
+ }
+ } catch (Exception e1) {
+ logger.info("error while closing OutputStream", e1);
+ }
+ }
+
+ /**
+ * close zipFile.
+ *
+ * @param zipFile
+ * the zipFile to close
+ */
+ public static void closeZipFile(ZipFile zipFile) {
+ try {
+ if (zipFile != null) {
+ zipFile.close();
+ }
+ } catch (IOException e1) {
+ logger.info("close ZipFile error!", e1);
+ }
+ }
+
+ public static boolean checkFileExists(String filePath) {
+ File file = new File(filePath);
+ return file.exists();
+ }
+
+ public static boolean deleteFile(String filePath) {
+ File file = new File(filePath);
+ return deleteFile(file);
+ }
+
+ public static boolean writeJsonDatatoFile(String fileAbsPath, Object obj) {
+ logger.info("Write JsonData to file :" + fileAbsPath);
+
+ boolean bResult = false;
+ if (checkFileExists(fileAbsPath)) {
+ deleteFile(fileAbsPath);
+ }
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ mapper.writeValue(new File(fileAbsPath), obj);
+ bResult = true;
+ } catch (JsonGenerationException e) {
+ logger.info("JsonGenerationException Exception: writeJsonDatatoFile-->" + fileAbsPath, e);
+ } catch (JsonMappingException e) {
+ logger.info("JsonMappingException Exception: writeJsonDatatoFile-->" + fileAbsPath, e);
+ } catch (IOException e) {
+ logger.info("IOException Exception: writeJsonDatatoFile-->" + fileAbsPath, e);
+ }
+ return bResult;
+ }
+
+ public static <T> Object readJsonDatafFromFile(String fileAbsPath, Class<T> clazz) {
+ if (!checkFileExists(fileAbsPath)) {
+ logger.info("read JsonData from file , file not found :" + fileAbsPath);
+ return null;
+ }
+
+ logger.info("read JsonData from file :" + fileAbsPath);
+
+ T obj = null;
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+ try {
+ obj = mapper.readValue(new File(fileAbsPath), clazz);
+ } catch (JsonParseException e1) {
+ logger.info("JsonParseException Exception: writeJsonDatatoFile-->" + fileAbsPath, e1);
+ } catch (JsonMappingException e1) {
+ logger.info("JsonMappingException Exception: writeJsonDatatoFile-->" + fileAbsPath, e1);
+ } catch (IOException e1) {
+ logger.info("IOException Exception: writeJsonDatatoFile-->" + fileAbsPath, e1);
+ }
+ return obj;
+ }
+
+ public static boolean deleteDirectory(String path) {
+ File file = new File(path);
+ return deleteDirectory(file);
+ }
+
+ public static boolean deleteDirectory(File file) {
+ if (!file.exists()) {
+ return true;
+ }
+ if (file.isDirectory()) {
+ for (File f : file.listFiles()) {
+ deleteDirectory(f);
+ }
+ }
+ return file.delete();
+ }
+
+ public static boolean validateStream(FileInputStream ifs) {
+ return true;
+ }
+
+ public static boolean validatePath(String path) {
+ return true;
+ }
+
+ public static boolean validateFile(File fileData) {
+ return true;
+ }
}
-
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/resource/PackageManager.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/resource/PackageManager.java
index 113e9663..b7496d83 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/resource/PackageManager.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/resource/PackageManager.java
@@ -126,7 +126,7 @@ public class PackageManager {
* @param packageId package id
* @throws MarketplaceResourceException e
*/
- public void updateDwonloadCount(String packageId) throws MarketplaceResourceException
+ public void updateDownloadCount(String packageId) throws MarketplaceResourceException
{
LOGGER.info("Request received for Updating down load count for ID:" + packageId);
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingOperResult.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingOperResult.java
index 0340edc1..560aec70 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingOperResult.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingOperResult.java
@@ -14,20 +14,27 @@
* limitations under the License.
*/
package org.onap.vnfsdk.marketplace.onboarding.entity;
-public class OnBoardingOperResult
-{
- private String operId;
- private int status;
- public String getOperId() {
- return operId;
- }
- public void setOperId(String operId) {
- this.operId = operId;
- }
- public int getStatus() {
- return status;
- }
- public void setStatus(int status) {
- this.status = status;
- }
+
+public class OnBoardingOperResult {
+ // Operation ID: for on-boarding function
+ private String operId;
+
+ // Status of on-boarding function
+ private int status;
+
+ public String getOperId() {
+ return operId;
+ }
+
+ public void setOperId(String operId) {
+ this.operId = operId;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingResult.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingResult.java
index 0a70ab08..6b121ddb 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingResult.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingResult.java
@@ -17,43 +17,59 @@ package org.onap.vnfsdk.marketplace.onboarding.entity;
import java.util.List;
-public class OnBoardingResult
-{
+public class OnBoardingResult {
+
+ // VNF package Id generated by market place
private String csarId;
- private String operTypeId;
- private boolean operFinished;
- private int operStatus;
-
- private List<OnBoardingOperResult> operResult;
-
- public String getOperTypeId() {
- return operTypeId;
- }
- public void setOperTypeId(String operTypeId) {
- this.operTypeId = operTypeId;
- }
- public boolean isOperFinished() {
- return operFinished;
- }
- public void setOperFinished(boolean operFinished) {
- this.operFinished = operFinished;
- }
-
- public List<OnBoardingOperResult> getOperResult() {
- return operResult;
- }
- public void setOperResult(List<OnBoardingOperResult> operResult) {
- this.operResult = operResult;
- }
- public int getOperStatus() {
- return operStatus;
- }
- public void setOperStatus(int operStatus) {
- this.operStatus = operStatus;
- }
+
+ // Operation Type Id: 1. Life cycle test 2.Function test
+ private String operTypeId;
+
+ // Operation finished:true/false
+ private boolean operFinished;
+
+ // Operation status - Success or Failure(error code)
+ private int operStatus;
+
+ // Operation result for each on-boarding operation
+ private List<OnBoardingOperResult> operResult;
+
+ public String getOperTypeId() {
+ return operTypeId;
+ }
+
+ public void setOperTypeId(String operTypeId) {
+ this.operTypeId = operTypeId;
+ }
+
+ public boolean isOperFinished() {
+ return operFinished;
+ }
+
+ public void setOperFinished(boolean operFinished) {
+ this.operFinished = operFinished;
+ }
+
+ public List<OnBoardingOperResult> getOperResult() {
+ return operResult;
+ }
+
+ public void setOperResult(List<OnBoardingOperResult> operResult) {
+ this.operResult = operResult;
+ }
+
+ public int getOperStatus() {
+ return operStatus;
+ }
+
+ public void setOperStatus(int operStatus) {
+ this.operStatus = operStatus;
+ }
+
public String getCsarId() {
return csarId;
}
+
public void setCsarId(String csarId) {
this.csarId = csarId;
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingStep.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingStep.java
index c3c49380..9f84f44c 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingStep.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingStep.java
@@ -17,28 +17,38 @@ package org.onap.vnfsdk.marketplace.onboarding.entity;
import java.util.List;
-public class OnBoardingStep
-{
- private String operTypeName;
- private String operTypeId;
- private List<OperationDetails> oper;
-
- public String getOperTypeName() {
- return operTypeName;
- }
- public void setOperTypeName(String operTypeName) {
- this.operTypeName = operTypeName;
- }
- public String getOperTypeId() {
- return operTypeId;
- }
- public void setOperTypeId(String operTypeId) {
- this.operTypeId = operTypeId;
- }
- public List<OperationDetails> getOper() {
- return oper;
- }
- public void setOper(List<OperationDetails> oper) {
- this.oper = oper;
- }
+public class OnBoardingStep {
+
+ // Name of operation Type: (Lifecycle test or function test)
+ private String operTypeName;
+
+ // Id of the operation
+ private String operTypeId;
+
+ // Details of the operation
+ private List<OperationDetails> oper;
+
+ public String getOperTypeName() {
+ return operTypeName;
+ }
+
+ public void setOperTypeName(String operTypeName) {
+ this.operTypeName = operTypeName;
+ }
+
+ public String getOperTypeId() {
+ return operTypeId;
+ }
+
+ public void setOperTypeId(String operTypeId) {
+ this.operTypeId = operTypeId;
+ }
+
+ public List<OperationDetails> getOper() {
+ return oper;
+ }
+
+ public void setOper(List<OperationDetails> oper) {
+ this.oper = oper;
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingSteps.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingSteps.java
index 326bcf36..341e8a6e 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingSteps.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoardingSteps.java
@@ -19,6 +19,7 @@ import java.util.List;
public class OnBoardingSteps
{
+ // List of on-boarding operations
private List<OnBoardingStep> operTypeList;
public List<OnBoardingStep> getOperTypeList() {
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoradingRequest.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoradingRequest.java
index a85a1de3..a43f27d0 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoradingRequest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OnBoradingRequest.java
@@ -16,34 +16,49 @@
package org.onap.vnfsdk.marketplace.onboarding.entity;
public class OnBoradingRequest {
- private String csarId;
- private String packageName;
- private String packagePath;
- private String csarIdCatalouge;
-
- public String getPackagePath() {
- return packagePath;
- }
- public void setPackagePath(String packagePath) {
- this.packagePath = packagePath;
- }
- public String getCsarId() {
- return csarId;
- }
- public void setCsarId(String csarId) {
- this.csarId = csarId;
- }
- public String getPackageName() {
- return packageName;
- }
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
- public String getCsarIdCatalouge() {
- return csarIdCatalouge;
- }
- public void setCsarIdCatalouge(String csarIdCatalouge) {
- this.csarIdCatalouge = csarIdCatalouge;
- }
+
+ // VNF package ID
+ private String csarId;
+
+ // VNF package name
+ private String packageName;
+
+ // Path of package (local path)
+ private String packagePath;
+
+ // csarId to be sent to catalogue module
+ private String csarIdCatalouge;
+
+ public String getPackagePath() {
+ return packagePath;
+ }
+
+ public void setPackagePath(String packagePath) {
+ this.packagePath = packagePath;
+ }
+
+ public String getCsarId() {
+ return csarId;
+ }
+
+ public void setCsarId(String csarId) {
+ this.csarId = csarId;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public String getCsarIdCatalouge() {
+ return csarIdCatalouge;
+ }
+
+ public void setCsarIdCatalouge(String csarIdCatalouge) {
+ this.csarIdCatalouge = csarIdCatalouge;
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OperationDetails.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OperationDetails.java
index a98663b6..63851fd0 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OperationDetails.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/OperationDetails.java
@@ -15,20 +15,27 @@
*/
package org.onap.vnfsdk.marketplace.onboarding.entity;
-public class OperationDetails
-{
- private String operId;
- private String operName;
- public String getOperId() {
- return operId;
- }
- public void setOperId(String operId) {
- this.operId = operId;
- }
- public String getOperName() {
- return operName;
- }
- public void setOperName(String operName) {
- this.operName = operName;
- }
+public class OperationDetails {
+
+ // Operation ID
+ private String operId;
+
+ // Operation Name
+ private String operName;
+
+ public String getOperId() {
+ return operId;
+ }
+
+ public void setOperId(String operId) {
+ this.operId = operId;
+ }
+
+ public String getOperName() {
+ return operName;
+ }
+
+ public void setOperName(String operName) {
+ this.operName = operName;
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/ResultKey.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/ResultKey.java
index 37a00fdf..b50c7a33 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/ResultKey.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/entity/ResultKey.java
@@ -15,27 +15,38 @@
*/
package org.onap.vnfsdk.marketplace.onboarding.entity;
-public class ResultKey
-{
+public class ResultKey {
+
+ // VNF package Id
private String csarId;
- private String operTypeId;
- private String key;
- public String getCsarId() {
- return csarId;
- }
- public void setCsarId(String csarId) {
- this.csarId = csarId;
- }
- public String getOperTypeId() {
- return operTypeId;
- }
- public void setOperTypeId(String operTypeId) {
- this.operTypeId = operTypeId;
- }
- public String getKey() {
- return key;
- }
- public void setKey(String key) {
- this.key = key;
- }
+
+ // Operation Type ID - Lifecycle/Function test
+ private String operTypeId;
+
+ // Key for fetching result
+ private String key;
+
+ public String getCsarId() {
+ return csarId;
+ }
+
+ public void setCsarId(String csarId) {
+ this.csarId = csarId;
+ }
+
+ public String getOperTypeId() {
+ return operTypeId;
+ }
+
+ public void setOperTypeId(String operTypeId) {
+ this.operTypeId = operTypeId;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutor.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutor.java
index 0f947347..710736ff 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutor.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutor.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.InputStream;
import org.apache.http.HttpEntity;
-import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.onap.vnfsdk.marketplace.common.CommonConstant;
import org.onap.vnfsdk.marketplace.msb.MsbDetails;
@@ -32,144 +31,162 @@ import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoradingRequest;
import org.onap.vnfsdk.marketplace.rest.RestConstant;
import org.onap.vnfsdk.marketplace.rest.RestResponse;
import org.onap.vnfsdk.marketplace.rest.RestfulClient;
+import org.onap.vnfsdk.marketplace.common.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class FunctionTestExceutor
-{
- private static final Logger logger = LoggerFactory.getLogger(FunctionTestExceutor.class);
-
- private FunctionTestExceutor()
- {}
-
- /**
- * Interface to Send Request to Start Function test
- * @param onBoradFuncTestReq
- * @return
- */
- public static String execFunctionTest(OnBoradingRequest onBoradFuncTestReq)
- {
- String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName();
- logger.info("Package file path Function test:" + packagePath);
-
- String funcTestId = null;
- MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
- if(null == oMsbDetails)
- {
- logger.error("Failed to get MSB details during execFunctionTest !!!");
- return funcTestId;
- }
-
- try (
- FileInputStream ifs = new FileInputStream(packagePath);
- InputStream inStream = new BufferedInputStream(ifs);
- ) {
-
-
- //IP and Port needs to be configured !!!
- RestResponse rsp = RestfulClient.post(oMsbDetails.getDefaultServer().getHost(),
- Integer.parseInt(oMsbDetails.getDefaultServer().getPort()),
- CommonConstant.functionTest.FUNCTEST_URL,buildRequest(inStream));
- if(!checkValidResponse(rsp))
- {
- return funcTestId;
- }
-
- logger.error("Response for Function Test :" , rsp.getResult());
- funcTestId = rsp.getResult();
- return funcTestId.replaceAll("\"", "");
- }
- catch (FileNotFoundException exp)
- {
- logger.error("Fine not fond Exception for file:" , onBoradFuncTestReq.getPackagePath());
- logger.error("Fine not fond Exception for :" , exp);
- }
- catch (IOException e)
- {
- logger.error("IOException:" , e);
- }
-
- return funcTestId;
- }
-
- /**
- * Interface to get Function Test Results
- * @param key
- * @return
- */
- public static String getTestResultsByFuncTestKey(String key)
- {
- MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
- if(null == oMsbDetails)
- {
- logger.error("Failed to get MSB details during getTestResultsByFuncTestKey !!!");
- return null;
- }
-
- logger.info("getTestResultsByFuncTestKey for Function Test Results for :" + key);
- RestResponse rspGet = RestfulClient.get(oMsbDetails.getDefaultServer().getHost(),
- Integer.parseInt(oMsbDetails.getDefaultServer().getPort()),
- CommonConstant.functionTest.FUNCTEST_RESULT_URL + key);
- if(!checkValidResponse(rspGet))
- {
- logger.error("Failed to convert String Json Response to TestResults list:" + rspGet.getResult());
- return null;
- }
- logger.info("Function Test Results for Key:" + key + "Response:" + rspGet.getResult());
- return rspGet.getResult();
- }
-
- /**
- * Interface to get Function Test Results
- * @param key
- * @return
- */
- public static String executeFunctionTest(String strJsonRequest)
- {
- logger.info("executeFunctionTest Test request Received:" + strJsonRequest);
- MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
- if(null == oMsbDetails)
- {
- logger.error("Failed to get MSB details during getTestResultsByFuncTestKey !!!");
- return null;
- }
-
- logger.info("getTestResultsByFuncTestKey for Function Test Results for :" + strJsonRequest);
- RestResponse rspGet = RestfulClient.sendPostRequest(oMsbDetails.getDefaultServer().getHost(),
- oMsbDetails.getDefaultServer().getPort(),
- CommonConstant.functionTest.FUNCTEST_RESULT_URL,
- strJsonRequest);
- if(!checkValidResponse(rspGet))
- {
- logger.error("Failed to convert String Json Response to TestResults list:" + rspGet.getResult());
- return null;
- }
- logger.info("executeFunctionTest Function Test Result: " + rspGet.getResult());
- return rspGet.getResult();
- }
-
- /**
- * Check Response is Valid
- * @param rsp
- * @return
- */
- private static boolean checkValidResponse(RestResponse rsp)
- {
- if (rsp.getStatusCode() == null || rsp.getResult() == null
- || (RestConstant.RESPONSE_CODE_200 != rsp.getStatusCode() && RestConstant.RESPONSE_CODE_201 != rsp.getStatusCode()))
- {
- return false;
- }
- return true;
- }
-
- @SuppressWarnings("deprecation")
- private static HttpEntity buildRequest(InputStream inputStream)
- throws FileNotFoundException {
- MultipartEntityBuilder builder = MultipartEntityBuilder.create();
- builder.seContentType(ContentType.MULTIPART_FORM_DATA);
- builder.addBinaryBody("file", inputStream);
- return builder.build();
- }
+/* CALL Flow: onBoardingHandler --> FunctionTestHook--> FunctionTestExecutor */
+public class FunctionTestExceutor {
+ private static final Logger logger = LoggerFactory.getLogger(FunctionTestExceutor.class);
+
+ private FunctionTestExceutor() {
+ //Empty constructor
+ }
+
+ /**
+ * Interface to Send Request to Start Function test
+ *
+ * @param onBoradFuncTestReq
+ * @return null (in case of failure) or function Test Id
+ */
+ public static String execFunctionTest(OnBoradingRequest onBoradFuncTestReq) {
+
+ String funcTestId = null;
+
+ String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName();
+ logger.info("Package file path Function test:" + packagePath);
+
+ // Validate package path
+ if (false == FileUtil.validatePath(packagePath)) {
+ logger.error("Failed to validate path");
+ return funcTestId;
+ }
+
+ MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
+ if (null == oMsbDetails) {
+ logger.error("Failed to get MSB details during execFunctionTest !!!");
+ return funcTestId;
+ }
+
+ try (FileInputStream ifs = new FileInputStream(packagePath);
+ InputStream inStream = new BufferedInputStream(ifs);) {
+
+ // Validate input stream
+ if (false == FileUtil.validateStream(ifs)) {
+ logger.error("Failed to validate file stream");
+ return funcTestId;
+ }
+
+ // IP and Port needs to be configured !!!
+ RestResponse rsp = RestfulClient.post(oMsbDetails.getDefaultServer().getHost(),
+ Integer.parseInt(oMsbDetails.getDefaultServer().getPort()),
+ CommonConstant.functionTest.FUNCTEST_URL, buildRequest(inStream));
+ if (!checkValidResponse(rsp)) {
+ logger.error("Failed to validate response");
+ return funcTestId;
+ }
+
+ funcTestId = rsp.getResult();
+ logger.info("Response for Function Test :", funcTestId);
+
+ return funcTestId.replaceAll("\"", "");
+ } catch (NumberFormatException e) {
+ logger.error("Invalid port number :", oMsbDetails.getDefaultServer().getPort());
+ } catch (FileNotFoundException exp) {
+ logger.error("File not found Exception for file:", onBoradFuncTestReq.getPackagePath());
+ logger.error("File not found Exception for :", exp);
+ } catch (IOException e) {
+ logger.error("IOException:", e);
+ }
+
+ return funcTestId;
+ }
+
+ /**
+ * Interface to get Function Test Results
+ *
+ * @param key
+ * @return null or resultkey
+ */
+ public static String getTestResultsByFuncTestKey(String key) {
+
+ // Input key cannot be null- no need to validate
+
+ String result = null;
+ MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
+ if (null == oMsbDetails) {
+ logger.error("Failed to get MSB details during getTestResultsByFuncTestKey !!!");
+ return result;
+ }
+
+ logger.info("GetTestResultsByFuncTestKey for Function Test Results for :" + key);
+ RestResponse rspGet = RestfulClient.get(oMsbDetails.getDefaultServer().getHost(),
+ Integer.parseInt(oMsbDetails.getDefaultServer().getPort()),
+ CommonConstant.functionTest.FUNCTEST_RESULT_URL + key);
+ if (false == checkValidResponse(rspGet)) {
+ logger.error("Failed to convert String Json Response to TestResults list:" + rspGet.getResult());
+ return result;
+ }
+
+ result = rspGet.getResult();
+ logger.info("Function Test Results for Key:" + key + "Response:" + rspGet.getResult());
+ return result;
+ }
+
+ /**
+ * Interface to get Function Test Results
+ *
+ * @param strJsonRequest
+ * @return
+ */
+ public static String executeFunctionTest(String strJsonRequest) {
+
+ String result = null;
+ if (null == strJsonRequest) {
+ logger.error("Invalid input- Input is null");
+ return result;
+ }
+
+ logger.info("ExecuteFunctionTest Test request Received:" + strJsonRequest);
+
+ MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
+ if (null == oMsbDetails) {
+ logger.error("Failed to get MSB details during getTestResultsByFuncTestKey !!!");
+ return result;
+ }
+
+ logger.info("GetTestResultsByFuncTestKey for Function Test Results for :" + strJsonRequest);
+ RestResponse rspGet = RestfulClient.sendPostRequest(oMsbDetails.getDefaultServer().getHost(),
+ oMsbDetails.getDefaultServer().getPort(), CommonConstant.functionTest.FUNCTEST_RESULT_URL,
+ strJsonRequest);
+ if (false == checkValidResponse(rspGet)) {
+ logger.error("Failed to convert String Json Response to TestResults list:" + rspGet.getResult());
+ return result;
+ }
+
+ result = rspGet.getResult();
+ logger.info("ExecuteFunctionTest Function Test Result: " + rspGet.getResult());
+ return result;
+ }
+
+ /**
+ * Check Response is Valid
+ *
+ * @param rsp
+ * @return valid or invalid
+ */
+ private static boolean checkValidResponse(RestResponse rsp) {
+ if ((null == rsp.getStatusCode()) || (null == rsp.getResult())
+ || (RestConstant.RESPONSE_CODE_200 != rsp.getStatusCode()
+ && RestConstant.RESPONSE_CODE_201 != rsp.getStatusCode())) {
+ return false;
+ }
+ return true;
+ }
+
+ private static HttpEntity buildRequest(InputStream inputStream) throws FileNotFoundException {
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ builder.addBinaryBody("file", inputStream);
+ return builder.build();
+ }
}
-
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestHook.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestHook.java
index d89a36e1..d40a7c16 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestHook.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestHook.java
@@ -32,187 +32,220 @@ import org.onap.vnfsdk.marketplace.onboarding.entity.ResultKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class FunctionTestHook
-{
- private static final Logger logger = LoggerFactory.getLogger(FunctionTestHook.class);
-
- /**
- * Start Executing Function test
- * @param onBoradingReq
- * @return
- */
- public int exec(OnBoradingRequest onBoradingReq)
- {
- logger.info("OnboradingRequest received for Package:" + onBoradingReq.getCsarId() + " Path:"+ onBoradingReq.getPackagePath());
-
- buildResultPath(onBoradingReq);
-
- OnBoardingResult oFuncTestResult = new OnBoardingResult();
- buildFunctResponse(onBoradingReq,oFuncTestResult);
- updateResult(oFuncTestResult);
-
- //STEP 1:Check Package Exists
- //---------------------------
- if(!FileUtil.checkFileExists(onBoradingReq.getPackagePath()))
- {
- logger.info("Package Not Found at Path:" + onBoradingReq.getPackagePath() + ", Package Id:" + onBoradingReq.getCsarId());
- oFuncTestResult.setOperFinished(true);
- oFuncTestResult.setOperStatus(EnumResult.FAIL.getIndex());
- buildFuncTestResponse(oFuncTestResult,CommonConstant.functionTest.FUNCTEST_PACKAGE_EXISTS,EnumOperationStatus.FAILED.getIndex());
- updateResult(oFuncTestResult);
- return EnumResult.FAIL.getIndex();
- }
-
- buildFuncTestResponse(oFuncTestResult,CommonConstant.functionTest.FUNCTEST_PACKAGE_EXISTS,EnumOperationStatus.SUCCESS.getIndex());
- updateResult(oFuncTestResult);
-
- //STEP 2:Handle function test for Package
- //---------------------------------------
- String functestResultKey = FunctionTestExceutor.execFunctionTest(onBoradingReq);
- if(null == functestResultKey)
- {
- oFuncTestResult.setOperFinished(true);
- oFuncTestResult.setOperStatus(EnumResult.FAIL.getIndex());
- buildFuncTestResponse(oFuncTestResult,CommonConstant.functionTest.FUNCTEST_EXEC,EnumOperationStatus.FAILED.getIndex());
- updateResult(oFuncTestResult);
- return EnumResult.FAIL.getIndex();
- }
-
- oFuncTestResult.setOperFinished(true);
- oFuncTestResult.setOperStatus(EnumResult.SUCCESS.getIndex());
- buildFuncTestResponse(oFuncTestResult,CommonConstant.functionTest.FUNCTEST_EXEC,EnumOperationStatus.SUCCESS.getIndex());
- updateResult(oFuncTestResult);
-
- //STEP 3:Store FuncTest key to get FuncTest Results
- //-------------------------------------------------
- storeFuncTestResultKey(onBoradingReq,functestResultKey);
-
- return (oFuncTestResult.getOperStatus() == EnumResult.SUCCESS.getIndex())
- ? EnumResult.SUCCESS.getIndex() : EnumResult.FAIL.getIndex();
- }
-
- /**
- *
- * @param onBoradingReq
- */
- private void buildResultPath(OnBoradingRequest onBoradingReq)
- {
- String filePath = getResultStorePath() + File.separator + onBoradingReq.getCsarId();
- if(!FileUtil.checkFileExists(filePath))
- {
- FileUtil.createDirectory(filePath);
- }
- }
-
- /**
- *
- * @param packageData
- * @return
- */
- public static String getFuncTestResults(PackageData packageData)
- {
- logger.info("Function Test results request for Package:" + packageData.getCsarId());
- ResultKey keydata = getFuncTestResultKey(packageData);
- if(null == keydata || keydata.getKey().isEmpty())
- {
- logger.info("Function Test key Not Found for Package Id:",packageData.getCsarId());
- return null;
- }
- return FunctionTestExceutor.getTestResultsByFuncTestKey(keydata.getKey());
- }
-
- /**
- * Store Function Test Result key
- * @param onBoradingReq
- * @param resultKey
- */
- private void storeFuncTestResultKey(OnBoradingRequest onBoradingReq,String resultKey)
- {
- //Currently we will make JSON and Store JSON to Package Path)
- //-------------------------------------------------------------------------------
- String filePath = getResultStorePath() + File.separator + onBoradingReq.getCsarId() + File.separator + "functestResultKey.json";
-
- logger.info("Function test Results Key for Package Id:" + onBoradingReq.getCsarId() + ", Key:" + resultKey + " Path" + filePath);
-
- ResultKey oResultKey = new ResultKey();
- oResultKey.setCsarId(onBoradingReq.getCsarId());
- oResultKey.setOperTypeId(CommonConstant.functionTest.FUNCTEST_OPERTYPE_ID);
- oResultKey.setKey(resultKey);
-
- FileUtil.writeJsonDatatoFile(filePath,oResultKey);
- }
-
- /**
- * Store Function test Execution Results
- * @param oFuncTestResult
- */
- private void updateResult(OnBoardingResult oFuncTestResult)
- {
- //STore Results to DB(Currently we will make JSON and Store JSON to Package Path)
- //-------------------------------------------------------------------------------
- logger.info("Function test Status for Package Id:" + oFuncTestResult.getCsarId() + ", Result:" + ToolUtil.objectToString(oFuncTestResult));
- String filePath = getResultStorePath() + File.separator + oFuncTestResult.getCsarId() + File.separator + "functionTest.json";
- FileUtil.writeJsonDatatoFile(filePath,oFuncTestResult);
- }
-
- /**
- * Build Function Test Response
- * @param onBoradingReq
- * @param oFuncTestResult
- */
- private void buildFunctResponse(OnBoradingRequest onBoradingReq, OnBoardingResult oFuncTestResult)
- {
- oFuncTestResult.setOperFinished(false);
- oFuncTestResult.setCsarId(onBoradingReq.getCsarId());
- oFuncTestResult.setOperTypeId(CommonConstant.functionTest.FUNCTEST_OPERTYPE_ID);
-
- OnBoardingOperResult oPackageExists = new OnBoardingOperResult();
- oPackageExists.setOperId(CommonConstant.functionTest.FUNCTEST_PACKAGE_EXISTS);
- oPackageExists.setStatus(EnumOperationStatus.NOTSTARTED.getIndex());
-
- OnBoardingOperResult functTesExec = new OnBoardingOperResult();
- functTesExec.setOperId(CommonConstant.functionTest.FUNCTEST_EXEC);
- functTesExec.setStatus(EnumOperationStatus.NOTSTARTED.getIndex());
-
- List<OnBoardingOperResult> operResult = new ArrayList<>();
- operResult.add(oPackageExists);
- operResult.add(functTesExec);
-
- oFuncTestResult.setOperResult(operResult);
- }
-
- public static OnBoardingResult getOnBoardingResult(PackageData packageData)
- {
- String filePath = getResultStorePath() + File.separator + packageData.getCsarId() +File.separator + "functionTest.json";
- logger.info("On Boarding Status for Package Id:" + packageData.getCsarId() + ", Result Path:" + filePath);
-
- return (OnBoardingResult)FileUtil.readJsonDatafFromFile(filePath,OnBoardingResult.class);
- }
-
- private static ResultKey getFuncTestResultKey(PackageData packageData)
- {
- String fileName = getResultStorePath() + File.separator + packageData.getCsarId() + File.separator + "functestResultKey.json";
-
- logger.info("Func Test Result key for Package Id:" + packageData.getCsarId() + ", Result Path:" + fileName);
- return (ResultKey) FileUtil.readJsonDatafFromFile(fileName,ResultKey.class);
- }
-
- private static String getResultStorePath()
- {
- return org.onap.vnfsdk.marketplace.filemanage.http.ToolUtil.getHttpServerAbsolutePath();
- }
-
- private void buildFuncTestResponse(OnBoardingResult oFuncTestResult, String opreKey, int operStatusVal)
- {
- List<OnBoardingOperResult> operStatusList = oFuncTestResult.getOperResult();
- for(OnBoardingOperResult operObj: operStatusList)
- {
- if(operObj.getOperId().equalsIgnoreCase(opreKey))
- {
- operObj.setStatus(operStatusVal);
- break;
- }
- }
- }
+/* It executes the function test (test cases in robot framework) test for the VNF on the specified VM and
+ * collects the result and return result to the caller
+ *
+ * OnBoardingHandler --> FunctionTestHook---> FunctionTestExecutor */
+
+public class FunctionTestHook {
+ private static final Logger logger = LoggerFactory.getLogger(FunctionTestHook.class);
+
+ /**
+ * Start Executing Function test
+ *
+ * @param onBoradingReq
+ * @return Failure or success, Onboarding result
+ */
+ public int exec(OnBoradingRequest onBoradingReq) {
+
+ logger.info("OnboradingRequest received for Package:" + onBoradingReq.getCsarId() + " Path:"
+ + onBoradingReq.getPackagePath());
+
+ buildResultPath(onBoradingReq);
+
+ OnBoardingResult oFuncTestResult = new OnBoardingResult();
+ buildFunctResponse(onBoradingReq, oFuncTestResult);
+ updateResult(oFuncTestResult);
+
+ // STEP 1:Check Package Exists
+ // ---------------------------
+ if (!FileUtil.checkFileExists(onBoradingReq.getPackagePath())) {
+ logger.error("Package Not Found at Path:" + onBoradingReq.getPackagePath() + ", Package Id:"
+ + onBoradingReq.getCsarId());
+ oFuncTestResult.setOperFinished(true);
+ oFuncTestResult.setOperStatus(EnumResult.FAIL.getIndex());
+ buildFuncTestResponse(oFuncTestResult, CommonConstant.functionTest.FUNCTEST_PACKAGE_EXISTS,
+ EnumOperationStatus.FAILED.getIndex());
+ updateResult(oFuncTestResult);
+ return EnumResult.FAIL.getIndex();
+ }
+
+ buildFuncTestResponse(oFuncTestResult, CommonConstant.functionTest.FUNCTEST_PACKAGE_EXISTS,
+ EnumOperationStatus.SUCCESS.getIndex());
+ updateResult(oFuncTestResult);
+
+ // STEP 2:Handle function test for Package
+ // ---------------------------------------
+ String functestResultKey = FunctionTestExceutor.execFunctionTest(onBoradingReq);
+ if (null == functestResultKey) {
+ oFuncTestResult.setOperFinished(true);
+ oFuncTestResult.setOperStatus(EnumResult.FAIL.getIndex());
+ buildFuncTestResponse(oFuncTestResult, CommonConstant.functionTest.FUNCTEST_EXEC,
+ EnumOperationStatus.FAILED.getIndex());
+ updateResult(oFuncTestResult);
+ return EnumResult.FAIL.getIndex();
+ }
+
+ oFuncTestResult.setOperFinished(true);
+ oFuncTestResult.setOperStatus(EnumResult.SUCCESS.getIndex());
+ buildFuncTestResponse(oFuncTestResult, CommonConstant.functionTest.FUNCTEST_EXEC,
+ EnumOperationStatus.SUCCESS.getIndex());
+ updateResult(oFuncTestResult);
+
+ // STEP 3:Store FuncTest key to get FuncTest Results
+ // -------------------------------------------------
+ storeFuncTestResultKey(onBoradingReq, functestResultKey);
+
+ return (oFuncTestResult.getOperStatus() == EnumResult.SUCCESS.getIndex()) ? EnumResult.SUCCESS.getIndex()
+ : EnumResult.FAIL.getIndex();
+ }
+
+ /**
+ * Build result path
+ *
+ * @param onBoradingReq
+ */
+ private void buildResultPath(OnBoradingRequest onBoradingReq) {
+ String filePath = getResultStorePath() + File.separator + onBoradingReq.getCsarId();
+ if (!FileUtil.checkFileExists(filePath)) {
+ FileUtil.createDirectory(filePath);
+ }
+ }
+
+ /**Get Function Test result
+ *
+ * @param packageData
+ * @return null on failure, function test result on success
+ */
+ public static String getFuncTestResults(PackageData packageData) {
+ if (null == packageData) {
+ logger.error("Package data is invalid - null");
+ return null;
+ }
+
+ logger.info("Function Test results request for Package:" + packageData.getCsarId());
+ ResultKey keydata = getFuncTestResultKey(packageData);
+ if ((null == keydata) || (keydata.getKey().isEmpty())) {
+ logger.error("Function Test key Not Found for Package Id:", packageData.getCsarId());
+ return null;
+ }
+ return FunctionTestExceutor.getTestResultsByFuncTestKey(keydata.getKey());
+ }
+
+ /**
+ * Store Function Test Result key
+ *
+ * @param onBoradingReq
+ * @param resultKey
+ */
+ private void storeFuncTestResultKey(OnBoradingRequest onBoradingReq, String resultKey) {
+ // Currently we will make JSON and Store JSON to Package Path)
+ // -------------------------------------------------------------------------------
+ StringBuffer filePath = new StringBuffer(getResultStorePath());
+ filePath.append(File.separator);
+ filePath.append(onBoradingReq.getCsarId());
+ filePath.append(File.separator);
+ filePath.append("functestResultKey.json");
+
+ logger.debug("Function test Results Key for Package Id:" + onBoradingReq.getCsarId() + ", Key:" + resultKey
+ + " Path" + filePath.toString());
+
+ ResultKey oResultKey = new ResultKey();
+ oResultKey.setCsarId(onBoradingReq.getCsarId());
+ oResultKey.setOperTypeId(CommonConstant.functionTest.FUNCTEST_OPERTYPE_ID);
+ oResultKey.setKey(resultKey);
+
+ FileUtil.writeJsonDatatoFile(filePath.toString(), oResultKey);
+ }
+
+ /**
+ * Store Function test Execution Results
+ *
+ * @param oFuncTestResult
+ */
+ private void updateResult(OnBoardingResult oFuncTestResult) {
+ // STore Results to DB(Currently we will make JSON and Store JSON to
+ // Package Path)
+ // -------------------------------------------------------------------------------
+ logger.debug("Function test Status for Package Id:" + oFuncTestResult.getCsarId() + ", Result:"
+ + ToolUtil.objectToString(oFuncTestResult));
+
+ StringBuffer filePath = new StringBuffer(getResultStorePath());
+ filePath.append(File.separator);
+ filePath.append(oFuncTestResult.getCsarId());
+ filePath.append(File.separator);
+ filePath.append("functionTest.json");
+
+ FileUtil.writeJsonDatatoFile(filePath.toString(), oFuncTestResult);
+ }
+
+ /**
+ * Build Function Test Response
+ *
+ * @param onBoradingReq
+ * @param oFuncTestResult
+ */
+ private void buildFunctResponse(OnBoradingRequest onBoradingReq, OnBoardingResult oFuncTestResult) {
+ oFuncTestResult.setOperFinished(false);
+ oFuncTestResult.setCsarId(onBoradingReq.getCsarId());
+ oFuncTestResult.setOperTypeId(CommonConstant.functionTest.FUNCTEST_OPERTYPE_ID);
+
+ OnBoardingOperResult oPackageExists = new OnBoardingOperResult();
+ oPackageExists.setOperId(CommonConstant.functionTest.FUNCTEST_PACKAGE_EXISTS);
+ oPackageExists.setStatus(EnumOperationStatus.NOTSTARTED.getIndex());
+
+ OnBoardingOperResult functTesExec = new OnBoardingOperResult();
+ functTesExec.setOperId(CommonConstant.functionTest.FUNCTEST_EXEC);
+ functTesExec.setStatus(EnumOperationStatus.NOTSTARTED.getIndex());
+
+ List<OnBoardingOperResult> operResult = new ArrayList<>();
+ operResult.add(oPackageExists);
+ operResult.add(functTesExec);
+
+ oFuncTestResult.setOperResult(operResult);
+ }
+
+ public static OnBoardingResult getOnBoardingResult(PackageData packageData) {
+
+ if (null == packageData) {
+ logger.error("Pacakage data is invalid-null");
+ return null;
+ }
+
+ StringBuffer filePath = new StringBuffer(getResultStorePath());
+ filePath.append(File.separator);
+ filePath.append(packageData.getCsarId());
+ filePath.append(File.separator);
+ filePath.append("functionTest.json");
+
+ logger.info("On Boarding Status for Package Id:" + packageData.getCsarId() + ", Result Path:" + filePath);
+
+ return (OnBoardingResult) FileUtil.readJsonDatafFromFile(filePath.toString(), OnBoardingResult.class);
+ }
+
+ private static ResultKey getFuncTestResultKey(PackageData packageData) {
+ StringBuffer fileName = new StringBuffer(getResultStorePath());
+ fileName.append(File.separator);
+ fileName.append(packageData.getCsarId());
+ fileName.append(File.separator);
+ fileName.append("functestResultKey.json");
+
+ logger.info("Func Test Result key for Package Id:" + packageData.getCsarId() + ", Result Path:" + fileName);
+ return (ResultKey) FileUtil.readJsonDatafFromFile(fileName.toString(), ResultKey.class);
+ }
+
+ private static String getResultStorePath() {
+ // Using full path due to compilation issue
+ return org.onap.vnfsdk.marketplace.filemanage.http.ToolUtil.getHttpServerAbsolutePath();
+ }
+
+ private void buildFuncTestResponse(OnBoardingResult oFuncTestResult, String opreKey, int operStatusVal) {
+ List<OnBoardingOperResult> operStatusList = oFuncTestResult.getOperResult();
+ for (OnBoardingOperResult operObj : operStatusList) {
+ if (operObj.getOperId().equalsIgnoreCase(opreKey)) {
+ operObj.setStatus(operStatusVal);
+ break;
+ }
+ }
+ }
}
-
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReq.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReq.java
index 2e6411d6..261bb5d0 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReq.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReq.java
@@ -17,27 +17,38 @@ package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle;
import java.util.List;
-public class LifeCycleTestReq
-{
- private String csarId;
- private String labVimId;
- private List<String> vimIds;
- public String getCsarId() {
- return csarId;
- }
- public void setCsarId(String csarId) {
- this.csarId = csarId;
- }
- public String getLabVimId() {
- return labVimId;
- }
- public void setLabVimId(String labVimId) {
- this.labVimId = labVimId;
- }
- public List<String> getVimIds() {
- return vimIds;
- }
- public void setVimIds(List<String> vimIds) {
- this.vimIds = vimIds;
- }
+public class LifeCycleTestReq {
+
+ // VNF package Id
+ private String csarId;
+
+ // VIM (lab-static) Id on which VNFs are located
+ private String labVimId;
+
+ // Dynamic VIM Ids
+ private List<String> vimIds;
+
+ public String getCsarId() {
+ return csarId;
+ }
+
+ public void setCsarId(String csarId) {
+ this.csarId = csarId;
+ }
+
+ public String getLabVimId() {
+ return labVimId;
+ }
+
+ public void setLabVimId(String labVimId) {
+ this.labVimId = labVimId;
+ }
+
+ public List<String> getVimIds() {
+ return vimIds;
+ }
+
+ public void setVimIds(List<String> vimIds) {
+ this.vimIds = vimIds;
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java
index 21a61add..3cf5310b 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java
@@ -22,6 +22,7 @@ import java.util.Map;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.onap.vnfsdk.marketplace.common.CommonConstant;
+import org.onap.vnfsdk.marketplace.common.FileUtil;
import org.onap.vnfsdk.marketplace.common.JsonUtil;
import org.onap.vnfsdk.marketplace.msb.MsbDetails;
import org.onap.vnfsdk.marketplace.msb.MsbDetailsHolder;
@@ -37,131 +38,158 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class LifecycleTestExceutor
-{
- private static final Logger logger = LoggerFactory.getLogger(LifecycleTestExceutor.class);
- public static final String CATALOUGE_UPLOAD_URL_IN = "{0}:{1}/openoapi/catalog/v1/csars";
-
- private LifecycleTestExceutor()
- {}
-
- /**
- * Interface to Send Request to Start Function test
- * @param onBoradFuncTestReq
- * @return
- */
- @SuppressWarnings("unchecked")
- public static String uploadPackageToCatalouge(OnBoradingRequest onBoradFuncTestReq)
- {
- String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName();
- logger.info("Package file path uploadPackageToCatalouge:" + packagePath);
-
- String catalougeCsarId = null;
- MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
- if(null == oMsbDetails)
- {
- logger.error("Failed to get MSB details during uploadPackageToCatalouge !!!");
- return catalougeCsarId;
- }
-
- File fileData = new File (packagePath);
-
- MultipartEntityBuilder builder = MultipartEntityBuilder.create();
- builder.addBinaryBody("file", fileData, ContentType.MULTIPART_FORM_DATA, onBoradFuncTestReq.getPackageName());
-
- //IP and Port needs to be configured !!!
- RestResponse rsp = RestfulClient.post(oMsbDetails.getDefaultServer().getHost(),Integer.parseInt(oMsbDetails.getDefaultServer().getPort()),CommonConstant.CATALOUGE_UPLOAD_URL,builder.build());
- if(!checkValidResponse(rsp))
- {
- logger.error("Failed to upload package to catalouge:" + rsp.getStatusCode());
- return catalougeCsarId;
- }
-
- logger.info("Response for uploadPackageToCatalouge :" + rsp.getResult());
- catalougeCsarId = getCsarIdValue(rsp.getResult());
-
- logger.info("CSARID for uploadPackageToCatalouge :" + catalougeCsarId);
- return catalougeCsarId;
- }
-
-
-
-
- public static String execlifecycleTest(OnBoradingRequest onBoradFuncTestReq, LifeCycleTestReq oLifeCycleTestReq)
- {
- String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName();
- logger.info("Package file path Function test:" + packagePath);
-
- MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
- if(null == oMsbDetails) {
- logger.error("Failed to get MSB details during execlifecycleTest !!!");
- return null;
- }
-
- String rawDataJson = JsonUtil.toJson(oLifeCycleTestReq);
- if(null == rawDataJson) {
- logger.error("Failed to convert LifeCycleTestReq object to Json String !!!");
- return null;
- }
-
- RestResponse oResponse = RestfulClient.sendPostRequest(oMsbDetails.getDefaultServer().getHost(),
- oMsbDetails.getDefaultServer().getPort(),
- CommonConstant.LifeCycleTest.LIFECYCLE_TEST_URL, rawDataJson);
-
- if(!checkValidResponse(oResponse)) {
- logger.error("execlifecycleTest response is faliure :"+ oResponse.getStatusCode());
- return null;
- }
- logger.info("Response execlifecycleTest :"+ oResponse.getResult());
- return oResponse.getResult();
- }
-
- /**
- * Check Response is Valid
- * @param rsp
- * @return
- */
- private static boolean checkValidResponse(RestResponse rsp)
- {
- if (rsp.getStatusCode() == null || rsp.getResult() == null
- || (RestConstant.RESPONSE_CODE_200 != rsp.getStatusCode() && RestConstant.RESPONSE_CODE_201 != rsp.getStatusCode()))
- {
- return false;
- }
- return true;
- }
-
- /**
- *
- * @param strJsonData
- * @return
- */
- private static String getCsarIdValue(String strJsonData)
- {
- ObjectMapper mapper = new ObjectMapper();
- mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- Map<String, String> dataMap = null;
- try
- {
- dataMap = mapper.readValue(strJsonData, Map.class);
- } catch(JsonParseException e) {
- logger.error("JsonParseException:Failed to upload package to catalouge:", e);
- } catch(JsonMappingException e) {
- logger.error("JsonMappingException:Failed to upload package to catalouge:", e);
- } catch(IOException e) {
- logger.error("IOException:Failed to upload package to catalouge:", e);
- }
- try
- {
- if(dataMap != null) {
- return dataMap.get("csarId");
- }
- }
- catch (NullPointerException e)
- {
- logger.error("NullPointerException:Failed to get csarId", e);
- }
- return "";
- }
+/* CALL Flow: onBoardingHandler --> LifecycleTestHook--> LifecycleTestExecutor */
+public class LifecycleTestExceutor {
+ private static final Logger logger = LoggerFactory.getLogger(LifecycleTestExceutor.class);
+ public static final String CATALOUGE_UPLOAD_URL_IN = "{0}:{1}/openoapi/catalog/v1/csars";
+
+ private LifecycleTestExceutor() {
+ // Empty constructor
+ }
+
+ /**
+ * Interface to upload package to catalogue
+ *
+ * @param onBoradFuncTestReq
+ * @return- csarId or null (in case of failure)
+ */
+ @SuppressWarnings("unchecked")
+ public static String uploadPackageToCatalouge(OnBoradingRequest onBoradFuncTestReq) {
+ String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName();
+ logger.info("Package file path uploadPackageToCatalouge:" + packagePath);
+
+ String catalougeCsarId = null;
+
+ // Validate package path
+ if (false == FileUtil.validatePath(packagePath)) {
+ logger.error("Failed to validate package path");
+ return catalougeCsarId;
+ }
+
+ MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
+ if (null == oMsbDetails) {
+ logger.error("Failed to get MSB details during uploadPackageToCatalouge !!!");
+ return catalougeCsarId;
+ }
+
+ File fileData = new File(packagePath);
+
+ // Validate file
+ if (false == FileUtil.validateFile(fileData)) {
+ logger.error("Failed to validate file information");
+ return catalougeCsarId;
+ }
+
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ builder.addBinaryBody("file", fileData, ContentType.MULTIPART_FORM_DATA, onBoradFuncTestReq.getPackageName());
+
+ // IP and Port needs to be configured !!!
+ RestResponse rsp = RestfulClient.post(oMsbDetails.getDefaultServer().getHost(),
+ Integer.parseInt(oMsbDetails.getDefaultServer().getPort()), CommonConstant.CATALOUGE_UPLOAD_URL,
+ builder.build());
+ if (false == checkValidResponse(rsp)) {
+ logger.error("Failed to upload package to catalouge:" + rsp.getStatusCode());
+ return catalougeCsarId;
+ }
+
+ logger.info("Response for uploadPackageToCatalouge :" + rsp.getResult());
+ catalougeCsarId = getCsarIdValue(rsp.getResult());
+
+ logger.info("CSARID for uploadPackageToCatalouge :" + catalougeCsarId);
+ return catalougeCsarId;
+ }
+
+ /**
+ * Interface to execute lifecycle test
+ *
+ * @param onBoradFuncTestReq,
+ * oLifeCycleTestReq
+ * @return result of the test or null (in case of failure)
+ */
+ public static String execlifecycleTest(OnBoradingRequest onBoradFuncTestReq, LifeCycleTestReq oLifeCycleTestReq) {
+
+ String result = null;
+ if ((null == onBoradFuncTestReq.getPackagePath()) || (null == onBoradFuncTestReq.getPackageName())) {
+ logger.error("Package path or name is invalid");
+ return result;
+ }
+
+ String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName();
+ logger.info("Package file path Function test:" + packagePath);
+
+ // Validate package path
+ if (false == FileUtil.validatePath(packagePath)) {
+ logger.error("Failed to validate path");
+ return result;
+ }
+
+ MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
+ if (null == oMsbDetails) {
+ logger.error("Failed to get MSB details during execlifecycleTest !!!");
+ return result;
+ }
+
+ String rawDataJson = JsonUtil.toJson(oLifeCycleTestReq);
+ if (null == rawDataJson) {
+ logger.error("Failed to convert LifeCycleTestReq object to Json String !!!");
+ return result;
+ }
+
+ RestResponse oResponse = RestfulClient.sendPostRequest(oMsbDetails.getDefaultServer().getHost(),
+ oMsbDetails.getDefaultServer().getPort(), CommonConstant.LifeCycleTest.LIFECYCLE_TEST_URL, rawDataJson);
+
+ if (false == checkValidResponse(oResponse)) {
+ logger.error("execlifecycleTest response is faliure :" + oResponse.getStatusCode());
+ return result;
+ }
+
+ result = oResponse.getResult();
+ logger.info("Response execlifecycleTest :" + oResponse.getResult());
+ return result;
+ }
+
+ /**
+ * Check Response is Valid
+ *
+ * @param rsp
+ * @return valid(true) or invalid(false)
+ */
+ private static boolean checkValidResponse(RestResponse rsp) {
+ if ((null == rsp.getStatusCode()) || (null == rsp.getResult())
+ || (RestConstant.RESPONSE_CODE_200 != rsp.getStatusCode()
+ && RestConstant.RESPONSE_CODE_201 != rsp.getStatusCode())) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Get csar Id value
+ *
+ * @param strJsonData
+ * @return empty(failure), or csarId(success)
+ */
+ private static String getCsarIdValue(String strJsonData) {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+ Map<String, String> dataMap = null;
+
+ try {
+ dataMap = mapper.readValue(strJsonData, Map.class);
+ } catch (JsonParseException e) {
+ logger.error("JsonParseException:Failed to upload package to catalouge:", e);
+ } catch (JsonMappingException e) {
+ logger.error("JsonMappingException:Failed to upload package to catalouge:", e);
+ } catch (IOException e) {
+ logger.error("IOException:Failed to upload package to catalouge:", e);
+ }
+ try {
+ if (null != dataMap) {
+ return dataMap.get("csarId");
+ }
+ } catch (NullPointerException e) {
+ logger.error("NullPointerException:Failed to get csarId", e);
+ }
+ return "";
+ }
}
-
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHook.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHook.java
index 6170d9bb..5526d380 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHook.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHook.java
@@ -22,7 +22,6 @@ import java.util.List;
import org.onap.vnfsdk.marketplace.common.CommonConstant;
import org.onap.vnfsdk.marketplace.common.FileUtil;
import org.onap.vnfsdk.marketplace.common.ToolUtil;
-import org.onap.vnfsdk.marketplace.db.entity.PackageData;
import org.onap.vnfsdk.marketplace.entity.EnumOperationStatus;
import org.onap.vnfsdk.marketplace.entity.EnumResult;
import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoardingOperResult;
@@ -32,163 +31,164 @@ import org.onap.vnfsdk.marketplace.onboarding.entity.ResultKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class LifecycleTestHook
-{
- private static final Logger logger = LoggerFactory.getLogger(LifecycleTestHook.class);
-
- /**
- * Start Executing Function test
- * @param onBoradingReq
- * @return
- */
- public int exec(OnBoradingRequest onBoradingReq)
- {
- logger.info("OnboradingRequest Lifecycle Request received for Package:" + onBoradingReq.getCsarId() + " Path:"+ onBoradingReq.getPackagePath());
-
- buildResultPath(onBoradingReq);
-
- OnBoardingResult olifecycleTestResult = new OnBoardingResult();
- buildlifecycleTestResponse(onBoradingReq,olifecycleTestResult);
- updateResult(olifecycleTestResult);
-
- if(null == onBoradingReq.getCsarIdCatalouge() || onBoradingReq.getCsarIdCatalouge().isEmpty())
- {
- olifecycleTestResult.setOperFinished(true);
- olifecycleTestResult.setOperStatus(EnumResult.FAIL.getIndex());
- buildFuncTestResponse(olifecycleTestResult,CommonConstant.LifeCycleTest.LIFECYCLE_TEST_EXEC,EnumOperationStatus.FAILED.getIndex());
- updateResult(olifecycleTestResult);
- return EnumResult.FAIL.getIndex();
- }
-
- LifeCycleTestReq oLifeCycleTestReq = new LifeCycleTestReq();
- populateLifeCycleReq(onBoradingReq,oLifeCycleTestReq);
-
-
- //STEP 2: Execute Life Cycle Test and Get Result Back !!!!
- //---------------------------------------------------------
- String lifecycleTestResultKey = LifecycleTestExceutor.execlifecycleTest(onBoradingReq,oLifeCycleTestReq);
- if(null == lifecycleTestResultKey)
- {
- olifecycleTestResult.setOperFinished(true);
- olifecycleTestResult.setOperStatus(EnumResult.FAIL.getIndex());
- buildFuncTestResponse(olifecycleTestResult,CommonConstant.LifeCycleTest.LIFECYCLE_TEST_EXEC,EnumOperationStatus.FAILED.getIndex());
- updateResult(olifecycleTestResult);
- return EnumResult.FAIL.getIndex();
- }
-
- olifecycleTestResult.setOperFinished(true);
- olifecycleTestResult.setOperStatus(EnumResult.SUCCESS.getIndex());
- buildFuncTestResponse(olifecycleTestResult,CommonConstant.LifeCycleTest.LIFECYCLE_TEST_EXEC,EnumOperationStatus.SUCCESS.getIndex());
- updateResult(olifecycleTestResult);
-
- //STEP 3: Store FuncTest key to get FuncTest Results
- //-------------------------------------------------
- storelifecycleResultKey(onBoradingReq,lifecycleTestResultKey);
-
- return (olifecycleTestResult.getOperStatus() == EnumResult.SUCCESS.getIndex())
- ? EnumResult.SUCCESS.getIndex() : EnumResult.FAIL.getIndex();
- }
-
- private void populateLifeCycleReq(OnBoradingRequest onBoradingReq, LifeCycleTestReq oLifeCycleTestReq)
- {
- oLifeCycleTestReq.setCsarId(onBoradingReq.getCsarId());
- oLifeCycleTestReq.setLabVimId(oLifeCycleTestReq.getLabVimId());
-
- List<String> vimIds = new ArrayList<>();
- oLifeCycleTestReq.setVimIds(vimIds);
- }
-
- /**
- *
- * @param onBoradingReq
- */
- private void buildResultPath(OnBoradingRequest onBoradingReq)
- {
- String filePath = getResultStorePath() + File.separator + onBoradingReq.getCsarId();
- if(!FileUtil.checkFileExists(filePath))
- {
- FileUtil.createDirectory(filePath);
- }
- }
-
- /**
- * Store Function test Execution Results
- * @param oFuncTestResult
- */
- private void updateResult(OnBoardingResult oFuncTestResult)
- {
- //STore Results to DB(Currently we will make JSON and Store JSON to Package Path)
- //-------------------------------------------------------------------------------
- logger.info("Lifecycle test Status for Package Id:" + oFuncTestResult.getCsarId() + ", Result:" + ToolUtil.objectToString(oFuncTestResult));
- String filePath = getResultStorePath() + File.separator + oFuncTestResult.getCsarId() + File.separator + "lifecycleTest.json";
- FileUtil.writeJsonDatatoFile(filePath,oFuncTestResult);
- }
-
- /**
- * Build Function Test Response
- * @param onBoradingReq
- * @param oFuncTestResult
- */
- private void buildlifecycleTestResponse(OnBoradingRequest onBoradingReq, OnBoardingResult oTestResult)
- {
- oTestResult.setOperFinished(false);
- oTestResult.setCsarId(onBoradingReq.getCsarId());
- oTestResult.setOperTypeId(CommonConstant.LifeCycleTest.LIFECYCLE_TEST_OPERTYPE_ID);
-
- OnBoardingOperResult lifecycleTestExec = new OnBoardingOperResult();
- lifecycleTestExec.setOperId(CommonConstant.LifeCycleTest.LIFECYCLE_TEST_EXEC);
- lifecycleTestExec.setStatus(EnumOperationStatus.NOTSTARTED.getIndex());
-
- List<OnBoardingOperResult> operResult = new ArrayList<>();
- operResult.add(lifecycleTestExec);
- oTestResult.setOperResult(operResult);
- }
-
- public static OnBoardingResult getOnBoardingResult(PackageData packageData)
- {
- String filePath = getResultStorePath() + File.separator + packageData.getCsarId() +File.separator + "lifecycleTest.json";
- logger.info("On Boarding Status for Package Id:" + packageData.getCsarId() + ", Result Path:" + filePath);
-
- return (OnBoardingResult)FileUtil.readJsonDatafFromFile(filePath,OnBoardingResult.class);
- }
-
- /**
- * Store Function Test Result key
- * @param onBoradingReq
- * @param resultKey
- */
- private void storelifecycleResultKey(OnBoradingRequest onBoradingReq,String resultKey)
- {
- //Currently we will make JSON and Store JSON to Package Path)
- //-------------------------------------------------------------------------------
- String filePath = getResultStorePath() + File.separator + onBoradingReq.getCsarId() + File.separator + "lifecycleTestResultKey.json";
-
- logger.info("Function test Results Key for Package Id:" + onBoradingReq.getCsarId() + ", Key:" + resultKey + " Path" + filePath);
-
- ResultKey oResultKey = new ResultKey();
- oResultKey.setCsarId(onBoradingReq.getCsarId());
- oResultKey.setOperTypeId(CommonConstant.LifeCycleTest.LIFECYCLE_TEST_OPERTYPE_ID);
- oResultKey.setKey(resultKey);
-
- FileUtil.writeJsonDatatoFile(filePath,oResultKey);
- }
-
- private static String getResultStorePath()
- {
- return org.onap.vnfsdk.marketplace.filemanage.http.ToolUtil.getHttpServerAbsolutePath();
- }
-
- private void buildFuncTestResponse(OnBoardingResult oFuncTestResult, String opreKey, int operStatusVal)
- {
- List<OnBoardingOperResult> operStatusList = oFuncTestResult.getOperResult();
- for(OnBoardingOperResult operObj: operStatusList)
- {
- if(operObj.getOperId().equalsIgnoreCase(opreKey))
- {
- operObj.setStatus(operStatusVal);
- break;
- }
- }
- }
+/* It executes the life cycle (create, delete) test for the VNF on the specified VM and collects the result
+ * and return result to the caller and then uploads package to the catalogue
+ *
+ * OnBoardingHandler --> LifecycleTestHook---> LifecycleTestExecutor */
+
+public class LifecycleTestHook {
+ private static final Logger logger = LoggerFactory.getLogger(LifecycleTestHook.class);
+
+ /**
+ * Start Executing Life cycle test
+ *
+ * @param onBoradingReq
+ * @return
+ */
+ public int exec(OnBoradingRequest onBoradingReq) {
+ logger.info("OnboardingRequest Lifecycle Request received for Package:" + onBoradingReq.getCsarId() + " Path:"
+ + onBoradingReq.getPackagePath());
+
+ // STEP 1: Validate Input and Build result
+ // ---------------------------------------------------------
+ buildResultPath(onBoradingReq);
+
+ OnBoardingResult olifecycleTestResult = new OnBoardingResult();
+ buildlifecycleTestResponse(onBoradingReq, olifecycleTestResult);
+ updateResult(olifecycleTestResult);
+
+ if (null == onBoradingReq.getCsarIdCatalouge() || onBoradingReq.getCsarIdCatalouge().isEmpty()) {
+ olifecycleTestResult.setOperFinished(true);
+ olifecycleTestResult.setOperStatus(EnumResult.FAIL.getIndex());
+ buildFuncTestResponse(olifecycleTestResult, CommonConstant.LifeCycleTest.LIFECYCLE_TEST_EXEC,
+ EnumOperationStatus.FAILED.getIndex());
+ updateResult(olifecycleTestResult);
+ return EnumResult.FAIL.getIndex();
+ }
+
+ LifeCycleTestReq oLifeCycleTestReq = new LifeCycleTestReq();
+ populateLifeCycleReq(onBoradingReq, oLifeCycleTestReq);
+
+ // STEP 2: Execute Life Cycle Test and Get Result Back !!!!
+ // ---------------------------------------------------------
+ String lifecycleTestResultKey = LifecycleTestExceutor.execlifecycleTest(onBoradingReq, oLifeCycleTestReq);
+ if (null == lifecycleTestResultKey) {
+ olifecycleTestResult.setOperFinished(true);
+ olifecycleTestResult.setOperStatus(EnumResult.FAIL.getIndex());
+ buildFuncTestResponse(olifecycleTestResult, CommonConstant.LifeCycleTest.LIFECYCLE_TEST_EXEC,
+ EnumOperationStatus.FAILED.getIndex());
+ updateResult(olifecycleTestResult);
+ return EnumResult.FAIL.getIndex();
+ }
+
+ olifecycleTestResult.setOperFinished(true);
+ olifecycleTestResult.setOperStatus(EnumResult.SUCCESS.getIndex());
+ buildFuncTestResponse(olifecycleTestResult, CommonConstant.LifeCycleTest.LIFECYCLE_TEST_EXEC,
+ EnumOperationStatus.SUCCESS.getIndex());
+ updateResult(olifecycleTestResult);
+
+ // STEP 3: Store Lifecycle test key to get Life cycle Test Results
+ // -------------------------------------------------
+ storelifecycleResultKey(onBoradingReq, lifecycleTestResultKey);
+
+ return (olifecycleTestResult.getOperStatus() == EnumResult.SUCCESS.getIndex()) ? EnumResult.SUCCESS.getIndex()
+ : EnumResult.FAIL.getIndex();
+ }
+
+ private void populateLifeCycleReq(OnBoradingRequest onBoradingReq, LifeCycleTestReq oLifeCycleTestReq) {
+
+ // Input error handling is done by lifecycle module, not need validate here
+ oLifeCycleTestReq.setCsarId(onBoradingReq.getCsarId());
+ oLifeCycleTestReq.setLabVimId(oLifeCycleTestReq.getLabVimId());
+
+ // Currently this is not populated, only lavVimId is sufficient
+ List<String> vimIds = new ArrayList<>();
+ oLifeCycleTestReq.setVimIds(vimIds);
+ }
+
+ /**
+ * Build result path where result is stored as a file
+ * @param onBoradingReq
+ */
+ private void buildResultPath(OnBoradingRequest onBoradingReq) {
+ String filePath = getResultStorePath() + File.separator + onBoradingReq.getCsarId();
+ if (!FileUtil.checkFileExists(filePath)) {
+ FileUtil.createDirectory(filePath);
+ }
+ }
+
+ /**
+ * Store Function test Execution Results
+ *
+ * @param oFuncTestResult
+ */
+ private void updateResult(OnBoardingResult oFuncTestResult) {
+ // STore Results to DB(Currently we will make JSON and Store JSON to
+ // Package Path)
+ // -------------------------------------------------------------------------------
+ logger.info("Lifecycle test Status for Package Id:" + oFuncTestResult.getCsarId() + ", Result:"
+ + ToolUtil.objectToString(oFuncTestResult));
+ String filePath = getResultStorePath() + File.separator + oFuncTestResult.getCsarId() + File.separator
+ + "lifecycleTest.json";
+ FileUtil.writeJsonDatatoFile(filePath, oFuncTestResult);
+ }
+
+ /**
+ * Build Function Test Response
+ *
+ * @param onBoradingReq
+ * @param oFuncTestResult
+ */
+ private void buildlifecycleTestResponse(OnBoradingRequest onBoradingReq, OnBoardingResult oTestResult) {
+ oTestResult.setOperFinished(false);
+ oTestResult.setCsarId(onBoradingReq.getCsarId());
+ oTestResult.setOperTypeId(CommonConstant.LifeCycleTest.LIFECYCLE_TEST_OPERTYPE_ID);
+
+ OnBoardingOperResult lifecycleTestExec = new OnBoardingOperResult();
+ lifecycleTestExec.setOperId(CommonConstant.LifeCycleTest.LIFECYCLE_TEST_EXEC);
+ lifecycleTestExec.setStatus(EnumOperationStatus.NOTSTARTED.getIndex());
+
+ List<OnBoardingOperResult> operResult = new ArrayList<>();
+ operResult.add(lifecycleTestExec);
+ oTestResult.setOperResult(operResult);
+ }
+
+
+ /**
+ * Store Lifecycle Test Result key
+ *
+ * @param onBoradingReq
+ * @param resultKey
+ */
+ private void storelifecycleResultKey(OnBoradingRequest onBoradingReq, String resultKey) {
+ // Currently we will make JSON and Store JSON to Package Path)
+ // -------------------------------------------------------------------------------
+ String filePath = getResultStorePath() + File.separator + onBoradingReq.getCsarId() + File.separator
+ + "lifecycleTestResultKey.json";
+
+ logger.debug("Function test Results Key for Package Id:" + onBoradingReq.getCsarId() + ", Key:" + resultKey
+ + " Path" + filePath);
+
+ ResultKey oResultKey = new ResultKey();
+ oResultKey.setCsarId(onBoradingReq.getCsarId());
+ oResultKey.setOperTypeId(CommonConstant.LifeCycleTest.LIFECYCLE_TEST_OPERTYPE_ID);
+ oResultKey.setKey(resultKey);
+
+ FileUtil.writeJsonDatatoFile(filePath, oResultKey);
+ }
+
+ private static String getResultStorePath() {
+ // Using full path due to compilation issue
+ return org.onap.vnfsdk.marketplace.filemanage.http.ToolUtil.getHttpServerAbsolutePath();
+ }
+
+ private void buildFuncTestResponse(OnBoardingResult oFuncTestResult, String opreKey, int operStatusVal) {
+ List<OnBoardingOperResult> operStatusList = oFuncTestResult.getOperResult();
+ for (OnBoardingOperResult operObj : operStatusList) {
+ if (operObj.getOperId().equalsIgnoreCase(opreKey)) {
+ operObj.setStatus(operStatusVal);
+ break;
+ }
+ }
+ }
}
-
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponse.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponse.java
index 691061cf..20ee53b1 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponse.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponse.java
@@ -15,34 +15,49 @@
*/
package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle;
-public class ValidateLifecycleTestResponse
-{
- private String jobId;
- private String validate_status;
- private String lifecycle_status;
- private VnfInfo vnf_info;
- public String getJobId() {
- return jobId;
- }
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
- public String getValidate_status() {
- return validate_status;
- }
- public void setValidate_status(String validate_status) {
- this.validate_status = validate_status;
- }
- public String getLifecycle_status() {
- return lifecycle_status;
- }
- public void setLifecycle_status(String lifecycle_status) {
- this.lifecycle_status = lifecycle_status;
- }
- public VnfInfo getVnf_info() {
- return vnf_info;
- }
- public void setVnf_info(VnfInfo vnf_info) {
- this.vnf_info = vnf_info;
- }
+public class ValidateLifecycleTestResponse {
+
+ // Job Id of the lifecycle test request
+ private String jobId;
+
+ // Status of the validation
+ private String validate_status;
+
+ // Status of lifecycle test
+ private String lifecycle_status;
+
+ // Vnf and VM information where the Vnfs are located
+ private VnfInfo vnf_info;
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getValidate_status() {
+ return validate_status;
+ }
+
+ public void setValidate_status(String validate_status) {
+ this.validate_status = validate_status;
+ }
+
+ public String getLifecycle_status() {
+ return lifecycle_status;
+ }
+
+ public void setLifecycle_status(String lifecycle_status) {
+ this.lifecycle_status = lifecycle_status;
+ }
+
+ public VnfInfo getVnf_info() {
+ return vnf_info;
+ }
+
+ public void setVnf_info(VnfInfo vnf_info) {
+ this.vnf_info = vnf_info;
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/VmsInfo.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/VmsInfo.java
index b65ab975..723bf67f 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/VmsInfo.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/VmsInfo.java
@@ -15,28 +15,38 @@
*/
package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle;
+public class VmsInfo {
+
+ // Virtual machine ip address
+ private String ip;
+
+ // Login username
+ private String username;
+
+ // Login password
+ private String passwd;
-public class VmsInfo
-{
- private String ip;
- private String username;
- private String password;
- public String getIp() {
- return ip;
- }
- public void setIp(String ip) {
- this.ip = ip;
- }
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return passwd;
+ }
+
+ public void setPassword(String password) {
+ this.passwd = password;
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/VnfInfo.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/VnfInfo.java
index 1228e81b..60c0f53d 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/VnfInfo.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/VnfInfo.java
@@ -17,15 +17,16 @@ package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle;
import java.util.List;
-public class VnfInfo
-{
- private List<VmsInfo> vms;
+public class VnfInfo {
+
+ // List of VM Info -Each VNF can run in several VMs
+ private List<VmsInfo> vms;
- public List<VmsInfo> getVms() {
- return vms;
- }
+ public List<VmsInfo> getVms() {
+ return vms;
+ }
- public void setVms(List<VmsInfo> vms) {
- this.vms = vms;
- }
+ public void setVms(List<VmsInfo> vms) {
+ this.vms = vms;
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandler.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandler.java
index 90514eea..b7cfdc1c 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandler.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandler.java
@@ -24,40 +24,56 @@ import org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle.LifecycleT
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class OnBoardingHandler
-{
- private static final Logger logger = LoggerFactory.getLogger(OnBoardingHandler.class);
-
- public void handleOnBoardingReq(OnBoradingRequest onBoradingReq)
- {
- //Handle Package Life cycle/Validation
- //------------------------------------
- LifecycleTestHook oLifecycleTestHook = new LifecycleTestHook();
- int iLifeCycleResponse = oLifecycleTestHook.exec(onBoradingReq);
- if(EnumResult.SUCCESS.getIndex() != iLifeCycleResponse)
- {
- logger.error("Onboarding falied for Package Id during Lifecycle Test:" + onBoradingReq.getCsarId());
- }
-
- //Handle Package FunctionTest
- //-------------------------
- FunctionTestHook oFunctionTestHook = new FunctionTestHook();
- int iFuncTestResponse = oFunctionTestHook.exec(onBoradingReq);
- if(EnumResult.SUCCESS.getIndex() != iFuncTestResponse)
- {
- logger.error("Onboarding falied for Package Id during Function Test:" + onBoradingReq.getCsarId());
- return;
- }
-
- FileUtil.deleteDirectory(onBoradingReq.getPackagePath());
- try
- {
- PackageManager.getInstance().updateDwonloadCount(onBoradingReq.getCsarId());
- }
- catch (Exception e)
- {
- logger.error("Download count udate failed for Package:" + onBoradingReq.getPackagePath() ,e);
- }
- }
+/* Call Flow: PackageWrapper(package upload) --> OnBoardingHandler (package on boarding) */
+public final class OnBoardingHandler {
+
+ private static final Logger logger = LoggerFactory.getLogger(OnBoardingHandler.class);
+
+ public void handleOnBoardingReq(OnBoradingRequest onBoardingReq) {
+
+ // Step 0: Input validation
+ // ------------------------------
+ if (null == onBoardingReq) {
+ logger.error("Invalid input:Onboarding request is null");
+ return;
+ }
+
+ if ((null == onBoardingReq.getPackagePath()) || (null == onBoardingReq.getPackageName())) {
+ logger.error("Package path or name is invalid");
+ return;
+ }
+
+ if (null == onBoardingReq.getCsarId()) {
+ logger.error("CsarId is invalid - null");
+ return;
+ }
+
+ // Step 1:Handle Package Life cycle/Validation
+ // ------------------------------------
+ LifecycleTestHook oLifecycleTestHook = new LifecycleTestHook();
+ int iLifeCycleResponse = oLifecycleTestHook.exec(onBoardingReq);
+ if (EnumResult.SUCCESS.getIndex() != iLifeCycleResponse) {
+ logger.error("Onboarding failed for Package Id during Lifecycle Test:" + onBoardingReq.getCsarId());
+ // Note: We need to continue even if life cycle test fails as this
+ // test is not mandatory
+ }
+
+ // Step 2: Handle Package FunctionTest
+ // -------------------------
+ FunctionTestHook oFunctionTestHook = new FunctionTestHook();
+ int iFuncTestResponse = oFunctionTestHook.exec(onBoardingReq);
+ if (EnumResult.SUCCESS.getIndex() != iFuncTestResponse) {
+ logger.error("Onboarding failed for Package Id during Function Test:" + onBoardingReq.getCsarId());
+ // Note: We need to continue even if function test fails as this
+ // test is not mandatory
+ }
+
+ FileUtil.deleteDirectory(onBoardingReq.getPackagePath());
+ try {
+ PackageManager.getInstance().updateDownloadCount(onBoardingReq.getCsarId());
+ } catch (Exception e) {
+ logger.error("Download count update failed for Package:" + onBoardingReq.getPackagePath(), e);
+ }
+ }
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java
index 7cc3ccc4..02ae5e30 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java
@@ -413,7 +413,7 @@ public class PackageWrapper {
boolean bupdateSucess = false;
try
{
- PackageManager.getInstance().updateDwonloadCount(csarId);
+ PackageManager.getInstance().updateDownloadCount(csarId);
bupdateSucess = true;
}
catch (Exception exp)