* 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;
+ }
+
+}
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;
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";
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();