From efedea1c5d80532f5b1180d57c8dafce5dcb302a Mon Sep 17 00:00:00 2001 From: Ofir Sonsino Date: Tue, 20 Feb 2018 18:03:30 +0200 Subject: org.onap migration Change-Id: I5e2d01a6da21d4003c910b5fe0702b35c2089a77 Issue-ID: VID-86 Signed-off-by: Ofir Sonsino --- .../onap/vid/controller/MaintenanceController.java | 135 --------------------- 1 file changed, 135 deletions(-) delete mode 100644 vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java (limited to 'vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java') diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java deleted file mode 100644 index df1e6e421..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.onap.vid.controller; - - -import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.vid.category.AddCategoryOptionResponse; -import org.onap.vid.category.AddCategoryOptionsRequest; -import org.onap.vid.category.CategoryParameterOptionRep; -import org.onap.vid.category.CategoryParametersResponse; -import org.onap.vid.model.CategoryParameter.Family; -import org.onap.vid.model.CategoryParameterOption; -import org.onap.vid.services.CategoryParameterService; -import org.onap.vid.services.CategoryParameterServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.ForbiddenException; -import java.util.Arrays; -import java.util.Collections; - -import static org.onap.vid.utils.Logging.getMethodName; - -/** - * Controler for APIs that are used only by vid operators - */ - -@RestController -@RequestMapping(MaintenanceController.Maintenance) -public class MaintenanceController extends UnRestrictedBaseController { - - public static final String Maintenance = "maintenance"; - - @Autowired - protected CategoryParameterService categoryParameterService; - private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MaintenanceController.class); - - /** - * Add list of options to one category parameter - * @param request the request - * @return the new option - * @throws Exception the exception - */ - @RequestMapping(value = "/category_parameter/{categoryName}", method = RequestMethod.POST) - public ResponseEntity addCategoryOptions ( - HttpServletRequest request, @PathVariable String categoryName, @RequestBody AddCategoryOptionsRequest option) throws Exception { - LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName()); - try { - AddCategoryOptionResponse response = categoryParameterService.createCategoryParameterOptions(categoryName, option); - HttpStatus httpStatus = response.getErrors().size()>0 ? HttpStatus.MULTI_STATUS : HttpStatus.OK; - LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), response); - return new ResponseEntity<>(response, httpStatus); - } - catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) { - return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.NOT_FOUND); - } - catch (Exception exception) { - LOGGER.error("failed to add option to parameter category " + categoryName, exception); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - @RequestMapping(value = "/category_parameter/{categoryName}", method = RequestMethod.PUT) - public ResponseEntity updateNameForOption ( - HttpServletRequest request, @PathVariable String categoryName, @RequestBody CategoryParameterOptionRep option) throws Exception { - LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName()); - try { - AddCategoryOptionResponse response = categoryParameterService.updateCategoryParameterOption(categoryName, option); - HttpStatus httpStatus = response.getErrors().size()>0 ? HttpStatus.MULTI_STATUS : HttpStatus.OK; - LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), response); - return new ResponseEntity<>(response, httpStatus); - } - catch (ForbiddenException exception) { - return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.FORBIDDEN); - } - catch (CategoryParameterServiceImpl.UnfoundedCategoryException|CategoryParameterServiceImpl.UnfoundedCategoryOptionException exception) { - return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.NOT_FOUND); - } - catch (CategoryParameterServiceImpl.AlreadyExistOptionNameException exception) { - return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.CONFLICT); - } - catch (Exception exception) { - LOGGER.error("failed to update option to parameter category " + categoryName, exception); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * Gets the owning entity properties. - * @param request the request - * @return the property - * @throws Exception the exception - */ - @RequestMapping(value = "/category_parameter", method = RequestMethod.GET) - public ResponseEntity getCategoryParameter(HttpServletRequest request, @RequestParam(value="familyName", required = true) Family familyName) throws Exception { - LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName()); - try { - CategoryParametersResponse response = categoryParameterService.getCategoryParameters(familyName); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), response); - return new ResponseEntity<>(response, HttpStatus.OK); - } - catch (Exception exception) { - LOGGER.error("failed to retrieve category parameter list from DB.", exception); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - - /** - * Delete option of the category. - * @param request the request - * @throws Exception the exception - */ - @RequestMapping(value = "/delete_category_parameter/{categoryName}", method = RequestMethod.POST) - public ResponseEntity deleteCategoryOption ( - HttpServletRequest request, @PathVariable String categoryName, @RequestBody CategoryParameterOption option) throws Exception { - LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName()); - - try { - categoryParameterService.deleteCategoryOption(categoryName, option); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), HttpStatus.OK); - return new ResponseEntity<>(HttpStatus.OK); - } - catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) { - return new ResponseEntity<>(new AddCategoryOptionResponse(Arrays.asList(exception.getMessage())), HttpStatus.NOT_FOUND); - } - catch (Exception exception) { - LOGGER.error("failed to add/update owning entity option", exception); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - -} -- cgit 1.2.3-korg