summaryrefslogtreecommitdiffstats
path: root/vnfmarket-be
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket-be')
-rwxr-xr-xvnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/docker-entrypoint.sh7
-rwxr-xr-xvnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/instance-init.sh5
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java46
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java130
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerAddrConfig.java5
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfig.java15
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/MsbAddrConfig.java4
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java2
8 files changed, 105 insertions, 109 deletions
diff --git a/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/docker-entrypoint.sh b/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/docker-entrypoint.sh
index 4dba1a4f..df6cfce9 100755
--- a/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/docker-entrypoint.sh
+++ b/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/docker-entrypoint.sh
@@ -37,10 +37,6 @@ echo
# Configure service based on docker environment variables
./instance-config.sh
-# Start mysql
-chown -R mysql /var/lib/mysql
-chgrp -R mysql /var/lib/mysql
-su mysql -c /usr/bin/mysqld_safe &
# Perform one-time config
@@ -48,8 +44,7 @@ if [ ! -e init.log ]; then
# Perform workarounds due to defects in release binary
./instance-workaround.sh
- # Init mysql; set root password
- ./init-mysql.sh
+
# microservice-specific one-time initialization
./instance-init.sh
diff --git a/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/instance-init.sh b/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/instance-init.sh
index f052db2a..697eaded 100755
--- a/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/instance-init.sh
+++ b/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/instance-init.sh
@@ -15,11 +15,6 @@
# limitations under the License.
#
-# Initialize DB schema
-mysql -uroot -prootpass < init/marketplace_tables_mysql.sql
-
-# Set mysql password
-sed -i 's|Changeme_123|rootpass|' webapps/ROOT/WEB-INF/classes/mybatis/configuration/configuration.xml
#Set postgres instance IP
sed -i 's|127.0.0.1|'"$POSTGRES_IP"'|' webapps/ROOT/WEB-INF/classes/mybatis/configuration/configuration.xml
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java
index 5432300f..efeef061 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonConstant.java
@@ -16,6 +16,9 @@
package org.onap.vnfsdk.marketplace.common;
public class CommonConstant {
+ // Address
+ public static final String DEFAULT_MSB_ADDRESS = "http://127.0.0.1:8080";
+
// Package Status
public static final String PACKAGE_STATUS_DELETING = "deleting";
@@ -39,9 +42,9 @@ public class CommonConstant {
public static final String DEFINITIONS = "Definitions";
public static final String CSAR_META = "csar.meta";
-
+
public static final String MANIFEST = ".mf";
-
+
public static final String MF_VERSION_META = "vnf_package_version";
public static final String MF_PRODUCT_NAME = "vnf_product_name";
@@ -53,46 +56,46 @@ public class CommonConstant {
public static final String CSAR_SUFFIX = ".csar";
public static final String HTTP_HEADER_CONTENT_RANGE = "Content-Range";
-
+
public static final String CATALOG_CSAR_DIR_NAME = "/csar";
-
+
public static final String REPORT_CSAR_DIR_NAME = "/reports";
-
+
public static final String COMETD_CHANNEL_PACKAGE_DELETE = "/package/delete";
-
+
public static final String SUCCESS_STR = "SUCCESS";
-
+
public static final int ONBOARDING_THREAD_COUNT = 1;
public static final int SUCESS = 0;
public static final int FAILED = -1;
-
+
public static final String CATALOUGE_UPLOAD_URL = "/openoapi/catalog/v1/csars";
-
+
private CommonConstant (){
- // Cannot create instance of the class
+ // Cannot create instance of the class
}
-
- public static class functionTest
- {
+
+ public static class functionTest
+ {
public static final String FUNCTEST_URL = "/openoapi/vnfsdk/v1/functest/";
public static final String FUNCTEST_RESULT_URL = "/openoapi/vnfsdk/v1/functest/download/";
public static final String FUNCTEST_OPERTYPE_ID = "functiontest";
public static final String FUNCTEST_PACKAGE_EXISTS = "packageExists";
public static final String FUNCTEST_EXEC = "functestexec";
-
+
private functionTest() {
}
}
-
- public static class LifeCycleTest
- {
+
+ public static class LifeCycleTest
+ {
public static final String LIFECYCLE_TEST_URL = "/openoapi/nslcm/v1/vnfpackage";
public static final String LIFECYCLE_TEST_OPERTYPE_ID = "lifecycletest";
public static final String LIFECYCLE_TEST_EXEC = "lifecycleTestexec";
private LifeCycleTest() {
}
}
-
+
public static class HttpContext {
public static final String CONTENT_TYPE = "Content-Type";
@@ -106,7 +109,7 @@ public class CommonConstant {
private HttpContext() {
}
}
-
+
public static class MethodType {
public static final String POST = "post";
@@ -120,12 +123,12 @@ public class CommonConstant {
private MethodType() {
}
}
-
+
public static class MsbRegisterCode {
public static final int MSDB_REGISTER_RETRIES = 12;
public static final int MSDB_REGISTER_RETRY_SLEEP = 10000;
-
+
public static final int MSDB_REGISTER_FILE_NOT_EXISTS = 2;
public static final int MSDB_REGISTER_SUCESS = 0;
public static final int MSDB_REGISTER_FAILED = -1;
@@ -133,3 +136,4 @@ public class CommonConstant {
}
}
}
+
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 564e7d79..87fb75b6 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
@@ -15,16 +15,6 @@
*/
package org.onap.vnfsdk.marketplace.common;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.io.Resources;
-
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -34,9 +24,19 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
public final class FileUtil {
@@ -101,31 +101,30 @@ public final class FileUtil {
* @return unzip file name
* @throws IOException e1
*/
- public static ArrayList<String> unzip(String zipFileName, String extPlace) throws IOException {
- ZipFile zipFile = null;
- ArrayList<String> unzipFileNams = new ArrayList<String>();
+ public static List<String> unzip(String zipFileName, String extPlace) throws IOException {
+ List<String> unzipFileNams = new ArrayList<>();
- try {
- zipFile = new ZipFile(zipFileName);
+ try (
+ ZipFile zipFile = new ZipFile(zipFileName);
+ ) {
Enumeration<?> fileEn = zipFile.entries();
byte[] buffer = new byte[BUFFER_SIZE];
while (fileEn.hasMoreElements()) {
- InputStream input = null;
- BufferedOutputStream bos = null;
- try {
- ZipEntry entry = (ZipEntry) fileEn.nextElement();
- if (entry.isDirectory()) {
- continue;
- }
+ ZipEntry entry = (ZipEntry) fileEn.nextElement();
+ if (entry.isDirectory()) {
+ continue;
+ }
- input = zipFile.getInputStream(entry);
- File file = new File(extPlace, entry.getName());
- if (!file.getParentFile().exists()) {
- createDirectory(file.getParentFile().getAbsolutePath());
- }
+ File file = new File(extPlace, entry.getName());
+ if (!file.getParentFile().exists()) {
+ createDirectory(file.getParentFile().getAbsolutePath());
+ }
- bos = new BufferedOutputStream(new FileOutputStream(file));
+ try (
+ InputStream input = zipFile.getInputStream(entry);
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
+ ) {
while (true) {
int length = input.read(buffer);
if (length == -1) {
@@ -134,20 +133,15 @@ public final class FileUtil {
bos.write(buffer, 0, length);
}
unzipFileNams.add(file.getAbsolutePath());
- } finally {
- closeOutputStream(bos);
- closeInputStream(input);
}
}
- } finally {
- closeZipFile(zipFile);
}
return unzipFileNams;
}
/**
* close InputStream.
- *
+ *
* @param inputStream the inputstream to close
*/
public static void closeInputStream(InputStream inputStream) {
@@ -162,7 +156,7 @@ public final class FileUtil {
/**
* close OutputStream.
- *
+ *
* @param outputStream the output stream to close
*/
public static void closeOutputStream(OutputStream outputStream) {
@@ -174,7 +168,7 @@ public final class FileUtil {
logger.info("error while closing OutputStream!", e1);
}
}
-
+
public static void closeFileStream(FileInputStream ifs) {
try {
if (ifs != null) {
@@ -187,14 +181,13 @@ public final class FileUtil {
/**
* close zipFile.
- *
+ *
* @param zipFile the zipFile to close
*/
public static void closeZipFile(ZipFile zipFile) {
try {
if (zipFile != null) {
zipFile.close();
- zipFile = null;
}
} catch (IOException e1) {
logger.info("close ZipFile error!", e1);
@@ -213,34 +206,34 @@ public final class FileUtil {
return deleteFile(file);
}
- public static boolean writeJsonDatatoFile(String fileAbsPath, Object obj)
- {
+ 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
+
+ ObjectMapper mapper = new ObjectMapper();
+ try
{
mapper.writeValue(new File(fileAbsPath), obj);
bResult = true;
- }
- catch (JsonGenerationException e)
+ }
+ catch (JsonGenerationException e)
{
logger.info("JsonGenerationException Exception: writeJsonDatatoFile-->"+fileAbsPath, e);
- }
- catch (JsonMappingException e)
+ }
+ catch (JsonMappingException e)
{
logger.info("JsonMappingException Exception: writeJsonDatatoFile-->"+fileAbsPath, e);
- }
- catch (IOException e)
+ }
+ catch (IOException e)
{
logger.info("IOException Exception: writeJsonDatatoFile-->"+fileAbsPath, e);
- }
+ }
return bResult;
}
@@ -251,44 +244,44 @@ public final class FileUtil {
logger.info("read JsonData from file , file not found :"+fileAbsPath);
return null;
}
-
+
logger.info("read JsonData from file :"+fileAbsPath);
-
- T obj = null;
+
+ T obj = null;
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- try
+ try
{
obj = mapper.readValue(new File(fileAbsPath), clazz);
- }
- catch (JsonParseException e1)
+ }
+ catch (JsonParseException e1)
{
logger.info("JsonParseException Exception: writeJsonDatatoFile-->"+fileAbsPath, e1);
- }
- catch (JsonMappingException e1)
+ }
+ catch (JsonMappingException e1)
{
logger.info("JsonMappingException Exception: writeJsonDatatoFile-->"+fileAbsPath, e1);
- }
- catch (IOException e1)
+ }
+ catch (IOException e1)
{
logger.info("IOException Exception: writeJsonDatatoFile-->"+fileAbsPath, e1);
}
return obj;
}
-
- public static boolean deleteDirectory(String path)
+
+ public static boolean deleteDirectory(String path)
{
File file = new File(path);
return deleteDirectory(file);
}
-
- public static boolean deleteDirectory(File file)
+
+ public static boolean deleteDirectory(File file)
{
if (!file.exists())
{
- return true;
- }
- if (file.isDirectory())
+ return true;
+ }
+ if (file.isDirectory())
{
for (File f : file.listFiles())
{
@@ -298,3 +291,4 @@ public final class FileUtil {
return file.delete();
}
}
+
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerAddrConfig.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerAddrConfig.java
index 2adf1b89..88913a1c 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerAddrConfig.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerAddrConfig.java
@@ -17,9 +17,11 @@ package org.onap.vnfsdk.marketplace.common;
public class HttpServerAddrConfig {
-
protected static String httpServerAddress;
+ private HttpServerAddrConfig () {
+ }
+
public static String getHttpServerAddress() {
return httpServerAddress;
}
@@ -29,3 +31,4 @@ public class HttpServerAddrConfig {
}
}
+
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfig.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfig.java
index 3d5cfacc..f7a499b5 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfig.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfig.java
@@ -17,15 +17,15 @@ package org.onap.vnfsdk.marketplace.common;
public class HttpServerPathConfig {
protected static String httpServerPath;
-
+
+ private HttpServerPathConfig() {
+ }
+
static
{
-// CatalogAppConfiguration configuration = new CatalogAppConfiguration();
-// Config.setConfigration(configuration);
-// Config.getConfigration().setMsbServerAddr("http://127.0.0.1:80");
- MsbAddrConfig.setMsbAddress("http://127.0.0.1:8080");
- HttpServerAddrConfig.setHttpServerAddress("http://127.0.0.1:8080");
- HttpServerPathConfig.setHttpServerPath("../tomcat/webapps/ROOT/");
+ MsbAddrConfig.setMsbAddress(CommonConstant.DEFAULT_MSB_ADDRESS);
+ HttpServerAddrConfig.setHttpServerAddress(CommonConstant.DEFAULT_MSB_ADDRESS);
+ HttpServerPathConfig.setHttpServerPath("../tomcat/webapps/ROOT/");
}
public static String getHttpServerPath() {
@@ -36,3 +36,4 @@ public class HttpServerPathConfig {
HttpServerPathConfig.httpServerPath = httpServerPath;
}
}
+
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/MsbAddrConfig.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/MsbAddrConfig.java
index d2ff4b55..379f1037 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/MsbAddrConfig.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/MsbAddrConfig.java
@@ -19,6 +19,9 @@ public class MsbAddrConfig {
protected static String msbAddress;
+ private MsbAddrConfig() {
+ }
+
public static String getMsbAddress() {
return msbAddress;
}
@@ -28,3 +31,4 @@ public class MsbAddrConfig {
}
}
+
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 e3bfe0e4..c55019d5 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
@@ -271,7 +271,7 @@ public class PackageWrapperUtil {
boolean isXmlCsar = false;
try {
String tempfolder = unzipDir;
- ArrayList<String> unzipFiles = FileUtil.unzip(fileLocation, tempfolder);
+ List<String> unzipFiles = FileUtil.unzip(fileLocation, tempfolder);
if (unzipFiles.isEmpty()) {
isXmlCsar = true;
}