Add validation to market place

Added Csar, Tosca, and Mainservice validation

Change-Id: I43e5245b77cd5f096e8bd062546138ee311ab86c
Issue-Id: VNFSDK-90
Signed-off-by: AvinashS <avinash.s@huawei.com>
diff --git a/vnfmarket-be/vnf-sdk-marketplace/pom.xml b/vnfmarket-be/vnf-sdk-marketplace/pom.xml
index d281b97..6a526b5 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/pom.xml
+++ b/vnfmarket-be/vnf-sdk-marketplace/pom.xml
@@ -191,6 +191,11 @@
 			<version>2.4</version>
 		</dependency>
 		<!-- UT end -->
+		<dependency>
+			<groupId>org.onap.vnfsdk.validation</groupId>
+			<artifactId>validation-csar</artifactId>
+			<version>1.0.0-SNAPSHOT</version>
+		</dependency>
 	</dependencies>
 	<profiles>
 		<profile>
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 b3773c5..9178931 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
@@ -58,6 +58,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.onap.validation.csar.CsarValidator;
+
 import net.sf.json.JSONObject;
 
 public class PackageWrapper {
@@ -230,6 +232,21 @@
 
         uploadedInputStream.close();
 
+	try {
+		CsarValidator cv = new CsarValidator(packageId, fileLocation);
+
+		if (!cv.validateCsar()) {
+			LOG.error("Could not validate failed");
+			return Response.status(Status.EXPECTATION_FAILED).build();
+		} 
+
+
+	} catch (Exception e) {
+		LOG.error("CSAR validation panicked");
+		return Response.status(Status.EXPECTATION_FAILED).build();
+	}  
+        
+
         PackageBasicInfo basicInfo = PackageWrapperUtil.getPacageBasicInfo(fileLocation);
         UploadPackageResponse result = new UploadPackageResponse();
         Boolean isEnd = PackageWrapperUtil.isUploadEnd(contentRange);