summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMurali-P <murali.p@huawei.com>2018-04-16 17:49:28 +0530
committerMurali-P <murali.p@huawei.com>2018-04-16 18:00:34 +0530
commitf5ff9ed0e62f4a511e5f725e0e09e3b266aac098 (patch)
tree7f857dcfdad0b32b5e121a56724f6cb98172b9ff
parent500c8e376369bcd9320dee15181b49081d4fa833 (diff)
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>
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/CommonErrorResponse.java31
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java15
2 files changed, 28 insertions, 18 deletions
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 967d0039..a78ebac5 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 3fbdd94d..8feab3f8 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.eclipse.jetty.http.HttpStatus;
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 @@ public class PackageWrapper {
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 @@ public class PackageWrapper {
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();