summaryrefslogtreecommitdiffstats
path: root/vnfmarket-be
diff options
context:
space:
mode:
authorMurali Mohan Murthy Potham <murali.p@huawei.com>2018-03-08 14:26:36 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-08 14:26:36 +0000
commit1491d33172f01bee49a38487e3e381be64302c7e (patch)
tree03ee2a887ed942352460d4ebd5b22e57ccb3ba99 /vnfmarket-be
parent625ccf273fd3438a423c8da7b54975fa196594e7 (diff)
parent7dbda3605e0809e4e2c3402b1f98f721f8e5110d (diff)
Merge "Fix security issues"
Diffstat (limited to 'vnfmarket-be')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/pom.xml19
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java292
2 files changed, 141 insertions, 170 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/pom.xml b/vnfmarket-be/vnf-sdk-marketplace/pom.xml
index 952925b5..1577526d 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/pom.xml
+++ b/vnfmarket-be/vnf-sdk-marketplace/pom.xml
@@ -22,7 +22,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <cxf.version>3.1.9</cxf.version>
+ <cxf.version>3.2.1</cxf.version>
<!-- slf4j.version>1.6.1</slf4j.version> -->
<maven.test.skip>false</maven.test.skip>
<maven.test.failure.ignore>false</maven.test.failure.ignore>
@@ -55,7 +55,7 @@
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
- <version>0.8.0</version>
+ <version>0.9.3</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
@@ -66,12 +66,12 @@
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-assets</artifactId>
- <version>0.8.0</version>
+ <version>0.9.3</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-hibernate</artifactId>
- <version>0.8.0</version>
+ <version>0.9.3</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
@@ -97,7 +97,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
- <version>4.5.2</version>
+ <version>4.5.3</version>
</dependency>
<!-- consumer -->
<dependency>
@@ -179,12 +179,7 @@
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
- <dependency>
- <groupId>net.sf.json-lib</groupId>
- <artifactId>json-lib</artifactId>
- <version>2.4</version>
- <classifier>jdk15</classifier>
- </dependency>
+
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
@@ -218,7 +213,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.19.1</version>
+ <version>2.20</version>
<configuration>
<forkMode>always</forkMode>
<argLine>${surefireArgLine}</argLine>
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 de77d240..d779bf5f 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
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.onap.vnfsdk.marketplace.wrapper;
import java.io.BufferedInputStream;
@@ -59,74 +60,68 @@ import org.onap.vnfsdk.marketplace.onboarding.onboardmanager.OnBoardingHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import net.sf.json.JSONObject;
-
public class PackageWrapper {
+
private static PackageWrapper packageWrapper;
+
private static final Logger LOG = LoggerFactory.getLogger(PackageWrapper.class);
/**
* get PackageWrapper instance.
+ *
* @return package wrapper instance
*/
public static PackageWrapper getInstance() {
- if (packageWrapper == null) {
+ if(packageWrapper == null) {
packageWrapper = new PackageWrapper();
}
return packageWrapper;
}
- public Response updateValidateStatus(InputStream inputStream) throws IOException
- {
+ public Response updateValidateStatus(InputStream inputStream) throws IOException {
String reqParam = IOUtils.toString(inputStream);
- LOG.info("updateValidateStatus request param:"+reqParam);
+ LOG.info("updateValidateStatus request param:" + reqParam);
if(StringUtils.isBlank(reqParam)) {
LOG.error("The updateValidateStatus request params can't be null");
return Response.status(Status.EXPECTATION_FAILED).build();
}
- ValidateLifecycleTestResponse lyfValidateResp = JsonUtil.fromJson(reqParam, ValidateLifecycleTestResponse.class);
- if(!checkOperationSucess(lyfValidateResp))
- {
+ ValidateLifecycleTestResponse lyfValidateResp =
+ JsonUtil.fromJson(reqParam, ValidateLifecycleTestResponse.class);
+ if(!checkOperationSucess(lyfValidateResp)) {
return Response.status(Status.EXPECTATION_FAILED).build();
}
String funcTestResponse = FunctionTestExceutor.executeFunctionTest(reqParam);
- if(null == funcTestResponse)
- {
+ if(null == funcTestResponse) {
return Response.status(Status.EXPECTATION_FAILED).build();
}
- JSONObject funcTestRspObject = JSONObject.fromObject(funcTestResponse);
- if(!funcTestRspObject.get("status").equals(CommonConstant.SUCCESS_STR))
- {
+ if(!funcTestResponse.contains(CommonConstant.SUCCESS_STR)) {
return Response.status(Status.EXPECTATION_FAILED).build();
}
- JSONObject result = new JSONObject();
- result.put("msg","SUCCESS");
- return Response.ok(ToolUtil.objectToString(result), MediaType.APPLICATION_JSON).build();
+ return Response.ok().build();
}
- private boolean checkOperationSucess(ValidateLifecycleTestResponse lyfValidateResp)
- {
+ private boolean checkOperationSucess(ValidateLifecycleTestResponse lyfValidateResp) {
boolean bOperStatus = false;
- if(null == lyfValidateResp)
- {
+ if(null == lyfValidateResp) {
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());
- bOperStatus = true;
+ && lyfValidateResp.getValidate_status().equalsIgnoreCase(CommonConstant.SUCCESS_STR)) {
+ LOG.error("Lifecycle/Validation Response failed :" + lyfValidateResp.getLifecycle_status() + File.separator
+ + lyfValidateResp.getValidate_status());
+ bOperStatus = true;
}
return bOperStatus;
}
/**
* query package list by condition.
+ *
* @param name package name
* @param provider package provider
* @param version package version
@@ -134,18 +129,17 @@ public class PackageWrapper {
* @param type package type
* @return Response
*/
- public Response queryPackageListByCond(String name, String provider, String version,
- String deletionPending, String type) {
+ public Response queryPackageListByCond(String name, String provider, String version, String deletionPending,
+ String type) {
List<PackageData> dbresult = new ArrayList<>();
List<PackageMeta> result = new ArrayList<>();
- LOG.info("query package info.name:" + name + " provider:" + provider + " version" + version
- + " deletionPending" + deletionPending + " type:" + type);
+ LOG.info("query package info.name:" + name + " provider:" + provider + " version" + version + " deletionPending"
+ + deletionPending + " type:" + type);
try {
- dbresult =
- PackageManager.getInstance().queryPackage(name, provider, version, deletionPending, type);
+ dbresult = PackageManager.getInstance().queryPackage(name, provider, version, deletionPending, type);
result = PackageWrapperUtil.packageDataList2PackageMetaList(dbresult);
return Response.ok(ToolUtil.objectToString(result)).build();
- } catch (MarketplaceResourceException e1) {
+ } catch(MarketplaceResourceException e1) {
LOG.error("query package by csarId from db error ! ", e1);
return RestUtil.getRestException(e1.getMessage());
}
@@ -153,6 +147,7 @@ public class PackageWrapper {
/**
* query package by id.
+ *
* @param csarId package id
* @return Response
*/
@@ -164,37 +159,38 @@ public class PackageWrapper {
/**
* upload package.
+ *
* @param uploadedInputStream inputStream
* @param fileDetail package detail
* @param head http header
* @return Response
* @throws Exception e
*/
- public Response uploadPackage(InputStream uploadedInputStream,
- FormDataContentDisposition fileDetail, String details, HttpHeaders head) throws MarketplaceResourceException
- {
+ public Response uploadPackage(InputStream uploadedInputStream, FormDataContentDisposition fileDetail,
+ String details, HttpHeaders head) throws MarketplaceResourceException {
LOG.info("Upload/Reupload request Received !!!!");
try {
String packageId = MarketplaceDbUtil.generateId();
- return handlePackageUpload(packageId,uploadedInputStream, fileDetail, details, head);
- } catch (IOException e) {
+ return handlePackageUpload(packageId, uploadedInputStream, fileDetail, details, head);
+ } catch(IOException e) {
LOG.error("can't get package id", e);
}
return Response.status(Status.INTERNAL_SERVER_ERROR).build();
}
- private UploadPackageResponse manageUpload(String packageId, String fileName, String fileLocation,
- String details, String contentRange) throws IOException, MarketplaceResourceException
- {
+ private UploadPackageResponse manageUpload(String packageId, String fileName, String fileLocation, String details,
+ String contentRange) throws IOException, MarketplaceResourceException {
String localDirName = ToolUtil.getTempDir(CommonConstant.CATALOG_CSAR_DIR_NAME, fileName);
PackageBasicInfo basicInfo = PackageWrapperUtil.getPacageBasicInfo(fileLocation);
UploadPackageResponse result = new UploadPackageResponse();
Boolean isEnd = PackageWrapperUtil.isUploadEnd(contentRange);
- if (isEnd)
- {
- PackageMeta packageMeta = PackageWrapperUtil.getPackageMeta(packageId, fileName, fileLocation, basicInfo, details);
+ if(isEnd) {
+ PackageMeta packageMeta =
+ 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 + basicInfo.getVersion();
+ String path = basicInfo.getType().toString() + File.separator + basicInfo.getProvider() + File.separator
+ + packageMeta.getCsarId() + File.separator + fileName.replace(".csar", "") + File.separator
+ + basicInfo.getVersion();
String dowloadUri = File.separator + path + File.separator;
packageMeta.setDownloadUri(dowloadUri);
@@ -206,8 +202,7 @@ public class PackageWrapper {
String destPath = File.separator + path + File.separator + File.separator;
boolean uploadResult = FileManagerFactory.createFileManager().upload(localDirName, destPath);
- if (uploadResult)
- {
+ if(uploadResult) {
OnBoradingRequest oOnboradingRequest = new OnBoradingRequest();
oOnboradingRequest.setCsarId(packageId);
oOnboradingRequest.setPackageName(fileName);
@@ -217,16 +212,17 @@ public class PackageWrapper {
packageData.setDownloadCount(-1);
PackageData packateDbData = PackageManager.getInstance().addPackage(packageData);
- LOG.info("Store package data to database succed ! packateDbData = " + ToolUtil.objectToString(packateDbData));
+ LOG.info("Store package data to database succed ! packateDbData = "
+ + ToolUtil.objectToString(packateDbData));
LOG.info("upload package file end, fileName:" + fileName);
result.setCsarId(packateDbData.getCsarId());
addOnBoardingRequest(oOnboradingRequest);
- LOG.info("OnboradingRequest Data : " + ToolUtil.objectToString(oOnboradingRequest));
+ LOG.info("OnboradingRequest Data : " + ToolUtil.objectToString(oOnboradingRequest));
}
- } catch (NullPointerException e) {
+ } catch(NullPointerException e) {
LOG.error("Package basicInfo is incorrect ! basicIonfo = " + ToolUtil.objectToString(basicInfo), e);
return null;
}
@@ -236,6 +232,7 @@ public class PackageWrapper {
/**
* Interface for Uploading package
+ *
* @param packageId
* @param uploadedInputStream
* @param fileDetail
@@ -245,19 +242,17 @@ public class PackageWrapper {
* @throws IOException
* @throws MarketplaceResourceException
*/
- private Response handlePackageUpload(String packageId,InputStream uploadedInputStream, FormDataContentDisposition fileDetail,
- String details, HttpHeaders head) throws IOException, MarketplaceResourceException
- {
- boolean bResult = handleDataValidate(packageId,uploadedInputStream,fileDetail);
- if(!bResult)
- {
+ private Response handlePackageUpload(String packageId, InputStream uploadedInputStream,
+ FormDataContentDisposition fileDetail, String details, HttpHeaders head)
+ throws IOException, MarketplaceResourceException {
+ boolean bResult = handleDataValidate(packageId, uploadedInputStream, fileDetail);
+ if(!bResult) {
LOG.error("Validation of Input received for Package Upload failed !!!");
return Response.status(Status.EXPECTATION_FAILED).build();
}
- String fileName = "temp_"+ packageId + ".csar";
- if (null != fileDetail)
- {
+ String fileName = "temp_" + packageId + ".csar";
+ if(null != fileDetail) {
LOG.info("the fileDetail = " + ToolUtil.objectToString(fileDetail));
fileName = ToolUtil.processFileName(fileDetail.getFileName());
@@ -266,13 +261,11 @@ public class PackageWrapper {
String localDirName = ToolUtil.getTempDir(CommonConstant.CATALOG_CSAR_DIR_NAME, fileName);
String contentRange = null;
- if (head != null)
- {
+ if(head != null) {
contentRange = head.getHeaderString(CommonConstant.HTTP_HEADER_CONTENT_RANGE);
}
LOG.info("store package chunk file, fileName:" + fileName + ",contentRange:" + contentRange);
- if (ToolUtil.isEmptyString(contentRange))
- {
+ if(ToolUtil.isEmptyString(contentRange)) {
int fileSize = uploadedInputStream.available();
contentRange = "0-" + fileSize + "/" + fileSize;
}
@@ -285,18 +278,17 @@ public class PackageWrapper {
try {
CsarValidator cv = new CsarValidator(packageId, fileLocation);
- if (!cv.validateCsar()) {
+ if(!cv.validateCsar()) {
LOG.error("Could not validate failed");
return Response.status(Status.EXPECTATION_FAILED).build();
}
- } catch (Exception e) {
+ } catch(Exception e) {
LOG.error("CSAR validation panicked", e);
return Response.status(Status.EXPECTATION_FAILED).build();
}
UploadPackageResponse result = manageUpload(packageId, fileName, fileLocation, details, contentRange);
- if (null != result)
- {
+ if(null != result) {
return Response.ok(ToolUtil.objectToString(result), MediaType.APPLICATION_JSON).build();
} else {
return Response.serverError().build();
@@ -305,10 +297,10 @@ public class PackageWrapper {
/**
* Execute OnBarding request
+ *
* @param oOnboradingRequest
*/
- private void addOnBoardingRequest(final OnBoradingRequest oOnboradingRequest)
- {
+ private void addOnBoardingRequest(final OnBoradingRequest oOnboradingRequest) {
ExecutorService es = Executors.newFixedThreadPool(CommonConstant.ONBOARDING_THREAD_COUNT);
Callable<Integer> callableInteger = () -> {
new OnBoardingHandler().handleOnBoardingReq(oOnboradingRequest);
@@ -319,12 +311,13 @@ public class PackageWrapper {
/**
* delete package by package id.
+ *
* @param csarId package id
* @return Response
*/
public Response delPackage(String csarId) {
LOG.info("delete package info.csarId:" + csarId);
- if (ToolUtil.isEmptyString(csarId)) {
+ if(ToolUtil.isEmptyString(csarId)) {
LOG.error("delete package fail, csarid is null");
return Response.serverError().build();
}
@@ -334,30 +327,31 @@ public class PackageWrapper {
/**
* Delete Package by CSAR ID
+ *
* @param csarId
*/
- private void deletePackageDataById(String csarId) {
+ private void deletePackageDataById(String csarId) {
String packagePath = PackageWrapperUtil.getPackagePath(csarId);
- if (packagePath == null) {
+ if(packagePath == null) {
LOG.error("package path is null! ");
}
- //Delete Package
+ // Delete Package
FileManagerFactory.createFileManager().delete(packagePath);
- //Delete Results Data
+ // Delete Results Data
FileManagerFactory.createFileManager().delete(File.separator + csarId);
-
- //delete package data from database
+ // delete package data from database
try {
PackageManager.getInstance().deletePackage(csarId);
- } catch (MarketplaceResourceException e1) {
+ } catch(MarketplaceResourceException e1) {
LOG.error("delete package by csarId from db error ! " + e1.getMessage(), e1);
}
}
/**
* download package by package id.
+ *
* @param csarId package id
* @return Response
*/
@@ -365,28 +359,25 @@ public class PackageWrapper {
PackageData packageData = PackageWrapperUtil.getPackageInfoById(csarId);
String packageName = packageData.getName();
- 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";
+ 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";
LOG.info("downloadCsarPackagesById path is : " + path);
File csarFile = new File(path);
- if (!csarFile.exists()) {
+ if(!csarFile.exists()) {
return Response.status(Status.INTERNAL_SERVER_ERROR).build();
}
LOG.info("downloadCsarPackagesById ABS path is : " + csarFile.getAbsolutePath());
- try
- {
+ try {
InputStream fis = new BufferedInputStream(new FileInputStream(csarFile.getAbsolutePath()));
- return Response.ok(fis)
- .header("Content-Disposition", "attachment; filename=\"" + csarFile.getName() + "\"")
+ return Response.ok(fis).header("Content-Disposition", "attachment; filename=\"" + csarFile.getName() + "\"")
.build();
- }
- catch (Exception e1)
- {
+ } catch(Exception e1) {
LOG.error("download vnf package fail.", e1);
return RestUtil.getRestException(e1.getMessage());
}
@@ -394,6 +385,7 @@ public class PackageWrapper {
/**
* get package file uri.
+ *
* @param csarId package id
* @param relativePath file relative path
* @return Response
@@ -404,29 +396,27 @@ public class PackageWrapper {
/**
* Interface to Update Download count for CSAR ID
+ *
* @param csarId
* @return
*/
public Response updateDwonloadCount(String csarId) {
- return handleDownladCountUpdate(csarId) ?
- Response.ok().build() :
- Response.status(Status.EXPECTATION_FAILED).build();
+ return handleDownladCountUpdate(csarId) ? Response.ok().build()
+ : Response.status(Status.EXPECTATION_FAILED).build();
}
/**
* Handle downlowa count update
+ *
* @param csarId
* @return
*/
private boolean handleDownladCountUpdate(String csarId) {
boolean bupdateSucess = false;
- try
- {
+ try {
PackageManager.getInstance().updateDownloadCount(csarId);
bupdateSucess = true;
- }
- catch (Exception exp)
- {
+ } catch(Exception exp) {
LOG.error("Updating Donwload count failed for Package with ID !!! : " + exp.getMessage(), exp);
}
return bupdateSucess;
@@ -434,6 +424,7 @@ public class PackageWrapper {
/**
* Interface to Re upload Package
+ *
* @param csarId
* @param uploadedInputStream
* @param fileDetail
@@ -442,32 +433,28 @@ public class PackageWrapper {
* @return
* @throws Exception
*/
- public Response reUploadPackage(String csarId,
- InputStream uploadedInputStream,
- FormDataContentDisposition fileDetail,
- String details,
- HttpHeaders head) throws MarketplaceResourceException
- {
+ 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
- //----------------------------
- boolean bResult = handleDataValidate(csarId,uploadedInputStream,fileDetail);
- if(!bResult)
- {
+ // STEP 1: Validate Input Data
+ // ----------------------------
+ boolean bResult = handleDataValidate(csarId, uploadedInputStream, fileDetail);
+ if(!bResult) {
LOG.error("Validation of Input received for Package Upload failed during Reload!!!");
return Response.status(Status.EXPECTATION_FAILED).build();
}
try {
- //STEP 2: Delete All Package Data based on package id
- //----------------------------------------------------
+ // STEP 2: Delete All Package Data based on package id
+ // ----------------------------------------------------
deletePackageDataById(csarId);
- //STEP 3: upload package with same package id
- //-------------------------------------------
- return handlePackageUpload(csarId,uploadedInputStream, fileDetail, details, head);
- } catch (IOException e) {
+ // STEP 3: upload package with same package id
+ // -------------------------------------------
+ return handlePackageUpload(csarId, uploadedInputStream, fileDetail, details, head);
+ } catch(IOException e) {
LOG.error("delete package failed", e);
}
return Response.status(Status.INTERNAL_SERVER_ERROR).build();
@@ -475,24 +462,24 @@ public class PackageWrapper {
/**
* Interface to get OnBoarding Result by Operation Type
+ *
* @param csarId
* @param operTypeId
* @param operId
* @return
*/
- public Response getOnBoardingResult(String csarId, String operTypeId, String operId)
- {
+ public Response getOnBoardingResult(String csarId, String operTypeId, String operId) {
LOG.info("getOnBoardingResult request : csarId:" + csarId + " operTypeId:" + operTypeId + " operId:" + operId);
try {
PackageData packageData = PackageWrapperUtil.getPackageInfoById(csarId);
- if (null == packageData) {
+ if(null == packageData) {
return Response.status(Response.Status.PRECONDITION_FAILED).build();
}
handleDelayExec(operId);
OnBoardingResult oOnBoardingResult = FunctionTestHook.getOnBoardingResult(packageData);
- if (null == oOnBoardingResult) {
+ if(null == oOnBoardingResult) {
return Response.status(Response.Status.PRECONDITION_FAILED).build();
}
filterOnBoardingResultByOperId(oOnBoardingResult, operId);
@@ -500,20 +487,17 @@ public class PackageWrapper {
String strResult = ToolUtil.objectToString(oOnBoardingResult);
LOG.info("getOnBoardingResult response : " + strResult);
return Response.ok(strResult, "application/json").build();
- } catch (NullPointerException e) {
+ } catch(NullPointerException e) {
LOG.error("Null param in getOnBoardingResult", e);
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
-
- private void filterOnBoardingResultByOperId(OnBoardingResult oOnBoardingResult, String operId)
- {
- if (0 == operId.compareToIgnoreCase("all")) {
+ private void filterOnBoardingResultByOperId(OnBoardingResult oOnBoardingResult, String operId) {
+ if(0 == operId.compareToIgnoreCase("all")) {
return;
}
- if (0 == operId.compareToIgnoreCase("download"))
- {
+ if(0 == operId.compareToIgnoreCase("download")) {
List<OnBoardingOperResult> operResultListTemp = new ArrayList<>();
OnBoardingOperResult operResultListTmp = new OnBoardingOperResult();
operResultListTmp.setOperId("download");
@@ -524,8 +508,8 @@ public class PackageWrapper {
}
List<OnBoardingOperResult> operResultListOut = new ArrayList<>();
List<OnBoardingOperResult> operResultList = oOnBoardingResult.getOperResult();
- for (OnBoardingOperResult operResult : operResultList) {
- if (0 == operResult.getOperId().compareToIgnoreCase(operId)) {
+ for(OnBoardingOperResult operResult : operResultList) {
+ if(0 == operResult.getOperId().compareToIgnoreCase(operId)) {
operResultListOut.add(operResult);
}
}
@@ -534,42 +518,38 @@ public class PackageWrapper {
/**
* Interface to get OnBoarding Status by Operation ID
+ *
* @param csarId
* @param operTypeId
* @return
*/
- public Response getOperResultByOperTypeId(String csarId, String operTypeId)
- {
- LOG.error("getOnBoardingResult request : csarId:"+ csarId + " operTypeId:"+operTypeId);
- if(null == csarId || null == operTypeId || csarId.isEmpty() || operTypeId.isEmpty())
- {
+ public Response getOperResultByOperTypeId(String csarId, String operTypeId) {
+ LOG.error("getOnBoardingResult request : csarId:" + csarId + " operTypeId:" + operTypeId);
+ if(null == csarId || null == operTypeId || csarId.isEmpty() || operTypeId.isEmpty()) {
return Response.status(Status.BAD_REQUEST).build();
}
PackageData packageData = PackageWrapperUtil.getPackageInfoById(csarId);
- if(null == packageData)
- {
- LOG.error("Failed to find package for PackageID:"+ csarId);
+ if(null == packageData) {
+ LOG.error("Failed to find package for PackageID:" + csarId);
return Response.status(Status.PRECONDITION_FAILED).build();
}
- //Get result key to fetch Function Test Results
- //---------------------------------------------
+ // Get result key to fetch Function Test Results
+ // ---------------------------------------------
String strResult = FunctionTestHook.getFuncTestResults(packageData);
- if(null == strResult)
- {
- LOG.error("NULL reponse for getOperResultByOperTypeId response :"+ strResult);
+ if(null == strResult) {
+ LOG.error("NULL reponse for getOperResultByOperTypeId response :" + strResult);
return Response.status(Status.INTERNAL_SERVER_ERROR).build();
}
- LOG.info("getOperResultByOperTypeId response :"+ strResult);
+ LOG.info("getOperResultByOperTypeId response :" + strResult);
return Response.ok(strResult, MediaType.APPLICATION_JSON).build();
}
- private boolean handleDataValidate(String packageId,InputStream uploadedInputStream, FormDataContentDisposition fileDetail)
- {
+ private boolean handleDataValidate(String packageId, InputStream uploadedInputStream,
+ FormDataContentDisposition fileDetail) {
boolean bvalidateOk = false;
- if ((null != uploadedInputStream) && (fileDetail != null) && !ToolUtil.isEmptyString(packageId))
- {
+ if((null != uploadedInputStream) && (fileDetail != null) && !ToolUtil.isEmptyString(packageId)) {
bvalidateOk = true;
}
return bvalidateOk;
@@ -577,17 +557,19 @@ public class PackageWrapper {
/**
* Interface to get OnBoarding Steps
+ *
* @return
*/
- public Response getOnBoardingSteps()
- {
+ public Response getOnBoardingSteps() {
LOG.info("Get OnBoarding Steps request Received !!!");
- String filePath = org.onap.vnfsdk.marketplace.filemanage.http.ToolUtil.getAppDeployPath() + File.separator +"generalconfig/OnBoardingSteps.json";
+ String filePath = org.onap.vnfsdk.marketplace.filemanage.http.ToolUtil.getAppDeployPath() + File.separator
+ + "generalconfig/OnBoardingSteps.json";
LOG.info("Onboarding Steps Json file Path :" + filePath);
- OnBoardingSteps oOnBoardingSteps = (OnBoardingSteps)FileUtil.readJsonDatafFromFile(filePath, OnBoardingSteps.class);
- if (null == oOnBoardingSteps) {
+ OnBoardingSteps oOnBoardingSteps =
+ (OnBoardingSteps)FileUtil.readJsonDatafFromFile(filePath, OnBoardingSteps.class);
+ if(null == oOnBoardingSteps) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
String strResult = ToolUtil.objectToString(oOnBoardingSteps);
@@ -595,20 +577,14 @@ public class PackageWrapper {
return Response.ok(strResult, MediaType.APPLICATION_JSON).build();
}
- private void handleDelayExec(String operId)
- {
- if (0 == operId.compareToIgnoreCase(CommonConstant.functionTest.FUNCTEST_EXEC))
- {
- try
- {
+ private void handleDelayExec(String operId) {
+ if(0 == operId.compareToIgnoreCase(CommonConstant.functionTest.FUNCTEST_EXEC)) {
+ try {
Thread.sleep(8000);
- }
- catch (InterruptedException e)
- {
+ } catch(InterruptedException e) {
LOG.info("handleDelayExex response : ", e);
Thread.currentThread().interrupt();
}
}
}
}
-