1 package org.openecomp.sdc.vendorsoftwareproduct;
3 import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
4 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
6 import org.openecomp.sdc.versioning.dao.types.Version;
7 import org.openecomp.core.utilities.file.FileUtils;
10 import java.util.List;
11 import java.util.zip.ZipEntry;
12 import java.util.zip.ZipOutputStream;
14 public class VSPCommon {
16 public static VspDetails createVspDetails(String id, Version version, String name, String desc,
17 String vendorName, String vlm, String icon,
18 String category, String subCategory,
19 String licenseAgreement, List<String> featureGroups) {
20 VspDetails vspDetails = new VspDetails(id, version);
21 vspDetails.setName(name);
22 vspDetails.setDescription(desc);
23 vspDetails.setIcon(icon);
24 vspDetails.setCategory(category);
25 vspDetails.setSubCategory(subCategory);
26 vspDetails.setVendorName(vendorName);
27 vspDetails.setVendorId(vlm);
28 vspDetails.setVlmVersion(new Version(1, 0));
29 vspDetails.setLicenseAgreement(licenseAgreement);
30 vspDetails.setFeatureGroups(featureGroups);
35 public static VendorLicenseModelEntity createVendorLicenseModel(String name, String desc,
37 VendorLicenseModelEntity vendorLicenseModel = new VendorLicenseModelEntity();
38 vendorLicenseModel.setVendorName(name);
39 vendorLicenseModel.setDescription(desc);
40 vendorLicenseModel.setIconRef(icon);
41 return vendorLicenseModel;
44 public static void zipDir(File file, String path, ZipOutputStream zos) {
45 zipDir(file, path, zos, false);
48 public static void zipDir(File file, String path, ZipOutputStream zos, boolean isRootDir) {
49 if (file.isDirectory()) {
50 path += File.separator + file.getName();
51 File[] files = file.listFiles();
53 for (File innerFile : files) {
55 zipDir(innerFile, "", zos, false);
57 zipDir(innerFile, path, zos, false);
64 if (!path.isEmpty()) {
65 path += File.separator;
67 zos.putNextEntry(new ZipEntry(path + file.getName()));
68 InputStream is = new FileInputStream(file);
69 byte[] data = FileUtils.toByteArray(is);
72 } catch (IOException e) {