summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ResponseWithRequestInfo.kt (renamed from vid-app-common/src/main/java/org/onap/vid/aai/ResponseWithRequestInfo.java)33
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java226
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java60
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java21
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java22
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java56
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java19
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java79
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Logging.java4
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js32
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js18
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html6
20 files changed, 257 insertions, 375 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ResponseWithRequestInfo.java b/vid-app-common/src/main/java/org/onap/vid/aai/ResponseWithRequestInfo.kt
index 567099c81..aaa41c2d3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/ResponseWithRequestInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ResponseWithRequestInfo.kt
@@ -18,32 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.aai;
+package org.onap.vid.aai
-import org.springframework.http.HttpMethod;
+import io.joshworks.restclient.http.HttpResponse
+import org.springframework.http.HttpMethod
-import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response
-public class ResponseWithRequestInfo {
- private String requestUrl;
- private HttpMethod requestHttpMethod;
- private Response response;
+open class BaseResponseWithRequestInfo(val requestUrl: String?, val requestHttpMethod: HttpMethod)
- public ResponseWithRequestInfo(Response response, String requestUrl, HttpMethod requestHttpMethod) {
- this.response = response;
- this.requestUrl = requestUrl;
- this.requestHttpMethod = requestHttpMethod;
- }
+class HttpResponseWithRequestInfo<T>(val response: HttpResponse<T>?, requestUrl: String?, requestHttpMethod: HttpMethod) :
+ BaseResponseWithRequestInfo(requestUrl, requestHttpMethod)
- public String getRequestUrl() {
- return requestUrl;
- }
-
- public HttpMethod getRequestHttpMethod() {
- return requestHttpMethod;
- }
-
- public Response getResponse() {
- return response;
- }
-}
+class ResponseWithRequestInfo(val response: Response?, requestUrl: String?, requestHttpMethod: HttpMethod) :
+ BaseResponseWithRequestInfo(requestUrl, requestHttpMethod)
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
index fc04080d9..44257a62e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
@@ -22,10 +22,11 @@
package org.onap.vid.asdc;
import io.joshworks.restclient.http.HttpResponse;
-import org.onap.vid.asdc.beans.Service;
-
+import java.io.InputStream;
import java.nio.file.Path;
import java.util.UUID;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
+import org.onap.vid.asdc.beans.Service;
/**
* The Interface AsdcClient.
@@ -55,6 +56,8 @@ public interface AsdcClient {
Path getServiceToscaModel(UUID uuid) throws AsdcCatalogException;
+ HttpResponseWithRequestInfo<InputStream> getServiceInputStream(UUID serviceUuid, boolean warpException);
+
HttpResponse<String> checkSDCConnectivity();
String getBaseUrl();
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
deleted file mode 100644
index ce1bbe930..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nokia. 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.asdc.local;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import io.joshworks.restclient.http.HttpResponse;
-import java.io.File;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.UUID;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.onap.vid.asdc.AsdcCatalogException;
-import org.onap.vid.asdc.AsdcClient;
-import org.onap.vid.asdc.beans.Service;
-import org.onap.vid.exceptions.GenericUncheckedException;
-
-/**
- * The Class LocalAsdcClient.
- */
-public class LocalAsdcClient implements AsdcClient {
-
-
- public static final String SERVICES = "services";
- /**
- * The catalog.
- */
- private final JSONObject catalog;
-
- /**
- * The mapper.
- */
- private final ObjectMapper mapper;
-
- /**
- * Instantiates a new in local sdc client.
- *
- * @param builder the builder
- */
- public LocalAsdcClient(org.onap.vid.asdc.local.LocalAsdcClient.Builder builder) {
- catalog = builder.catalog;
- mapper = builder.mapper;
- }
-
- /**
- * Gets the catalog.
- *
- * @return the catalog
- */
- private JSONObject getCatalog() {
- return catalog;
- }
-
- /**
- * Gets the mapper.
- *
- * @return the mapper
- */
- private ObjectMapper getMapper() {
- return mapper;
- }
-
- /**
- * Convert.
- *
- * @param <T> the generic type
- * @param json the json
- * @param clazz the clazz
- * @return the t
- * @throws AsdcCatalogException the sdc catalog exception
- */
- private <T> T convert(JSONObject json, Class<T> clazz) throws AsdcCatalogException {
- try {
- return getMapper().readValue(json.toString(), clazz);
- } catch (JsonParseException e) {
- throw new AsdcCatalogException("Failed to parse SDC response (bad data)", e);
- } catch (JsonMappingException e) {
- throw new AsdcCatalogException("Failed to map SDC response to internal VID data structure(s)", e);
- } catch (IOException e) {
- throw new AsdcCatalogException("Failed to get a response from SDC", e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.onap.vid.asdc.AsdcClient#getService(java.util.UUID)
- */
- public Service getService(UUID uuid) throws AsdcCatalogException {
-
- JSONObject serviceJsonObject = null;
- final JSONArray categoryJsonArray = getCatalog().getJSONArray(SERVICES);
-
- for (int i = 0; i < categoryJsonArray.length(); i++) {
- JSONObject jsonServiceObject = categoryJsonArray.getJSONObject(i);
- if (jsonServiceObject.get("uuid").equals(uuid.toString())) {
- serviceJsonObject = jsonServiceObject;
- break;
- }
- }
-
- if (serviceJsonObject != null)
- return convert(serviceJsonObject, Service.class);
- else return null;
- }
-
- /* (non-Javadoc)
- * @see org.onap.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)
- */
- public Path getServiceToscaModel(UUID serviceUuid) {
-
- String toscaModelURL = null;
-
- final JSONArray categoryJsonArray = getCatalog().getJSONArray(SERVICES);
-
- for (int i = 0; i < categoryJsonArray.length(); i++) {
-
- JSONObject jsonServiceObject = categoryJsonArray.getJSONObject(i);
- if (jsonServiceObject.get("uuid").equals(serviceUuid.toString())) {
- toscaModelURL = jsonServiceObject.getString("toscaModelURL");
- }
- }
- if (toscaModelURL == null) {
- return null;
- }
- ClassLoader classLoader = getClass().getClassLoader();
-
- try {
- File file = new File(classLoader.getResource(toscaModelURL).getFile());
- //using URLDecoder.decode to convert special characters from %XX to real character
- //see https://stackoverflow.com/questions/32251251/java-classloader-getresource-with-special-characters-in-path
- return Paths.get(URLDecoder.decode(file.getPath(), "UTF-8"));
- } catch (RuntimeException | UnsupportedEncodingException e) {
- throw new GenericUncheckedException("Can't find " + toscaModelURL, e);
- }
- }
-
- @Override
- public HttpResponse<String> checkSDCConnectivity() {
- return HttpResponse.fallback("");
- }
-
-
- @Override
- public String getBaseUrl(){
- return "";
- }
-
- /**
- * The Class Builder.
- */
- public static class Builder {
-
- /**
- * The catalog.
- */
- private JSONObject catalog = new JSONObject()
- .put("resources", new JSONObject())
- .put(SERVICES, new JSONObject());
-
- /**
- * The mapper.
- */
- private ObjectMapper mapper = new ObjectMapper();
-
- /**
- * Instantiates a new builder.
- */
- public Builder() {
- }
-
- /**
- * Catalog.
- *
- * @param catalog the catalog
- * @return the builder
- */
- public org.onap.vid.asdc.local.LocalAsdcClient.Builder catalog(JSONObject catalog) {
- this.catalog = catalog;
- return this;
- }
-
- /**
- * Mapper.
- *
- * @param mapper the mapper
- * @return the builder
- */
- public org.onap.vid.asdc.local.LocalAsdcClient.Builder mapper(ObjectMapper mapper) {
- this.mapper = mapper;
- return this;
- }
-
- /**
- * Builds the.
- *
- * @return the in local sdc client
- */
- public org.onap.vid.asdc.local.LocalAsdcClient build() {
- return new org.onap.vid.asdc.local.LocalAsdcClient(this);
- }
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
index a82110744..decf446d6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
@@ -20,11 +20,32 @@
package org.onap.vid.asdc.rest;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM;
+import static org.onap.portalsdk.core.util.SystemProperties.APP_DISPLAY_NAME;
+import static org.onap.vid.asdc.AsdcClient.URIS.METADATA_URL_TEMPLATE;
+import static org.onap.vid.asdc.AsdcClient.URIS.TOSCA_MODEL_URL_TEMPLATE;
+import static org.onap.vid.client.SyncRestClientInterface.HEADERS.AUTHORIZATION;
+import static org.onap.vid.client.SyncRestClientInterface.HEADERS.CONTENT_TYPE;
+import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID;
+import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
+import static org.onap.vid.utils.Logging.logRequest;
+
import com.att.eelf.configuration.EELFLogger;
import com.google.common.collect.ImmutableMap;
import io.joshworks.restclient.http.HttpResponse;
import io.vavr.control.Try;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.aai.ExceptionWithRequestInfo;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.asdc.AsdcClient;
import org.onap.vid.asdc.beans.Service;
@@ -34,26 +55,6 @@ import org.onap.vid.properties.VidProperties;
import org.onap.vid.utils.Logging;
import org.springframework.http.HttpMethod;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-import static javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM;
-import static org.onap.portalsdk.core.util.SystemProperties.APP_DISPLAY_NAME;
-import static org.onap.vid.asdc.AsdcClient.URIS.METADATA_URL_TEMPLATE;
-import static org.onap.vid.asdc.AsdcClient.URIS.TOSCA_MODEL_URL_TEMPLATE;
-import static org.onap.vid.client.SyncRestClientInterface.HEADERS.AUTHORIZATION;
-import static org.onap.vid.client.SyncRestClientInterface.HEADERS.CONTENT_TYPE;
-import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID;
-import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
-import static org.onap.vid.utils.Logging.logRequest;
-
public class SdcRestClient implements AsdcClient {
private String baseUrl;
@@ -86,17 +87,28 @@ public class SdcRestClient implements AsdcClient {
@Override
public Path getServiceToscaModel(UUID uuid) throws AsdcCatalogException {
- String finalUrl = String.format(TOSCA_MODEL_URL_TEMPLATE, baseUrl, path, uuid);
- logRequest(LOGGER, HttpMethod.GET, finalUrl);
-
InputStream inputStream = Try
- .of(() -> syncRestClient.getStream(finalUrl, prepareHeaders(auth, APPLICATION_OCTET_STREAM), Collections.emptyMap()))
+ .of(() -> getServiceInputStream(uuid, false))
.getOrElseThrow(AsdcCatalogException::new)
+ .getResponse()
.getBody();
return createTmpFile(inputStream);
}
+ @Override
+ public HttpResponseWithRequestInfo<InputStream> getServiceInputStream(UUID serviceUuid, boolean warpException) {
+ String finalUrl = String.format(TOSCA_MODEL_URL_TEMPLATE, baseUrl, path, serviceUuid);
+ logRequest(LOGGER, HttpMethod.GET, finalUrl);
+ try {
+ HttpResponse<InputStream> httpResponse = syncRestClient.getStream(finalUrl, prepareHeaders(auth, APPLICATION_OCTET_STREAM), Collections.emptyMap());
+ return new HttpResponseWithRequestInfo<>(httpResponse, finalUrl, HttpMethod.GET);
+ }
+ catch (RuntimeException exception) {
+ throw warpException ? new ExceptionWithRequestInfo(HttpMethod.GET, finalUrl, exception) : exception;
+ }
+ }
+
@Override
public HttpResponse<String> checkSDCConnectivity() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
index ff8516ea5..dc6e56f4a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +27,12 @@ import org.onap.vid.mso.model.RequestInfo;
* Created by Oren on 9/5/17.
*/
public class UpdateRequestInfo {
+
+ public String source;
+
+ public Boolean suppressRollback;
+
+ public String requestorId;
public UpdateRequestInfo() {
}
@@ -36,11 +43,6 @@ public class UpdateRequestInfo {
this.suppressRollback = requestInfo.getSuppressRollback();
this.source = requestInfo.getSource();
}
- public String source;
-
- public Boolean suppressRollback;
-
- public String requestorId;
-
+
}
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 eee2acc51..2b3ad60ea 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
@@ -77,6 +77,7 @@ public class AaiController extends RestrictedBaseController {
private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AaiController.class);
private static final String FROM_APP_ID = "VidAaiController";
+ private final ObjectMapper objectMapper = new ObjectMapper();
private AaiService aaiService;
private AAIRestInterface aaiRestInterface;
@@ -157,7 +158,7 @@ public class AaiController extends RestrictedBaseController {
throws IOException {
ResponseEntity<String> responseEntity;
if (aaiResponseData.getHttpCode() == 200) {
- responseEntity = new ResponseEntity<>(new ObjectMapper().writeValueAsString(aaiResponseData.getT()),
+ responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(aaiResponseData.getT()),
HttpStatus.OK);
} else {
responseEntity = new ResponseEntity<>(aaiResponseData.getErrorMessage(),
@@ -225,7 +226,6 @@ public class AaiController extends RestrictedBaseController {
@RequestMapping(value = "/aai_get_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> getFullSubscriberList(HttpServletRequest request) throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
ResponseEntity<String> responseEntity;
RoleValidator roleValidator = RoleValidator.by(roleProvider.getUserRoles(request));
SubscriberFilteredResults subscriberList = aaiService.getFullSubscriberList(roleValidator);
@@ -270,17 +270,14 @@ public class AaiController extends RestrictedBaseController {
@RequestMapping(value = "/aai_sub_details/{subscriberId}", method = RequestMethod.GET)
public ResponseEntity<String> getSubscriberDetails(HttpServletRequest request, @PathVariable("subscriberId") String subscriberId,
@RequestParam(value="omitServiceInstances", required = false, defaultValue = "false") boolean omitServiceInstances) 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, featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH) && omitServiceInstances);
- String httpMessage = subscriberData.getT() != null ?
- objectMapper.writeValueAsString(subscriberData.getT()) :
- subscriberData.getErrorMessage();
+ AaiResponse subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator,
+ featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH) && omitServiceInstances);
+ String httpMessage = subscriberData.getT() != null ? objectMapper.writeValueAsString(subscriberData.getT()) : subscriberData.getErrorMessage();
- responseEntity = new ResponseEntity<>(httpMessage, HttpStatus.valueOf(subscriberData.getHttpCode()));
- return responseEntity;
+ return new ResponseEntity<>(httpMessage,
+ HttpStatus.valueOf(subscriberData.getHttpCode()));
}
@RequestMapping(value = "/search_service_instances", method = RequestMethod.GET)
@@ -289,7 +286,6 @@ public class AaiController extends RestrictedBaseController {
@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);
@@ -354,7 +350,6 @@ public class AaiController extends RestrictedBaseController {
@RequestMapping(value = "/aai_get_network_collection_details/{serviceInstanceId}", method = RequestMethod.GET)
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 ?
@@ -367,7 +362,6 @@ public class AaiController extends RestrictedBaseController {
public ResponseEntity<String> getInstanceGroupsByCloudRegion(@PathVariable("cloudOwner") String cloudOwner,
@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);
@@ -424,7 +418,6 @@ public class AaiController extends RestrictedBaseController {
ResponseEntity responseEntity;
try {
- ObjectMapper objectMapper = new ObjectMapper();
List<Role> roles = roleProvider.getUserRoles(request);
RoleValidator roleValidator = RoleValidator.by(roles);
AaiResponse<GetTenantsResponse[]> response = aaiService
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
index fc718f0d2..535c97ce7 100644
--- 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
@@ -302,7 +302,6 @@ public class MsoController extends RestrictedBaseController {
* @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 msoRequest) {
@@ -449,7 +448,6 @@ public class MsoController extends RestrictedBaseController {
* @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,
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java b/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java
index cc8fff614..cd6942ee8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +34,11 @@ public class RequestReferencesContainer {
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<>();
-
+
+ public RequestReferencesContainer(@JsonProperty("requestReferences") RequestReferences requestReferences) {
+ this.requestReferences = requestReferences;
+ }
+
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
@@ -44,10 +49,6 @@ public class RequestReferencesContainer {
this.additionalProperties.put(name, value);
}
- public RequestReferencesContainer(@JsonProperty("requestReferences") RequestReferences requestReferences) {
- this.requestReferences = requestReferences;
- }
-
public RequestReferences getRequestReferences() {
return requestReferences;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java
index febd8e0fd..f5c1428fe 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +31,10 @@ public class RelatedVnf extends Node {
private String serviceInstanceName;
private String tenantName;
+ public RelatedVnf(AAITreeNode node) {
+ super(node);
+ }
+
public String getServiceInstanceId() {
return serviceInstanceId;
}
@@ -54,10 +59,6 @@ public class RelatedVnf extends Node {
this.tenantName = tenantName;
}
- public RelatedVnf(AAITreeNode node) {
- super(node);
- }
-
public static RelatedVnf from(AAITreeNode node) {
RelatedVnf vnf = new RelatedVnf(node);
if (node.getParent() != null && node.getParent().getType() == NodeType.SERVICE_INSTANCE) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java b/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
index 1638a376c..984c0d766 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
@@ -21,17 +21,19 @@
package org.onap.vid.model.probes;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+
import com.google.common.base.MoreObjects;
-import io.joshworks.restclient.http.HttpResponse;
+import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.vid.aai.ExceptionWithRequestInfo;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.aai.ResponseWithRequestInfo;
import org.onap.vid.mso.RestObjectWithRequestInfo;
import org.onap.vid.utils.Logging;
import org.springframework.http.HttpMethod;
-import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-
public class HttpRequestMetadata extends StatusMetadata {
private final HttpMethod httpMethod;
private final int httpCode;
@@ -81,6 +83,20 @@ public class HttpRequestMetadata extends StatusMetadata {
duration);
}
+ public HttpRequestMetadata(HttpResponseWithRequestInfo response, String description, long duration, boolean readRawData) {
+ super(description, duration);
+ this.httpMethod = response.getRequestHttpMethod();
+ this.url = response.getRequestUrl();
+ this.httpCode = response.getResponse().getStatus();
+ if (readRawData) {
+ try {
+ response.getResponse().getRawBody().reset();
+ this.rawData = IOUtils.toString(response.getResponse().getRawBody(), StandardCharsets.UTF_8.name());
+ } catch (Exception e) {
+ //Nothing to do here
+ }
+ }
+ }
public HttpMethod getHttpMethod() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
index 9146e8f1b..4d0d4ee74 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -60,6 +60,8 @@ import javax.ws.rs.BadRequestException;
import org.apache.commons.collections4.ListUtils;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.aai.ExceptionWithRequestInfo;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.changeManagement.ChangeManagementRequest;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
@@ -67,6 +69,7 @@ import org.onap.vid.controller.OperationalEnvironmentController;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
+import org.onap.vid.model.probes.ErrorMetadata;
import org.onap.vid.model.probes.ExternalComponentStatus;
import org.onap.vid.model.probes.HttpRequestMetadata;
import org.onap.vid.model.probes.StatusMetadata;
@@ -84,8 +87,8 @@ import org.onap.vid.mso.rest.RequestList;
import org.onap.vid.mso.rest.RequestWrapper;
import org.onap.vid.mso.rest.Task;
import org.onap.vid.mso.rest.TaskList;
+import org.onap.vid.utils.Logging;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
public class MsoBusinessLogicImpl implements MsoBusinessLogic {
@@ -383,12 +386,13 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
}
private List<RequestWrapper> getOrchestrationRequestsByFilter(String filterName, String filterValue) {
+ HttpResponseWithRequestInfo<String> msoResponseWrapper = getRawOrchestrationRequestsByFilter(filterName, filterValue);
+ return deserializeOrchestrationRequestsJson(msoResponseWrapper.getResponse().getBody());
+ }
+
+ private HttpResponseWithRequestInfo<String> getRawOrchestrationRequestsByFilter(String filterName, String filterValue) {
String orchestrationReqPath = constructOrchestrationRequestFilter(filterName, filterValue);
- RestObject<String> restObjStr = new RestObject<>();
- String str = new String();
- restObjStr.set(str);
- MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequest(str, "", orchestrationReqPath, restObjStr, true);
- return deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity());
+ return msoClientInterface.getOrchestrationRequest(orchestrationReqPath, true);
}
private List<RequestWrapper> deserializeOrchestrationRequestsJson(String orchestrationRequestsJson) {
@@ -837,22 +841,38 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
@Override
public ExternalComponentStatus probeComponent() {
- String url = SystemProperties.getProperty(
- MsoProperties.MSO_SERVER_URL) + "/" + SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
- long startTime = System.currentTimeMillis();
- ExternalComponentStatus externalComponentStatus;
-
+ final long startTime = System.currentTimeMillis();
+ HttpResponseWithRequestInfo<String> responseWithRequestInfo = null;
try {
- String rawBody = objectMapper.writeValueAsString(getOrchestrationRequestsForDashboard());
- StatusMetadata statusMetadata=new HttpRequestMetadata(HttpMethod.GET,200,url,rawBody,"VID-SO",System.currentTimeMillis() - startTime);
+ responseWithRequestInfo = getRawOrchestrationRequestsByFilter("requestExecutionDate", "01-01-2100" );
+ int httpCode = responseWithRequestInfo.getResponse().getStatus();
+ boolean isAvailable = httpCode == 200 || httpCode == 202;
+ if (isAvailable) {
+ //make sure response can be parsed to RequestList.class
+ JACKSON_OBJECT_MAPPER.readValue(responseWithRequestInfo.getResponse().getBody(), RequestList.class);
+ }
+
+ HttpRequestMetadata metadata = new HttpRequestMetadata(responseWithRequestInfo,
+ isAvailable ? "OK" : "MSO returned no orchestration requests",
+ System.currentTimeMillis() - startTime, true);
+ return new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, isAvailable, metadata);
- externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, true, statusMetadata);
+ } catch (ExceptionWithRequestInfo e) {
+ long duration = System.currentTimeMillis() - startTime;
+ return new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, false,
+ new HttpRequestMetadata(e, duration));
} catch (Exception e) {
- StatusMetadata statusMetadata = new HttpRequestMetadata(HttpMethod.GET, HttpStatus.INTERNAL_SERVER_ERROR.value(), url, "", e.getMessage(), System.currentTimeMillis() - startTime);
- externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, false, statusMetadata);
- }
+ StatusMetadata metadata;
+ long duration = System.currentTimeMillis() - startTime;
- return externalComponentStatus;
+ if (responseWithRequestInfo == null) {
+ metadata = new ErrorMetadata(Logging.exceptionToDescription(e), duration);
+ } else {
+ metadata = new HttpRequestMetadata(responseWithRequestInfo, Logging.exceptionToDescription(e), duration, true);
+ }
+
+ return new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, false, metadata);
+ }
}
private void validateUpdateVnfConfig(RequestDetails requestDetails) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
index 46bd2731d..d1cb3a37b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
@@ -21,6 +21,7 @@
package org.onap.vid.mso;
import io.joshworks.restclient.http.HttpResponse;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
@@ -89,7 +90,7 @@ public interface MsoInterface {
MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint);
- MsoResponseWrapper getOrchestrationRequest(String t, String sourceId, String endpoint, RestObject restObject, boolean warpException);
+ HttpResponseWithRequestInfo<String> getOrchestrationRequest(String endpoint, boolean warpException);
MsoResponseWrapper getOrchestrationRequest(String endpoint);
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
index df8034b22..cc6d6123d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
@@ -35,6 +35,7 @@ import org.apache.commons.codec.binary.Base64;
import org.eclipse.jetty.util.security.Password;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.changeManagement.MsoRequestDetails;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
@@ -51,6 +52,7 @@ import org.onap.vid.mso.RestMsoImplementation;
import org.onap.vid.mso.RestObject;
import org.onap.vid.utils.Logging;
import org.onap.vid.utils.SystemPropertiesWrapper;
+import org.springframework.http.HttpMethod;
/**
@@ -216,11 +218,11 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
}
@Override
- public MsoResponseWrapper getOrchestrationRequest(String t, String sourceId, String endpoint, RestObject restObject, boolean warpException) {
+ public HttpResponseWithRequestInfo<String> getOrchestrationRequest(String endpoint, boolean warpException) {
String path = baseUrl + endpoint;
HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
- return MsoUtil.wrapResponse(response);
+ return new HttpResponseWithRequestInfo<>(response, path, HttpMethod.GET);
}
@Override
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java
index 90e3a21e3..cfde4c954 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,8 @@ package org.onap.vid.mso.rest;
import java.util.List;
public class TaskList {
+
+ private List<Task> taskList;
public List<Task> getTaskList() {
return taskList;
@@ -32,5 +35,4 @@ public class TaskList {
this.taskList = taskList;
}
- private List<Task> taskList;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
index 78b3e9709..001a8ae6d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
@@ -21,6 +21,7 @@
package org.onap.vid.scheduler;
import com.att.eelf.configuration.EELFLogger;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import io.joshworks.restclient.http.HttpResponse;
@@ -43,6 +44,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
@Service
@@ -90,15 +92,20 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
.putAll(commonHeaders)
.put(REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId())
.build();
- final HttpResponse<T> response = ((HttpResponse<T>) syncRestClient.get(url, requestHeaders,
- Collections.emptyMap(), t.getClass()));
+ final HttpResponse<String> response = syncRestClient.get(url, requestHeaders,
+ Collections.emptyMap(), String.class);
Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, response);
status = response.getStatus();
restObject.setStatusCode(status);
-
+ rawData = response.getBody();
+ restObject.setRaw(rawData);
if (status == 200) {
- t = response.getBody();
- restObject.set(t);
+ if (t instanceof String) {
+ restObject.set((T)rawData);
+ }
+ else {
+ restObject.set(JACKSON_OBJECT_MAPPER.readValue(rawData, (Class<T>)t.getClass()));
+ }
logger.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + SUCCESSFUL_API_MESSAGE);
logger.info(EELFLoggerDelegate.errorLogger, "<== " + methodName + SUCCESSFUL_API_MESSAGE);
} else {
@@ -106,7 +113,7 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
}
return new RestObjectWithRequestInfo<>(HttpMethod.GET, url, restObject, status, rawData);
}
- catch (RuntimeException e) {
+ catch (Exception e) {
throw new ExceptionWithRequestInfo(HttpMethod.GET, url, rawData, status, e);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
index 9d6f74def..a5988a156 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
@@ -20,12 +20,22 @@
*/
package org.onap.vid.services;
+import static org.onap.vid.model.probes.ExternalComponentStatus.Component.SDC;
+import static org.onap.vid.properties.Features.FLAG_SERVICE_MODEL_CACHE;
+
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import io.joshworks.restclient.http.HttpResponse;
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.vid.aai.ExceptionWithRequestInfo;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.asdc.AsdcClient;
import org.onap.vid.asdc.beans.Service;
@@ -34,20 +44,16 @@ import org.onap.vid.asdc.parser.ToscaParserImpl;
import org.onap.vid.asdc.parser.ToscaParserImpl2;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.probes.ErrorMetadata;
import org.onap.vid.model.probes.ExternalComponentStatus;
import org.onap.vid.model.probes.HttpRequestMetadata;
+import org.onap.vid.model.probes.StatusMetadata;
+import org.onap.vid.properties.VidProperties;
import org.onap.vid.utils.Logging;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.togglz.core.manager.FeatureManager;
-import java.nio.file.Path;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-
-import static org.onap.vid.properties.Features.FLAG_SERVICE_MODEL_CACHE;
-
/**
* The Class VidController.
*/
@@ -150,6 +156,20 @@ public class VidServiceImpl implements VidService {
@Override
public ExternalComponentStatus probeComponent() {
+ UUID modelUUID;
+ try {
+ modelUUID = UUID.fromString(VidProperties.getPropertyWithDefault(
+ VidProperties.PROBE_SDC_MODEL_UUID,""));
+ }
+ //in case of no such PROBE_SDC_MODEL_UUID property or non uuid there we check only sdc connectivity
+ catch (Exception e) {
+ return probeComponentBySdcConnectivity();
+ }
+
+ return probeSdcByGettingModel(modelUUID);
+ }
+
+ public ExternalComponentStatus probeComponentBySdcConnectivity() {
long startTime = System.currentTimeMillis();
ExternalComponentStatus externalComponentStatus;
try {
@@ -158,10 +178,49 @@ public class VidServiceImpl implements VidService {
System.currentTimeMillis() - startTime);
externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.SDC, stringHttpResponse.isSuccessful(), httpRequestMetadata);
} catch (Exception e) {
- HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(HttpMethod.GET, 0,
- AsdcClient.URIS.HEALTH_CHECK_ENDPOINT, "", Logging.exceptionToDescription(e), System.currentTimeMillis() - startTime);
- externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.SDC, false, httpRequestMetadata);
+ ErrorMetadata errorMetadata = new ErrorMetadata(Logging.exceptionToDescription(e), System.currentTimeMillis() - startTime);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.SDC, false, errorMetadata);
}
return externalComponentStatus;
}
+
+ protected ExternalComponentStatus probeSdcByGettingModel(UUID modelUUID) {
+ final long startTime = System.currentTimeMillis();
+
+ HttpResponseWithRequestInfo<InputStream> response = null;
+ try {
+ response = asdcClient.getServiceInputStream(modelUUID, true);
+ int responseStatusCode = response.getResponse().getStatus();
+
+ if (responseStatusCode == 404) {
+ return errorStatus(response, startTime, "model " + modelUUID + " not found in SDC" +
+ " (consider updating vid probe configuration '" + VidProperties.PROBE_SDC_MODEL_UUID + "')");
+ } else if (responseStatusCode >= 400) {
+ return errorStatus(response, startTime, "error while retrieving model " + modelUUID + " from SDC");
+ } else {
+ InputStream inputStreamEntity = response.getResponse().getRawBody();//validate we can read the input steam from the response
+ if (inputStreamEntity.read() <= 0) {
+ return errorStatus(response, startTime, "error reading model " + modelUUID + " from SDC");
+ } else {
+ // RESPONSE IS SUCCESS
+ return new ExternalComponentStatus(SDC, true,
+ new HttpRequestMetadata(response, "OK", startTime, false));
+ }
+ }
+ } catch (ExceptionWithRequestInfo e) {
+ return new ExternalComponentStatus(SDC, false,
+ new HttpRequestMetadata(e, System.currentTimeMillis() - startTime));
+ } catch (Exception e) {
+ return errorStatus(response, startTime, Logging.exceptionToDescription(e));
+ }
+ }
+
+ private ExternalComponentStatus errorStatus(HttpResponseWithRequestInfo<InputStream> response, long startTime, String description) {
+ final long duration = System.currentTimeMillis() - startTime;
+ StatusMetadata statusMetadata = (response == null) ?
+ new ErrorMetadata(description, duration) :
+ new HttpRequestMetadata(response, description, duration, true);
+
+ return new ExternalComponentStatus(SDC, false, statusMetadata);
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
index df7f20e49..71478fcf1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
@@ -119,7 +119,7 @@ public class Logging {
response.bufferEntity();
logger.debug("Received {} {} Status: {} . Body: {}", method.name(), url, response.getStatus(), response.readEntity(entityClass));
}
- catch (ProcessingException | IllegalStateException e) {
+ catch (Exception e) {
logger.debug("Received {} {} Status: {} . Failed to read response as {}", method.name(), url, response.getStatus(), entityClass.getName());
}
}
@@ -128,7 +128,7 @@ public class Logging {
try {
logger.debug("Received {} {} Status: {} . Body: {}", method.name(), url, response.getStatus(), response.getBody());
}
- catch (ProcessingException | IllegalStateException e) {
+ catch (Exception e) {
logger.debug("Received {} {} Status: {} . Failed to read response", method.name(), url, response.getStatus());
}
}
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
index e66b8ff6c..bf3d54af0 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
@@ -55,7 +55,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
componentId: COMPONENT.VNF,
callbackFunction: callbackFunction
});
- }
+ };
$scope.popup = new Object();
@@ -85,18 +85,18 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
$scope.getServiceTypes = function (globalCustomerId) {
DataService.setGlobalCustomerId(globalCustomerId);
- DataService.setServiceIdList($scope.customerList)
+ DataService.setServiceIdList($scope.customerList);
if (globalCustomerId !== "" && globalCustomerId !== undefined) {
window.location.href = COMPONENT.SERVICE_TYPE_LIST_PATH + $scope.serviceTypeList;
}
- }
+ };
$scope.refreshServiceTypes = function (globalCustomerId) {
DataService.setGlobalCustomerId(globalCustomerId);
$scope.getServiceTypesList();
- }
+ };
$scope.subId = "";
$scope.createSubscriberName = "";
@@ -138,7 +138,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
$scope.subList = [];
$scope.getAaiServiceModels = function (selectedServicetype, subName) {
DataService.setGlobalCustomerId(selectedServicetype);
- DataService.setServiceIdList($scope.serviceTypeList)
+ DataService.setServiceIdList($scope.serviceTypeList);
DataService.setSubscriberName(subName);
DataService.setSubscribers($scope.custSubList);
@@ -347,12 +347,12 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
callbackFunction: function (response) {
}
});
- }
+ };
$scope.cancelCreateSIType = function () {
window.location.href = COMPONENT.SERVICE_MODLES_INSTANCES_SUBSCRIBERS_PATH;
- }
+ };
$scope.fetchServices = function () {
var serviceIdList = [];
@@ -395,12 +395,12 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
$scope.errorMsg = FIELD.ERROR.AAI_FETCHING_CUST_DATA + response.status;
$scope.errorDetails = response.data;
});
- }
+ };
$scope.getPermitted = function (item) {
return item.isPermitted || item[FIELD.ID.IS_PERMITTED];
- }
+ };
$scope.getSubDetails = function () {
@@ -482,7 +482,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
$scope.enableCloseButton(false);
$scope.resetProgress();
$scope.setProgress(2); // Show "a little" progress
- }
+ };
function getRelatedInstanceGroupsByVnfId(genericVnf) {
var model = vidService.getModel();
@@ -503,7 +503,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
)
}
}
- })
+ });
}
}
@@ -516,7 +516,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
return resolveIfIsPermitted()
.then(function() {
return getAsdcModelByVersionId(modelVersionId);
- })
+ });
}
}
@@ -689,7 +689,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
// the response is erroneous
console.log("aaiSubscriber getAsdcModel BAD RESPONSE");
errorCallback(response);
- return $q.reject()
+ return $q.reject();
}
}, errorCallback);
@@ -706,9 +706,9 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
if (item[FIELD.ID.SERVICE_INSTANCES] != null) {
item[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE].forEach(function (service) {
if (service[FIELD.ID.SERVICE_INSTANCE_ID] === serviceId) {
- orchStatus = service['orchestration-status']
+ orchStatus = service['orchestration-status'];
}
- })
+ });
}
});
return orchStatus;
@@ -722,7 +722,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
}, function (response) {
//TODO
});
- }
+ };
$scope.isConfigurationDataAvailiable = function (configuration) {
$log.debug(configuration);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js
index a7f7e9128..b6725b124 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js
@@ -30,7 +30,7 @@ var vfModuleActionModalController = function(COMPONENT, FIELD, $scope, $uibModal
$scope.vfModuleName = vfModule.name;
$scope.volumeGroups = vfModule.volumeGroups;
$scope.lcpAndTenant = null;
- $scope.regionSelection = {lcpRegion: null, legacyRegion: null, tenant: null};
+ $scope.regionSelection = {optionId: null, legacyRegion: null, tenant: null};
$scope.lcpRegionList = null;
$scope.isHomingData = false;
$scope.megaRegion = ['AAIAIC25'];
@@ -60,12 +60,12 @@ var vfModuleActionModalController = function(COMPONENT, FIELD, $scope, $uibModal
.then(function (res) {
if (res && res.data) {
$scope.regionSelection = {
- lcpRegion: (res.data[COMPONENT.CLOUD_REGION_ID]) ? res.data[COMPONENT.CLOUD_REGION_ID] : null,
+ optionId: (res.data[COMPONENT.CLOUD_REGION_ID]) ? res.data[COMPONENT.CLOUD_REGION_ID] : null,
legacyRegion: null,
tenant: (res.data[COMPONENT.TENANT_ID]) ? res.data[COMPONENT.TENANT_ID] : null
};
- $scope.isHomingData = $scope.regionSelection.lcpRegion !== null && res.data.tenant !== null;
- $scope.isHomingData = $scope.isHomingData && (($scope.megaRegion).indexOf($scope.regionSelection.lcpRegion) === -1);
+ $scope.isHomingData = $scope.regionSelection.optionId !== null && res.data.tenant !== null;
+ $scope.isHomingData = $scope.isHomingData && !$scope.selectedLcpRegionIsMegaRegion();
}
if (!$scope.isHomingData) {
@@ -75,11 +75,11 @@ var vfModuleActionModalController = function(COMPONENT, FIELD, $scope, $uibModal
.catch(function (error) {
getLcpCloudRegionTenantList();
});
- };
+ }
function getLcpRegionId() {
if(_.isEmpty($scope.regionSelection.legacyRegion)) {
- return $scope.regionSelection.lcpRegion
+ return DataService.getCloudOwnerAndLcpCloudRegionFromOptionId($scope.regionSelection.optionId).cloudRegionId;
}
return $scope.regionSelection.legacyRegion;
}
@@ -144,6 +144,12 @@ var vfModuleActionModalController = function(COMPONENT, FIELD, $scope, $uibModal
return AaiService.removeVendorFromCloudOwner(cloudOwner)
};
+ $scope.selectedLcpRegionIsMegaRegion = function() {
+ let cloudRegionId =
+ DataService.getCloudOwnerAndLcpCloudRegionFromOptionId($scope.regionSelection.optionId).cloudRegionId;
+ return ($scope.megaRegion).indexOf(cloudRegionId) > -1
+ };
+
$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html
index 3fbe07e83..944352403 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html
@@ -55,7 +55,7 @@
<div class="lcp-region field">
<label>LCP Region</label>
<select name="lcp-region" required class="form-item wide"
- data-tests-id="lcpRegion" data-ng-model="regionSelection.lcpRegion"
+ data-tests-id="lcpRegion" data-ng-model="regionSelection.optionId"
data-ng-change="regionSelection.tenant = null; regionSelection.legacyRegion = null;">
<option class="lcp-region-placeholder" value="" selected>Select LCP Region</option>
<option ng-repeat="option in lcpRegionList" value="{{option.cloudRegionOptionId}}"
@@ -69,7 +69,7 @@
</select>
</div>
- <div class="legacy-region field" data-ng-if="(megaRegion).indexOf(regionSelection.lcpRegion) > -1">
+ <div class="legacy-region field" data-ng-if="selectedLcpRegionIsMegaRegion()">
<label>Legacy Region</label>
<input type="text" data-tests-id="lcpRegionText" required data-ng-model="regionSelection.legacyRegion"
placeholder="Enter legacy region">
@@ -81,7 +81,7 @@
data-tests-id="tenant" data-ng-model="regionSelection.tenant">
<option class="tenant-placeholder" value="" selected>Select Tenant Name</option>
<option ng-repeat="option in lcpAndTenant" class="tenantOption" value="{{option.tenantId}}"
- data-ng-if="option.isPermitted && option.cloudRegionOptionId === regionSelection.lcpRegion">{{option.tenantName}}
+ data-ng-if="option.isPermitted && option.cloudRegionOptionId === regionSelection.optionId">{{option.tenantName}}
</option>
</select>
</div>