Error message in wrong format

Convert entity to JSON

Issue-ID: VNFSDK-233

Change-Id: Ide6530607080e93bdea97269a8a4f49a018f6e5f
Signed-off-by: Murali-P <murali.p@huawei.com>
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonErrorResponse.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonErrorResponse.java
index 967d003..a78ebac 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonErrorResponse.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonErrorResponse.java
@@ -13,24 +13,29 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onap.vnfsdk.marketplace.common;
 
+package org.onap.vnfsdk.marketplace.common;
 
 public class CommonErrorResponse {
 
-  private String message;
-  
-  public CommonErrorResponse(String message) {
-	    super();
-	    this.message = message;
-	  }
+    private String statusText;
 
-  public String getMessage() {
-        return message;
+    public CommonErrorResponse(String statusText) {
+        super();
+        this.statusText = statusText;
     }
 
-  public static Object failure(String message) {
-    return message;
-  }
-}
+    @Override
+    public String toString() {
+        return "CommonErrorResponse [statusText=" + statusText + "]";
+    }
 
+    public String getStatusText() {
+        return statusText;
+    }
+
+    public void setStatusText(String statusText) {
+        this.statusText = statusText;
+    }
+
+}
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 3fbdd94..8feab3f 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
@@ -38,6 +38,7 @@
 import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
 import org.onap.validation.csar.CsarValidator;
 import org.onap.vnfsdk.marketplace.common.CommonConstant;
+import org.onap.vnfsdk.marketplace.common.CommonErrorResponse;
 import org.onap.vnfsdk.marketplace.common.FileUtil;
 import org.onap.vnfsdk.marketplace.common.RestUtil;
 import org.onap.vnfsdk.marketplace.common.ToolUtil;
@@ -257,7 +258,8 @@
         if(!bResult) {
             LOG.error("Validation of Input received for Package Upload failed !!!");
             return Response.status(Status.EXPECTATION_FAILED)
-                    .entity("Input package is empty or exception happened during validation").build();
+                    .entity(new CommonErrorResponse("Input package is empty or exception happened during validation"))
+                    .build();
         }
 
         String fileName = "temp_" + packageId + ".csar";
@@ -290,19 +292,22 @@
             String validationResp = cv.validateCsar();
             if("SUCCESS" != validationResp) {
                 LOG.error("Could not validate failed");
-                return Response.status(Status.EXPECTATION_FAILED).entity(validationResp).build();
+                return Response.status(Status.EXPECTATION_FAILED).entity(new CommonErrorResponse(validationResp))
+                        .build();
             }
         } catch(Exception e) {
             LOG.error("CSAR validation panicked", e);
-            return Response.status(Status.EXPECTATION_FAILED)
-                    .entity("Exception occurred while validating csar package:" + e.getMessage()).build();
+            return Response.status(Status.EXPECTATION_FAILED).entity(
+                    new CommonErrorResponse("Exception occurred while validating csar package:" + e.getMessage()))
+                    .build();
         }
 
         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();
+            return Response.status(Status.EXPECTATION_FAILED)
+                    .entity(new CommonErrorResponse("Package Name already exists")).build();
         }
         if(null != result) {
             return Response.ok(ToolUtil.objectToString(result), MediaType.APPLICATION_JSON).build();