Merge "GSO-35"
diff --git a/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/roa/impl/ServiceGatewayRoaModuleImpl.java b/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/roa/impl/ServiceGatewayRoaModuleImpl.java
index 7d2e072..bd91ff2 100644
--- a/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/roa/impl/ServiceGatewayRoaModuleImpl.java
+++ b/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/roa/impl/ServiceGatewayRoaModuleImpl.java
@@ -101,7 +101,6 @@
      */
     @Override
     public Response deleteService(String serviceId, HttpServletRequest servletReq) {
-        Map<String, Object> operateStatus = null;
         Map<String, Object> result = null;
         try {
             // 1. Check validation
@@ -109,20 +108,11 @@
             ValidateUtil.assertStringNotNull(reqContent);
 
             // 2. Delete service
-            serviceGateway.deleteService(serviceId, servletReq);
+            result = serviceGateway.deleteService(serviceId, reqContent, servletReq);
         } catch(ServiceException exception) {
             LOGGER.error("Fail to delete service instance.");
-            operateStatus = ResponseUtils.setOperateStatus(Constant.RESPONSE_STATUS_FAIL, exception,
-                    String.valueOf(exception.getHttpCode()));
-            result = ResponseUtils.setResult(serviceId, operateStatus);
-
-            return Response.accepted().entity(result).build();
+            return Response.serverError().build();
         }
-
-        operateStatus = ResponseUtils.setOperateStatus(Constant.RESPONSE_STATUS_SUCCESS, null,
-                String.valueOf(HttpCode.RESPOND_OK));
-        result = ResponseUtils.setResult(serviceId, operateStatus);
-
         return Response.accepted().entity(result).build();
     }
 
diff --git a/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImpl.java b/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImpl.java
index 3ff4f89..4f592f5 100644
--- a/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImpl.java
+++ b/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImpl.java
@@ -16,6 +16,7 @@
 
 package org.openo.gso.gui.servicegateway.service.impl;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
@@ -130,14 +131,13 @@
      * @since GSO 0.5
      */
     @Override
-    public void deleteService(String serviceId, HttpServletRequest httpRequest) throws ServiceException {
+    public Map<String, Object> deleteService(String serviceId, String reqContent, HttpServletRequest httpRequest) throws ServiceException {
     	if(httpRequest == null)
     	{    		
     		LOGGER.error("ServiceGatewayImpl.deleteService httpRequest is null");
     		throw new ServiceException("ServiceGatewayImpl.deleteService httpRequest is null");
     	}
         // Parse request
-        String reqContent = RestUtils.getRequestBody(httpRequest);
         Map<String, Object> requestBody = JsonUtil.unMarshal(reqContent, Map.class);
         ValidateUtil.assertObjectNotNull(requestBody);
 
@@ -153,16 +153,26 @@
         // call the restful
         try {
             RestfulResponse restfulRsp = null;
+            Map<String, Object> result = new HashMap<String, Object>();
             if(Constant.SERVICE_DELETE_OPERATION.equalsIgnoreCase(operation)) {
                 restfulRsp = RestfulFactory.getRestInstance("http").delete(gatewayUri,
                         getRestfulParameters(JsonUtil.marshal(requestBody)));
+                result.put(Constant.RESPONSE_STATUS, "success");
+                result.put(Constant.RESPONSE_STATUS_DESCRIPTION, "It is deleting.");
+                result.put(Constant.RESPONSE_ERRORCODE, "202");
             } else {
                 restfulRsp = RestfulFactory.getRestInstance("http").post(gatewayUri,
                         getRestfulParameters(JsonUtil.marshal(requestBody)));
+                if (null != restfulRsp) {
+                    String jobId = restfulRsp.getRespHeaderStr(Constant.JOB_ID);
+                    result.put(Constant.JOB_ID, jobId);
+                }
             }
             if (null != restfulRsp) {
                 LOGGER.info("restful call result:", restfulRsp.getStatus());
+                LOGGER.info("restful call content:", restfulRsp.getResponseContent());
             }
+            return result;
         } catch(ServiceException e) {
             LOGGER.error("service gateway delete restful call result:", e);
             throw e;
diff --git a/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/service/inf/IServiceGateway.java b/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/service/inf/IServiceGateway.java
index 9e18cb1..a5f6b6f 100644
--- a/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/service/inf/IServiceGateway.java
+++ b/servicegateway/service/src/main/java/org/openo/gso/gui/servicegateway/service/inf/IServiceGateway.java
@@ -21,6 +21,8 @@
 
 import org.openo.baseservice.remoteservice.exception.ServiceException;
 
+import java.util.Map;
+
 /**
  * Interface to operate service.<br/>
  * <p>
@@ -50,6 +52,6 @@
      * @throws ServiceException operate DB or parameter is wrong.
      * @since GSO 0.5
      */
-    void deleteService(String serviceId, HttpServletRequest httpRequest) throws ServiceException;
+    Map<String, Object> deleteService(String serviceId, String reqContent, HttpServletRequest httpRequest) throws ServiceException;
 
 }
diff --git a/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImplTest.java b/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImplTest.java
index d1cb391..b7c1657 100644
--- a/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImplTest.java
+++ b/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImplTest.java
@@ -66,7 +66,7 @@
      */
     @Test(expected = ServiceException.class)
     public void testDeleteServiceFail() throws ServiceException {    	
-        serviceManager.deleteService(null, httpRequest);
+        serviceManager.deleteService(null, "", httpRequest);
     }
 
 }