*/
@Override
public Response deleteService(String serviceId, HttpServletRequest servletReq) {
- Map<String, Object> operateStatus = null;
Map<String, Object> result = null;
try {
// 1. Check validation
ValidateUtil.assertStringNotNull(reqContent);
// 2. Delete service
- serviceGateway.deleteService(serviceId, servletReq);
+ result = serviceGateway.deleteService(serviceId, 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();
}
package org.openo.gso.gui.servicegateway.service.impl;
+import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
* @since GSO 0.5
*/
@Override
- public void deleteService(String serviceId, HttpServletRequest httpRequest) throws ServiceException {
+ public Map<String, Object> deleteService(String serviceId, HttpServletRequest httpRequest) throws ServiceException {
if(httpRequest == null)
{
LOGGER.error("ServiceGatewayImpl.deleteService httpRequest is null");
// 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;
import org.openo.baseservice.remoteservice.exception.ServiceException;
+import java.util.Map;
+
/**
* Interface to operate service.<br/>
* <p>
* @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, HttpServletRequest httpRequest) throws ServiceException;
}