aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vnfmarket-be/deployment/install/docker-compose.yml3
-rw-r--r--vnfmarket-be/deployment/zip/src/main/release/bin/start.sh2
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/pom.xml9
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeException.java25
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java44
5 files changed, 54 insertions, 29 deletions
diff --git a/vnfmarket-be/deployment/install/docker-compose.yml b/vnfmarket-be/deployment/install/docker-compose.yml
index e4d9c5d5..75f31c20 100644
--- a/vnfmarket-be/deployment/install/docker-compose.yml
+++ b/vnfmarket-be/deployment/install/docker-compose.yml
@@ -21,8 +21,11 @@ services:
image: "${NEXUS_REPO}/onap/refrepo:${REFREPO_TAG}"
ports:
- "8702-8703:8702-8703"
+ - "8000:8000"
environment:
POSTGRES_IP: postgres
+ JPDA_ADDRESS: 8000
+ JPDA_TRANSPORT: dt_socket
volumes:
- /data/csars:/service/webapps/ROOT/WEB-INF/tomcat/webapps/ROOT/CSAR
links:
diff --git a/vnfmarket-be/deployment/zip/src/main/release/bin/start.sh b/vnfmarket-be/deployment/zip/src/main/release/bin/start.sh
index 0724e98b..d11c6b1f 100644
--- a/vnfmarket-be/deployment/zip/src/main/release/bin/start.sh
+++ b/vnfmarket-be/deployment/zip/src/main/release/bin/start.sh
@@ -40,6 +40,6 @@ LOG_DIR=$CATALINA_BASE/logs
if [ ! -d "$LOG_DIR" ]; then
mkdir $LOG_DIR
fi
-$CATALINA_HOME/bin/catalina.sh start
+$CATALINA_HOME/bin/catalina.sh jpda start
diff --git a/vnfmarket-be/vnf-sdk-marketplace/pom.xml b/vnfmarket-be/vnf-sdk-marketplace/pom.xml
index b9b69119..790de5c3 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/pom.xml
+++ b/vnfmarket-be/vnf-sdk-marketplace/pom.xml
@@ -72,7 +72,7 @@
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
- <version>2.21</version>
+ <version>2.26</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
@@ -161,11 +161,16 @@
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
+ <artifactId>jersey-guava</artifactId>
+ <version>2.6</version>
+ </dependency>
<!-- UT end -->
<dependency>
<groupId>org.onap.vnfsdk.validation</groupId>
<artifactId>validation-csar</artifactId>
- <version>1.1.0</version>
+ <version>1.1.1</version>
</dependency>
</dependencies>
<profiles>
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeException.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeException.java
index 50cdb2ac..b41a759d 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeException.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeException.java
@@ -13,20 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.onap.vnfsdk.marketplace.db.exception;
public class ErrorCodeException extends Exception {
- private static final long serialVersionUID = 3220072444842529499L;
- private final int errorCode;
+ private static final long serialVersionUID = 3220072444842529499L;
+
+ private final int errorCode;
+
+ public ErrorCodeException(Throwable source, int category, int code, String debugMessage, String[] arguments) {
+ super(debugMessage, source);
+ this.errorCode = code;
+ }
- public ErrorCodeException(Throwable source, int category, int code, String debugMessage, String[] arguments) {
- super(debugMessage, source);
- this.errorCode = code;
- }
+ public ErrorCodeException(int errorCode, String debugMessage) {
+ super(debugMessage);
+ this.errorCode = errorCode;
+ }
- public int getErrorCode() {
- return errorCode;
- }
+ public int getErrorCode() {
+ return errorCode;
+ }
}
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 cc3ec203..3fbdd94d 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
@@ -34,6 +34,7 @@ import javax.ws.rs.core.Response.Status;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
+import org.eclipse.jetty.http.HttpStatus;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.onap.validation.csar.CsarValidator;
import org.onap.vnfsdk.marketplace.common.CommonConstant;
@@ -41,6 +42,7 @@ import org.onap.vnfsdk.marketplace.common.FileUtil;
import org.onap.vnfsdk.marketplace.common.RestUtil;
import org.onap.vnfsdk.marketplace.common.ToolUtil;
import org.onap.vnfsdk.marketplace.db.entity.PackageData;
+import org.onap.vnfsdk.marketplace.db.exception.ErrorCodeException;
import org.onap.vnfsdk.marketplace.db.exception.MarketplaceResourceException;
import org.onap.vnfsdk.marketplace.db.resource.PackageManager;
import org.onap.vnfsdk.marketplace.db.util.MarketplaceDbUtil;
@@ -85,8 +87,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/
+ // JsonUtil.fromJson(reqParam, ValidateLifecycleTestResponse.class);
if(!checkOperationSucess(lyfValidateResp)) {
return Response.status(Status.EXPECTATION_FAILED).build();
}
@@ -166,7 +169,7 @@ public class PackageWrapper {
* @throws Exception e
*/
public Response uploadPackage(InputStream uploadedInputStream, FormDataContentDisposition fileDetail,
- String details, HttpHeaders head) throws MarketplaceResourceException {
+ String details, HttpHeaders head) {
LOG.info("Upload/Reupload request Received !!!!");
try {
String packageId = MarketplaceDbUtil.generateId();
@@ -178,7 +181,7 @@ public class PackageWrapper {
}
private UploadPackageResponse manageUpload(String packageId, String fileName, String fileLocation, String details,
- String contentRange) throws IOException, MarketplaceResourceException {
+ String contentRange) throws IOException, ErrorCodeException {
String localDirName = ToolUtil.getTempDir(CommonConstant.CATALOG_CSAR_DIR_NAME, fileName);
PackageBasicInfo basicInfo = PackageWrapperUtil.getPacageBasicInfo(fileLocation);
UploadPackageResponse result = new UploadPackageResponse();
@@ -198,12 +201,12 @@ public class PackageWrapper {
LOG.info("packageMeta = " + ToolUtil.objectToString(packageMeta));
PackageData packageData = PackageWrapperUtil.getPackageData(packageMeta);
-
- List<PackageData> lstPkgData = PackageManager.getInstance().queryPackage(packageMeta.getName(), "", "", "", "");
- if (!lstPkgData.isEmpty())
- {
- LOG.error ("Package name is not unique");
- return null;
+
+ List<PackageData> lstPkgData =
+ PackageManager.getInstance().queryPackage(packageMeta.getName(), "", "", "", "");
+ if(!lstPkgData.isEmpty()) {
+ LOG.error("Package name is not unique");
+ throw new ErrorCodeException(HttpStatus.INTERNAL_SERVER_ERROR_500, "Package name already exists");
}
String destPath = File.separator + path + File.separator + File.separator;
@@ -249,12 +252,12 @@ public class PackageWrapper {
* @throws MarketplaceResourceException
*/
private Response handlePackageUpload(String packageId, InputStream uploadedInputStream,
- FormDataContentDisposition fileDetail, String details, HttpHeaders head)
- throws IOException, MarketplaceResourceException {
+ FormDataContentDisposition fileDetail, String details, HttpHeaders head) throws IOException {
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();
+ return Response.status(Status.EXPECTATION_FAILED)
+ .entity("Input package is empty or exception happened during validation").build();
}
String fileName = "temp_" + packageId + ".csar";
@@ -284,16 +287,23 @@ public class PackageWrapper {
try {
CsarValidator cv = new CsarValidator(packageId, fileLocation);
- if(!cv.validateCsar()) {
+ String validationResp = cv.validateCsar();
+ if("SUCCESS" != validationResp) {
LOG.error("Could not validate failed");
- return Response.status(Status.EXPECTATION_FAILED).build();
+ return Response.status(Status.EXPECTATION_FAILED).entity(validationResp).build();
}
} catch(Exception e) {
LOG.error("CSAR validation panicked", e);
- return Response.status(Status.EXPECTATION_FAILED).build();
+ return Response.status(Status.EXPECTATION_FAILED)
+ .entity("Exception occurred while validating csar package:" + e.getMessage()).build();
}
- UploadPackageResponse result = manageUpload(packageId, fileName, fileLocation, details, contentRange);
+ UploadPackageResponse result = null;
+ try {
+ result = manageUpload(packageId, fileName, fileLocation, details, contentRange);
+ } catch(ErrorCodeException e) {
+ return Response.status(Status.EXPECTATION_FAILED).entity("Package Name already exists").build();
+ }
if(null != result) {
return Response.ok(ToolUtil.objectToString(result), MediaType.APPLICATION_JSON).build();
} else {