summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponse.java20
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/PackageResource.java4
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/rest/RestResponse.java7
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java30
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java5
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java11
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java8
7 files changed, 43 insertions, 42 deletions
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 1ca65d89..5308c082 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
@@ -21,10 +21,10 @@ public class ValidateLifecycleTestResponse {
private String jobId;
// Status of the validation
- private String validate_status;
+ private String validateStatus;
// Status of lifecycle test
- private String lifecycle_status;
+ private String lifecycleStatus;
// Vnf and VM information where the Vnfs are located
@@ -37,20 +37,20 @@ public class ValidateLifecycleTestResponse {
this.jobId = jobId;
}
- public String getValidate_status() {
- return validate_status;
+ public String getValidateStatus() {
+ return validateStatus;
}
- public void setValidate_status(String validate_status) {
- this.validate_status = validate_status;
+ public void setValidateStatus(String validateStatus) {
+ this.validateStatus = validateStatus;
}
- public String getLifecycle_status() {
- return lifecycle_status;
+ public String getLifecycleStatus() {
+ return lifecycleStatus;
}
- public void setLifecycle_status(String lifecycle_status) {
- this.lifecycle_status = lifecycle_status;
+ public void setLifecycleStatus(String lifecycleStatus) {
+ this.lifecycleStatus = lifecycleStatus;
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/PackageResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/PackageResource.java
index e4b947f5..b2e31b63 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/PackageResource.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/PackageResource.java
@@ -113,7 +113,7 @@ public class PackageResource {
@FormDataParam("params") String details,
@ApiParam(value = "file detail", required = false) @FormDataParam("file") FormDataContentDisposition fileDetail,
@ApiParam(value = "http header") @Context HttpHeaders head)
- throws IOException, MarketplaceResourceException {
+ {
return PackageWrapper.getInstance().uploadPackage(uploadedInputStream, fileDetail, details, head);
}
@@ -161,7 +161,7 @@ public class PackageResource {
@FormDataParam("params") String details,
@ApiParam(value = "file detail", required = false) @FormDataParam("file") FormDataContentDisposition fileDetail,
@ApiParam(value = "http header") @Context HttpHeaders head)
- throws IOException, MarketplaceResourceException {
+ throws MarketplaceResourceException {
return PackageWrapper.getInstance().reUploadPackage(csarId, uploadedInputStream, fileDetail, details, head);
}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/rest/RestResponse.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/rest/RestResponse.java
index a1926b68..72f46403 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/rest/RestResponse.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/rest/RestResponse.java
@@ -22,6 +22,10 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class RestResponse {
+ private Integer statusCode;
+
+ private String result;
+
public Integer getStatusCode() {
return statusCode;
}
@@ -38,7 +42,4 @@ public class RestResponse {
this.result = result;
}
- private Integer statusCode;
-
- private String result;
}
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 6aee857b..f05a22f9 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
@@ -70,7 +70,9 @@ public class PackageWrapper {
private static final Logger LOG = LoggerFactory.getLogger(PackageWrapper.class);
- private static final boolean disableValidation = true;
+ private static final boolean DISABLE_VALIDATION = true;
+
+ private static final String fileFormat = ".csar";
/**
* get PackageWrapper instance.
@@ -92,9 +94,9 @@ public class PackageWrapper {
return Response.status(Status.EXPECTATION_FAILED).build();
}
- ValidateLifecycleTestResponse lyfValidateResp = null; // TBD - Use Gson - jackson has
- // security issue/
- // JsonUtil.fromJson(reqParam, ValidateLifecycleTestResponse.class);
+ ValidateLifecycleTestResponse lyfValidateResp = null;
+ // TBD - Use Gson - jackson has security issue/
+
if(!checkOperationSucess(lyfValidateResp)) {
return Response.status(Status.EXPECTATION_FAILED).build();
}
@@ -117,10 +119,10 @@ public class PackageWrapper {
LOG.error("ValidateLifecycleTestResponse is NUll !!!");
return bOperStatus;
}
- if(lyfValidateResp.getLifecycle_status().equalsIgnoreCase(CommonConstant.SUCCESS_STR)
- && lyfValidateResp.getValidate_status().equalsIgnoreCase(CommonConstant.SUCCESS_STR)) {
- LOG.error("Lifecycle/Validation Response failed :" + lyfValidateResp.getLifecycle_status() + File.separator
- + lyfValidateResp.getValidate_status());
+ if(lyfValidateResp.getLifecycleStatus().equalsIgnoreCase(CommonConstant.SUCCESS_STR)
+ && lyfValidateResp.getValidateStatus().equalsIgnoreCase(CommonConstant.SUCCESS_STR)) {
+ LOG.error("Lifecycle/Validation Response failed :" + lyfValidateResp.getLifecycleStatus() + File.separator
+ + lyfValidateResp.getValidateStatus());
bOperStatus = true;
}
return bOperStatus;
@@ -186,7 +188,7 @@ public class PackageWrapper {
}
private UploadPackageResponse manageUpload(String packageId, String fileName, String fileLocation, String details,
- String contentRange) throws IOException, ErrorCodeException {
+ String contentRange) throws ErrorCodeException {
String localDirName = ToolUtil.getTempDir(CommonConstant.CATALOG_CSAR_DIR_NAME, fileName);
PackageBasicInfo basicInfo = PackageWrapperUtil.getPacageBasicInfo(fileLocation);
UploadPackageResponse result = new UploadPackageResponse();
@@ -196,7 +198,7 @@ public class PackageWrapper {
PackageWrapperUtil.getPackageMeta(packageId, fileName, fileLocation, basicInfo, details);
try {
String path = basicInfo.getType().toString() + File.separator + basicInfo.getProvider() + File.separator
- + packageMeta.getCsarId() + File.separator + fileName.replace(".csar", "") + File.separator
+ + packageMeta.getCsarId() + File.separator + fileName.replace(fileFormat, "") + File.separator
+ basicInfo.getVersion();
String dowloadUri = File.separator + path + File.separator;
@@ -266,7 +268,7 @@ public class PackageWrapper {
.build();
}
- String fileName = "temp_" + packageId + ".csar";
+ String fileName = "temp_" + packageId + fileFormat;
if(null != fileDetail) {
LOG.info("the fileDetail = " + ToolUtil.objectToString(fileDetail));
@@ -290,7 +292,7 @@ public class PackageWrapper {
uploadedInputStream.close();
- if (!disableValidation) {
+ if (!DISABLE_VALIDATION) {
try {
Result result = OpenRemoteCli.run("localhost", 50051, null, Arrays.asList(new String[] { "--product", "onap-vtp", "csar-validate", "--csar", fileLocation, "--format", "json" }));
LOG.info("CSAR validation is successful" + result.getOutput());
@@ -392,7 +394,7 @@ public class PackageWrapper {
String path = org.onap.vnfsdk.marketplace.filemanage.http.ToolUtil.getHttpServerAbsolutePath()
+ File.separatorChar + packageData.getType() + File.separatorChar + packageData.getProvider()
+ File.separatorChar + packageData.getCsarId() + File.separator + packageName + File.separatorChar
- + packageData.getVersion() + File.separator + packageName + ".csar";
+ + packageData.getVersion() + File.separator + packageName + fileFormat;
LOG.info("downloadCsarPackagesById path is : " + path);
@@ -465,7 +467,7 @@ public class PackageWrapper {
*/
public Response reUploadPackage(String csarId, InputStream uploadedInputStream,
FormDataContentDisposition fileDetail, String details, HttpHeaders head)
- throws MarketplaceResourceException {
+ {
LOG.info("Reupload request Received !!!!");
// STEP 1: Validate Input Data
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java
index 3fbf584d..daa58031 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java
@@ -95,10 +95,7 @@ public class PackageWrapperUtil {
int fileSize = Integer.parseInt(size);
String[] ranges = range.split("-");
int endPosition = Integer.parseInt(ranges[1]) + 1;
- if(endPosition >= fileSize) {
- return true;
- }
- return false;
+ return endPosition >= fileSize;
}
/**
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java
index b0cbcad8..40c43c06 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java
@@ -70,6 +70,7 @@ import io.swagger.annotations.ApiResponses;
@Path("/vtp")
@Api(tags = {"VTP Execution"})
public class VTPExecutionResource extends VTPResource{
+ private static final String EXECUTION_ID = "exection-id";
public VTPTestExecutionList executeHandler(VTPTestExecutionList executions, String requestId) throws VTPException, IOException {
if (requestId == null) {
requestId = UUID.randomUUID().toString();
@@ -89,7 +90,7 @@ public class VTPExecutionResource extends VTPResource{
);
String endTime = dateFormatter.format(new Date());
execution.setEndTime(endTime);
- execution.setExecutionId(output.getAddonsMap().get("execution-id"));
+ execution.setExecutionId(output.getAddonsMap().get(EXECUTION_ID));
// set execution status based on success from test.
if (output.getSuccess()) {
@@ -248,8 +249,8 @@ public class VTPExecutionResource extends VTPResource{
if (n.get("end-time") != null)
exec.setEndTime(n.get("end-time").asText());
- if (n.get("execution-id") != null)
- exec.setExecutionId(n.get("execution-id").asText());
+ if (n.get(EXECUTION_ID) != null)
+ exec.setExecutionId(n.get(EXECUTION_ID).asText());
if (n.get("request-id") != null)
exec.setRequestId(n.get("request-id").asText());
@@ -315,8 +316,8 @@ public class VTPExecutionResource extends VTPResource{
if (result.get("end-time") != null)
exec.setEndTime(result.get("end-time").asText());
- if (result.get("execution-id") != null)
- exec.setExecutionId(result.get("execution-id").asText());
+ if (result.get(EXECUTION_ID) != null)
+ exec.setExecutionId(result.get(EXECUTION_ID).asText());
if (result.get("request-id") != null)
exec.setExecutionId(result.get("request-id").asText());
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java
index b6629ccf..a273d31b 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java
@@ -32,9 +32,9 @@ public class ValidateLifecycleTestResponseTest {
{
validateLifecycleTestResponse.setJobId("huawei");
assertEquals(validateLifecycleTestResponse.getJobId(),"huawei");
- validateLifecycleTestResponse.setLifecycle_status("huawei");
- assertEquals(validateLifecycleTestResponse.getLifecycle_status(),"huawei");
- validateLifecycleTestResponse.setValidate_status("huawei");
- assertEquals(validateLifecycleTestResponse.getValidate_status(),"huawei");
+ validateLifecycleTestResponse.setLifecycleStatus("huawei");
+ assertEquals(validateLifecycleTestResponse.getLifecycleStatus(),"huawei");
+ validateLifecycleTestResponse.setValidateStatus("huawei");
+ assertEquals(validateLifecycleTestResponse.getValidateStatus(),"huawei");
}
} \ No newline at end of file