aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2019-05-28 12:40:07 +0000
committerGerrit Code Review <gerrit@onap.org>2019-05-28 12:40:07 +0000
commitbd42250f5046225cfb155d004c839eb9e1de1899 (patch)
tree38335d6937588fb8a67beba03b50856e88f33408 /vid-app-common
parentfcc997f27346a5db7f7e69e8d2bfd42d2bbc4fa1 (diff)
parenta522d00bf9ae8938886ebb235a4741a601bc8d93 (diff)
Merge "AaiController cleanup"
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java281
1 files changed, 152 insertions, 129 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
index 817e94442..6a3b4f9eb 100644
--- 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
@@ -8,9 +8,9 @@
* 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.
@@ -94,27 +94,29 @@ public class AaiController extends RestrictedBaseController {
}
@RequestMapping(value = {"/subscriberSearch"}, method = RequestMethod.GET)
- public ModelAndView welcome(HttpServletRequest request) {
+ public ModelAndView welcome() {
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== AaiController welcome start");
return new ModelAndView(getViewName());
}
@RequestMapping(value = {"/aai_get_aic_zones"}, method = RequestMethod.GET)
- public ResponseEntity<String> getAicZones(HttpServletRequest request) throws IOException {
+ public ResponseEntity<String> getAicZones() throws IOException {
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== 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 IOException {
+ @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) throws IOException {
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== getAicZoneForPnf controller start");
- AaiResponse response = aaiService.getAicZoneForPnf(globalCustomerId , serviceType , serviceId);
+ AaiResponse response = aaiService.getAicZoneForPnf(globalCustomerId, serviceType, serviceId);
return aaiResponseToResponseEntity(response);
}
@RequestMapping(value = {"/aai_get_instance_groups_by_vnf_instance_id/{vnfInstanceId}"}, method = RequestMethod.GET)
- public ResponseEntity<String> getInstanceGroupsByVnfInstanceId(@PathVariable("vnfInstanceId") String vnfInstanceId ,HttpServletRequest request) throws IOException {
+ public ResponseEntity<String> getInstanceGroupsByVnfInstanceId(@PathVariable("vnfInstanceId") String vnfInstanceId) throws IOException {
AaiResponse response = aaiService.getInstanceGroupsByVnfInstanceId(vnfInstanceId);
return aaiResponseToResponseEntity(response);
}
@@ -137,7 +139,7 @@ public class AaiController extends RestrictedBaseController {
@RequestMapping(value = {"/aai_get_version_by_invariant_id"}, method = RequestMethod.POST)
- public ResponseEntity<String> getVersionByInvariantId(HttpServletRequest request, @RequestBody VersionByInvariantIdsRequest versions) {
+ public ResponseEntity<String> getVersionByInvariantId(@RequestBody VersionByInvariantIdsRequest versions) {
Response result = aaiService.getVersionByInvariantId(versions.versions);
return new ResponseEntity<>(result.readEntity(String.class), HttpStatus.OK);
@@ -145,43 +147,47 @@ public class AaiController extends RestrictedBaseController {
private ResponseEntity<String> aaiResponseToResponseEntity(AaiResponse aaiResponseData)
- throws IOException {
+ throws IOException {
ResponseEntity<String> responseEntity;
ObjectMapper objectMapper = new ObjectMapper();
if (aaiResponseData.getHttpCode() == 200) {
- responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(aaiResponseData.getT()), HttpStatus.OK);
+ responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(aaiResponseData.getT()),
+ HttpStatus.OK);
} else {
- responseEntity = new ResponseEntity<>(aaiResponseData.getErrorMessage(), HttpStatus.valueOf(aaiResponseData.getHttpCode()));
+ responseEntity = new ResponseEntity<>(aaiResponseData.getErrorMessage(),
+ HttpStatus.valueOf(aaiResponseData.getHttpCode()));
}
return responseEntity;
}
@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) {
+ public ResponseEntity<String> doGetServiceInstance(@PathVariable("service-instance-id") String serviceInstanceId,
+ @PathVariable("service-instance-type") String serviceInstanceType) {
Response resp = null;
if (serviceInstanceType.equalsIgnoreCase("Service Instance Id")) {
resp = doAaiGet(
- "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:"
- + serviceInstanceId, false);
+ "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:"
+ + serviceInstanceId, false);
} else {
resp = doAaiGet(
- "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:"
- + serviceInstanceId, false);
+ "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:"
+ + serviceInstanceId, false);
}
return convertResponseToResponseEntity(resp);
}
@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) {
+ @PathVariable("service-subscription-id") String serviceSubscriptionId) {
Response resp = doAaiGet("business/customers/customer/" + globalCustomerId
- + "/service-subscriptions/service-subscription/" + serviceSubscriptionId + "?depth=0", false);
+ + "/service-subscriptions/service-subscription/" + serviceSubscriptionId + "?depth=0", false);
return convertResponseToResponseEntity(resp);
}
@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 {
+ public ResponseEntity<String> doGetSubscriberList(HttpServletRequest request,
+ @DefaultValue("n") @QueryParam("fullSet") String fullSet) throws IOException {
return getFullSubscriberList(request);
}
@@ -192,13 +198,16 @@ public class AaiController extends RestrictedBaseController {
}
@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) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({}, {})", getMethodName(), operationalEnvironmentType, operationalEnvironmentStatus);
- AaiResponse<OperationalEnvironmentList> response = aaiService.getOperationalEnvironments(operationalEnvironmentType,operationalEnvironmentStatus);
+ public AaiResponse<OperationalEnvironmentList> getOperationalEnvironments(
+ @RequestParam(value = "operationalEnvironmentType", required = false) String operationalEnvironmentType,
+ @RequestParam(value = "operationalEnvironmentStatus", required = false) String operationalEnvironmentStatus) {
+ 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) {
+ if (errorMessage != null) {
response = new AaiResponse<>(response.getT(), errorMessage, response.getHttpCode());
}
}
@@ -214,22 +223,23 @@ public class AaiController extends RestrictedBaseController {
RoleValidator roleValidator = RoleValidator.by(roleProvider.getUserRoles(request));
SubscriberFilteredResults subscriberList = aaiService.getFullSubscriberList(roleValidator);
if (subscriberList.getHttpCode() == 200) {
- responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(subscriberList.getSubscriberList()), HttpStatus.OK);
+ responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(subscriberList.getSubscriberList()),
+ HttpStatus.OK);
} else {
- responseEntity = new ResponseEntity<>(subscriberList.getErrorMessage(), HttpStatus.valueOf(subscriberList.getHttpCode()));
+ responseEntity = new ResponseEntity<>(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 {
+ method = RequestMethod.GET,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> getVnfDataByGlobalIdAndServiceType(
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType) throws IOException {
AaiResponse<AaiGetVnfResponse> resp = aaiService.getVNFData(globalCustomerId, serviceType);
return aaiResponseToResponseEntity(resp);
@@ -251,44 +261,45 @@ public class AaiController extends RestrictedBaseController {
}
@RequestMapping(value = "/aai_sub_details/{subscriberId}", method = RequestMethod.GET)
- public ResponseEntity<String> GetSubscriberDetails(HttpServletRequest request, @PathVariable("subscriberId") String subscriberId) throws IOException {
+ 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 = RoleValidator.by(roles);
AaiResponse subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator);
String httpMessage = subscriberData.getT() != null ?
- objectMapper.writeValueAsString(subscriberData.getT()) :
- subscriberData.getErrorMessage();
+ objectMapper.writeValueAsString(subscriberData.getT()) :
+ subscriberData.getErrorMessage();
- responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(subscriberData.getHttpCode()));
+ responseEntity = new ResponseEntity<>(httpMessage, HttpStatus.valueOf(subscriberData.getHttpCode()));
return responseEntity;
}
@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 {
+ @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 = RoleValidator.by(roles);
- AaiResponse<ServiceInstancesSearchResults> searchResult = aaiService.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects);
+ AaiResponse<ServiceInstancesSearchResults> searchResult = aaiService
+ .getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects);
String httpMessage = searchResult.getT() != null ?
- objectMapper.writeValueAsString(searchResult.getT()) :
- searchResult.getErrorMessage();
-
+ objectMapper.writeValueAsString(searchResult.getT()) :
+ searchResult.getErrorMessage();
- if(searchResult.getT().serviceInstances.isEmpty()){
- responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.NOT_FOUND);
+ if (searchResult.getT().serviceInstances.isEmpty()) {
+ responseEntity = new ResponseEntity<>(httpMessage, HttpStatus.NOT_FOUND);
} else {
- responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(searchResult.getHttpCode()));
+ responseEntity = new ResponseEntity<>(httpMessage, HttpStatus.valueOf(searchResult.getHttpCode()));
}
return responseEntity;
@@ -296,12 +307,13 @@ public class AaiController extends RestrictedBaseController {
@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) {
+ @PathVariable("namedQueryId") String namedQueryId,
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("serviceInstance") String serviceInstance) {
- String componentListPayload = getComponentListPutPayload(namedQueryId, globalCustomerId, serviceType, serviceInstance);
+ String componentListPayload = getComponentListPutPayload(namedQueryId, globalCustomerId, serviceType,
+ serviceInstance);
Response resp = doAaiPost("search/named-query", componentListPayload, false);
return convertResponseToResponseEntity(resp);
@@ -309,9 +321,9 @@ public class AaiController extends RestrictedBaseController {
@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) {
+ @PathVariable("namedQueryId") String namedQueryId,
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType) {
String componentListPayload = getModelsByServiceTypePayload(namedQueryId, globalCustomerId, serviceType);
@@ -321,37 +333,40 @@ public class AaiController extends RestrictedBaseController {
@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);
+ @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<>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
}
@RequestMapping(value = "/aai_get_network_collection_details/{serviceInstanceId}", method = RequestMethod.GET)
- public ResponseEntity<String> getNetworkCollectionDetails(@PathVariable("serviceInstanceId") String serviceInstanceId) throws IOException {
+ public ResponseEntity<String> getNetworkCollectionDetails(
+ @PathVariable("serviceInstanceId") String serviceInstanceId) throws IOException {
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
AaiResponse<String> resp = aaiService.getNetworkCollectionDetails(serviceInstanceId);
String httpMessage = resp.getT() != null ?
- objectMapper.writeValueAsString(resp.getT()) :
- resp.getErrorMessage();
+ objectMapper.writeValueAsString(resp.getT()) :
+ resp.getErrorMessage();
return new ResponseEntity<>(httpMessage, HttpStatus.valueOf(resp.getHttpCode()));
}
@RequestMapping(value = "/aai_get_instance_groups_by_cloudregion/{cloudOwner}/{cloudRegionId}/{networkFunction}", method = RequestMethod.GET)
public ResponseEntity<String> getInstanceGroupsByCloudRegion(@PathVariable("cloudOwner") String cloudOwner,
- @PathVariable("cloudRegionId") String cloudRegionId,
- @PathVariable("networkFunction") String networkFunction) throws IOException {
+ @PathVariable("cloudRegionId") String cloudRegionId,
+ @PathVariable("networkFunction") String networkFunction) throws IOException {
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
- AaiResponse<AaiGetInstanceGroupsByCloudRegion> resp = aaiService.getInstanceGroupsByCloudRegion(cloudOwner, cloudRegionId, networkFunction);
+ AaiResponse<AaiGetInstanceGroupsByCloudRegion> resp = aaiService
+ .getInstanceGroupsByCloudRegion(cloudOwner, cloudRegionId, networkFunction);
String httpMessage = resp.getT() != null ?
- objectMapper.writeValueAsString(resp.getT()) :
- resp.getErrorMessage();
+ objectMapper.writeValueAsString(resp.getT()) :
+ resp.getErrorMessage();
return new ResponseEntity<>(httpMessage, HttpStatus.valueOf(resp.getHttpCode()));
}
@@ -359,7 +374,7 @@ public class AaiController extends RestrictedBaseController {
public ResponseEntity<String> getByUri(HttpServletRequest request) {
String restOfTheUrl = (String) request.getAttribute(
- HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
+ HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
String formattedUri = restOfTheUrl.replaceFirst("/aai_get_by_uri/", "").replaceFirst("^aai/v[\\d]+/", "");
Response resp = doAaiGet(formattedUri, false);
@@ -370,16 +385,16 @@ public class AaiController extends RestrictedBaseController {
@RequestMapping(value = "/aai_get_configuration/{configuration_id}", method = RequestMethod.GET)
public ResponseEntity<String> getSpecificConfiguration(@PathVariable("configuration_id") String configurationId) {
- Response resp = doAaiGet("network/configurations/configuration/"+configurationId, false);
+ Response resp = doAaiGet("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) {
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("serviceInstanceId") String serviceInstanceId) {
return aaiService.getServiceInstanceAssociatedPnfs(globalCustomerId, serviceType, serviceInstanceId);
}
@@ -391,7 +406,7 @@ public class AaiController extends RestrictedBaseController {
try {
resp = aaiService.getSpecificPnf(pnfId);
re = new ResponseEntity<>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
- } catch (Exception e){
+ } catch (Exception e) {
return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
return re;
@@ -399,61 +414,68 @@ public class AaiController extends RestrictedBaseController {
@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) {
+ @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 = RoleValidator.by(roles);
- AaiResponse<GetTenantsResponse[]> response = aaiService.getTenants(globalCustomerId, serviceType, roleValidator);
+ AaiResponse<GetTenantsResponse[]> response = aaiService
+ .getTenants(globalCustomerId, serviceType, roleValidator);
if (response.getHttpCode() == 200) {
- responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(response.getT()), HttpStatus.OK);
+ responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(response.getT()),
+ HttpStatus.OK);
} else {
- responseEntity = new ResponseEntity<String>(response.getErrorMessage(), HttpStatus.valueOf(response.getHttpCode()));
+ responseEntity = new ResponseEntity<>(response.getErrorMessage(),
+ HttpStatus.valueOf(response.getHttpCode()));
}
} catch (Exception e) {
- responseEntity = new ResponseEntity<String>("Unable to proccess getTenants reponse", HttpStatus.INTERNAL_SERVER_ERROR);
+ responseEntity = new ResponseEntity<>("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);
+ @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<>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
}
@RequestMapping(value = "/aai_getPortMirroringConfigsData", method = RequestMethod.GET)
public Map<String, PortMirroringConfigData> getPortMirroringConfigsData(
- @RequestParam ("configurationIds") List<String> configurationIds) {
+ @RequestParam("configurationIds") List<String> configurationIds) {
return configurationIds.stream()
- .map(id -> ImmutablePair.of(id, aaiService.getPortMirroringConfigData(id)))
- .collect(Collectors.toMap(Pair::getKey, Pair::getValue));
+ .map(id -> ImmutablePair.of(id, aaiService.getPortMirroringConfigData(id)))
+ .collect(Collectors.toMap(Pair::getKey, Pair::getValue));
}
@RequestMapping(value = "/aai_getPortMirroringSourcePorts", method = RequestMethod.GET)
public Map<String, Object> getPortMirroringSourcePorts(
- @RequestParam ("configurationIds") List<String> configurationIds) {
+ @RequestParam("configurationIds") List<String> configurationIds) {
return configurationIds.stream()
- .map(id -> ImmutablePair.of(id, aaiService.getPortMirroringSourcePorts(id)))
- .collect(Collectors.toMap(Pair::getKey, Pair::getValue));
+ .map(id -> ImmutablePair.of(id, aaiService.getPortMirroringSourcePorts(id)))
+ .collect(Collectors.toMap(Pair::getKey, Pair::getValue));
}
private ResponseEntity<String> convertResponseToResponseEntity(Response resp) {
ResponseEntity<String> respEnt;
if (resp == null) {
- respEnt = new ResponseEntity<>("Failed to fetch data from A&AI, check server logs for details.", HttpStatus.INTERNAL_SERVER_ERROR);
+ respEnt = new ResponseEntity<>("Failed to fetch data from A&AI, check server logs for details.",
+ HttpStatus.INTERNAL_SERVER_ERROR);
} else {
respEnt = new ResponseEntity<>(resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus()));
}
@@ -466,7 +488,8 @@ public class AaiController extends RestrictedBaseController {
Response resp = doAaiGet("business/customers?subscriber-type=INFRA&depth=" + depth, false);
if (resp != null) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== getSubscribers() resp=" + resp.getStatusInfo().toString());
+ LOGGER
+ .debug(EELFLoggerDelegate.debugLogger, "<== getSubscribers() resp=" + resp.getStatusInfo().toString());
}
return resp;
}
@@ -479,7 +502,6 @@ public class AaiController extends RestrictedBaseController {
Response resp = null;
try {
-
resp = aaiRestInterface.RestGet(FROM_APP_ID, transId, Unchecked.toURI(uri), xml).getResponse();
} catch (WebApplicationException e) {
@@ -511,42 +533,19 @@ public class AaiController extends RestrictedBaseController {
return resp;
}
- private String getComponentListPutPayload(String namedQueryId, String globalCustomerId, String serviceType, String serviceInstance) {
+ 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-instance\": {" +
+ " \"service-instance-id\": \"" + serviceInstance + "\"" +
+ " }," +
" \"service-subscription\": {" +
" \"service-type\": \"" + serviceType + "\"" +
" }" +
@@ -562,6 +561,30 @@ public class AaiController extends RestrictedBaseController {
}
+ 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);