aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/controller
diff options
context:
space:
mode:
authorOfir Sonsino <os0695@att.com>2018-02-20 18:03:30 +0200
committerOfir Sonsino <os0695@intl.att.com>2018-02-27 14:47:52 +0200
commitefedea1c5d80532f5b1180d57c8dafce5dcb302a (patch)
treec4bdefe8758b01f31c9e91a9ded0ab989daeb5e2 /vid-app-common/src/main/java/org/onap/vid/controller
parentb94bd70f1595fad9546c3506393613f68504f495 (diff)
org.onap migration
Change-Id: I5e2d01a6da21d4003c910b5fe0702b35c2089a77 Issue-ID: VID-86 Signed-off-by: Ofir Sonsino <os0695@intl.att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/controller')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java750
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java193
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java192
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java115
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java135
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java42
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java655
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java354
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/PolicyController.java84
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/PropertyController.java132
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java31
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/VidController.java149
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java65
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java123
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/filter/TempFilterForCORS.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestPageController.java2
21 files changed, 7 insertions, 3067 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
deleted file mode 100644
index 1719ff6d4..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
+++ /dev/null
@@ -1,750 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.controller;
-
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.onap.vid.aai.AaiResponse;
-import org.onap.vid.aai.ServiceInstancesSearchResults;
-import org.onap.vid.aai.SubscriberData;
-import org.onap.vid.aai.SubscriberFilteredResults;
-import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
-import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
-import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
-import org.onap.vid.aai.util.AAIRestInterface;
-import org.onap.vid.model.VersionByInvariantIdsRequest;
-import org.onap.vid.roles.Role;
-import org.onap.vid.roles.RoleProvider;
-import org.onap.vid.roles.RoleValidator;
-import org.onap.vid.services.AaiService;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.util.SystemProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.servlet.HandlerMapping;
-import org.springframework.web.servlet.ModelAndView;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.BadRequestException;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import java.io.File;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-import static org.onap.vid.utils.Logging.getMethodName;
-
-/**
- * Controller to handle a&ai requests.
- */
-
-@RestController
-public class
-AaiController extends RestrictedBaseController {
- /**
- * The Constant dateFormat.
- */
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
- /**
- * The from app id.
- */
- protected String fromAppId = "VidAaiController";
- /**
- * The logger.
- */
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AaiController.class);
- /**
- * The model.
- */
- private Map<String, Object> model = new HashMap<String, Object>();
- /**
- * The servlet context.
- */
- @Autowired
- private ServletContext servletContext;
- /**
- * aai service
- */
- @Autowired
- private AaiService aaiService;
- @Autowired
- private RoleProvider roleProvider;
-
- public AaiController() {
-
- }
-
- public AaiController(ServletContext servletContext) {
- this.servletContext = servletContext;
-
- }
-
- /**
- * Welcome method.
- *
- * @param request the request
- * @return ModelAndView The view
- */
- @RequestMapping(value = {"/subscriberSearch"}, method = RequestMethod.GET)
- public ModelAndView welcome(HttpServletRequest request) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== AaiController welcome start");
- return new ModelAndView(getViewName());
- }
-
- @RequestMapping(value = {"/aai_get_aic_zones"}, method = RequestMethod.GET)
- public ResponseEntity<String> getAicZones(HttpServletRequest request) throws JsonGenerationException, JsonMappingException, IOException {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== getAicZones controller start");
- AaiResponse response = aaiService.getAaiZones();
- return aaiResponseToResponseEntity(response);
- }
-
- @RequestMapping(value = {"/aai_get_aic_zone_for_pnf/{globalCustomerId}/{serviceType}/{serviceId}"}, method = RequestMethod.GET)
- public ResponseEntity<String> getAicZoneForPnf(@PathVariable("globalCustomerId") String globalCustomerId ,@PathVariable("serviceType") String serviceType , @PathVariable("serviceId") String serviceId ,HttpServletRequest request) throws JsonGenerationException, JsonMappingException, IOException {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== getAicZoneForPnf controller start");
- AaiResponse response = aaiService.getAicZoneForPnf(globalCustomerId , serviceType , serviceId);
- return aaiResponseToResponseEntity(response);
- }
-
- /**
- * Get services from a&ai.
- *
- * @return ResponseEntity<String> The response entity with the logged in user uuid.
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException the interrupted exception
- */
- @RequestMapping(value = {"/getuserID"}, method = RequestMethod.GET)
- public ResponseEntity<String> getUserID(HttpServletRequest request) throws IOException, InterruptedException {
-
- String userId = ControllersUtils.extractUserId(request);
-
- return new ResponseEntity<String>(userId, HttpStatus.OK);
- }
-
- /**
- * Get services from a&ai.
- *
- * @return ResponseEntity<String> The response entity
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException the interrupted exception
- */
- @RequestMapping(value = "/aai_get_services", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<String> doGetServices(HttpServletRequest request) throws IOException, InterruptedException {
- RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request));
-
- AaiResponse subscriberList = aaiService.getServices(roleValidator);
- ResponseEntity<String> responseEntity = aaiResponseToResponseEntity(subscriberList);
-
- return responseEntity;
- }
-
-
- @RequestMapping(value = {"/aai_get_version_by_invariant_id"}, method = RequestMethod.POST)
- public ResponseEntity<String> getVersionByInvariantId(HttpServletRequest request, @RequestBody VersionByInvariantIdsRequest versions) throws IOException {
- ResponseEntity<String> responseEntity;
- ObjectMapper objectMapper = new ObjectMapper();
-
- Response result = aaiService.getVersionByInvariantId(versions.versions);
-
- return new ResponseEntity<String>(result.readEntity(String.class), HttpStatus.OK);
- }
-
-
- private ResponseEntity<String> aaiResponseToResponseEntity(AaiResponse aaiResponseData)
- throws IOException, JsonGenerationException, JsonMappingException {
- ResponseEntity<String> responseEntity;
- ObjectMapper objectMapper = new ObjectMapper();
- if (aaiResponseData.getHttpCode() == 200) {
- responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(aaiResponseData.getT()), HttpStatus.OK);
- } else {
- responseEntity = new ResponseEntity<String>(aaiResponseData.getErrorMessage(), HttpStatus.valueOf(aaiResponseData.getHttpCode()));
- }
- return responseEntity;
- }
-
- /**
- * Lookup single service instance in a&ai. Get the service-subscription and customer, too, i guess?
- *
- * @param serviceInstanceId the service instance Id
- * @return ResponseEntity The response entity
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException the interrupted exception
- */
- @RequestMapping(value = "/aai_get_service_instance/{service-instance-id}/{service-instance-type}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<String> doGetServiceInstance(@PathVariable("service-instance-id") String serviceInstanceId, @PathVariable("service-instance-type") String serviceInstanceType) throws IOException, InterruptedException {
- File certiPath = GetCertificatesPath();
- Response resp = null;
-
- if (serviceInstanceType.equalsIgnoreCase("Service Instance Id")) {
- resp = doAaiGet(certiPath.getAbsolutePath(),
- "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:"
- + serviceInstanceId, false);
- } else {
- resp = doAaiGet(certiPath.getAbsolutePath(),
- "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:"
- + serviceInstanceId, false);
- }
- return convertResponseToResponseEntity(resp);
- }
-
- /**
- * Get services from a&ai.
- *
- * @param globalCustomerId the global customer id
- * @param serviceSubscriptionId the service subscription id
- * @return ResponseEntity The response entity
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException the interrupted exception
- */
- @RequestMapping(value = "/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<String> doGetServices(@PathVariable("global-customer-id") String globalCustomerId,
- @PathVariable("service-subscription-id") String serviceSubscriptionId) throws IOException, InterruptedException {
- File certiPath = GetCertificatesPath();
- Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + globalCustomerId
- + "/service-subscriptions/service-subscription/" + serviceSubscriptionId + "?depth=0", false);
- return convertResponseToResponseEntity(resp);
- }
-
- /**
- * Obtain the subscriber list from a&ai.
- *
- * @param fullSet the full set
- * @return ResponseEntity The response entity
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException the interrupted exception
- */
- @RequestMapping(value = "/aai_get_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<String> doGetSubscriberList(HttpServletRequest request, @DefaultValue("n") @QueryParam("fullSet") String fullSet) throws IOException, InterruptedException {
- return getFullSubscriberList(request);
- }
-
- /**
- * Obtain the Target Prov Status from the System.Properties file.
- *
- * @return ResponseEntity The response entity
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException the interrupted exception
- */
- @RequestMapping(value = "/get_system_prop_vnf_prov_status", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<String> getTargetProvStatus() throws IOException, InterruptedException {
- String p = SystemProperties.getProperty("aai.vnf.provstatus");
- return new ResponseEntity<String>(p, HttpStatus.OK);
- }
-
-
- /**
- * Obtain the Target Prov Status from the System.Properties file.
- *
- * @return ResponseEntity The response entity
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException the interrupted exception
- */
- @RequestMapping(value = "/get_operational_environments", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public AaiResponse<OperationalEnvironmentList> getOperationalEnvironments(@RequestParam(value="operationalEnvironmentType", required = false) String operationalEnvironmentType,
- @RequestParam(value="operationalEnvironmentStatus", required = false) String operationalEnvironmentStatus) throws IOException, InterruptedException {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({}, {})", getMethodName(), operationalEnvironmentType, operationalEnvironmentStatus);
- AaiResponse<OperationalEnvironmentList> response = aaiService.getOperationalEnvironments(operationalEnvironmentType,operationalEnvironmentStatus);
- if (response.getHttpCode() != 200) {
- String errorMessage = getAaiErrorMessage(response.getErrorMessage());
- if(errorMessage != null) {
- response = new AaiResponse<OperationalEnvironmentList>(response.getT(), errorMessage, response.getHttpCode());
- }
- }
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), response);
- return response;
- }
-
- /**
- * Obtain the full subscriber list from a&ai.
- * <p>
- * g @return ResponseEntity The response entity
- *
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException the interrupted exception
- */
- @RequestMapping(value = "/aai_get_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<String> getFullSubscriberList(HttpServletRequest request) throws IOException, InterruptedException {
- ObjectMapper objectMapper = new ObjectMapper();
- ResponseEntity<String> responseEntity;
- RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request));
- SubscriberFilteredResults subscriberList = aaiService.getFullSubscriberList(roleValidator);
- if (subscriberList.getHttpCode() == 200) {
- responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(subscriberList.getSubscriberList()), HttpStatus.OK);
- } else {
- responseEntity = new ResponseEntity<String>(subscriberList.getErrorMessage(), HttpStatus.valueOf(subscriberList.getHttpCode()));
- }
-
-
- return responseEntity;
- }
-
-
- @RequestMapping(value = "/get_vnf_data_by_globalid_and_service_type/{globalCustomerId}/{serviceType}",
- method = RequestMethod.GET,
- produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<String> getVnfDataByGlobalIdAndServiceType(HttpServletRequest request,
- @PathVariable("globalCustomerId") String globalCustomerId,
- @PathVariable("serviceType") String serviceType) throws IOException {
-
- Response resp = aaiService.getVNFData(globalCustomerId, serviceType);
- return convertResponseToResponseEntity(resp);
- }
-
-
- /**
- * Refresh the subscriber list from a&ai.
- *
- * @return ResponseEntity The response entity
- * @throws IOException Signals that an I/O exception has occurred.
- */
- @RequestMapping(value = "/aai_refresh_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<String> doRefreshSubscriberList() throws IOException {
- Response resp = getSubscribers(false);
- return convertResponseToResponseEntity(resp);
- }
-
- /**
- * Refresh the full subscriber list from a&ai.
- *
- * @return ResponseEntity The response entity
- * @throws IOException Signals that an I/O exception has occurred.
- */
- @RequestMapping(value = "/aai_refresh_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<String> doRefreshFullSubscriberList() throws IOException {
- Response resp = getSubscribers(false);
- return convertResponseToResponseEntity(resp);
- }
-
- /**
- * Get subscriber details from a&ai.
- *
- * @param subscriberId the subscriber id
- * @return ResponseEntity The response entity
- */
- @RequestMapping(value = "/aai_sub_details/{subscriberId}", method = RequestMethod.GET)
- public ResponseEntity<String> GetSubscriberDetails(HttpServletRequest request, @PathVariable("subscriberId") String subscriberId) throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- ResponseEntity responseEntity;
- List<Role> roles = roleProvider.getUserRoles(request);
- RoleValidator roleValidator = new RoleValidator(roles);
- AaiResponse<SubscriberData> subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator);
- String httpMessage = subscriberData.getT() != null ?
- objectMapper.writeValueAsString(subscriberData.getT()) :
- subscriberData.getErrorMessage();
-
- responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(subscriberData.getHttpCode()));
- return responseEntity;
- }
-
- /**
- * Get service instances that match the query from a&ai.
- *
- * @param subscriberId the subscriber id
- * @param instanceIdentifier the service instance name or id.
- * @param projects the projects that are related to the instance
- * @param owningEntities the owningEntities that are related to the instance
- * @return ResponseEntity The response entity
- */
- @RequestMapping(value = "/search_service_instances", method = RequestMethod.GET)
- public ResponseEntity<String> SearchServiceInstances(HttpServletRequest request,
- @RequestParam(value="subscriberId", required = false) String subscriberId,
- @RequestParam(value="serviceInstanceIdentifier", required = false) String instanceIdentifier,
- @RequestParam(value="project", required = false) List<String> projects,
- @RequestParam(value="owningEntity", required = false) List<String> owningEntities) throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- ResponseEntity responseEntity;
-
- List<Role> roles = roleProvider.getUserRoles(request);
- RoleValidator roleValidator = new RoleValidator(roles);
-
- AaiResponse<ServiceInstancesSearchResults> searchResult = aaiService.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects);
-
- String httpMessage = searchResult.getT() != null ?
- objectMapper.writeValueAsString(searchResult.getT()) :
- searchResult.getErrorMessage();
-
-
- if(searchResult.getT().serviceInstances.size() == 0){
- responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.NOT_FOUND);
-
- } else {
- responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(searchResult.getHttpCode()));
-
- }
- return responseEntity;
- }
-
-
-
- /**
- * Issue a named query to a&ai.
- *
- * @param namedQueryId the named query id
- * @param globalCustomerId the global customer id
- * @param serviceType the service type
- * @param serviceInstance the service instance
- * @return ResponseEntity The response entity
- */
- @RequestMapping(value = "/aai_sub_viewedit/{namedQueryId}/{globalCustomerId}/{serviceType}/{serviceInstance}", method = RequestMethod.GET)
- public ResponseEntity<String> viewEditGetComponentList(
- @PathVariable("namedQueryId") String namedQueryId,
- @PathVariable("globalCustomerId") String globalCustomerId,
- @PathVariable("serviceType") String serviceType,
- @PathVariable("serviceInstance") String serviceInstance) {
-
- String componentListPayload = getComponentListPutPayload(namedQueryId, globalCustomerId, serviceType, serviceInstance);
- File certiPath = GetCertificatesPath();
-
- Response resp = doAaiPost(certiPath.getAbsolutePath(), "search/named-query", componentListPayload, false);
- return convertResponseToResponseEntity(resp);
- }
-
- @RequestMapping(value = "/aai_get_vnf_data/{globalCustomerId}/{serviceType}/{serviceInstanceId}", method = RequestMethod.GET)
- public AaiResponse<String> getVnfData(
- @PathVariable("globalCustomerId") String globalCustomerId,
- @PathVariable("serviceType") String serviceType,
- @PathVariable("serviceInstanceId") String serviceInstanceId) {
-
- return aaiService.getVNFData(globalCustomerId, serviceType, serviceInstanceId);
-
- }
-
-
- /**
- * Issue a named query to a&ai.
- *
- * @param namedQueryId the named query id
- * @param globalCustomerId the global customer id
- * @param serviceType the service type
- * @return ResponseEntity The response entity
- */
- @RequestMapping(value = "/aai_get_models_by_service_type/{namedQueryId}/{globalCustomerId}/{serviceType}", method = RequestMethod.GET)
- public ResponseEntity<String> viewEditGetComponentList(
- @PathVariable("namedQueryId") String namedQueryId,
- @PathVariable("globalCustomerId") String globalCustomerId,
- @PathVariable("serviceType") String serviceType) {
-
- String componentListPayload = getModelsByServiceTypePayload(namedQueryId, globalCustomerId, serviceType);
- File certiPath = GetCertificatesPath();
-
- Response resp = doAaiPost(certiPath.getAbsolutePath(), "search/named-query", componentListPayload, false);
- return convertResponseToResponseEntity(resp);
- }
-
- @RequestMapping(value = "/aai_get_vnf_instances/{globalCustomerId}/{serviceType}/{modelVersionId}/{modelInvariantId}/{cloudRegion}", method = RequestMethod.GET)
- public ResponseEntity<String> getNodeTemplateInstances(
- @PathVariable("globalCustomerId") String globalCustomerId,
- @PathVariable("serviceType") String serviceType,
- @PathVariable("modelVersionId") String modelVersionId,
- @PathVariable("modelInvariantId") String modelInvariantId,
- @PathVariable("cloudRegion") String cloudRegion) {
-
- AaiResponse<String> resp = aaiService.getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion);
- return new ResponseEntity<String>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
- }
-
- @RequestMapping(value = "/aai_get_by_uri/**", method = RequestMethod.GET)
- public ResponseEntity<String> getByUri(HttpServletRequest request) {
- File certiPath = GetCertificatesPath();
-
- String restOfTheUrl = (String) request.getAttribute(
- HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
- String formattedUri = restOfTheUrl.replaceFirst("/aai_get_by_uri/", "").replaceFirst("^aai/v[\\d]+/", "");
-
- Response resp = doAaiGet(certiPath.getAbsolutePath(), formattedUri, false);
-
- return convertResponseToResponseEntity(resp);
- }
-
- @RequestMapping(value = "/aai_get_configuration/{configuration_id}", method = RequestMethod.GET)
- public ResponseEntity<String> getSpecificConfiguration(@PathVariable("configuration_id") String configurationId) {
- File certiPath = GetCertificatesPath();
-
- Response resp = doAaiGet(certiPath.getAbsolutePath(), "network/configurations/configuration/"+configurationId, false);
-
- return convertResponseToResponseEntity(resp);
- }
-
- @RequestMapping(value = "/aai_get_service_instance_pnfs/{globalCustomerId}/{serviceType}/{serviceInstanceId}", method = RequestMethod.GET)
- public List<String> getServiceInstanceAssociatedPnfs(
- @PathVariable("globalCustomerId") String globalCustomerId,
- @PathVariable("serviceType") String serviceType,
- @PathVariable("serviceInstanceId") String serviceInstanceId) {
-
- return aaiService.getServiceInstanceAssociatedPnfs(globalCustomerId, serviceType, serviceInstanceId);
- }
-
- /**
- * PNF section
- */
- @RequestMapping(value = "/aai_get_pnfs/pnf/{pnf_id}", method = RequestMethod.GET)
- public ResponseEntity getSpecificPnf(@PathVariable("pnf_id") String pnfId) {
- //logger.trace(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), pnfId);
- AaiResponse<Pnf> resp;
- ResponseEntity<Pnf> re;
- try {
- resp = aaiService.getSpecificPnf(pnfId);
- re = new ResponseEntity<Pnf>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
- } catch (Exception e){
- return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
- }
- //logger.trace(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), resp.getHttpCode());
- return re;
- }
-
-
- /**
- * Obtain tenants for a given service type.
- *
- * @param globalCustomerId the global customer id
- * @param serviceType the service type
- * @return ResponseEntity The response entity
- */
- @RequestMapping(value = "/aai_get_tenants/{global-customer-id}/{service-type}", method = RequestMethod.GET)
- public ResponseEntity<String> viewEditGetTenantsFromServiceType(HttpServletRequest request,
- @PathVariable("global-customer-id") String globalCustomerId, @PathVariable("service-type") String serviceType) {
-
- ResponseEntity responseEntity;
- try {
- ObjectMapper objectMapper = new ObjectMapper();
- List<Role> roles = roleProvider.getUserRoles(request);
- RoleValidator roleValidator = new RoleValidator(roles);
- AaiResponse<GetTenantsResponse[]> response = aaiService.getTenants(globalCustomerId, serviceType, roleValidator);
- if (response.getHttpCode() == 200) {
- responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(response.getT()), HttpStatus.OK);
- } else {
- responseEntity = new ResponseEntity<String>(response.getErrorMessage(), HttpStatus.valueOf(response.getHttpCode()));
- }
- } catch (Exception e) {
- responseEntity = new ResponseEntity<String>("Unable to proccess getTenants reponse", HttpStatus.INTERNAL_SERVER_ERROR);
- }
- return responseEntity;
- }
-
- @RequestMapping(value = "/aai_get_pnf_instances/{globalCustomerId}/{serviceType}/{modelVersionId}/{modelInvariantId}/{cloudRegion}/{equipVendor}/{equipModel}", method = RequestMethod.GET)
- public ResponseEntity<String> getPnfInstances(
- @PathVariable("globalCustomerId") String globalCustomerId,
- @PathVariable("serviceType") String serviceType,
- @PathVariable("modelVersionId") String modelVersionId,
- @PathVariable("modelInvariantId") String modelInvariantId,
- @PathVariable("cloudRegion") String cloudRegion,
- @PathVariable("equipVendor") String equipVendor,
- @PathVariable("equipModel") String equipModel) {
-
- AaiResponse<String> resp = aaiService.getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel);
- return new ResponseEntity<String>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
- }
-
- private ResponseEntity<String> convertResponseToResponseEntity(Response resp) {
- ResponseEntity<String> respEnt;
- ObjectMapper objectMapper = new ObjectMapper();
- if (resp == null) {
- respEnt = new ResponseEntity<String>("Failed to fetch data from A&AI, check server logs for details.", HttpStatus.INTERNAL_SERVER_ERROR);
- } else {
- respEnt = new ResponseEntity<String>(resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus()));
- }
- return respEnt;
- }
-
- /**
- * Gets the subscribers.
- *
- * @param isFullSet the is full set
- * @return the subscribers
- */
- private Response getSubscribers(boolean isFullSet) {
-
- File certiPath = GetCertificatesPath();
- String depth = "0";
-
- Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers?subscriber-type=INFRA&depth=" + depth, false);
- if (resp != null) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscribers() resp=" + resp.getStatusInfo().toString());
- }
- return resp;
- }
-
- /**
- * Gets the subscriber details.
- *
- * @param subscriberId the subscriber id
- * @return the subscriber details
- */
- private Response getSubscriberDetails(String subscriberId) {
- File certiPath = GetCertificatesPath();
- Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + subscriberId + "?depth=2", false);
- //String resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + subscriberId, false);
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscriberDetails() resp=" + resp.getStatusInfo().toString());
- return resp;
- }
-
- /**
- * Gets the certificates path.
- *
- * @return the file
- */
- private File GetCertificatesPath() {
- if (servletContext != null)
- return new File(servletContext.getRealPath("/WEB-INF/cert/"));
- return null;
- }
-
- /**
- * Send a GET request to a&ai.
- *
- * @param certiPath the certi path
- * @param uri the uri
- * @param xml the xml
- * @return String The response
- */
- protected Response doAaiGet(String certiPath, String uri, boolean xml) {
- String methodName = "getSubscriberList";
- String transId = UUID.randomUUID().toString();
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- Response resp = null;
- try {
-
- AAIRestInterface restContrller = new AAIRestInterface(certiPath);
- resp = restContrller.RestGet(fromAppId, transId, uri, xml);
-
- } catch (WebApplicationException e) {
- final String message = ((BadRequestException) e).getResponse().readEntity(String.class);
- LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + message);
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + message);
- } catch (Exception e) {
- LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- }
-
- return resp;
- }
-
- /**
- * Send a POST request to a&ai.
- *
- * @param certiPath the certi path
- * @param uri the uri
- * @param payload the payload
- * @param xml the xml
- * @return String The response
- */
- protected Response doAaiPost(String certiPath, String uri, String payload, boolean xml) {
- String methodName = "getSubscriberList";
- String transId = UUID.randomUUID().toString();
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- Response resp = null;
- try {
-
- AAIRestInterface restContrller = new AAIRestInterface(certiPath);
- resp = restContrller.RestPost(fromAppId, transId, uri, payload, xml);
-
- } catch (Exception e) {
- LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- }
-
- return resp;
- }
-
- /**
- * Gets the component list put payload.
- *
- * @param namedQueryId the named query id
- * @param globalCustomerId the global customer id
- * @param serviceType the service type
- * @param serviceInstance the service instance
- * @return the component list put payload
- */
- private String getComponentListPutPayload(String namedQueryId, String globalCustomerId, String serviceType, String serviceInstance) {
- return
- " {" +
- " \"instance-filters\": {" +
- " \"instance-filter\": [" +
- " {" +
- " \"customer\": {" +
- " \"global-customer-id\": \"" + globalCustomerId + "\"" +
- " }," +
- " \"service-instance\": {" +
- " \"service-instance-id\": \"" + serviceInstance + "\"" +
- " }," +
- " \"service-subscription\": {" +
- " \"service-type\": \"" + serviceType + "\"" +
- " }" +
- " }" +
- " ]" +
- " }," +
- " \"query-parameters\": {" +
- " \"named-query\": {" +
- " \"named-query-uuid\": \"" + namedQueryId + "\"" +
- " }" +
- " }" +
- "}";
-
- }
-
- private String getModelsByServiceTypePayload(String namedQueryId, String globalCustomerId, String serviceType) {
- // TODO Auto-generated method stub
- return " {" +
- " \"instance-filters\": {" +
- " \"instance-filter\": [" +
- " {" +
- " \"customer\": {" +
- " \"global-customer-id\": \"" + globalCustomerId + "\"" +
- " }," +
- " \"service-subscription\": {" +
- " \"service-type\": \"" + serviceType + "\"" +
- " }" +
- " }" +
- " ]" +
- " }," +
- " \"query-parameters\": {" +
- " \"named-query\": {" +
- " \"named-query-uuid\": \"" + namedQueryId + "\"" +
- " }" +
- " }" +
- "}";
-
- }
-
- private String getAaiErrorMessage(String message) {
- try {
- org.json.JSONObject json = new org.json.JSONObject(message);
- json = json.getJSONObject("requestError").getJSONObject("serviceException");
-
- return json.getString("messageId") + ": " + json.getString("text");
-
- } catch (Exception e) {
- return null;
- }
- }
-} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java b/vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java
deleted file mode 100644
index 4f307ed96..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java
+++ /dev/null
@@ -1,193 +0,0 @@
-package org.onap.vid.controller;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.json.simple.JSONArray;
-import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.changeManagement.*;
-import org.onap.vid.exceptions.NotFoundException;
-import org.onap.vid.model.ExceptionResponse;
-import org.onap.vid.model.MsoExceptionResponse;
-import org.onap.vid.mso.MsoResponseWrapper2;
-import org.onap.vid.mso.MsoResponseWrapperInterface;
-import org.onap.vid.mso.rest.Request;
-import org.onap.vid.services.ChangeManagementService;
-import org.onap.vid.services.WorkflowService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.WebApplicationException;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-
-import static org.onap.vid.utils.Logging.getMethodName;
-import static org.springframework.http.HttpStatus.*;
-
-/**
- * Controller to handle ChangeManagement feature requests.
- */
-@RestController
-@RequestMapping(ChangeManagementController.CHANGE_MANAGEMENT)
-public class ChangeManagementController extends UnRestrictedBaseController {
- private static final String GetWorkflowsResponse = null;
- public static final String VNF_WORKFLOW_RELATION = "vnf_workflow_relation";
- public static final String CHANGE_MANAGEMENT = "change-management";
- public static final String GET_VNF_WORKFLOW_RELATION = "get_vnf_workflow_relation";
- public static final String SCHEDULER_BY_SCHEDULE_ID = "/scheduler/schedules/{scheduleId}";
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ChangeManagementController.class);
- private String fromAppId;
- private final WorkflowService workflowService;
- private final ChangeManagementService changeManagementService;
- private final ObjectMapper objectMapper;
-
-
- @Autowired
- public ChangeManagementController(WorkflowService workflowService, ChangeManagementService changeManagementService, ObjectMapper objectMapper) {
- this.fromAppId = "VidChangeManagementController";
- this.workflowService = workflowService;
- this.changeManagementService = changeManagementService;
- this.objectMapper = objectMapper;
- }
-
- @RequestMapping(value = {"/workflow"}, method = RequestMethod.GET)
- public ResponseEntity<Collection<String>> getWorkflow(@RequestParam("vnfs") Collection<String> vnfs) throws IOException, InterruptedException {
- Collection<String> result = this.workflowService.getWorkflowsForVNFs(vnfs);
- return new ResponseEntity<>(result, OK);
- }
-
- @RequestMapping(value = {"/mso"}, method = RequestMethod.GET)
- public ResponseEntity<Collection<Request>> getMSOChangeManagements() throws Exception, IOException, InterruptedException {
-
- Collection<Request> result = this.changeManagementService.getMSOChangeManagements();
- return new ResponseEntity<>(result, OK);
- }
-
- @RequestMapping(value = "/workflow/{vnfName}", method = RequestMethod.POST)
- public ResponseEntity<String> changeManagement(@PathVariable("vnfName") String vnfName,
- HttpServletRequest request,
- @RequestBody ChangeManagementRequest changeManagmentRequest)
- throws Exception {
- return this.changeManagementService.doChangeManagement(changeManagmentRequest, vnfName);
- }
-
- @RequestMapping(value = "/uploadConfigUpdateFile", method = RequestMethod.POST)
- public @ResponseBody ResponseEntity uploadConfigUpdateFile(@RequestPart("file") MultipartFile file)
- throws Exception {
- try {
- String jsonString = this.changeManagementService.uploadConfigUpdateFile(file);
- return new ResponseEntity<>(jsonString, HttpStatus.OK);
- }
- catch(WebApplicationException e){
- return new ResponseEntity<>(handleException(e), HttpStatus.valueOf(e.getResponse().getStatus()));
- }
- catch (Exception e) {
- return new ResponseEntity<>(handleException(e), INTERNAL_SERVER_ERROR);
- }
- }
-
-
- @RequestMapping(value = {"/scheduler"}, method = RequestMethod.GET)
- public ResponseEntity<JSONArray> getSchedulerChangeManagements() throws IOException, InterruptedException {
- JSONArray result = this.changeManagementService.getSchedulerChangeManagements();
- return new ResponseEntity<>(result, OK);
- }
-
- @RequestMapping(value = {SCHEDULER_BY_SCHEDULE_ID}, method = RequestMethod.DELETE)
- public ResponseEntity deleteSchedule(@PathVariable("scheduleId") String scheduleId) throws IOException, InterruptedException {
- Pair<String, Integer> result = this.changeManagementService.deleteSchedule(scheduleId);
- return ResponseEntity.status(result.getRight()).build();
- }
-
-
- @RequestMapping(value = {GET_VNF_WORKFLOW_RELATION}, method = RequestMethod.POST)
- public ResponseEntity getWorkflows(@RequestBody GetVnfWorkflowRelationRequest getVnfWorkflowRelationRequest) throws IOException, InterruptedException {
- try {
- GetWorkflowsResponse response = new GetWorkflowsResponse(changeManagementService.getWorkflowsForVnf(getVnfWorkflowRelationRequest));
- return ResponseEntity.status(OK).body(response);
- }
- catch (NotFoundException exception) {
- LOGGER.error(exception.getMessage(), exception);
- return new ResponseEntity<>(new VnfWorkflowRelationResponse(Collections.singletonList(exception.getMessage())),HttpStatus.NOT_FOUND);
- }
- catch (Exception exception) {
- return handleException(exception, "Failed to get workflows for vnf");
- }
- }
-
- @RequestMapping(value = {VNF_WORKFLOW_RELATION}, method = RequestMethod.POST)
- public ResponseEntity createWorkflowRelation(@RequestBody VnfWorkflowRelationRequest vnfWorkflowRelationRequest) throws IOException, InterruptedException {
- VnfWorkflowRelationResponse vnfWorkflowRelationResponse;
- try {
- vnfWorkflowRelationResponse = changeManagementService.addVnfWorkflowRelation(vnfWorkflowRelationRequest);
- }
- catch (Exception exception) {
- return handleException(exception, "Failed to add vnf to workflow relation");
- }
-
- return new ResponseEntity<>(vnfWorkflowRelationResponse, OK);
- }
-
- @RequestMapping(value = {VNF_WORKFLOW_RELATION}, method = RequestMethod.GET)
- public ResponseEntity getAllWorkflowRelation() throws IOException, InterruptedException {
-
- try {
- VnfWorkflowRelationAllResponse vnfWorkflowRelationAllResponse = changeManagementService.getAllVnfWorkflowRelations();
- return new ResponseEntity<>(vnfWorkflowRelationAllResponse, OK);
- }
- catch (Exception exception) {
- return handleException(exception, "Failed to get all vnf to workflow relations");
- }
- }
-
- @RequestMapping(value = {VNF_WORKFLOW_RELATION}, method = RequestMethod.DELETE)
- public ResponseEntity deleteWorkflowRelation(@RequestBody VnfWorkflowRelationRequest vnfWorkflowRelationRequest) throws IOException, InterruptedException {
- VnfWorkflowRelationResponse vnfWorkflowRelationResponse;
- try {
- vnfWorkflowRelationResponse = changeManagementService.deleteVnfWorkflowRelation(vnfWorkflowRelationRequest);
- }
- catch (Exception exception) {
- return handleException(exception, "Failed to delete vnf from workflow relation");
- }
-
- return new ResponseEntity<>(vnfWorkflowRelationResponse, OK);
- }
-
- private ResponseEntity handleException(Exception exception, String msg) {
- LOGGER.error(msg, exception);
- return new ResponseEntity<>(new VnfWorkflowRelationResponse(Collections.singletonList(msg)), HttpStatus.INTERNAL_SERVER_ERROR);
- }
-
-
- private ExceptionResponse handleException(Exception e) {
- return ControllersUtils.handleException(e, LOGGER);
- }
-
- @ExceptionHandler(Exception.class)
- @ResponseStatus(value=OK) //return 200 for Backwards compatibility with the previous responses to scheduler
- private MsoResponseWrapperInterface exceptionHandler(Exception e) {
- return exceptionHandler(e, INTERNAL_SERVER_ERROR);
- }
-
- @ExceptionHandler({
- javax.ws.rs.BadRequestException.class,
- })
- @ResponseStatus(value = OK) //return 200 for Backwards compatibility with the previous responses to scheduler
- public MsoResponseWrapperInterface clientDerivedExceptionAsBadRequest(Exception e) {
- // same handler, different HTTP Code
- return exceptionHandler(e, BAD_REQUEST);
- }
-
- private MsoResponseWrapperInterface exceptionHandler(Exception e, HttpStatus httpStatus) {
- LOGGER.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodName(), ExceptionUtils.getMessage(e), e);
- MsoResponseWrapper2<MsoExceptionResponse> responseWrapper2 = new MsoResponseWrapper2<>(httpStatus.value(), new MsoExceptionResponse(e));
- return responseWrapper2;
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java b/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java
deleted file mode 100644
index 1df4f42bc..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.onap.vid.controller;
-
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.openecomp.portalsdk.core.domain.User;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.util.SystemProperties;
-import org.onap.vid.model.ExceptionResponse;
-import org.slf4j.MDC;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
-import static org.onap.vid.utils.Logging.getMethodName;
-
-public class ControllersUtils {
-
-
- public static String extractUserId(HttpServletRequest request) {
- String userId = "";
- HttpSession session = request.getSession();
- if (session != null) {
- User user = (User) session.getAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME));
- if (user != null) {
- //userId = user.getHrid();
- userId = user.getLoginId();
- if (userId == null)
- userId = user.getOrgUserId();
- }
- }
- return userId;
- }
-
- public static ExceptionResponse handleException(Exception e, EELFLoggerDelegate logger) {
- logger.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodName(), ExceptionUtils.getMessage(e), e);
-
- ExceptionResponse exceptionResponse = new ExceptionResponse(e);
- return exceptionResponse;
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java b/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java
deleted file mode 100644
index 2368649a4..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.controller;
-
-import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.util.SystemProperties;
-import org.onap.vid.dao.FnAppDoaImpl;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Controller for user profile view. The view is restricted to authenticated
- * users. The view name resolves to page user_profile.jsp which uses Angular.
- */
-
-@RestController
-@RequestMapping("/")
-public class HealthCheckController extends UnRestrictedBaseController {
-
-
- /** The logger. */
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(HealthCheckController.class);
-
- /** The Constant dateFormat. */
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- private static final String HEALTH_CHECK_PATH = "/healthCheck";
-
- /**
- * Model for JSON response with health-check results.
- */
- public class HealthStatus {
- // Either 200 or 500
- public int statusCode;
-
- // Additional detail in case of error, empty in case of success.
- public String message;
-
- public String date;
-
- public HealthStatus(int code, String msg) {
- this.statusCode = code;
- this.message = msg;
- }
-
- public HealthStatus(int code,String date, String msg) {
- this.statusCode = code;
- this.message = msg;
- this.date=date;
- }
-
- public int getStatusCode() {
- return statusCode;
- }
-
- public void setStatusCode(int code) {
- this.statusCode = code;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String msg) {
- this.message = msg;
- }
-
- public String getDate() {
- return date;
- }
-
- public void setDate(String date) {
- this.date = date;
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public int getProfileCount(String driver, String URL, String username, String password) {
- FnAppDoaImpl doa= new FnAppDoaImpl();
- int count= doa.getProfileCount(driver,URL,username,password);
- return count;
- }
-
-
-
- /**
- * Obtain the HealthCheck Status from the System.Properties file.
- * Used by IDNS for redundancy
- * @return ResponseEntity The response entity
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException the interrupted exception
- */
- @RequestMapping(value="/healthCheck",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public HealthStatus gethealthCheckStatusforIDNS() throws IOException, InterruptedException {
-
- String driver = SystemProperties.getProperty("db.driver");
- String URL = SystemProperties.getProperty("db.connectionURL");
- String username = SystemProperties.getProperty("db.userName");
- String password = SystemProperties.getProperty("db.password");
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "driver ::" + driver);
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "URL::" + URL);
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "username::" + username);
- LOGGER.debug(EELFLoggerDelegate.debugLogger,"password::" + password);
-
-
- HealthStatus healthStatus = null;
- try {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "Performing health check");
- int count=getProfileCount(driver,URL,username,password);
- LOGGER.debug(EELFLoggerDelegate.debugLogger,"count:::"+count);
- healthStatus = new HealthStatus(200, "health check succeeded");
- } catch (Exception ex) {
-
- LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex);
- healthStatus = new HealthStatus(500, "health check failed: " + ex.toString());
- }
- return healthStatus;
- }
-
- /**
- * Obtain the HealthCheck Status from the System.Properties file.
- *
- * @return ResponseEntity The response entity
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException the interrupted exception
- * Project :
- */
- @RequestMapping(value="rest/healthCheck/{User-Agent}/{X-ECOMP-RequestID}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- public HealthStatus getHealthCheck(
- @PathVariable("User-Agent") String UserAgent,
- @PathVariable("X-ECOMP-RequestID") String ECOMPRequestID) throws IOException, InterruptedException {
-
- String driver = SystemProperties.getProperty("db.driver");
- String URL = SystemProperties.getProperty("db.connectionURL");
- String username = SystemProperties.getProperty("db.userName");
- String password = SystemProperties.getProperty("db.password");
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "driver ::" + driver);
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "URL::" + URL);
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "username::" + username);
- LOGGER.debug(EELFLoggerDelegate.debugLogger,"password::" + password);
-
-
- HealthStatus healthStatus = null;
- try {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "Performing health check");
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "User-Agent" + UserAgent);
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "X-ECOMP-RequestID" + ECOMPRequestID);
-
-
- int count=getProfileCount(driver,URL,username,password);
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger,"count:::"+count);
- healthStatus = new HealthStatus(200,dateFormat.format(new Date()) ,"health check succeeded");
- } catch (Exception ex) {
-
- LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex);
- healthStatus = new HealthStatus(500,dateFormat.format(new Date()),"health check failed: " + ex.toString());
- }
- return healthStatus;
- }
-}
-
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
deleted file mode 100644
index e70c87115..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.onap.vid.controller;
-
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.core.Appender;
-import ch.qos.logback.core.FileAppender;
-import ch.qos.logback.core.spi.AppenderAttachable;
-import org.apache.commons.io.input.ReversedLinesFileReader;
-import org.apache.commons.lang3.StringUtils;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.model.ExceptionResponse;
-import org.onap.vid.roles.Role;
-import org.onap.vid.roles.RoleProvider;
-import org.onap.vid.utils.Streams;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.InternalServerErrorException;
-import javax.ws.rs.NotAuthorizedException;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.util.Objects;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static com.att.eelf.configuration.Configuration.GENERAL_LOGGER_NAME;
-
-
-@RestController
-@RequestMapping("logger")
-public class LoggerController extends RestrictedBaseController {
-
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(LoggerController.class);
-
- @Autowired
- RoleProvider roleProvider;
-
- @RequestMapping(value = "/{loggerName:audit|error|metrics}", method = RequestMethod.GET)
- public String getLog(@PathVariable String loggerName, HttpServletRequest request,
- @RequestParam(value="limit", defaultValue = "5000") Integer limit) throws IOException {
-
- List<Role> roles = roleProvider.getUserRoles(request);
- boolean userPermitted = roleProvider.userPermissionIsReadLogs(roles);
- if (!userPermitted) {
- throw new NotAuthorizedException("User not authorized to get logs");
- }
-
- String logfilePath = getLogfilePath(loggerName);
-
- try (final ReversedLinesFileReader reader = new ReversedLinesFileReader(new File(logfilePath))) {
- Supplier<String> reverseLinesSupplier = () -> {
- try {
- return reader.readLine();
- } catch (NullPointerException e) {
- // EOF Reached
- return null;
- } catch (IOException e) {
- throw new InternalServerErrorException("error while reading " + logfilePath, e);
- }
- };
-
- return Streams.takeWhile(
- Stream.generate(reverseLinesSupplier),
- line -> !StringUtils.contains(line, "Logging is started"))
- .limit(limit)
- .limit(5_000)
- .filter(Objects::nonNull)
- .collect(Collectors.joining("\n"));
- }
- }
-
- private String getLogfilePath(String loggerName) {
- /*
- Find the requested logger, and pull all of it's appenders.
- Find the first of the appenders that is a FileAppender, and return it's
- write-out filename.
- */
- LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- return context.getLoggerList().stream()
- .filter(logger -> logger.getName().equals(GENERAL_LOGGER_NAME + "." + loggerName))
- .flatMap(this::pullSubAppenders)
- .flatMap(appender -> {
- // Appender might be "attachable", if so - roll-up its sub-appenders
- return (appender instanceof AppenderAttachable) ?
- pullSubAppenders((AppenderAttachable<?>) appender) : Stream.of(appender);
- })
- .filter(appender -> appender instanceof FileAppender)
- .map(appender -> (FileAppender<?>) appender)
- .map(FileAppender::getFile)
- .findFirst()
- .orElseThrow(() -> new InternalServerErrorException("logfile for " + loggerName + " not found"));
- }
-
- private <T> Stream<Appender<T>> pullSubAppenders(AppenderAttachable<T> logger) {
- return Streams.fromIterator(logger.iteratorForAppenders());
- }
-
- @ExceptionHandler({ NotAuthorizedException.class })
- @ResponseStatus(HttpStatus.UNAUTHORIZED)
- public String notAuthorizedHandler(NotAuthorizedException e) {
- return "UNAUTHORIZED";
- }
-
- @ExceptionHandler({ IOException.class, InternalServerErrorException.class })
- @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
- public ExceptionResponse ioExceptionHandler(Exception e) {
- return org.onap.vid.controller.ControllersUtils.handleException(e, LOGGER);
- }
-
-}
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);
- }
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
deleted file mode 100644
index 2aa52b858..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.onap.vid.controller;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.vid.factories.MsoRequestFactory;
-import org.onap.vid.mso.MsoBusinessLogic;
-import org.onap.vid.mso.MsoBusinessLogicImpl;
-import org.onap.vid.mso.MsoInterface;
-import org.onap.vid.mso.rest.MsoRestClientNew;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-
-@Configuration
-public class MsoConfig {
-
- /**
- * Gets the object mapper.
- *
- * @return the object mapper
- */
- @Bean
- public ObjectMapper getObjectMapper() {
- return new ObjectMapper();
- }
-
- @Bean
- public MsoRequestFactory createRequestDetailsFactory(){
- return new MsoRequestFactory();
- }
-
- @Bean
- public MsoInterface getMsoClient(){
- return new MsoRestClientNew();
- }
-
- @Bean
- public MsoBusinessLogic getMsoBusinessLogic(){
- return new MsoBusinessLogicImpl(getMsoClient());
- }
-
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
deleted file mode 100644
index 1ce1d64c4..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
+++ /dev/null
@@ -1,655 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.controller;
-
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.vid.model.ExceptionResponse;
-import org.onap.vid.mso.MsoBusinessLogic;
-import org.onap.vid.mso.MsoResponseWrapper;
-import org.onap.vid.mso.rest.Request;
-import org.onap.vid.mso.rest.RequestDetails;
-import org.onap.vid.mso.rest.Task;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-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.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-//import java.util.UUID;
-//import org.springframework.http.ResponseEntity;
-//import org.springframework.http.RequestEntity;
-
-/**
- * The Class MsoController.
- */
-@RestController
-@RequestMapping("mso")
-public class MsoController extends RestrictedBaseController {
-
- /**
- * The logger.
- */
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
-
- /**
- * The Constant dateFormat.
- */
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- /**
- * The Constant SVC_INSTANCE_ID.
- */
- public final static String SVC_INSTANCE_ID = "<service_instance_id>";
- public final static String REQUEST_TYPE = "<request_type>";
-
- /**
- * The Constant CONFIGURATION_ID
- */
- public final static String CONFIGURATION_ID = "<configuration_id>";
-
- /**
- * The Constant VNF_INSTANCE_ID.
- */
- public final static String VNF_INSTANCE_ID = "<vnf_instance_id>";
-
- private final MsoBusinessLogic msoBusinessLogic;
-
- @Autowired
- public MsoController(MsoBusinessLogic msoBusinessLogic) {
- this.msoBusinessLogic = msoBusinessLogic;
- }
-
- /**
- * Creates the svc instance.
- *
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
- public ResponseEntity<String> createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
- String methodName = "createSvcInstance";
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- // always return OK, the MSO status code is embedded in the body
-
- MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(mso_request);
-
- return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
-
- }
-
- /**
- * Creates the vnf.
- *
- * @param serviceInstanceId the service instance id
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
-
- MsoResponseWrapper w = msoBusinessLogic.createVnf(mso_request, serviceInstanceId);
-
- // always return OK, the MSO status code is embedded in the body
-
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
-
- }
-
- /**
- * Creates the nw instance.
- *
- * @param serviceInstanceId the service instance id
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
- String methodName = "createNwInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
-
- MsoResponseWrapper w = msoBusinessLogic.createNwInstance(mso_request, serviceInstanceId);
-
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
-
- }
-
- /**
- * Creates the volume group instance.
- *
- * @param serviceInstanceId the service instance id
- * @param vnfInstanceId the vnf instance id
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
- HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
- String methodName = "createVolumeGroupInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
- }
-
- /**
- * Creates the vf module instance.
- *
- * @param serviceInstanceId the service instance id
- * @param vnfInstanceId the vnf instance id
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
- String methodName = "createVfModuleInstance";
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(mso_request, serviceInstanceId, vnfInstanceId);
-
- // always return OK, the MSO status code is embedded in the body
-
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
- }
-
- /**
- * Creates a configuration instance.
- *
- * @param serviceInstanceId the service instance id
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
- public ResponseEntity<String> createConfigurationInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
- String methodName = "createConfigurationInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(mso_request, serviceInstanceId);
-
- // always return OK, the MSO status code is embedded in the body
-
- return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
- }
-
- /**
- * Delete svc instance.
- *
- * @param serviceInstanceId the service instance id
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
-
- String methodName = "deleteSvcInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(mso_request, serviceInstanceId);
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
- // always return OK, the MSO status code is embedded in the body
-
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
-
- }
-
- /**
- * Delete vnf.
- *
- * @param serviceInstanceId the service instance id
- * @param vnfInstanceId the vnf instance id
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
-
- public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
- HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
- String methodName = "deleteVnf";
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.deleteVnf(mso_request, serviceInstanceId, vnfInstanceId);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
-
- }
-
- /**
- * Delete configuration instance
- * @param serviceInstanceId the service instance id
- * @param configurationId the configuration id
- * @param mso_request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
- method = RequestMethod.POST)
- public ResponseEntity<String> deleteConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable ("configurationId") String configurationId,
- @RequestBody RequestDetails mso_request) throws Exception {
-
- String methodName = "deleteConfiguration";
- LOGGER.debug(EELFLoggerDelegate.debugLogger,
- dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(mso_request, serviceInstanceId, configurationId);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
- }
-
- /**
- * Activate configuration instance
- * @param serviceInstanceId the service instace id
- * @param configurationId the configuration id
- * @param mso_request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
- method = RequestMethod.POST)
- public ResponseEntity<String> activateConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails mso_request) throws Exception {
-
- MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, true);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
- }
-
- /**
- * Deactivate configuration instance
- * @param serviceInstanceId the service instace id
- * @param configurationId the configuration id
- * @param mso_request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
- method = RequestMethod.POST)
- public ResponseEntity<String> deactivateConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails mso_request) throws Exception {
-
- MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, false);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
- }
-
- /**
- * Disable port on configuration instance
- * @param serviceInstanceId the service instance id
- * @param configurationId the configuration instance id
- * @param mso_request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
- method = RequestMethod.POST)
- public ResponseEntity<String> disablePortOnConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails mso_request) throws Exception {
-
- MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, false);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
- }
-
- /**
- * Enable port on configuration instance
- * @param serviceInstanceId the service instance id
- * @param configurationId the configuration instance id
- * @param mso_request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
- method = RequestMethod.POST)
- public ResponseEntity<String> enablePortOnConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails mso_request) throws Exception {
-
- MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, true);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
- }
-
- /**
- * Delete vf module.
- *
- * @param serviceInstanceId the service instance id
- * @param vnfInstanceId the vnf instance id
- * @param vfModuleId the vf module id
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- //mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
- @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
- public ResponseEntity<String> deleteVfModule(
- @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
- @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
-
- String methodName = "deleteVfModule";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.deleteVfModule(mso_request, serviceInstanceId, vnfInstanceId, vfModuleId);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
-
- }
-
- /**
- * Delete volume group instance.
- *
- * @param serviceInstanceId the service instance id
- * @param vnfInstanceId the vnf instance id
- * @param volumeGroupId the volume group id
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
- public ResponseEntity<String> deleteVolumeGroupInstance(
- @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
- HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
- String methodName = "deleteVolumeGroupInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.deleteVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId, volumeGroupId);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
- }
-
- /**
- * Delete nw instance.
- *
- * @param serviceInstanceId the service instance id
- * @param networkInstanceId the network instance id
- * @param request the request
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
- String methodName = "deleteNwInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(mso_request, serviceInstanceId, networkInstanceId);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
-
- }
-
- /**
- * Gets the orchestration request.
- *
- * @param requestId the request id
- * @param request the request
- * @return the orchestration request
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
- public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
- HttpServletRequest request) throws Exception {
-
- String methodName = "getOrchestrationRequest";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
-
- MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
- }
-
-
- /**
- * Gets the orchestration requests.
- *
- * @param filterString the filter string
- * @param request the request
- * @return the orchestration requests
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
- public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
- HttpServletRequest request) throws Exception {
-
- String methodName = "getOrchestrationRequests";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
-
- MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
-
- // always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
- }
-
-
- /**
- * activate to a pnf instance.
- *
- * @param serviceInstanceId the id of the service.
- * @param requestDetails the body of the request.
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
- String methodName = "activateServiceInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
- return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
- }
-
- /**
- * deactivate a service instance.
- *
- * @param serviceInstanceId the id of the service.
- * @param requestDetails the body of the request.
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
- String methodName = "deactivateServiceInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
- return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
- }
-
-
- /**
- * Gets the orchestration requests for the dashboard.
- * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
- * @return the orchestration requests
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
- public List<Request> getOrchestrationRequestsForDashboard() throws Exception {
-
- String methodName = "getOrchestrationRequestsForDashboard";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
-
- return msoBusinessLogic.getOrchestrationRequestsForDashboard();
- }
-
- /**
- * Gets the Manual Tasks for the given request id.
- *
- * @param originalRequestId the id of the original request.
- * @return the tasks
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
- public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) throws Exception {
-
- String methodName = "getManualTasksByRequestId";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
- }
-
-
-
- /**
- * Complete the manual task.
- *
- * @param taskId the id of the task to complete.
- * @param requestDetails the body of the request.
- * @return the response entity
- * @throws Exception the exception
- */
- @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
- public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId , @RequestBody RequestDetails requestDetails) throws Exception {
-
- String methodName = "manualTaskComplete";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
- return new ResponseEntity<String>(w.getResponse(), HttpStatus.OK);
- }
-
- @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> removeRelationshipFromServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
- @RequestBody RequestDetails requestDetails) throws Exception {
-
- String methodName = "removeRelationshipFromServiceInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w;
- try {
- w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
- } catch (Exception e){
- LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
- return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
- }
- return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
- }
-
- @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> addRelationshipToServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
- @RequestBody RequestDetails requestDetails) throws Exception {
-
- String methodName = "addRelationshipToServiceInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w;
- try {
- w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
- } catch (Exception e){
- LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
- return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
- }
- return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
- }
-
-
- /**
- * Exception handler.
- *
- * @param e the e
- * @param response the response
- * @throws IOException Signals that an I/O exception has occurred.
- */
- @ExceptionHandler(Exception.class)
- private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
-
- /*
- * The following "logger.error" lines "should" be sufficient for logging the exception.
- * However, the console output in my Eclipse environment is NOT showing ANY of the
- * logger statements in this class. Thus the temporary "e.printStackTrace" statement
- * is also included.
- */
-
- String methodName = "exceptionHandler";
- LOGGER.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- LOGGER.error(EELFLoggerDelegate.errorLogger, sw.toString());
-
- /*
- * Temporary - IF the above mentioned "logger.error" glitch is resolved ...
- * this statement could be removed since it would then likely result in duplicate
- * trace output.
- */
- e.printStackTrace(System.err);
-
- response.setContentType("application/json; charset=UTF-8");
- response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-
- ExceptionResponse exceptionResponse = new ExceptionResponse();
- exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
- exceptionResponse.setMessage(e.getMessage());
-
- response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
-
- response.flushBuffer();
-
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java b/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
deleted file mode 100644
index e57aab392..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
+++ /dev/null
@@ -1,354 +0,0 @@
-package org.onap.vid.controller;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.MoreObjects;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.model.ExceptionResponse;
-import org.onap.vid.model.RequestReferencesContainer;
-import org.onap.vid.mso.MsoBusinessLogic;
-import org.onap.vid.mso.MsoResponseWrapper2;
-import org.onap.vid.mso.RestMsoImplementation;
-import org.onap.vid.mso.RestObject;
-import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
-import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
-import org.onap.vid.mso.rest.MsoRestClientNew;
-import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
-import org.onap.vid.mso.rest.RequestDetails;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.MissingServletRequestParameterException;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.onap.vid.utils.Logging.getMethodCallerName;
-import static org.onap.vid.utils.Logging.getMethodName;
-import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
-
-@RestController
-@RequestMapping("operationalEnvironment")
-public class OperationalEnvironmentController extends RestrictedBaseController {
-
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(OperationalEnvironmentController.class);
- private final RestMsoImplementation restMso;
- private final MsoBusinessLogic msoBusinessLogic;
-
- private static final Pattern RECOVERY_ACTION_MESSAGE_PATTERN = Pattern.compile("String value \'(.*)\': value not");
-
-
- @Autowired
- public OperationalEnvironmentController(MsoBusinessLogic msoBusinessLogic, MsoRestClientNew msoClientInterface) {
- this.restMso = msoClientInterface;
- this.msoBusinessLogic = msoBusinessLogic;
- }
-
- @RequestMapping(value = "/create", method = RequestMethod.POST)
- public MsoResponseWrapper2 createOperationalEnvironment(HttpServletRequest request, @RequestBody OperationalEnvironmentCreateBody operationalEnvironment) throws Exception {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), operationalEnvironment);
- String userId = ControllersUtils.extractUserId(request);
- RequestDetailsWrapper<OperationEnvironmentRequestDetails> requestDetailsWrapper = msoBusinessLogic.convertParametersToRequestDetails(operationalEnvironment, userId);
- String path = msoBusinessLogic.getOperationalEnvironmentCreationPath();
- RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetailsWrapper, "",
- path, RequestReferencesContainer.class);
- debugEnd(msoResponse);
- return new MsoResponseWrapper2<>(msoResponse);
- }
-
- @RequestMapping(value = "/activate", method = RequestMethod.POST)
- public MsoResponseWrapper2 activate(HttpServletRequest request,
- @RequestParam("operationalEnvironment") String operationalEnvironmentId,
- @RequestBody OperationalEnvironmentActivateBody activateRequest) throws Exception {
-
- verifyIsNotEmpty(operationalEnvironmentId, "operationalEnvironment");
-
- //manifest is null in case of wrong manifest structure (deserialization failure of the manifest)
- if (activateRequest.getManifest()==null || activateRequest.getManifest().getServiceModelList()==null) {
- throw new BadManifestException("Manifest structure is wrong");
- }
-
- String userId = ControllersUtils.extractUserId(request);
-
- OperationalEnvironmentActivateInfo activateInfo = new OperationalEnvironmentActivateInfo(activateRequest, userId, operationalEnvironmentId);
- debugStart(activateInfo);
-
- String path = msoBusinessLogic.getOperationalEnvironmentActivationPath(activateInfo);
- RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = msoBusinessLogic.createOperationalEnvironmentActivationRequestDetails(activateInfo);
-
- RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetailsWrapper, "",
- path, RequestReferencesContainer.class);
-
- debugEnd(msoResponse);
- return new MsoResponseWrapper2<>(msoResponse);
- }
-
- @RequestMapping(value = "/deactivate", method = RequestMethod.POST)
- public MsoResponseWrapper2 deactivate(HttpServletRequest request,
- @RequestParam("operationalEnvironment") String operationalEnvironmentId,
- @RequestBody Map deactivationRequest) throws Exception {
-
- verifyIsNotEmpty(operationalEnvironmentId, "operationalEnvironment");
-
- String userId = ControllersUtils.extractUserId(request);
-
- OperationalEnvironmentDeactivateInfo deactivateInfo = new OperationalEnvironmentDeactivateInfo(userId, operationalEnvironmentId);
- debugStart(deactivateInfo);
-
- String path = msoBusinessLogic.getOperationalEnvironmentDeactivationPath(deactivateInfo);
- RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = msoBusinessLogic.createOperationalEnvironmentDeactivationRequestDetails(deactivateInfo);
-
- RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetailsWrapper, "",
- path, RequestReferencesContainer.class);
-
- debugEnd(msoResponse);
- return new MsoResponseWrapper2<>(msoResponse);
- }
-
- @RequestMapping(value = "/requestStatus", method = RequestMethod.GET)
- public MsoResponseWrapper2 status(HttpServletRequest request, @RequestParam("requestId") String requestId) throws Exception {
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), requestId);
-
- verifyIsNotEmpty(requestId, "requestId");
- String path = msoBusinessLogic.getCloudResourcesRequestsStatusPath(requestId);
-
- final RestObject<HashMap> msoResponse = restMso.GetForObject("", path, HashMap.class);
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), msoResponse);
- return new MsoResponseWrapper2<>(msoResponse);
- }
-
- @ExceptionHandler(Exception.class)
- @ResponseStatus(value=INTERNAL_SERVER_ERROR)
- private ExceptionResponse exceptionHandler(Exception e) {
- return ControllersUtils.handleException(e, LOGGER);
- }
-
- @ExceptionHandler({
- org.springframework.web.bind.MissingServletRequestParameterException.class,
- BadManifestException.class
- })
- @ResponseStatus(value = HttpStatus.BAD_REQUEST)
- public ExceptionResponse clientDerivedExceptionAsBadRequest(Exception e) {
- // same handler, different HTTP Code
- return exceptionHandler(e);
- }
-
- @ExceptionHandler({
- org.springframework.http.converter.HttpMessageNotReadableException.class,
- })
- @ResponseStatus(value = HttpStatus.BAD_REQUEST)
- public ExceptionResponse handlingHttpMessageNotReadableException(Exception e) {
- //in case of wrong value in manifest for RecoveryAction the message contains the class name.
- //The wrong value is in also part of this messages
- //within the pattern of: String value '<WRONG_VALUE>': value not
- //so we use regex to find the wrong value
- if (e.getMessage().contains(OperationalEnvironmentRecoveryAction.class.getName())) {
- LOGGER.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodName(), ExceptionUtils.getMessage(e), e);
- String message = "Wrong value for RecoveryAction in manifest. Allowed options are: "+OperationalEnvironmentRecoveryAction.options;
-
- Matcher matcher = RECOVERY_ACTION_MESSAGE_PATTERN.matcher(e.getMessage());
- if (matcher.find()) {
- String wrongValue = matcher.group(1);
- message = message+". Wrong value is: "+wrongValue;
- }
- return new ExceptionResponse(new BadManifestException(message));
- }
- return exceptionHandler(e);
- }
-
-
- public enum OperationalEnvironmentRecoveryAction {
- abort,
- retry,
- skip;
-
- public static final String options = Stream.of(OperationalEnvironmentRecoveryAction.values()).map(OperationalEnvironmentRecoveryAction::name).collect(Collectors.joining(", "));
- }
-
- public static class ActivateServiceModel {
- private String serviceModelVersionId;
- private OperationalEnvironmentRecoveryAction recoveryAction;
-
- public ActivateServiceModel() {
- }
-
- public ActivateServiceModel(String serviceModelVersionId, OperationalEnvironmentRecoveryAction recoveryAction) {
- this.serviceModelVersionId = serviceModelVersionId;
- this.recoveryAction = recoveryAction;
- }
-
- public String getServiceModelVersionId() {
- return serviceModelVersionId;
- }
-
- public void setServiceModelVersionId(String serviceModelVersionId) {
- this.serviceModelVersionId = serviceModelVersionId;
- }
-
- public OperationalEnvironmentRecoveryAction getRecoveryAction() {
- return recoveryAction;
- }
-
- public void setRecoveryAction(OperationalEnvironmentRecoveryAction recoveryAction) {
- this.recoveryAction = recoveryAction;
- }
- }
-
- @JsonIgnoreProperties(ignoreUnknown = true)
- public static class OperationalEnvironmentManifest {
-
-
- private List<ActivateServiceModel> serviceModelList;
-
- public OperationalEnvironmentManifest() {
- }
-
- public OperationalEnvironmentManifest(List<ActivateServiceModel> serviceModelList) {
- this.serviceModelList = serviceModelList;
- }
-
- public List<ActivateServiceModel> getServiceModelList() {
- return serviceModelList;
- }
-
- public void setServiceModelList(List<ActivateServiceModel> serviceModelList) {
- this.serviceModelList = serviceModelList;
- }
- }
-
- public static class OperationalEnvironmentActivateBody {
- private final String relatedInstanceId;
- private final String relatedInstanceName;
- private final String workloadContext;
- private final OperationalEnvironmentManifest manifest;
-
- public OperationalEnvironmentActivateBody(@JsonProperty(value = "relatedInstanceId", required = true) String relatedInstanceId,
- @JsonProperty(value = "relatedInstanceName", required = true) String relatedInstanceName,
- @JsonProperty(value = "workloadContext", required = true) String workloadContext,
- @JsonProperty(value = "manifest", required = true) OperationalEnvironmentManifest manifest) {
- this.relatedInstanceId = relatedInstanceId;
- this.relatedInstanceName = relatedInstanceName;
- this.workloadContext = workloadContext;
- this.manifest = manifest;
- }
-
-
- public String getRelatedInstanceId() {
- return relatedInstanceId;
- }
-
- public String getRelatedInstanceName() {
- return relatedInstanceName;
- }
-
- public String getWorkloadContext() {
- return workloadContext;
- }
-
- public OperationalEnvironmentManifest getManifest() {
- return manifest;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("relatedInstanceId", relatedInstanceId)
- .add("relatedInstanceName", relatedInstanceName)
- .add("workloadContext", workloadContext)
- .add("manifest", manifest)
- .toString();
- }
- }
-
- public static class OperationalEnvironmentCreateBody {
- private final String instanceName;
- private final String ecompInstanceId;
- private final String ecompInstanceName;
- private final String operationalEnvironmentType;
- private final String tenantContext;
- private final String workloadContext;
-
- public OperationalEnvironmentCreateBody(@JsonProperty(value = "instanceName", required = true) String instanceName,
- @JsonProperty(value = "ecompInstanceId", required = true) String ecompInstanceId,
- @JsonProperty(value = "ecompInstanceName", required = true) String ecompInstanceName,
- @JsonProperty(value = "operationalEnvironmentType", required = true) String operationalEnvironmentType,
- @JsonProperty(value = "tenantContext", required = true) String tenantContext,
- @JsonProperty(value = "workloadContext", required = true) String workloadContext) {
- this.instanceName = instanceName;
- this.ecompInstanceId = ecompInstanceId;
- this.ecompInstanceName = ecompInstanceName;
- this.operationalEnvironmentType = operationalEnvironmentType;
- this.tenantContext = tenantContext;
- this.workloadContext = workloadContext;
- }
-
- public String getInstanceName() {
- return instanceName;
- }
-
- public String getEcompInstanceId() {
- return ecompInstanceId;
- }
-
- public String getEcompInstanceName() {
- return ecompInstanceName;
- }
-
- public String getOperationalEnvironmentType() {
- return operationalEnvironmentType;
- }
-
- public String getTenantContext() {
- return tenantContext;
- }
-
- public String getWorkloadContext() {
- return workloadContext;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("instanceName", instanceName)
- .add("ecompInstanceId", ecompInstanceId)
- .add("ecompInstanceName", ecompInstanceName)
- .add("operationalEnvironmentType", operationalEnvironmentType)
- .add("tenantContext", tenantContext)
- .add("workloadContext", workloadContext)
- .toString();
- }
- }
-
- private void debugEnd(RestObject<RequestReferencesContainer> msoResponse) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodCallerName(), msoResponse);
- }
-
- private void debugStart(Object requestInfo) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodCallerName(), requestInfo);
- }
-
- private void verifyIsNotEmpty(String fieldValue, String fieldName) throws MissingServletRequestParameterException {
- if (StringUtils.isEmpty(fieldValue)) {
- throw new MissingServletRequestParameterException(fieldName, "String");
- }
- }
-
- public static class BadManifestException extends RuntimeException {
- public BadManifestException(String message) {
- super(message);
- }
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/PolicyController.java b/vid-app-common/src/main/java/org/onap/vid/controller/PolicyController.java
deleted file mode 100644
index 4e9ec2539..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/PolicyController.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.controller;
-
-import org.json.simple.JSONObject;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.policy.*;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.UUID;
-
-/**
- * Controller to handle Policy requests.
- */
-
-@RestController
-public class PolicyController extends RestrictedBaseController{
-
- /** The logger. */
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(PolicyController.class);
-
- @RequestMapping(value="/get_policy",method = RequestMethod.POST)
- public ResponseEntity<String> getPolicyInfo( HttpServletRequest request, @RequestBody JSONObject policy_request) throws Exception {
-
- LOGGER.debug("#####################POLICY API CALL STARTED ###############"+ PolicyProperties.POLICY_GET_CONFIG_VAL);
- LOGGER.debug("#####################Policy Request ###############"+policy_request.toString());
-
- String path = PolicyProperties.getProperty(PolicyProperties.POLICY_GET_CONFIG_VAL);
- PolicyResponseWrapper policyResWrapper = getPolicyConfig(policy_request,path);
-
- LOGGER.debug("$$$$$$$$$$$$$$$$$$$$$$ " + new ResponseEntity<String>(policyResWrapper.getResponse(), HttpStatus.OK).toString());
-
- return ( new ResponseEntity<String>(policyResWrapper.getResponse(), HttpStatus.valueOf(policyResWrapper.getStatus())) );
- }
-
- protected static PolicyResponseWrapper getPolicyConfig(JSONObject request, String path) throws Exception {
- String methodName = "getPolicyConfig";
- String uuid = UUID.randomUUID().toString();
- LOGGER.debug( "starting getPolicyConfig ");
-
- try {
- //STARTING REST API CALL AS AN FACTORY INSTACE
- PolicyRestInterfaceIfc restController = PolicyRestInterfaceFactory.getInstance();
-
- RestObject<String> restObjStr = new RestObject<String>();
- String str = new String();
- restObjStr.set(str);
- restController.<String>Post(str, request, uuid, path, restObjStr );
- PolicyResponseWrapper policyRespWrapper = PolicyUtil.wrapResponse (restObjStr);
-
- LOGGER.debug( "<== " + methodName + " w=" + policyRespWrapper.getResponse());
- return policyRespWrapper;
- } catch (Exception e) {
- LOGGER.debug( "EXCEPTION in getPolicyConfig <== " + "." + methodName + e.toString());
- throw e;
- }
- }
-}
-
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/PropertyController.java b/vid-app-common/src/main/java/org/onap/vid/controller/PropertyController.java
deleted file mode 100644
index 2d282edb8..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/PropertyController.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.controller;
-
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.util.SystemProperties;
-import org.onap.vid.category.CategoryParametersResponse;
-import org.onap.vid.model.CategoryParameter.Family;
-import org.onap.vid.services.CategoryParameterService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.servlet.ModelAndView;
-
-import javax.servlet.http.HttpServletRequest;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import static org.onap.vid.utils.Logging.getMethodName;
-
-/**
- * The Class PropertyController.
- */
-@RestController
-public class PropertyController extends RestrictedBaseController{
-
-
- /** The logger. */
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(PropertyController.class);
-
- /** The Constant dateFormat. */
- final protected static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- @Autowired
- protected CategoryParameterService categoryParameterService;
-
-
- /**
- * Welcome.
- *
- * @param request the request
- * @return the model and view
- */
- @RequestMapping(value = {"/propertyhome" }, method = RequestMethod.GET)
- public ModelAndView welcome(HttpServletRequest request) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== PropertyController welcome start");
- return new ModelAndView(getViewName());
- }
-
- /**
- * Gets the property.
- *
- * @param name the name
- * @param defaultvalue the defaultvalue
- * @param request the request
- * @return the property
- * @throws Exception the exception
- */
- @RequestMapping(value = "/get_property/{name}/{defaultvalue}", method = RequestMethod.GET)
- public ResponseEntity<String> getProperty (@PathVariable("name") String name, @PathVariable("defaultvalue") String defaultvalue,
- HttpServletRequest request) throws Exception {
-
- String methodName = "getProperty";
- ResponseEntity<String> resp = null;
- String pvalue = null;
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- try {
- // convert "_" to "." in the property name
- if (name == null || name.length() == 0 ) {
- return ( new ResponseEntity<String> (defaultvalue, HttpStatus.OK));
- }
- // convert "_" to "." in the property name
- String propertyName = name.replace('_', '.');
- pvalue = SystemProperties.getProperty(propertyName);
- if ( ( pvalue == null ) || ( pvalue.length() == 0 ) ) {
- pvalue = defaultvalue;
- }
- resp = new ResponseEntity<String>(pvalue, HttpStatus.OK);
- }
- catch (Exception e) {
- LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- throw e;
- }
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " returning " + pvalue);
- return ( resp );
- }
-
- /**
- * 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);
- }
- }
-
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java b/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java
deleted file mode 100644
index 3e15153ac..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.onap.vid.controller;
-
-import fj.test.Bool;
-import org.json.JSONObject;
-import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
-import org.onap.vid.services.RoleGeneratorService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-
-@RestController
-public class RoleGeneratorController extends UnRestrictedBaseController {
- @Autowired
- private RoleGeneratorService roleGeneratorService;
- public static final String GENERATE_ROLE_SCRIPT = "generateRoleScript";
- @RequestMapping(value = GENERATE_ROLE_SCRIPT +"/{firstRun}", method = RequestMethod.GET )
- public ResponseEntity<String> generateRoleScript (@PathVariable("firstRun") boolean firstRun) throws Exception {
- ResponseEntity<String> response = null;
- String query = roleGeneratorService.generateRoleScript(firstRun);
- response = new ResponseEntity<String>(query, HttpStatus.OK);
- return response;
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/VidController.java b/vid-app-common/src/main/java/org/onap/vid/controller/VidController.java
deleted file mode 100644
index c93d8027f..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/VidController.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.controller;
-
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
-import org.onap.vid.asdc.AsdcCatalogException;
-import org.onap.vid.asdc.beans.SecureServices;
-import org.onap.vid.exceptions.VidServiceUnavailableException;
-import org.onap.vid.model.ServiceModel;
-import org.onap.vid.roles.Role;
-import org.onap.vid.roles.RoleProvider;
-import org.onap.vid.services.AaiService;
-import org.onap.vid.services.VidService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.servlet.ModelAndView;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-
-//import org.onap.vid.model.Service;
-
-@RestController
-public class VidController extends RestrictedBaseController {
-
- private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidController.class);
-
- private final VidService service;
-
- @Autowired
- public VidController(VidService vidService) throws SdcToscaParserException{
-
- service = vidService;
- }
-
- @Autowired
- private AaiService aaiService;
-
- @Autowired
- RoleProvider roleProvider;
-
-// /**
-// * Gets the services.
-// *
-// * @param request the request
-// * @return the services
-// * @throws VidServiceUnavailableException the vid service unavailable exception
-// */
-// @RequestMapping(value={"/rest/models/services"}, method = RequestMethod.GET)
-// public SecureServices getServices(HttpServletRequest request) throws VidServiceUnavailableException {
-// try {
-// AaiService aaiService = new AaiServiceImpl();
-// LOG.info("Start API for browse ASDC was called");
-// SecureServices secureServices = new SecureServices();
-// Map<String, String[]> requestParams = request.getParameterMap();
-// List<Role> roles = roleProvider.getUserRoles(request);
-// secureServices.setServices(aaiService.getServicesByDistributionStatus());
-// secureServices.setServices(service.getServices(requestParams));
-// secureServices.setReadOnly(roleProvider.userPermissionIsReadOnly(roles));
-// return secureServices;
-// } catch (AsdcCatalogException e) {
-// LOG.error("Failed to retrieve service definitions from SDC", e);
-// throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e);
-// } catch (Throwable t) {
-// LOG.debug("Unexpected error while retrieving service definitions from SDC: " + t.getMessage() + ":", t);
-// t.printStackTrace();
-// throw new VidServiceUnavailableException("Unexpected error while retrieving service definitions from SDC: " + t.getMessage(), t);
-// }
-// }
-
- /**
- * Gets the services.
- *
- * @param request the request
- * @return the services
- * @throws VidServiceUnavailableException the vid service unavailable exception
- */
- @RequestMapping(value={"/rest/models/services"}, method = RequestMethod.GET)
- public SecureServices getServices(HttpServletRequest request) throws VidServiceUnavailableException {
- try {
- LOG.info("Start API for browse ASDC was called");
- SecureServices secureServices = new SecureServices();
- List<Role> roles = roleProvider.getUserRoles(request);
- secureServices.setServices(aaiService.getServicesByDistributionStatus());
- secureServices.setReadOnly(roleProvider.userPermissionIsReadOnly(roles));
- return secureServices;
- }
- catch (Exception t) {
- LOG.debug("Unexpected error while retrieving service definitions from A&AI: " + t.getMessage() + ":", t);
- t.printStackTrace();
- throw new VidServiceUnavailableException("Unexpected error while retrieving service definitions from A&AI: " + t.getMessage(), t);
- }
- }
-
-
-
- /**
- * Gets the services.
- *
- * @param uuid the uuid
- * @return the services
- * @throws VidServiceUnavailableException the vid service unavailable exception
- */
- @RequestMapping(value={"/rest/models/services/{uuid}"}, method = RequestMethod.GET)
- public ServiceModel getServices(@PathVariable("uuid") String uuid, HttpServletRequest request) throws VidServiceUnavailableException {
- try {
- return service.getService(uuid);
- } catch (AsdcCatalogException e) {
- LOG.error("Failed to retrieve service definitions from SDC", e);
- throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e);
- }
- }
-
-
- /**
- * Gets the services view.
- *
- * @param request the request
- * @return the services view
- * @throws VidServiceUnavailableException the vid service unavailable exception
- */
- @RequestMapping(value={"/serviceModels"}, method=RequestMethod.GET)
- public ModelAndView getServicesView(HttpServletRequest request) throws VidServiceUnavailableException {
- return new ModelAndView("serviceModels");
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java b/vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java
deleted file mode 100644
index 4a87df10d..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.controller;
-
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.servlet.ModelAndView;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-
-
-/**
- * The Class ViewLogController.
- */
-@RestController
-public class ViewLogController extends RestrictedBaseController{
-
- /** The logger. */
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ViewLogController.class);
-
- /** The Constant dateFormat. */
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- /** The servlet context. */
- private @Autowired ServletContext servletContext;
-
- /**
- * Welcome.
- *
- * @param request the request
- * @return the model and view
- */
- @RequestMapping(value = {"/viewlog" }, method = RequestMethod.GET)
- public ModelAndView welcome(HttpServletRequest request) {
-
- return new ModelAndView(getViewName());
- }
-
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
deleted file mode 100644
index 2838e7f3c..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.onap.vid.controller;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.io.IOUtils;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.onap.vid.aai.AaiClient;
-import org.onap.vid.aai.AaiClientInterface;
-import org.onap.vid.asdc.AsdcClient;
-import org.onap.vid.asdc.local.LocalAsdcClient;
-import org.onap.vid.asdc.memory.InMemoryAsdcClient;
-import org.onap.vid.asdc.parser.ToscaParserImpl2;
-import org.onap.vid.asdc.rest.RestfulAsdcClient;
-import org.onap.vid.properties.AsdcClientConfiguration;
-import org.onap.vid.properties.AsdcClientConfiguration.AsdcClientType;
-import org.onap.vid.services.AaiService;
-import org.onap.vid.services.AaiServiceImpl;
-import org.onap.vid.services.VidService;
-import org.onap.vid.services.VidServiceImpl;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import javax.net.ssl.SSLContext;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-
-@Configuration
-public class WebConfig {
-
- /**
- * Gets the object mapper.
- *
- * @return the object mapper
- */
- @Bean
- public ObjectMapper getObjectMapper() {
- return new ObjectMapper();
- }
-
-
-
-
- @Bean
- public VidService vidService(AsdcClient asdcClient) {
- return new VidServiceImpl(asdcClient);
- }
-
- @Bean
- public AaiService getAaiService(){
- return new AaiServiceImpl();
- }
-
- @Bean
- public AaiClientInterface getAaiClientInterface(){
- return new AaiClient();
- }
-
- @Bean
- public AsdcClient asdcClient(AsdcClientConfiguration asdcClientConfig) throws IOException {
- switch (asdcClientConfig.getAsdcClientType()) {
- case IN_MEMORY:
- final InputStream asdcCatalogFile = VidController.class.getClassLoader().getResourceAsStream("catalog.json");
- final JSONTokener tokener = new JSONTokener(asdcCatalogFile);
- final JSONObject catalog = new JSONObject(tokener);
-
- return new InMemoryAsdcClient.Builder().catalog(catalog).build();
- case REST:
-
- final String protocol = asdcClientConfig.getAsdcClientProtocol();
- final String host = asdcClientConfig.getAsdcClientHost();
- final int port = asdcClientConfig.getAsdcClientPort();
- final String auth = asdcClientConfig.getAsdcClientAuth();
- Client cl = null;
- if (protocol.equalsIgnoreCase("https")) {
- try {
- SSLContext ctx = SSLContext.getInstance("TLSv1.2");
- ctx.init(null, null, null);
- cl = ClientBuilder.newBuilder().sslContext(ctx).build();
- } catch (NoSuchAlgorithmException n) {
- throw new RuntimeException("SDC Client could not be instantiated due to unsupported protocol TLSv1.2", n);
- } catch (KeyManagementException k) {
- throw new RuntimeException("SDC Client could not be instantiated due to a key management exception", k);
- }
- } else {
- cl = ClientBuilder.newBuilder().build();
- }
-
- try {
- final URI uri = new URI(protocol + "://" + host + ":" + port + "/");
- return new RestfulAsdcClient.Builder(cl, uri)
- .auth(auth)
- .build();
- } catch (URISyntaxException e) {
- throw new RuntimeException("SDC Client could not be instantiated due to a syntax error in the URI", e);
- }
-
- case LOCAL:
-
- final InputStream asdcServicesFile = VidController.class.getClassLoader().getResourceAsStream("sdcservices.json");
-
- final JSONTokener jsonTokener = new JSONTokener(IOUtils.toString(asdcServicesFile));
- final JSONObject sdcServicesCatalog = new JSONObject(jsonTokener);
-
- return new LocalAsdcClient.Builder().catalog(sdcServicesCatalog).build();
-
- default:
- throw new RuntimeException(asdcClientConfig.getAsdcClientType() + " is invalid; must be one of " + Arrays.toString(AsdcClientType.values()));
- }
- }
-
- @Bean
- public ToscaParserImpl2 getToscaParser() {
- return new ToscaParserImpl2();
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java
index a83fa281b..7501b1032 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java
@@ -3,7 +3,7 @@ package org.onap.vid.controller.filter;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.StringUtils;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.springframework.web.filter.GenericFilterBean;
import javax.servlet.FilterChain;
@@ -19,7 +19,7 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.UUID;
-import static org.openecomp.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID;
+import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID;
@WebFilter(urlPatterns = "/*")
public class PromiseEcompRequestIdFilter extends GenericFilterBean {
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/filter/TempFilterForCORS.java b/vid-app-common/src/main/java/org/onap/vid/controller/filter/TempFilterForCORS.java
index 02dcde095..e89ae99e5 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/filter/TempFilterForCORS.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/filter/TempFilterForCORS.java
@@ -1,7 +1,7 @@
package org.onap.vid.controller.filter;
import org.apache.commons.lang3.StringUtils;
-import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.portalsdk.core.util.SystemProperties;
import org.springframework.web.filter.GenericFilterBean;
import javax.servlet.FilterChain;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java
index 29e7a4d7d..c57d93cb9 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java
@@ -21,7 +21,7 @@
package org.onap.vid.controller.test;
import org.codehaus.jackson.map.ObjectMapper;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.vid.model.ExceptionResponse;
import org.springframework.web.bind.annotation.*;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java
index 2b289b91a..ae6396475 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java
@@ -21,7 +21,7 @@
package org.onap.vid.controller.test;
import org.codehaus.jackson.map.ObjectMapper;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.vid.model.ExceptionResponse;
import org.springframework.web.bind.annotation.*;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java
index 9d6a3de9c..ba4476fa6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java
@@ -21,7 +21,7 @@
package org.onap.vid.controller.test;
import org.codehaus.jackson.map.ObjectMapper;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.vid.model.ExceptionResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestPageController.java b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestPageController.java
index 48ccdf8d8..d4c65f851 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestPageController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestPageController.java
@@ -20,7 +20,7 @@
package org.onap.vid.controller.test;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;