import javax.servlet.http.HttpServletResponse;
import org.apache.http.HttpStatus;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
+import org.apache.commons.io.IOUtils;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf.VnfmDriverMgmrInf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import com.google.gson.Gson;
@Controller
-@RequestMapping(value = "/nokiavnfm/v1")
+@RequestMapping(value = "/api/nokiavnfmdriver/v1")
public class VnfmDriverController {
- private static final Logger logger = LogManager.getLogger("VnfmDriverController");
+ private static final Logger logger = LoggerFactory.getLogger(VnfmDriverController.class);
@Autowired
private VnfmDriverMgmrInf vnfmDriverMgmr;
private Gson gson = new Gson();
+ @RequestMapping(value = "/swagger.json", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public String apidoc() throws IOException {
+ ClassLoader classLoader = getClass().getClassLoader();
+ return IOUtils.toString(classLoader.getResourceAsStream("swagger.json"));
+ }
+
@RequestMapping(value = "/{vnfmId}/vnfs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public InstantiateVnfResponse instantiateVnf(@RequestBody InstantiateVnfRequest request, @PathVariable("vnfmId") String vnfmId, HttpServletResponse httpResponse)
}
catch(VnfmDriverException e)
{
- try {
- httpResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
- httpResponse.sendError(e.getHttpStatus(), e.getMessage());
- } catch (IOException e1) {
-
- }
+ processControllerException(httpResponse, e);
}
return null;
}
catch(VnfmDriverException e)
{
- try {
- httpResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
- httpResponse.sendError(e.getHttpStatus(), e.getMessage());
- } catch (IOException e1) {
-
- }
+ processControllerException(httpResponse, e);
}
return null;
}
catch(VnfmDriverException e)
{
- try {
- httpResponse.sendError(e.getHttpStatus(), e.getMessage());
- } catch (IOException e1) {
-
- }
+ processControllerException(httpResponse, e);
}
return null;
}
catch(VnfmDriverException e)
{
- try {
- httpResponse.sendError(e.getHttpStatus(), e.getMessage());
- } catch (IOException e1) {
-
- }
+ processControllerException(httpResponse, e);
}
return null;
}
catch(VnfmDriverException e)
{
- try {
- httpResponse.sendError(e.getHttpStatus(), e.getMessage());
- } catch (IOException e1) {
-
- }
+ processControllerException(httpResponse, e);
}
return null;
}
+ private void processControllerException(HttpServletResponse httpResponse, VnfmDriverException e) {
+ try {
+ logger.error(" VnfmDriverController --> processControllerException", e);
+ httpResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
+ httpResponse.sendError(e.getHttpStatus(), e.getMessage());
+ } catch (IOException e1) {
+ logger.error("VnfmDriverController --> processControllerException error to sendError ", e1);
+ }
+ }
+
}