From 9dfd7e28c1eb348fcb4a2de8c6faae2a01b34942 Mon Sep 17 00:00:00 2001 From: Ofir Sonsino Date: Wed, 20 Sep 2017 13:20:42 +0300 Subject: Global Read only role, Support VID specific Roles Issue-ID: VID-46 , VID-47 Change-Id: Ib100d20ac40a65d39e27a6e2741b19a173a2b8ea Signed-off-by: Ofir Sonsino --- .../org/ecomp/aai/model/AaiAICZones/AicZones.java | 10 + .../java/org/ecomp/aai/model/AaiAICZones/Zone.java | 13 + .../org/openecomp/aai/util/HttpsAuthClient.java | 2 +- .../main/java/org/openecomp/vid/aai/AaiClient.java | 284 ++++ .../org/openecomp/vid/aai/AaiClientInterface.java | 22 + .../java/org/openecomp/vid/aai/AaiResponse.java | 21 + .../org/openecomp/vid/aai/ServiceInstance.java | 33 + .../org/openecomp/vid/aai/ServiceInstances.java | 14 + .../org/openecomp/vid/aai/ServiceSubscription.java | 20 + .../openecomp/vid/aai/ServiceSubscriptions.java | 17 + .../main/java/org/openecomp/vid/aai/Services.java | 24 + .../openecomp/vid/aai/SubscriberAaiResponse.java | 24 + .../java/org/openecomp/vid/aai/SubscriberData.java | 7 + .../vid/aai/SubscriberFilteredResults.java | 29 + .../vid/aai/SubscriberListWithFilterData.java | 31 + .../openecomp/vid/aai/SubscriberWithFilter.java | 21 + .../exceptions/InvalidAAIResponseException.java | 7 + .../GetServicesAAIRespone.java | 11 + .../model/AaiGetServicesRequestModel/Service.java | 21 + .../model/AaiGetTenatns/GetTenantsResponse.java | 26 + .../openecomp/vid/aai/model/ServiceInstance.java | 26 + .../openecomp/vid/aai/model/ServiceInstances.java | 12 + .../vid/aai/model/ServiceSubscription.java | 17 + .../java/org/openecomp/vid/aai/model/Services.java | 24 + .../openecomp/vid/asdc/beans/SecureService.java | 9 + .../openecomp/vid/asdc/beans/SecureServices.java | 30 + .../vid/asdc/beans/tosca/ToscaMetadata.java | 30 + .../openecomp/vid/asdc/local/LocalAsdcClient.java | 2 +- .../vid/asdc/parser/ToscaParserImpl2.java | 60 +- .../openecomp/vid/asdc/rest/RestfulAsdcClient.java | 2 + .../org/openecomp/vid/client/FakeHttpSession.java | 224 +++ .../org/openecomp/vid/client/HttpsBasicClient.java | 4 +- .../openecomp/vid/controller/AaiController.java | 924 ++++++------ .../openecomp/vid/controller/MsoController.java | 1373 ++++++++--------- .../openecomp/vid/controller/VidController.java | 20 +- .../org/openecomp/vid/controller/WebConfig.java | 18 +- .../java/org/openecomp/vid/model/ModelUtil.java | 45 + .../org/openecomp/vid/model/ProxyResponse.java | 21 + .../main/java/org/openecomp/vid/model/Service.java | 23 + .../java/org/openecomp/vid/model/Subscriber.java | 26 + .../org/openecomp/vid/model/SubscriberList.java | 15 + .../java/org/openecomp/vid/roles/EcompRole.java | 5 + .../main/java/org/openecomp/vid/roles/Role.java | 48 + .../java/org/openecomp/vid/roles/RoleProvider.java | 62 + .../org/openecomp/vid/roles/RoleValidator.java | 57 + .../org/openecomp/vid/services/AaiService.java | 25 + .../org/openecomp/vid/services/AaiServiceImpl.java | 70 + .../org/openecomp/vid/services/VidServiceImpl.java | 4 +- .../src/main/resources/csar3933948645405128424.zip | Bin 0 -> 104292 bytes vid-app-common/src/main/resources/pnf.csar | Bin 0 -> 33299 bytes vid-app-common/src/main/resources/roles.json | 8 + vid-app-common/src/main/resources/sdcservices.json | 29 +- .../vid/scripts/constants/componentConstants.js | 18 +- .../app/vid/scripts/constants/fieldConstants.js | 615 ++++---- .../app/vid/scripts/constants/vidConfiguration.js | 5 +- .../scripts/controller/InstantiationController.js | 18 +- .../scripts/controller/ServiceModelController.js | 100 +- .../scripts/controller/aaiSubscriberController.js | 1561 +++++++++++--------- .../scripts/controller/creationDialogController.js | 14 +- .../scripts/controller/deletionDialogController.js | 4 + .../scripts/controller/previousVersionContoller.js | 40 + .../controller/previousVersionDialogController.js | 40 + .../scripts/controller/statusDialogController.js | 2 +- .../app/vid/scripts/controller/subscriberSearch.js | 2 +- .../scripts/directives/parameterBlockDirective.js | 654 ++++---- .../directives/parameterBlockDirective.js.orig | 507 +++++++ .../webapp/app/vid/scripts/services/aaiService.js | 674 +++++---- .../app/vid/scripts/services/componentService.js | 4 +- .../app/vid/scripts/services/creationService.js | 154 +- .../webapp/app/vid/scripts/services/dataService.js | 15 + .../app/vid/scripts/services/deletionService.js | 22 +- .../webapp/app/vid/scripts/services/vnfService.js | 39 +- .../app/vid/scripts/view-models/aaiGetSubs.htm | 133 +- .../scripts/view-models/aaiGetSubscriberList.htm | 6 +- .../vid/scripts/view-models/aaiServiceTypes.htm | 8 +- .../app/vid/scripts/view-models/aaiSubDetails.htm | 7 +- .../app/vid/scripts/view-models/aaiSubViewEdit.htm | 250 ++-- .../view-models/createInstanceServiceModels.htm | 20 +- .../app/vid/scripts/view-models/creationDialog.htm | 2 +- .../app/vid/scripts/view-models/instantiate.htm | 386 ++--- .../app/vid/scripts/view-models/msoCommit.htm | 2 +- .../vid/scripts/view-models/previousVersion.htm | 44 + .../scripts/view-models/previousVersionDialog.htm | 48 + .../app/vid/scripts/view-models/serviceModels.htm | 10 +- .../src/main/webapp/app/vid/test/testMso.js | 2 +- .../src/main/webapp/app/vid/test/testViewEdit.js | 2 +- 86 files changed, 5978 insertions(+), 3280 deletions(-) create mode 100644 vid-app-common/src/main/java/org/ecomp/aai/model/AaiAICZones/AicZones.java create mode 100644 vid-app-common/src/main/java/org/ecomp/aai/model/AaiAICZones/Zone.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/AaiClient.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/AaiClientInterface.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/AaiResponse.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceInstance.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceInstances.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceSubscription.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceSubscriptions.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/Services.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberAaiResponse.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberData.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberFilteredResults.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberListWithFilterData.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberWithFilter.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/exceptions/InvalidAAIResponseException.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetServicesRequestModel/Service.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceInstance.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceInstances.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceSubscription.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/aai/model/Services.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SecureService.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SecureServices.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/client/FakeHttpSession.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/model/ProxyResponse.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/model/Subscriber.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/model/SubscriberList.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/roles/EcompRole.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/roles/Role.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/roles/RoleProvider.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/roles/RoleValidator.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/services/AaiService.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java create mode 100644 vid-app-common/src/main/resources/csar3933948645405128424.zip create mode 100644 vid-app-common/src/main/resources/pnf.csar create mode 100644 vid-app-common/src/main/resources/roles.json create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/controller/previousVersionContoller.js create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/controller/previousVersionDialogController.js create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js.orig create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/view-models/previousVersion.htm create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/view-models/previousVersionDialog.htm (limited to 'vid-app-common/src/main') diff --git a/vid-app-common/src/main/java/org/ecomp/aai/model/AaiAICZones/AicZones.java b/vid-app-common/src/main/java/org/ecomp/aai/model/AaiAICZones/AicZones.java new file mode 100644 index 00000000..ee8bcf0c --- /dev/null +++ b/vid-app-common/src/main/java/org/ecomp/aai/model/AaiAICZones/AicZones.java @@ -0,0 +1,10 @@ +package org.ecomp.aai.model.AaiAICZones; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class AicZones { + @JsonProperty("zone") + public List zones; +} diff --git a/vid-app-common/src/main/java/org/ecomp/aai/model/AaiAICZones/Zone.java b/vid-app-common/src/main/java/org/ecomp/aai/model/AaiAICZones/Zone.java new file mode 100644 index 00000000..00d387c2 --- /dev/null +++ b/vid-app-common/src/main/java/org/ecomp/aai/model/AaiAICZones/Zone.java @@ -0,0 +1,13 @@ +package org.ecomp.aai.model.AaiAICZones; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class Zone { + @JsonProperty("zone-id") + public String zoneId; + + @JsonProperty("zone-name") + public String zoneName; +} diff --git a/vid-app-common/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java b/vid-app-common/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java index 6a3665ed..3323b3fb 100755 --- a/vid-app-common/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java +++ b/vid-app-common/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java @@ -80,7 +80,7 @@ public class HttpsAuthClient{ useClientCert = true; } - System.setProperty("javax.net.ssl.trustStore", truststore_path); + System.setProperty("javax.net.ssl.trustStore", truststore_path); System.setProperty("javax.net.ssl.trustStorePassword", decrypted_truststore_password); HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){ public boolean verify(String string,SSLSession ssls) { diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/AaiClient.java new file mode 100644 index 00000000..af1f4042 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/AaiClient.java @@ -0,0 +1,284 @@ +package org.openecomp.vid.aai; + +import org.apache.http.HttpStatus; +import org.codehaus.jackson.map.ObjectMapper; +import org.ecomp.aai.model.AaiAICZones.AicZones; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.openecomp.aai.util.AAIRestInterface; +import org.apache.tiles.request.ApplicationContext; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.web.support.UserUtils; +import org.openecomp.vid.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone; +import org.openecomp.vid.aai.model.AaiGetTenatns.GetTenantsResponse; +import org.openecomp.vid.model.SubscriberList; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.servlet.ServletContext; +import javax.ws.rs.BadRequestException; +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.Date; +import java.util.Iterator; +import java.util.UUID; + + +/** + * Created by Oren on 7/4/17. + */ +public class AaiClient implements AaiClientInterface { + + /** + * The Constant dateFormat. + */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + protected String fromAppId = "VidAaiController"; + @Autowired + ServletContext servletContext; + /** + * The logger + */ + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AaiClient.class); + + + public AaiClient() { + // certiPath = getCertificatesFile().getAbsolutePath(); + // depth = "0"; + } + + public AaiClient(ServletContext context) { + servletContext = context; + } + + + + private static String checkForNull(String local) { + if (local != null) + return local; + else + return ""; + + } + + @Override + public AaiResponse getAllSubscribers() { + String certiPath = getCertificatesFile().getAbsolutePath(); + String depth = "0"; + Response resp = doAaiGet(certiPath, "business/customers?subscriber-type=INFRA&depth=" + depth, false); + UserUtils userUtils = new UserUtils(); + return proccessAaiResponse(resp, SubscriberList.class,null); + } + + + @Override + public AaiResponse getAllAicZones() { + String certiPath = getCertificatesFile().getAbsolutePath(); + Response resp = doAaiGet(certiPath, "network/zones" , false); + AaiResponse aaiAicZones = proccessAaiResponse(resp, AicZones.class,null); + return aaiAicZones; + } + + @Override + public AaiResponse getSubscriberData(String subscriberId) { + + File certiPath = getCertificatesFile(); + String depth = "2"; + AaiResponse subscriberDataResponse; + Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + subscriberId + "?depth=" + depth, false); + subscriberDataResponse = proccessAaiResponse(resp, Services.class,null); + return subscriberDataResponse; + } + + @Override + public AaiResponse getServices() { + File certiPath = getCertificatesFile(); + Response resp = doAaiGet(certiPath.getAbsolutePath(), "service-design-and-creation/services", false); + AaiResponse getServicesResponse = proccessAaiResponse(resp, GetServicesAAIRespone.class,null); + + return getServicesResponse; + } + + @Override + public AaiResponse getTenants(String globalCustomerId, String serviceType) { + File certiPath = getCertificatesFile(); + String url = "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + serviceType; + + Response resp = doAaiGet(certiPath.getAbsolutePath(), url, false); + String responseAsString = parseForTenantsByServiceSubscription(resp.readEntity(String.class)); + + AaiResponse getTenantsResponse = proccessAaiResponse(resp, GetTenantsResponse[].class,responseAsString); + return getTenantsResponse; + } + + private AaiResponse proccessAaiResponse(Response resp, Class classType,String responseBody) { + AaiResponse subscriberDataResponse; + if (resp == null) { + subscriberDataResponse = new AaiResponse<>(null, null, HttpStatus.SC_INTERNAL_SERVER_ERROR); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI"); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscribers() resp=" + resp.getStatusInfo().toString()); + if (resp.getStatus() != HttpStatus.SC_OK) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI"); + subscriberDataResponse = new AaiResponse<>(null, resp.readEntity(String.class), resp.getStatus()); + } else { + String finalResponse; + try { + if (responseBody != null){ + finalResponse = responseBody; + } + else{ + finalResponse = resp.readEntity(String.class);; + } + + subscriberDataResponse = new AaiResponse<>((new ObjectMapper().readValue(finalResponse, classType)), null, HttpStatus.SC_OK); + + } catch (IOException e) { + subscriberDataResponse = new AaiResponse<>(null, null, HttpStatus.SC_INTERNAL_SERVER_ERROR); + } + + } + } + return subscriberDataResponse; + } + + private File getCertificatesFile() { + if (servletContext != null) + return new File(servletContext.getRealPath("/WEB-INF/cert/")); + return null; + } + + @SuppressWarnings("all") + 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; + } + + private String parseForTenantsByServiceSubscription(String resp) { + String tenantList = ""; + + try { + JSONParser jsonParser = new JSONParser(); + + JSONObject jsonObject = (JSONObject) jsonParser.parse(resp); + + return parseServiceSubscriptionObjectForTenants(jsonObject); + } catch (Exception ex) { + + } + + return tenantList; + } + + + + public static String parseServiceSubscriptionObjectForTenants(JSONObject jsonObject) { + + JSONArray tenantArray = new JSONArray(); + boolean bconvert = false; + + try { + JSONObject relationShipListsObj = (JSONObject) jsonObject.get("relationship-list"); + if (relationShipListsObj != null) { + JSONArray rShipArray = (JSONArray) relationShipListsObj.get("relationship"); + if (rShipArray != null) { + Iterator i1 = rShipArray.iterator(); + + while (i1.hasNext()) { + + JSONObject inner1Obj = (JSONObject) i1.next(); + + if (inner1Obj == null) + continue; + + String relatedTo = checkForNull((String) inner1Obj.get("related-to")); + if (relatedTo.equalsIgnoreCase("tenant")) { + JSONObject tenantNewObj = new JSONObject(); + + String relatedLink = checkForNull((String) inner1Obj.get("related-link")); + tenantNewObj.put("link", relatedLink); + + JSONArray rDataArray = (JSONArray) inner1Obj.get("relationship-data"); + if (rDataArray != null) { + Iterator i2 = rDataArray.iterator(); + + while (i2.hasNext()) { + JSONObject inner2Obj = (JSONObject) i2.next(); + + if (inner2Obj == null) + continue; + + String rShipKey = checkForNull((String) inner2Obj.get("relationship-key")); + String rShipVal = checkForNull((String) inner2Obj.get("relationship-value")); + if (rShipKey.equalsIgnoreCase("cloud-region.cloud-owner")) { + tenantNewObj.put("cloudOwner", rShipVal); + } else if (rShipKey.equalsIgnoreCase("cloud-region.cloud-region-id")) { + tenantNewObj.put("cloudRegionID", rShipVal); + } + + if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) { + tenantNewObj.put("tenantID", rShipVal); + } + } + } + + JSONArray relatedTPropArray = (JSONArray) inner1Obj.get("related-to-property"); + if (relatedTPropArray != null) { + Iterator i3 = relatedTPropArray.iterator(); + + while (i3.hasNext()) { + JSONObject inner3Obj = (JSONObject) i3.next(); + + if (inner3Obj == null) + continue; + + String propKey = checkForNull((String) inner3Obj.get("property-key")); + String propVal = checkForNull((String) inner3Obj.get("property-value")); + if (propKey.equalsIgnoreCase("tenant.tenant-name")) { + tenantNewObj.put("tenantName", propVal); + } + } + } + bconvert = true; + tenantArray.add(tenantNewObj); + } + } + + } + } + } catch (NullPointerException ex) { + + + } + + if (bconvert) + return tenantArray.toJSONString(); + else + return ""; + + } + +} \ No newline at end of file diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/AaiClientInterface.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/AaiClientInterface.java new file mode 100644 index 00000000..fdaf602f --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/AaiClientInterface.java @@ -0,0 +1,22 @@ +package org.openecomp.vid.aai; + +import org.openecomp.vid.aai.model.AaiGetTenatns.GetTenantsResponse; +import org.openecomp.vid.model.SubscriberList; + +import java.util.List; + +/** + * Created by Oren on 7/4/17. + */ +public interface AaiClientInterface { + + AaiResponse getAllSubscribers(); + + AaiResponse getSubscriberData(String subscriberId); + + AaiResponse getServices(); + + AaiResponse getTenants(String globalCustomerId, String serviceType); + + AaiResponse getAllAicZones(); +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/AaiResponse.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/AaiResponse.java new file mode 100644 index 00000000..337d1371 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/AaiResponse.java @@ -0,0 +1,21 @@ +package org.openecomp.vid.aai; + +import org.openecomp.vid.model.ProxyResponse; + +/** + * Created by Oren on 7/10/17. + */ +public class AaiResponse extends ProxyResponse{ + + T t; + + public AaiResponse(T t, String errorMessage, int aaiHttpCode) { + this.t = t; + this.errorMessage = errorMessage; + this.httpCode = aaiHttpCode; + } + + public T getT() { + return t; + } +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceInstance.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceInstance.java new file mode 100644 index 00000000..45f7947e --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceInstance.java @@ -0,0 +1,33 @@ +package org.openecomp.vid.aai; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ServiceInstance { + + @JsonProperty("service-instance-id") + public String serviceInstanceId; + + @JsonProperty("service-instance-name") + public String serviceInstanceName; + + @JsonProperty("persona-model-id") + public String personaModelId; + + @JsonProperty("persona-model-version") + public String personaModelVersion; + + @JsonProperty("resource-version") + public String resourceVersion; + + @JsonProperty("orchestration-status") + public String orchestrationStatus; + + @JsonProperty("model-invariant-id") + public String modelInvariantId; + + @JsonProperty("model-version-id") + public String modelVersionId; + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceInstances.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceInstances.java new file mode 100644 index 00000000..063317e4 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceInstances.java @@ -0,0 +1,14 @@ +package org.openecomp.vid.aai; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ServiceInstances { + + @JsonProperty("service-instance") + public List serviceInstance; + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceSubscription.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceSubscription.java new file mode 100644 index 00000000..6a178d97 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceSubscription.java @@ -0,0 +1,20 @@ +package org.openecomp.vid.aai; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ServiceSubscription { + + @JsonProperty("service-type") + public String serviceType; + + @JsonProperty("resource-version") + public String resourceVersion; + + @JsonProperty("service-instances") + public ServiceInstances serviceInstances; + + @JsonProperty("is-permitted") + public boolean isPermitted =false; +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceSubscriptions.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceSubscriptions.java new file mode 100644 index 00000000..eaadba2c --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/ServiceSubscriptions.java @@ -0,0 +1,17 @@ +package org.openecomp.vid.aai; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + +import java.util.List; + +/** + * Created by Oren on 7/9/17. + */ +@JsonIgnoreProperties(ignoreUnknown = true) + +public class ServiceSubscriptions { + + @JsonProperty("service-subscription") + public List serviceSubscription; +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/Services.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/Services.java new file mode 100644 index 00000000..e8148a92 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/Services.java @@ -0,0 +1,24 @@ +package org.openecomp.vid.aai; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class Services { + @JsonProperty("global-customer-id") + public String globalCustomerId; + + @JsonProperty("subscriber-name") + public String subscriberName; + + @JsonProperty("subscriber-type") + public String subscriberType; + + @JsonProperty("resource-version") + public String resourceVersion; + + @JsonProperty("service-subscriptions") + public ServiceSubscriptions serviceSubscriptions; + + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberAaiResponse.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberAaiResponse.java new file mode 100644 index 00000000..53304e93 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberAaiResponse.java @@ -0,0 +1,24 @@ +package org.openecomp.vid.aai; + +import org.openecomp.vid.model.ProxyResponse; +import org.openecomp.vid.model.SubscriberList; + +/** + * Created by Oren on 7/5/17. + */ +public class SubscriberAaiResponse extends ProxyResponse { + + + private SubscriberList subscriberList; + + public SubscriberAaiResponse(SubscriberList subscriberList, String errorMessage, int aaiHttpCode) { + this.subscriberList = subscriberList; + this.errorMessage = errorMessage; + this.httpCode = aaiHttpCode; + } + + + public SubscriberList getSubscriberList() { + return subscriberList; + } +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberData.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberData.java new file mode 100644 index 00000000..efaa4788 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberData.java @@ -0,0 +1,7 @@ +package org.openecomp.vid.aai; + +/** + * Created by Oren on 7/10/17. + */ +public class SubscriberData { +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberFilteredResults.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberFilteredResults.java new file mode 100644 index 00000000..c2afee33 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberFilteredResults.java @@ -0,0 +1,29 @@ +package org.openecomp.vid.aai; + +import org.openecomp.vid.model.ProxyResponse; +import org.openecomp.vid.model.SubscriberList; +import org.openecomp.vid.roles.RoleValidator; + +/** + * Created by Oren on 7/5/17. + */ + +public class SubscriberFilteredResults extends ProxyResponse { + + private SubscriberListWithFilterData subscriberList; + + public SubscriberFilteredResults(RoleValidator roleValidator,SubscriberList subscribers, String errorMessage, int aaiHttpCode) { + this.subscriberList = new SubscriberListWithFilterData(subscribers,roleValidator); + this.errorMessage = errorMessage; + this.httpCode = aaiHttpCode; + } + + + public SubscriberListWithFilterData getSubscriberList() { + return subscriberList; + } + + public void setSubscriberList(SubscriberListWithFilterData subscriberList) { + this.subscriberList = subscriberList; + } +} \ No newline at end of file diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberListWithFilterData.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberListWithFilterData.java new file mode 100644 index 00000000..75f505f2 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberListWithFilterData.java @@ -0,0 +1,31 @@ +package org.openecomp.vid.aai; + +import org.openecomp.vid.model.Subscriber; +import org.openecomp.vid.model.SubscriberList; +import org.openecomp.vid.roles.RoleValidator; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Oren on 7/5/17. + */ +public class SubscriberListWithFilterData { + + public SubscriberListWithFilterData(SubscriberList subscriberList, RoleValidator roleValidator){ + List subscribers = subscriberList.customer; + List subscribersWithFilter = new ArrayList<>(); + for (Subscriber subscriber :subscribers){ + SubscriberWithFilter subscriberWithFilter = new SubscriberWithFilter(); + subscriberWithFilter.setIsPermitted(roleValidator.isSubscriberPermitted(subscriber.globalCustomerId)); + subscriberWithFilter.subscriberType = subscriber.subscriberType; + subscriberWithFilter.resourceVersion = subscriber.resourceVersion; + subscriberWithFilter.subscriberName = subscriber.subscriberName; + subscriberWithFilter.globalCustomerId = subscriber.globalCustomerId; + subscribersWithFilter.add(subscriberWithFilter); + } + this.customer = subscribersWithFilter; + } + + public List customer; +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberWithFilter.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberWithFilter.java new file mode 100644 index 00000000..abd9c0f3 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/SubscriberWithFilter.java @@ -0,0 +1,21 @@ +package org.openecomp.vid.aai; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.openecomp.vid.model.Subscriber; + +/** + * Created by Oren on 7/5/17. + */ +public class SubscriberWithFilter extends Subscriber{ + + @JsonProperty("is-permitted") + private boolean isPermitted; + + public boolean getIsPermitted() { + return isPermitted; + } + + public void setIsPermitted(boolean isPermitted) { + this.isPermitted = isPermitted; + } +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/exceptions/InvalidAAIResponseException.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/exceptions/InvalidAAIResponseException.java new file mode 100644 index 00000000..f84c09af --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/exceptions/InvalidAAIResponseException.java @@ -0,0 +1,7 @@ +package org.openecomp.vid.aai.exceptions; + +/** + * Created by Oren on 7/4/17. + */ +public class InvalidAAIResponseException extends Exception { +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java new file mode 100644 index 00000000..27c38ce8 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java @@ -0,0 +1,11 @@ +package org.openecomp.vid.aai.model.AaiGetServicesRequestModel; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + +import java.util.List; +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetServicesAAIRespone { + + public List service; +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetServicesRequestModel/Service.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetServicesRequestModel/Service.java new file mode 100644 index 00000000..977e57e6 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetServicesRequestModel/Service.java @@ -0,0 +1,21 @@ +package org.openecomp.vid.aai.model.AaiGetServicesRequestModel; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Created by Oren on 7/17/17. + */ + +@JsonIgnoreProperties(ignoreUnknown = true) +public class Service { + @JsonProperty("service-id") + public String serviceId; + @JsonProperty("service-description") + public String serviceDescription; + @JsonProperty("resource-version") + public String resourceVersion; + @JsonProperty("is-permitted") + public boolean isPermitted; + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java new file mode 100644 index 00000000..5e88bf37 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java @@ -0,0 +1,26 @@ +package org.openecomp.vid.aai.model.AaiGetTenatns; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Created by Oren on 7/18/17. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetTenantsResponse { + + @JsonProperty("cloudRegionID") + public String cloudRegionId; + + @JsonProperty("tenantName") + public String tenantName; + + @JsonProperty("tenantID") + public String tenantID; + + @JsonProperty("is-permitted") + public boolean isPermitted; + + + +} \ No newline at end of file diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceInstance.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceInstance.java new file mode 100644 index 00000000..9fe4c06b --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceInstance.java @@ -0,0 +1,26 @@ +package org.openecomp.vid.aai.model; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ServiceInstance { + + @JsonProperty("service-instance-id") + public String serviceInstanceId; + + @JsonProperty("service-instance-name") + public String serviceInstanceName; + + @JsonProperty("persona-model-id") + public String personaModelId; + + @JsonProperty("persona-model-version") + public String personaModelVersion; + + @JsonProperty("resource-version") + public String resourceVersion; + + @JsonProperty("orchestration-status") + public String orchestrationStatus; + + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceInstances.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceInstances.java new file mode 100644 index 00000000..163ed045 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceInstances.java @@ -0,0 +1,12 @@ +package org.openecomp.vid.aai.model; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ServiceInstances { + + @JsonProperty("service-instance") + public List serviceInstance; + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceSubscription.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceSubscription.java new file mode 100644 index 00000000..02ddfd17 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/ServiceSubscription.java @@ -0,0 +1,17 @@ +package org.openecomp.vid.aai.model; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ServiceSubscription { + + @JsonProperty("service-type") + public String serviceType; + + @JsonProperty("resource-version") + public String resourceVersion; + + @JsonProperty("service-instances") + public ServiceInstances serviceInstances; + + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/aai/model/Services.java b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/Services.java new file mode 100644 index 00000000..6e7b8907 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/aai/model/Services.java @@ -0,0 +1,24 @@ +package org.openecomp.vid.aai.model; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class Services { + @JsonProperty("global-customer-id") + public String globalCustomerId; + + @JsonProperty("subscriber-name") + public String subscriberName; + + @JsonProperty("subscriber-type") + public String subscriberType; + + @JsonProperty("resource-version") + public String resourceVersion; + + @JsonProperty("service-subscriptions") + public List serviceSubscriptions; + + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SecureService.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SecureService.java new file mode 100644 index 00000000..1372472f --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SecureService.java @@ -0,0 +1,9 @@ +package org.openecomp.vid.asdc.beans; + +/** + * Created by Oren on 6/27/17. + */ +public class SecureService extends Service{ + + public boolean isPermmited = true; +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SecureServices.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SecureServices.java new file mode 100644 index 00000000..0d2c2fba --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SecureServices.java @@ -0,0 +1,30 @@ +package org.openecomp.vid.asdc.beans; + +import java.util.Collection; +import java.util.List; + +/** + * Created by Oren on 6/27/17. + */ +public class SecureServices { + + private Collection services; + private boolean isReadOnly = true; + + public void setServices(Collection services) { + this.services = services; + } + + public Collection getServices() { + + return services; + } + public boolean isReadOnly() { + return isReadOnly; + } + + public void setReadOnly(boolean readOnly) { + isReadOnly = readOnly; + } + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMetadata.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMetadata.java index d42c1f15..41c7ca5b 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMetadata.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMetadata.java @@ -61,6 +61,9 @@ public class ToscaMetadata { /** The resource vendor release. */ private String resourceVendorRelease; + /** the resourceVendorModelNumber */ + private String resourceVendorModelNumber; + /** The service ecomp naming. */ private String serviceEcompNaming; @@ -88,6 +91,11 @@ public class ToscaMetadata { /** The vf module model version. */ private String vfModuleModelVersion; + + /** serviceType */ + private String serviceType; + /** serviceRole */ + private String serviceRole; /** * Instantiates a new tosca metadata. @@ -458,4 +466,26 @@ public class ToscaMetadata { return vfModuleModelCustomizationUUID; } + + /** serviceType */ + public String getServiceType() { + return serviceType; + } + public void setServiceType(String serviceType) { + this.serviceType= serviceType; + } + /** serviceRole */ + public String getServiceRole() { + return serviceRole; + } + public void setServiceRole(String serviceRole) { + this.serviceRole= serviceRole; + } + /** resourceVendorModelNumber */ + public String getResourceVendorModelNumber() { + return resourceVendorModelNumber; + } + public void setResourceVendorModelNumber(String resourceVendorModelNumber) { + this.resourceVendorModelNumber= resourceVendorModelNumber; + } } diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/local/LocalAsdcClient.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/local/LocalAsdcClient.java index 8538f6ba..d73c75b3 100644 --- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/local/LocalAsdcClient.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/local/LocalAsdcClient.java @@ -264,7 +264,7 @@ public class LocalAsdcClient implements AsdcClient { * @see org.openecomp.vid.asdc.AsdcClient#getResourceArtifact(java.util.UUID, java.util.UUID) */ public Artifact getResourceArtifact(UUID resourceUuid, UUID artifactUuid) throws AsdcCatalogException { - final JSONArray artifacts = getCatalog().getJSONObject("resources") + final JSONArray artifacts = getCatalog().getJSONObject("resources") .getJSONObject(resourceUuid.toString()) .getJSONArray("artifacts"); diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl2.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl2.java index 4819cae8..3f0dd8c3 100644 --- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl2.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl2.java @@ -7,7 +7,6 @@ import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory; import org.openecomp.sdc.toscaparser.api.Group; import org.openecomp.sdc.toscaparser.api.NodeTemplate; import org.openecomp.sdc.toscaparser.api.Property; -import org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint; import org.openecomp.sdc.toscaparser.api.parameters.Input; import org.openecomp.vid.asdc.beans.Service; import org.openecomp.vid.model.*; @@ -23,8 +22,11 @@ public class ToscaParserImpl2 { public class Constants { public final static String uuid = "UUID"; public final static String description = "description"; - public final static String ecompGeneratedNaming = "ecompGeneratedNaming"; - public final static String customizationUUID = "customizationUUID"; + public final static String serviceType = "serviceType"; + public final static String serviceRole = "serviceRole"; + public final static String ecompGeneratedNaming = "ecompGeneratedNaming"; + + public final static String customizationUUID = "customizationUUID"; public final static String vfModuleModelVersion = "vfModuleModelVersion"; public final static String vfModuleModelCustomizationUUID = "vfModuleModelCustomizationUUID"; public final static String volume_group = "volume_group"; @@ -49,7 +51,7 @@ public class ToscaParserImpl2 { serviceModel.setService(extractServiceFromCsar(asdcServiceMetadata, sdcCsarHelper)); serviceModel.setVolumeGroups(extractVolumeGroups(sdcCsarHelper)); serviceModel.setVfModules(extractVfModuleFromCsar(sdcCsarHelper)); - serviceModel.setVnfs(extractVnfsFromCsar(sdcCsarHelper)); + serviceModel.setVnfs(extractVnfsFromCsar(serviceModel,sdcCsarHelper)); serviceModel.setNetworks(extractNetworksFromCsar(sdcCsarHelper)); return serviceModel; } @@ -65,22 +67,52 @@ public class ToscaParserImpl2 { service.setDescription(csarHelper.getServiceMetadata().getValue(Constants.description)); service.setInputs(inputsListToInputsMap(csarHelper.getServiceInputs())); service.setServiceEcompNaming(csarHelper.getServiceMetadata().getValue(Constants.ecompGeneratedNaming)); + service.setServiceType(csarHelper.getServiceMetadata().getValue(Constants.serviceType)); + service.setServiceRole(csarHelper.getServiceMetadata().getValue(Constants.serviceRole)); + return service; } - private Map extractVnfsFromCsar(ISdcCsarHelper csarHelper) { + private Map extractVnfsFromCsar(ServiceModel serviceModel,ISdcCsarHelper csarHelper) { List nodeTemplates = csarHelper.getServiceVfList(); Map vnfsMaps = new HashMap(); for (NodeTemplate nodeTemplate : nodeTemplates) { VNF vnf = new VNF(); populateNodeFromNodeTemplate(nodeTemplate, csarHelper, vnf); + vnf.setModelCustomizationName(nodeTemplate.getName()); + Map vfModuleHashMap = getVfModulesFromVF(csarHelper, vnf.getCustomizationUuid()); + vnf.setVfModules(vfModuleHashMap); + + Map volumeGroupMap = getVolumeGroupsFromVF(csarHelper, vnf.getCustomizationUuid()); + vnf.setVolumeGroups(volumeGroupMap); + vnfsMaps.put(nodeTemplate.getName(), vnf); } return vnfsMaps; } + private Map getVfModulesFromVF(ISdcCsarHelper csarHelper, String vfUuid) { + Map vfModuleHashMap = new HashMap(); + for (Group group : csarHelper.getVfModulesByVf(vfUuid)) { + vfModuleHashMap.put(group.getName(), populateVfModuleFromGroup(group)); + } + return vfModuleHashMap; + } + + private Map getVolumeGroupsFromVF(ISdcCsarHelper csarHelper, String vfCustomizationUuid) { + Map volumeGroupMap = new HashMap(); + List groups = csarHelper.getVfModulesByVf(vfCustomizationUuid); + for (Group group : groups) { + boolean isVolumeGroup = Boolean.valueOf(group.getPropertyValue(Constants.volume_group).toString()); + if (isVolumeGroup) { + volumeGroupMap.put(group.getName(), populateVolumeGroupFromGroup(group)); + } + } + return volumeGroupMap; + } + private Map extractNetworksFromCsar(ISdcCsarHelper csarHelper) { List nodeTemplates = csarHelper.getServiceVlList(); Map networksMap = new HashMap(); @@ -99,25 +131,19 @@ public class ToscaParserImpl2 { HashMap vfModuleHashMap = new HashMap<>(); for (NodeTemplate nodeTemplate : serviceVfList) { - List groups = csarHelper.getVfModulesByVf(nodeTemplate.getMetaData().getValue(Constants.customizationUUID)); - for (Group group : groups) { - vfModuleHashMap.put(group.getName(), populateVfModuleFromGroup(group)); - } + Map nodeTemplateVfModule = + getVfModulesFromVF(csarHelper, nodeTemplate.getMetaData().getValue(Constants.customizationUUID)); + vfModuleHashMap.putAll(nodeTemplateVfModule); } return vfModuleHashMap; } - private Map extractVolumeGroups(ISdcCsarHelper csarHelper) { HashMap volumeGroupHashMap = new HashMap<>(); for (NodeTemplate nodeTemplate : csarHelper.getServiceVfList()) { - List groups = csarHelper.getVfModulesByVf(csarHelper.getNodeTemplateCustomizationUuid(nodeTemplate)); - for (Group group : groups) { - boolean isVolumeGroup = Boolean.valueOf(group.getPropertyValue(Constants.volume_group).toString()); - if (isVolumeGroup) { - volumeGroupHashMap.put(group.getName(), populateVolumeGroupFromGroup(group)); - } - } + Map nodeTemplateVolumeGroups = + getVolumeGroupsFromVF(csarHelper, csarHelper.getNodeTemplateCustomizationUuid(nodeTemplate)); + volumeGroupHashMap.putAll(nodeTemplateVolumeGroups); } return volumeGroupHashMap; } diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java index 5b783f5c..67375aa6 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java @@ -57,6 +57,7 @@ import java.util.UUID; /** * The Class RestfulAsdcClient. */ +@SuppressWarnings("Duplicates") public class RestfulAsdcClient implements AsdcClient { /** @@ -183,6 +184,7 @@ public class RestfulAsdcClient implements AsdcClient { * @see org.openecomp.vid.asdc.AsdcClient#getResource(java.util.UUID) */ public Resource getResource(UUID uuid) throws AsdcCatalogException { + String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH); try { return getClient() diff --git a/vid-app-common/src/main/java/org/openecomp/vid/client/FakeHttpSession.java b/vid-app-common/src/main/java/org/openecomp/vid/client/FakeHttpSession.java new file mode 100644 index 00000000..226e6c4d --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/client/FakeHttpSession.java @@ -0,0 +1,224 @@ +package org.openecomp.vid.client; + +import org.apache.commons.io.IOUtils; +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONTokener; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpSession; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by pickjonathan on 03/07/2017. + */ +public class FakeHttpSession implements HttpSession { + + /** + * Setup the creation time + */ + public FakeHttpSession() { + File file = new File("resources/roles.json"); + + String rolesInputStream = null; + try { + rolesInputStream = IOUtils.toString(FakeHttpSession.class.getClassLoader().getResourceAsStream("roles.json"),"UTF8"); + } catch (IOException e) { + e.printStackTrace(); + } + JSONTokener tokener = new JSONTokener(rolesInputStream); + JSONObject roles = new JSONObject(tokener); + + JSONArray rolesArray = roles.getJSONArray("roles"); + + //set permissions to the roles from file. + this.setAttribute("role", rolesArray); + + creationTime = System.currentTimeMillis(); + } + + + /** + * Setup the creation time + * @param id The new session id + */ + public FakeHttpSession(String id) + { + this.id = id; + creationTime = System.currentTimeMillis(); + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#getCreationTime() + */ + public long getCreationTime() + { + return creationTime; + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#getId() + */ + public String getId() + { + if (id == null) + { + System.out.println("Inventing data in FakeHttpSession.getId() to remain plausible."); + id = "fake"; + } + + return id; + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#getLastAccessedTime() + */ + public long getLastAccessedTime() + { + return creationTime; + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#getServletContext() + */ + public ServletContext getServletContext() + { + return null; + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#setMaxInactiveInterval(int) + */ + public void setMaxInactiveInterval(int maxInactiveInterval) + { + this.maxInactiveInterval = maxInactiveInterval; + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#getMaxInactiveInterval() + */ + public int getMaxInactiveInterval() + { + return maxInactiveInterval; + } + + /** + * @see javax.servlet.http.HttpSession#getSessionContext() + * @deprecated + */ + @SuppressWarnings({"UnnecessaryFullyQualifiedName"}) + @Deprecated + public javax.servlet.http.HttpSessionContext getSessionContext() + { + return null; + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#getAttribute(java.lang.String) + */ + public Object getAttribute(String name) + { + return attributes.get(name); + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#getValue(java.lang.String) + */ + @Deprecated + public Object getValue(String name) + { + return attributes.get(name); + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#getAttributeNames() + */ + public Enumeration getAttributeNames() + { + return Collections.enumeration(attributes.keySet()); + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#getValueNames() + */ + @Deprecated + public String[] getValueNames() + { + return attributes.keySet().toArray(new String[attributes.keySet().size()]); + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#setAttribute(java.lang.String, java.lang.Object) + */ + public void setAttribute(String name, Object value) + { + attributes.put(name, value); + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#putValue(java.lang.String, java.lang.Object) + */ + @Deprecated + public void putValue(String name, Object value) + { + attributes.put(name, value); + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#removeAttribute(java.lang.String) + */ + public void removeAttribute(String name) + { + attributes.remove(name); + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#removeValue(java.lang.String) + */ + @Deprecated + public void removeValue(String name) + { + attributes.remove(name); + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#invalidate() + */ + public void invalidate() + { + } + + /* (non-Javadoc) + * @see javax.servlet.http.HttpSession#isNew() + */ + public boolean isNew() + { + return true; + } + + /** + * The session id + */ + private String id = null; + + /** + * The list of attributes + */ + private Map attributes = new HashMap(); + + /** + * When were we created + */ + private long creationTime; + + /** + * How long before we timeout? + */ + private int maxInactiveInterval = 30 * 60 * 1000; +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/client/HttpsBasicClient.java b/vid-app-common/src/main/java/org/openecomp/vid/client/HttpsBasicClient.java index dc0e3559..676a7e79 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/client/HttpsBasicClient.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/client/HttpsBasicClient.java @@ -95,7 +95,7 @@ public class HttpsBasicClient{ //May need to make the algorithm a parameter. MSO requires TLSv1.1 or TLSv1.2 ctx = SSLContext.getInstance("TLSv1.2"); - /* + /* KeyManagerFactory kmf = null; try { kmf = KeyManagerFactory.getInstance("SunX509"); @@ -113,7 +113,7 @@ public class HttpsBasicClient{ ctx.init(kmf.getKeyManagers(), null, null); */ ctx.init(null, null, null); - //config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, + //config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, // new HTTPSProperties( , ctx)); return ClientBuilder.newBuilder() diff --git a/vid-app-common/src/main/java/org/openecomp/vid/controller/AaiController.java b/vid-app-common/src/main/java/org/openecomp/vid/controller/AaiController.java index 861ddf8d..c0b6a514 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/controller/AaiController.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/controller/AaiController.java @@ -18,31 +18,27 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.vid.controller; - -import java.io.File; -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.UUID; - -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -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; +package org.openecomp.vid.controller; +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.openecomp.aai.util.AAIRestInterface; +import org.openecomp.portalsdk.core.controller.RestrictedBaseController; +import org.openecomp.portalsdk.core.domain.User; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.vid.aai.AaiResponse; +import org.openecomp.vid.aai.SubscriberData; +import org.openecomp.vid.aai.SubscriberFilteredResults; +import org.openecomp.vid.aai.model.AaiGetTenatns.GetTenantsResponse; +import org.openecomp.vid.roles.Role; +import org.openecomp.vid.roles.RoleProvider; +import org.openecomp.vid.roles.RoleValidator; +import org.openecomp.vid.services.AaiService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -53,35 +49,292 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.util.SystemProperties; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +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.*; /** * Controller to handle a&ai requests. */ @RestController -public class AaiController extends RestrictedBaseController{ +public class AaiController extends RestrictedBaseController { + + public AaiController() { + + } +public AaiController(ServletContext servletContext) { + this.servletContext = servletContext; + + } + + + - /** The view name. */ + /** + * The Constant dateFormat. + */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + /** + * The from app id. + */ + protected String fromAppId = "VidAaiController"; + /** + * The view name. + */ String viewName; - - /** The logger. */ + /** + * The logger. + */ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AaiController.class); - /** The Constant dateFormat. */ - final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); - /** The from app id. */ - protected String fromAppId = "VidAaiController"; + /** + * The model. + */ + private Map model = new HashMap(); + /** + * The servlet context. + */ + @Autowired + private ServletContext servletContext; + + /** + * aai service + */ + @Autowired + private AaiService aaiService; + + + + /** + * Return tenant details. + * + * @param jsonObject the json object + * @return String The parsing results + */ + public static String parseCustomerObjectForTenants(JSONObject jsonObject) { + + JSONArray tenantArray = new JSONArray(); + boolean bconvert = false; + + try { + + JSONObject serviceSubsObj = (JSONObject) jsonObject.get("service-subscriptions"); + + if (serviceSubsObj != null) { + JSONArray srvcSubArray = (JSONArray) serviceSubsObj.get("service-subscription"); + + if (srvcSubArray != null) { + Iterator i = srvcSubArray.iterator(); + + while (i.hasNext()) { + + JSONObject innerObj = (JSONObject) i.next(); + + if (innerObj == null) + continue; + + JSONObject relationShipListsObj = (JSONObject) innerObj.get("relationship-list"); + if (relationShipListsObj != null) { + JSONArray rShipArray = (JSONArray) relationShipListsObj.get("relationship"); + if (rShipArray != null) { + Iterator i1 = rShipArray.iterator(); + + while (i1.hasNext()) { + + JSONObject inner1Obj = (JSONObject) i1.next(); + + if (inner1Obj == null) + continue; + + String relatedTo = checkForNull((String) inner1Obj.get("related-to")); + if (relatedTo.equalsIgnoreCase("tenant")) { + JSONObject tenantNewObj = new JSONObject(); + + String relatedLink = checkForNull((String) inner1Obj.get("related-link")); + tenantNewObj.put("link", relatedLink); + + JSONArray rDataArray = (JSONArray) inner1Obj.get("relationship-data"); + if (rDataArray != null) { + Iterator i2 = rDataArray.iterator(); + + while (i2.hasNext()) { + JSONObject inner2Obj = (JSONObject) i2.next(); + + if (inner2Obj == null) + continue; + + String rShipKey = checkForNull((String) inner2Obj.get("relationship-key")); + String rShipVal = checkForNull((String) inner2Obj.get("relationship-value")); + if (rShipKey.equalsIgnoreCase("cloud-region.cloud-owner")) { + tenantNewObj.put("cloudOwner", rShipVal); + } else if (rShipKey.equalsIgnoreCase("cloud-region.cloud-region-id")) { + tenantNewObj.put("cloudRegionID", rShipVal); + } + + if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) { + tenantNewObj.put("tenantID", rShipVal); + } + } + } + + JSONArray relatedTPropArray = (JSONArray) inner1Obj.get("related-to-property"); + if (relatedTPropArray != null) { + Iterator i3 = relatedTPropArray.iterator(); + + while (i3.hasNext()) { + JSONObject inner3Obj = (JSONObject) i3.next(); + + if (inner3Obj == null) + continue; + + String propKey = checkForNull((String) inner3Obj.get("property-key")); + String propVal = checkForNull((String) inner3Obj.get("property-value")); + if (propKey.equalsIgnoreCase("tenant.tenant-name")) { + tenantNewObj.put("tenantName", propVal); + } + } + } + bconvert = true; + tenantArray.add(tenantNewObj); + } + } + } + } + } + } + } + } catch (NullPointerException ex) { + + + } + + if (bconvert) + return tenantArray.toJSONString(); + else + return ""; + + } - /** The model. */ - private Map model = new HashMap(); - /** The servlet context. */ - private @Autowired ServletContext servletContext; + + /** + * Retrieve the service subscription from the jsonObject. + * + * @param jsonObject the json object + * @return String + */ + public static String parseServiceSubscriptionObjectForTenants(JSONObject jsonObject) { + + JSONArray tenantArray = new JSONArray(); + boolean bconvert = false; + + try { + JSONObject relationShipListsObj = (JSONObject) jsonObject.get("relationship-list"); + if (relationShipListsObj != null) { + JSONArray rShipArray = (JSONArray) relationShipListsObj.get("relationship"); + if (rShipArray != null) { + Iterator i1 = rShipArray.iterator(); + + while (i1.hasNext()) { + + JSONObject inner1Obj = (JSONObject) i1.next(); + + if (inner1Obj == null) + continue; + + String relatedTo = checkForNull((String) inner1Obj.get("related-to")); + if (relatedTo.equalsIgnoreCase("tenant")) { + JSONObject tenantNewObj = new JSONObject(); + + String relatedLink = checkForNull((String) inner1Obj.get("related-link")); + tenantNewObj.put("link", relatedLink); + + JSONArray rDataArray = (JSONArray) inner1Obj.get("relationship-data"); + if (rDataArray != null) { + Iterator i2 = rDataArray.iterator(); + + while (i2.hasNext()) { + JSONObject inner2Obj = (JSONObject) i2.next(); + + if (inner2Obj == null) + continue; + + String rShipKey = checkForNull((String) inner2Obj.get("relationship-key")); + String rShipVal = checkForNull((String) inner2Obj.get("relationship-value")); + if (rShipKey.equalsIgnoreCase("cloud-region.cloud-owner")) { + tenantNewObj.put("cloudOwner", rShipVal); + } else if (rShipKey.equalsIgnoreCase("cloud-region.cloud-region-id")) { + tenantNewObj.put("cloudRegionID", rShipVal); + } + + if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) { + tenantNewObj.put("tenantID", rShipVal); + } + } + } + + JSONArray relatedTPropArray = (JSONArray) inner1Obj.get("related-to-property"); + if (relatedTPropArray != null) { + Iterator i3 = relatedTPropArray.iterator(); + + while (i3.hasNext()) { + JSONObject inner3Obj = (JSONObject) i3.next(); + + if (inner3Obj == null) + continue; + + String propKey = checkForNull((String) inner3Obj.get("property-key")); + String propVal = checkForNull((String) inner3Obj.get("property-value")); + if (propKey.equalsIgnoreCase("tenant.tenant-name")) { + tenantNewObj.put("tenantName", propVal); + } + } + } + bconvert = true; + tenantArray.add(tenantNewObj); + } + } + + } + } + } catch (NullPointerException ex) { + + + } + + if (bconvert) + return tenantArray.toJSONString(); + else + return ""; + + } + + /** + * Check for null. + * + * @param local the local + * @return the string + */ + private static String checkForNull(String local) { + if (local != null) + return local; + else + return ""; + + } /** * Welcome method. @@ -89,10 +342,18 @@ public class AaiController extends RestrictedBaseController{ * @param request the request * @return ModelAndView The view */ - @RequestMapping(value = {"/subscriberSearch" }, method = RequestMethod.GET) + @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()); + return new ModelAndView(getViewName()); + } + + @RequestMapping(value = {"/aai_get_aic_zones"}, method = RequestMethod.GET) + public ResponseEntity 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); + } /* (non-Javadoc) @@ -113,19 +374,17 @@ public class AaiController extends RestrictedBaseController{ * Get services from a&ai. * * @return ResponseEntity The response entity with the logged in user uuid. - * @throws IOException Signals that an I/O exception has occurred. + * @throws IOException Signals that an I/O exception has occurred. * @throws InterruptedException the interrupted exception */ - @RequestMapping(value = {"/getuserID" }, method = RequestMethod.GET) + @RequestMapping(value = {"/getuserID"}, method = RequestMethod.GET) public ResponseEntity getUserID(HttpServletRequest request) throws IOException, InterruptedException { String userId = ""; HttpSession session = request.getSession(); - if (session != null) - { + if (session != null) { User user = (User) session.getAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)); - if (user != null) - { + if (user != null) { //userId = user.getHrid(); userId = user.getLoginId(); if (userId == null) @@ -133,23 +392,39 @@ public class AaiController extends RestrictedBaseController{ } } - return new ResponseEntity( userId, HttpStatus.OK); + return new ResponseEntity(userId, HttpStatus.OK); } - /** * Get services from a&ai. * * @return ResponseEntity The response entity - * @throws IOException Signals that an I/O exception has occurred. + * @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 doGetServices() throws IOException, InterruptedException { - File certiPath = GetCertificatesPath(); - Response resp = doAaiGet(certiPath.getAbsolutePath(), "service-design-and-creation/services", false); + @RequestMapping(value = "/aai_get_services", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity doGetServices(HttpServletRequest request) throws IOException, InterruptedException { + + RoleValidator roleValidator = new RoleValidator(new RoleProvider().getUserRoles(request)); - return convertResponseToResponseEntity(resp); + AaiResponse subscriberList = aaiService.getServices(roleValidator); + ResponseEntity responseEntity = aaiResponseToResponseEntity( subscriberList); + + return responseEntity; + } + + + + private ResponseEntity aaiResponseToResponseEntity( AaiResponse aaiResponseData) + throws IOException, JsonGenerationException, JsonMappingException { + ResponseEntity responseEntity; + ObjectMapper objectMapper = new ObjectMapper(); + if (aaiResponseData.getHttpCode() == 200) { + responseEntity = new ResponseEntity(objectMapper.writeValueAsString(aaiResponseData.getT()), HttpStatus.OK); + } else { + responseEntity = new ResponseEntity(aaiResponseData.getErrorMessage(), HttpStatus.valueOf(aaiResponseData.getHttpCode())); + } + return responseEntity; } /** @@ -157,41 +432,40 @@ public class AaiController extends RestrictedBaseController{ * * @param serviceInstanceId the service instance Id * @return ResponseEntity The response entity - * @throws IOException Signals that an I/O exception has occurred. + * @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 doGetServiceInstance(@PathVariable("service-instance-id") String serviceInstanceId,@PathVariable("service-instance-type") String serviceInstanceType) throws IOException, InterruptedException { + @RequestMapping(value = "/aai_get_service_instance/{service-instance-id}/{service-instance-type}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity doGetServiceInstance(@PathVariable("service-instance-id") String serviceInstanceId, @PathVariable("service-instance-type") String serviceInstanceType) throws IOException, InterruptedException { File certiPath = GetCertificatesPath(); - Response resp=null; + 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:" + 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:" + 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 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 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) + @RequestMapping(value = "/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity doGetServices(@PathVariable("global-customer-id") String globalCustomerId, - @PathVariable("service-subscription-id") String serviceSubscriptionId) throws IOException, InterruptedException { + @PathVariable("service-subscription-id") String serviceSubscriptionId) throws IOException, InterruptedException { File certiPath = GetCertificatesPath(); - Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + globalCustomerId + Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + serviceSubscriptionId + "?depth=0", false); return convertResponseToResponseEntity(resp); } @@ -201,23 +475,22 @@ public class AaiController extends RestrictedBaseController{ * * @param fullSet the full set * @return ResponseEntity The response entity - * @throws IOException Signals that an I/O exception has occurred. + * @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 doGetSubscriberList(@DefaultValue("n") @QueryParam("fullSet") String fullSet) throws IOException, InterruptedException { - Response resp = getSubscribers(false); - return convertResponseToResponseEntity(resp); + @RequestMapping(value = "/aai_get_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity 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 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) + */ + @RequestMapping(value = "/get_system_prop_vnf_prov_status", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getTargetProvStatus() throws IOException, InterruptedException { String p = SystemProperties.getProperty("aai.vnf.provstatus"); return new ResponseEntity(p, HttpStatus.OK); @@ -225,17 +498,27 @@ public class AaiController extends RestrictedBaseController{ /** * Obtain the full subscriber list from a&ai. + *

+ * g @return ResponseEntity The response entity * - * @return ResponseEntity The response entity - * @throws IOException Signals that an I/O exception has occurred. + * @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 getFullSubscriberList() throws IOException, InterruptedException { - Response resp = getSubscribers(true); - return convertResponseToResponseEntity(resp); - } + @RequestMapping(value = "/aai_get_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity getFullSubscriberList(HttpServletRequest request) throws IOException, InterruptedException { + ObjectMapper objectMapper = new ObjectMapper(); + ResponseEntity responseEntity; + RoleValidator roleValidator = new RoleValidator(new RoleProvider().getUserRoles(request)); + SubscriberFilteredResults subscriberList = aaiService.getFullSubscriberList(roleValidator); + if (subscriberList.getHttpCode() == 200) { + responseEntity = new ResponseEntity(objectMapper.writeValueAsString(subscriberList.getSubscriberList()), HttpStatus.OK); + } else { + responseEntity = new ResponseEntity(subscriberList.getErrorMessage(), HttpStatus.valueOf(subscriberList.getHttpCode())); + } + + return responseEntity; + } /** * Refresh the subscriber list from a&ai. @@ -243,7 +526,7 @@ public class AaiController extends RestrictedBaseController{ * @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) + @RequestMapping(value = "/aai_refresh_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity doRefreshSubscriberList() throws IOException { Response resp = getSubscribers(false); return convertResponseToResponseEntity(resp); @@ -255,7 +538,7 @@ public class AaiController extends RestrictedBaseController{ * @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) + @RequestMapping(value = "/aai_refresh_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity doRefreshFullSubscriberList() throws IOException { Response resp = getSubscribers(false); return convertResponseToResponseEntity(resp); @@ -267,75 +550,88 @@ public class AaiController extends RestrictedBaseController{ * @param subscriberId the subscriber id * @return ResponseEntity The response entity */ - @RequestMapping(value="/aai_sub_details/{subscriberId}", method = RequestMethod.GET) - public ResponseEntity GetSubscriber(@PathVariable("subscriberId") String subscriberId) { - Response resp = getSubscriberDetails(subscriberId); - return convertResponseToResponseEntity(resp); + @RequestMapping(value = "/aai_sub_details/{subscriberId}", method = RequestMethod.GET) + public ResponseEntity GetSubscriberDetails(HttpServletRequest request,@PathVariable("subscriberId") String subscriberId) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + ResponseEntity responseEntity; + List roles = new RoleProvider().getUserRoles(request); + RoleValidator roleValidator = new RoleValidator(roles); + AaiResponse subscriberData = aaiService.getSubscriberData(subscriberId,roleValidator); + String httpMessage = subscriberData.getT() != null ? + objectMapper.writeValueAsString(subscriberData.getT()) : + subscriberData.getErrorMessage(); + + responseEntity = new ResponseEntity(httpMessage, HttpStatus.valueOf(subscriberData.getHttpCode())); + return responseEntity; } /** * Issue a named query to a&ai. * - * @param namedQueryId the named query id + * @param namedQueryId the named query id * @param globalCustomerId the global customer id - * @param serviceType the service type - * @param serviceInstance the service instance + * @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) + @RequestMapping(value = "/aai_sub_viewedit/{namedQueryId}/{globalCustomerId}/{serviceType}/{serviceInstance}", method = RequestMethod.GET) public ResponseEntity viewEditGetComponentList( @PathVariable("namedQueryId") String namedQueryId, @PathVariable("globalCustomerId") String globalCustomerId, @PathVariable("serviceType") String serviceType, - @PathVariable("serviceInstance") String serviceInstance) { + @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); + Response resp = doAaiPost(certiPath.getAbsolutePath(), "search/named-query", componentListPayload, false); + return convertResponseToResponseEntity(resp); } + + // @RequestMapping(value="/aai_get_tenants/{global-customer-id}", method = RequestMethod.GET) + // public ResponseEntity viewEditGetComponentList( + // @PathVariable("global-customer-id") String globalCustomerId) { + // return new ResponseEntity(getTenants(globalCustomerId), HttpStatus.OK); + // } + /** * Issue a named query to a&ai. * - * @param namedQueryId the named query id + * @param namedQueryId the named query id * @param globalCustomerId the global customer id - * @param serviceType the service type + * @param serviceType the service type * @return ResponseEntity The response entity */ - @RequestMapping(value="/aai_get_models_by_service_type/{namedQueryId}/{globalCustomerId}/{serviceType}", method = RequestMethod.GET) + @RequestMapping(value = "/aai_get_models_by_service_type/{namedQueryId}/{globalCustomerId}/{serviceType}", method = RequestMethod.GET) public ResponseEntity viewEditGetComponentList( @PathVariable("namedQueryId") String namedQueryId, @PathVariable("globalCustomerId") String globalCustomerId, - @PathVariable("serviceType") String serviceType) { + @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); + Response resp = doAaiPost(certiPath.getAbsolutePath(), "search/named-query", componentListPayload, false); + return convertResponseToResponseEntity(resp); } - + /** * Parses the for tenants. * * @param resp the resp * @return the string */ - private String parseForTenants(String resp) - { + private String parseForTenants(String resp) { String tenantList = ""; - try - { + try { JSONParser jsonParser = new JSONParser(); JSONObject jsonObject = (JSONObject) jsonParser.parse(resp); - return parseCustomerObjectForTenants(jsonObject); - } - catch (Exception ex) { + return parseCustomerObjectForTenants(jsonObject); + } catch (Exception ex) { } @@ -348,51 +644,59 @@ public class AaiController extends RestrictedBaseController{ * @param resp the resp * @return the string */ - private String parseForTenantsByServiceSubscription(String resp) - { + private String parseForTenantsByServiceSubscription(String resp) { String tenantList = ""; - try - { + try { JSONParser jsonParser = new JSONParser(); JSONObject jsonObject = (JSONObject) jsonParser.parse(resp); - return parseServiceSubscriptionObjectForTenants(jsonObject); - } - catch (Exception ex) { + return parseServiceSubscriptionObjectForTenants(jsonObject); + } catch (Exception ex) { } return tenantList; } - - // @RequestMapping(value="/aai_get_tenants/{global-customer-id}", method = RequestMethod.GET) - // public ResponseEntity viewEditGetComponentList( - // @PathVariable("global-customer-id") String globalCustomerId) { - // return new ResponseEntity(getTenants(globalCustomerId), HttpStatus.OK); - // } - /** * Obtain tenants for a given service type. * * @param globalCustomerId the global customer id - * @param serviceType the service type + * @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 viewEditGetTenantsFromServiceType( + @RequestMapping(value = "/aai_get_tenants/{global-customer-id}/{service-type}", method = RequestMethod.GET) + public ResponseEntity viewEditGetTenantsFromServiceType(HttpServletRequest request, @PathVariable("global-customer-id") String globalCustomerId, @PathVariable("service-type") String serviceType) { - return getTenantsFromServiceType(globalCustomerId, serviceType); + + ResponseEntity responseEntity; + try { + ObjectMapper objectMapper = new ObjectMapper(); + List roles = new RoleProvider().getUserRoles(request); + RoleValidator roleValidator = new RoleValidator(roles); + AaiResponse response = aaiService.getTenants(globalCustomerId, serviceType, roleValidator); + if (response.getHttpCode() == 200) { + responseEntity = new ResponseEntity(objectMapper.writeValueAsString(response.getT()), HttpStatus.OK); + } else { + responseEntity = new ResponseEntity(response.getErrorMessage(), HttpStatus.valueOf(response.getHttpCode())); + } + } + catch (Exception e){ + responseEntity = new ResponseEntity("Unable to proccess getTenants reponse", HttpStatus.INTERNAL_SERVER_ERROR); + } + return responseEntity; } - private ResponseEntity convertResponseToResponseEntity(Response resp) { + + private ResponseEntity convertResponseToResponseEntity(Response resp) { ResponseEntity respEnt; - if (resp == null) { + ObjectMapper objectMapper = new ObjectMapper(); + if (resp == null) { respEnt = new ResponseEntity("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())); + } else { + respEnt = new ResponseEntity(resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus())); } return respEnt; } @@ -403,18 +707,17 @@ public class AaiController extends RestrictedBaseController{ * @param globalCustomerId the global customer id * @return the tenants */ - private ResponseEntity getTenants(String globalCustomerId) - { + private ResponseEntity getTenants(String globalCustomerId) { File certiPath = GetCertificatesPath(); - Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + globalCustomerId, false); - - ResponseEntity respEnt; - if (resp.getStatus() >= 200 && resp.getStatus() <= 299) { - respEnt = new ResponseEntity(parseForTenants((String)resp.readEntity(String.class)), HttpStatus.OK); - } else { - respEnt = new ResponseEntity((String)resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus())); - } - return respEnt; + Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + globalCustomerId, false); + + ResponseEntity respEnt; + if (resp.getStatus() >= 200 && resp.getStatus() <= 299) { + respEnt = new ResponseEntity(parseForTenants((String) resp.readEntity(String.class)), HttpStatus.OK); + } else { + respEnt = new ResponseEntity((String) resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus())); + } + return respEnt; } @@ -422,23 +725,27 @@ public class AaiController extends RestrictedBaseController{ * Gets the tenants from service type. * * @param globalCustomerId the global customer id - * @param serviceType the service type + * @param serviceType the service type * @return the tenants from service type */ - private ResponseEntity getTenantsFromServiceType(String globalCustomerId, String serviceType) - { + private ResponseEntity getTenantsFromServiceType(String globalCustomerId, String serviceType) { + + + + + File certiPath = GetCertificatesPath(); - String url = "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + serviceType; + String url = "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + serviceType; - Response resp = doAaiGet(certiPath.getAbsolutePath(), url, false); - - ResponseEntity respEnt; - if (resp.getStatus() >= 200 && resp.getStatus() <= 299) { - respEnt = new ResponseEntity(parseForTenantsByServiceSubscription((String)resp.readEntity(String.class)), HttpStatus.OK); - } else { - respEnt = new ResponseEntity((String)resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus())); - } - return respEnt; + Response resp = doAaiGet(certiPath.getAbsolutePath(), url, false); + + ResponseEntity respEnt; + if (resp.getStatus() >= 200 && resp.getStatus() <= 299) { + respEnt = new ResponseEntity(parseForTenantsByServiceSubscription((String) resp.readEntity(String.class)), HttpStatus.OK); + } else { + respEnt = new ResponseEntity((String) resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus())); + } + return respEnt; } @@ -447,45 +754,40 @@ public class AaiController extends RestrictedBaseController{ * * @return the services */ - private Response getServices() - { + private Response getServices() { File certiPath = GetCertificatesPath(); - Response resp = doAaiGet(certiPath.getAbsolutePath(), "service-design-and-creation/services", false); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getServices() resp=" + resp.getStatusInfo()); + Response resp = doAaiGet(certiPath.getAbsolutePath(), "service-design-and-creation/services", false); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getServices() resp=" + resp.getStatusInfo()); //model.put("aai_get_services", resp); return resp; } - /** * Gets the subscribers. * * @param isFullSet the is full set * @return the subscribers */ - private Response getSubscribers(boolean isFullSet) - { + 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()); - } + 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) - { + 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); @@ -498,10 +800,9 @@ public class AaiController extends RestrictedBaseController{ * * @return the file */ - private File GetCertificatesPath() - { + private File GetCertificatesPath() { if (servletContext != null) - return new File( servletContext.getRealPath("/WEB-INF/cert/") ); + return new File(servletContext.getRealPath("/WEB-INF/cert/")); return null; } @@ -509,12 +810,12 @@ public class AaiController extends RestrictedBaseController{ * Send a GET request to a&ai. * * @param certiPath the certi path - * @param uri the uri - * @param xml the xml + * @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 methodName = "getSubscriberList"; String transId = UUID.randomUUID().toString(); logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); @@ -526,11 +827,11 @@ public class AaiController extends RestrictedBaseController{ } 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); + 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()); + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); } return resp; @@ -540,13 +841,13 @@ public class AaiController extends RestrictedBaseController{ * Send a POST request to a&ai. * * @param certiPath the certi path - * @param uri the uri - * @param payload the payload - * @param xml the xml + * @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 methodName = "getSubscriberList"; String transId = UUID.randomUUID().toString(); logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); @@ -557,8 +858,8 @@ public class AaiController extends RestrictedBaseController{ 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()); + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); } return resp; @@ -567,14 +868,14 @@ public class AaiController extends RestrictedBaseController{ /** * Gets the component list put payload. * - * @param namedQueryId the named query id + * @param namedQueryId the named query id * @param globalCustomerId the global customer id - * @param serviceType the service type - * @param serviceInstance the service instance + * @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 + return " {" + " \"instance-filters\": {" + " \"instance-filter\": [" + @@ -599,9 +900,10 @@ public class AaiController extends RestrictedBaseController{ "}"; } + private String getModelsByServiceTypePayload(String namedQueryId, String globalCustomerId, String serviceType) { // TODO Auto-generated method stub - return " {" + + return " {" + " \"instance-filters\": {" + " \"instance-filter\": [" + " {" + @@ -620,246 +922,6 @@ public class AaiController extends RestrictedBaseController{ " }" + " }" + "}"; - - } - - /** - * Return tenant details. - * - * @param jsonObject the json object - * @return String The parsing results - */ - public static String parseCustomerObjectForTenants(JSONObject jsonObject) { - - JSONArray tenantArray = new JSONArray(); - boolean bconvert = false; - - try { - - JSONObject serviceSubsObj = (JSONObject) jsonObject.get("service-subscriptions"); - - if (serviceSubsObj != null) - { - JSONArray srvcSubArray = (JSONArray) serviceSubsObj.get("service-subscription"); - - if (srvcSubArray != null) - { - Iterator i = srvcSubArray.iterator(); - - while (i.hasNext()) { - - JSONObject innerObj = (JSONObject) i.next(); - - if (innerObj == null) - continue; - - JSONObject relationShipListsObj = (JSONObject) innerObj.get("relationship-list"); - if (relationShipListsObj != null) - { - JSONArray rShipArray = (JSONArray) relationShipListsObj.get("relationship"); - if (rShipArray != null) - { - Iterator i1 = rShipArray.iterator(); - - while (i1.hasNext()) { - - JSONObject inner1Obj = (JSONObject) i1.next(); - - if (inner1Obj == null) - continue; - - String relatedTo = checkForNull((String)inner1Obj.get("related-to")); - if (relatedTo.equalsIgnoreCase("tenant")) - { - JSONObject tenantNewObj = new JSONObject(); - - String relatedLink = checkForNull((String) inner1Obj.get("related-link")); - tenantNewObj.put("link", relatedLink); - - JSONArray rDataArray = (JSONArray) inner1Obj.get("relationship-data"); - if (rDataArray != null) - { - Iterator i2 = rDataArray.iterator(); - - while (i2.hasNext()) { - JSONObject inner2Obj = (JSONObject) i2.next(); - - if (inner2Obj == null) - continue; - - String rShipKey = checkForNull((String)inner2Obj.get("relationship-key")); - String rShipVal = checkForNull((String)inner2Obj.get("relationship-value")); - if (rShipKey.equalsIgnoreCase("cloud-region.cloud-owner")) - { - tenantNewObj.put("cloudOwner", rShipVal); - } - else if (rShipKey.equalsIgnoreCase("cloud-region.cloud-region-id")) - { - tenantNewObj.put("cloudRegionID", rShipVal); - } - - if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) - { - tenantNewObj.put("tenantID", rShipVal); - } - } - } - - JSONArray relatedTPropArray = (JSONArray) inner1Obj.get("related-to-property"); - if (relatedTPropArray != null) - { - Iterator i3 = relatedTPropArray.iterator(); - - while (i3.hasNext()) { - JSONObject inner3Obj = (JSONObject) i3.next(); - - if (inner3Obj == null) - continue; - - String propKey = checkForNull((String)inner3Obj.get("property-key")); - String propVal = checkForNull((String)inner3Obj.get("property-value")); - if (propKey.equalsIgnoreCase("tenant.tenant-name")) - { - tenantNewObj.put("tenantName", propVal); - } - } - } - bconvert = true; - tenantArray.add(tenantNewObj); - } - } - } - } - } - } - } - } catch (NullPointerException ex) { - - - } - - if (bconvert) - return tenantArray.toJSONString(); - else - return ""; - - } - - - /** - * Retrieve the service subscription from the jsonObject. - * - * @param jsonObject the json object - * @return String - */ - public static String parseServiceSubscriptionObjectForTenants(JSONObject jsonObject) { - - JSONArray tenantArray = new JSONArray(); - boolean bconvert = false; - - try { - JSONObject relationShipListsObj = (JSONObject) jsonObject.get("relationship-list"); - if (relationShipListsObj != null) - { - JSONArray rShipArray = (JSONArray) relationShipListsObj.get("relationship"); - if (rShipArray != null) - { - Iterator i1 = rShipArray.iterator(); - - while (i1.hasNext()) { - - JSONObject inner1Obj = (JSONObject) i1.next(); - - if (inner1Obj == null) - continue; - - String relatedTo = checkForNull((String)inner1Obj.get("related-to")); - if (relatedTo.equalsIgnoreCase("tenant")) - { - JSONObject tenantNewObj = new JSONObject(); - - String relatedLink = checkForNull((String) inner1Obj.get("related-link")); - tenantNewObj.put("link", relatedLink); - - JSONArray rDataArray = (JSONArray) inner1Obj.get("relationship-data"); - if (rDataArray != null) - { - Iterator i2 = rDataArray.iterator(); - - while (i2.hasNext()) { - JSONObject inner2Obj = (JSONObject) i2.next(); - - if (inner2Obj == null) - continue; - - String rShipKey = checkForNull((String)inner2Obj.get("relationship-key")); - String rShipVal = checkForNull((String)inner2Obj.get("relationship-value")); - if (rShipKey.equalsIgnoreCase("cloud-region.cloud-owner")) - { - tenantNewObj.put("cloudOwner", rShipVal); - } - else if (rShipKey.equalsIgnoreCase("cloud-region.cloud-region-id")) - { - tenantNewObj.put("cloudRegionID", rShipVal); - } - - if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) - { - tenantNewObj.put("tenantID", rShipVal); - } - } - } - - JSONArray relatedTPropArray = (JSONArray) inner1Obj.get("related-to-property"); - if (relatedTPropArray != null) - { - Iterator i3 = relatedTPropArray.iterator(); - - while (i3.hasNext()) { - JSONObject inner3Obj = (JSONObject) i3.next(); - - if (inner3Obj == null) - continue; - - String propKey = checkForNull((String)inner3Obj.get("property-key")); - String propVal = checkForNull((String)inner3Obj.get("property-value")); - if (propKey.equalsIgnoreCase("tenant.tenant-name")) - { - tenantNewObj.put("tenantName", propVal); - } - } - } - bconvert = true; - tenantArray.add(tenantNewObj); - } - } - - } - } - } catch (NullPointerException ex) { - - - } - - if (bconvert) - return tenantArray.toJSONString(); - else - return ""; - - } - - /** - * Check for null. - * - * @param local the local - * @return the string - */ - private static String checkForNull(String local) - { - if (local != null) - return local; - else - return ""; } } diff --git a/vid-app-common/src/main/java/org/openecomp/vid/controller/MsoController.java b/vid-app-common/src/main/java/org/openecomp/vid/controller/MsoController.java index f051ed38..56fbd4cb 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/controller/MsoController.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/controller/MsoController.java @@ -21,106 +21,80 @@ package org.openecomp.vid.controller; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -//import java.util.UUID; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Scanner; -import java.util.stream.Collectors; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.codehaus.jackson.JsonEncoding; -import org.codehaus.jackson.JsonFactory; -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonToken; +import com.fasterxml.jackson.databind.ObjectMapper; import org.glassfish.jersey.client.ClientResponse; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; -import org.openecomp.vid.domain.mso.CloudConfiguration; -import org.openecomp.vid.domain.mso.ModelInfo; -import org.openecomp.vid.domain.mso.ModelInfo.ModelType; -import org.openecomp.vid.domain.mso.RequestInfo; -import org.openecomp.vid.domain.mso.RequestParameters; +import org.openecomp.portalsdk.core.controller.RestrictedBaseController; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.util.SystemProperties; import org.openecomp.vid.model.ExceptionResponse; -import org.openecomp.vid.mso.MsoProperties; -import org.openecomp.vid.mso.MsoResponseWrapper; -import org.openecomp.vid.mso.MsoRestInterfaceFactory; -import org.openecomp.vid.mso.MsoRestInterfaceIfc; -import org.openecomp.vid.mso.MsoUtil; -import org.openecomp.vid.mso.RestObject; -import org.openecomp.vid.mso.rest.RelatedModel; +import org.openecomp.vid.mso.*; import org.openecomp.vid.mso.rest.RequestDetails; +import org.openecomp.vid.roles.RoleProvider; +import org.openecomp.vid.roles.RoleValidator; import org.springframework.http.HttpStatus; -//import org.springframework.http.ResponseEntity; -//import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.PathVariable; -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 org.springframework.web.servlet.ModelAndView; +import org.springframework.web.bind.annotation.*; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.util.SystemProperties; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.DeserializationFeature; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; /** * The Class MsoController. */ @RestController @RequestMapping("mso") -public class MsoController extends RestrictedBaseController{ - - /** The view name. */ - String viewName; - - /** The logger. */ - 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 = ""; - - /** The Constant VNF_INSTANCE_ID. */ - public final static String VNF_INSTANCE_ID = ""; - - /** - * Welcome. - * - * @param request the request - * @return the model and view - - public ModelAndView welcome(HttpServletRequest request) { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== MsoController welcome start"); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " MSO_SERVER_URL=" + - SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) ); - return new ModelAndView(getViewName()); - } - */ +public class MsoController extends RestrictedBaseController { + + /** + * The Constant SVC_INSTANCE_ID. + */ + public final static String SVC_INSTANCE_ID = ""; + /** + * The Constant VNF_INSTANCE_ID. + */ + public final static String VNF_INSTANCE_ID = ""; + /** + * The Constant dateFormat. + */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + /** + * The view name. + */ + String viewName; + /** + * The logger. + */ + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoController.class); + + /** + * Welcome. + * + * @param request the request + * @return the model and view + + public ModelAndView welcome(HttpServletRequest request) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== MsoController welcome start"); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " MSO_SERVER_URL=" + + SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) ); + return new ModelAndView(getViewName()); + } + */ /* (non-Javadoc) - * @see org.openecomp.portalsdk.core.controller.RestrictedBaseController#getViewName() + * @see org.openecomp.portalsdk.core.controller.RestrictedBaseController#getViewName() public String getViewName() { return viewName; @@ -128,504 +102,538 @@ public class MsoController extends RestrictedBaseController{ */ /* (non-Javadoc) - * @see org.openecomp.portalsdk.core.controller.RestrictedBaseController#setViewName(java.lang.String) + * @see org.openecomp.portalsdk.core.controller.RestrictedBaseController#setViewName(java.lang.String) public void setViewName(String viewName) { this.viewName = viewName; } */ - /** - * 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 createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception { - String methodName = "createSvcInstance"; - - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start" ); - + /** + * 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 createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception { + + + String methodName = "createSvcInstance"; + + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + if (!userIsPermmited(request, mso_request)) { + return new ResponseEntity(HttpStatus.FORBIDDEN); + } // mso_request = retrieveRequestObject (request, mso_request); - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); - - MsoResponseWrapper w = createInstance(mso_request, p); - // always return OK, the MSO status code is embedded in the body - - 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 createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception { - - String methodName = "createVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); - - //RequestDetails mso_request = retrieveRequestObject (request); - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VNF_INSTANCE); - - if ( p == null || p.isEmpty()) { - throw new Exception ( "Vnf instance path is not defined"); - } - // /serviceInstances/v2//vnfs - String vnf_path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId ); - MsoResponseWrapper w = createInstance(mso_request, vnf_path); - - // always return OK, the MSO status code is embedded in the body - - return ( new ResponseEntity(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 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 ); - - //RequestDetails mso_request = retrieveRequestObject (request); - - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); - - if ( p == null || p.isEmpty()) { - throw new Exception ( "Network instance path is not defined"); - } - // /serviceInstances/v2//networks/ - - String nw_path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId ); - MsoResponseWrapper w = createInstance(mso_request, nw_path); - - // always return OK, the MSO status code is embedded in the body - - return ( new ResponseEntity(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 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"); - - //RequestDetails mso_request = retrieveRequestObject (request); - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); - - if ( p == null || p.isEmpty()) { - throw new Exception ( "Volume group instance path is not defined"); - } - String path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); - path = path.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); - - MsoResponseWrapper w = createInstance(mso_request, path); - - // always return OK, the MSO status code is embedded in the body - return ( new ResponseEntity(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 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"); - //RequestDetails mso_request = retrieveRequestObject (request); - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); - - if ( p == null || p.isEmpty()) { - throw new Exception ( "VF module instance path is not defined"); - } - // /serviceInstances/v2//vnfs//vfmodules - String path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); - path = path.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); - - MsoResponseWrapper w = createInstance(mso_request, path); - - // always return OK, the MSO status code is embedded in the body - - return ( new ResponseEntity(w.getResponse(), HttpStatus.OK) ); - } - - /** - * Creates the instance. - * - * @param request the request - * @param path the path - * @return the mso response wrapper - * @throws ClientHandlerException the client handler exception - * @throws Exception the exception - */ - protected MsoResponseWrapper createInstance(RequestDetails request, String path) throws Exception { - String methodName = "createInstance"; - logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start"); - - try { - MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance(); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Post, request = (" + request + ")"); - - RestObject restObjStr = new RestObject(); - String str = new String(); - restObjStr.set(str); - restController.Post(str, request, "", path, restObjStr ); - MsoResponseWrapper w = MsoUtil.wrapResponse (restObjStr); - - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); - return w; - } 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; - } - } - - /** - * 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 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"); - - //RequestDetails mso_request = retrieveRequestObject (request); - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); - String path = p + "/" + serviceInstanceId; - MsoResponseWrapper w = deleteInstance ( mso_request, path ); - - 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(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 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"); - - //RequestDetails mso_request = retrieveRequestObject (request); - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VNF_INSTANCE); - if ( p == null || p.isEmpty()) { - throw new Exception ( "Vnf instance path is not defined"); - } - // /serviceInstances/v2//vnfs/ - String vnf_path = p.replaceFirst(SVC_INSTANCE_ID, vnfInstanceId ); - MsoResponseWrapper w = deleteInstance ( mso_request, vnf_path + "/" + vnfInstanceId ); - - // always return OK, the MSO status code is embedded in the body - return ( new ResponseEntity(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 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"); - - //RequestDetails mso_request = new RequestDetails(); - //mso_request = retrieveRequestObject (request); - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); - if ( p == null || p.isEmpty()) { - throw new Exception ( "VF Module instance path is not defined"); - } - // /serviceInstances/v2//vnfs//vfmodules - String path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId ); - path = path.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId ); - MsoResponseWrapper w = deleteInstance ( mso_request, path + "/" + vfModuleId); - - // always return OK, the MSO status code is embedded in the body - return ( new ResponseEntity(w.getResponse(), HttpStatus.OK) ); + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); + String userId = ""; + HttpSession session = request.getSession(); + System.out.println((new ObjectMapper().writeValueAsString(session.getAttribute("roles")))); + MsoResponseWrapper w = createInstance(mso_request, p); + return (new ResponseEntity(w.getResponse(), HttpStatus.OK)); + // always return OK, the MSO status code is embedded in the body - } - /** - * 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 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"); - //RequestDetails mso_request = retrieveRequestObject (request); - - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); - if ( p == null || p.isEmpty()) { - throw new Exception ( "Volume group instance path is not defined"); - } - // /serviceInstances/v2/{serviceInstanceId}/volumeGroups - String path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId ); - path = path.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId ); - MsoResponseWrapper w = deleteInstance ( mso_request, path + "/" + volumeGroupId); - - // always return OK, the MSO status code is embedded in the body - return ( new ResponseEntity(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 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"); - - //RequestDetails mso_request = retrieveRequestObject (request); - - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); - if ( p == null || p.isEmpty()) { - throw new Exception ( "Network instance path is not defined"); - } - // /serviceInstances/v2//networks - String path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId ); - MsoResponseWrapper w = deleteInstance ( mso_request, path + "/" + networkInstanceId); - - // always return OK, the MSO status code is embedded in the body - return ( new ResponseEntity(w.getResponse(), HttpStatus.OK) ); - - } - - /** - * Delete instance. - * - * @param request the request - * @param path the path - * @return the mso response wrapper - * @throws Exception the exception - */ - protected MsoResponseWrapper deleteInstance(RequestDetails request, String path) throws Exception { - String methodName = "deleteInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); - - try { - MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance(); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]"); - - RestObject restObjStr = new RestObject(); - String str = new String(); - restObjStr.set(str); - restController.Delete(str, request, "", path, restObjStr ); - MsoResponseWrapper w = MsoUtil.wrapResponse (restObjStr); - - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); - return w; - - } 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; - } - - } - - /** - * 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 getOrchestrationRequest(@PathVariable("requestId") String requestId, - HttpServletRequest request) throws Exception { - - String methodName = "getOrchestrationRequest"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); - MsoResponseWrapper w = null; - try { - MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance(); - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ); - String path = p + "/" + requestId; - - RestObject restObjStr = new RestObject(); - String str = new String(); - restObjStr.set(str); - - restController.Get(str, "", path, restObjStr); - - w = MsoUtil.wrapResponse (restObjStr); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); - // always return OK, the MSO status code is embedded in the body - - } 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; - } - // always return OK, the MSO status code is embedded in the body - return ( new ResponseEntity(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 getOrchestrationRequests(@PathVariable("filterString") String filterString, - HttpServletRequest request) throws Exception { - - String methodName = "getOrchestrationRequests"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); - MsoResponseWrapper w = null; - try { - MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance(); - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS); - String path = p + filterString; - - RestObject restObjStr = new RestObject(); - String str = new String(); - restObjStr.set(str); - - restController.Get(str, "", path, restObjStr); - - w = MsoUtil.wrapResponse (restObjStr); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); - } 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; - } - // always return OK, the MSO status code is embedded in the body - return ( new ResponseEntity(w.getResponse(), HttpStatus.OK) ); - } - - /** - * Gets the orchestration requests for svc instance. - * - * @param svc_instance_id the svc instance id - * @return the orchestration requests for svc instance - * @throws Exception the exception - */ - public MsoResponseWrapper getOrchestrationRequestsForSvcInstance (String svc_instance_id) throws Exception { - - String methodName = "getOrchestrationRequestsForSvcInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); - MsoResponseWrapper w = null; - - try { - MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance(); - String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS); - String path = p + svc_instance_id; - - RestObject restObjStr = new RestObject(); - String str = new String(); - restObjStr.set(str); - - restController.Get(str, "", path, restObjStr); - w = MsoUtil.wrapResponse (restObjStr); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); - - } 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; - } - return w; - } - - /** - * 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 { + } + + private boolean userIsPermmited(HttpServletRequest request, RequestDetails mso_request) { + + RoleValidator roleValidator = new RoleValidator(new RoleProvider().getUserRoles(request)); + boolean isPermitted = roleValidator.isMsoRequestValid(mso_request); + if (!isPermitted) { + return false; + } else { + return true; + } + } + + /** + * 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 createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception { +// if (!userIsPermmited(request, mso_request)) { + String instanceId = (String) ((Map)((Map)((ArrayList)((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("relatedInstanceList")).get(0)).get("relatedInstance")).get("instanceId"); + ResponseEntity a = new AaiController(request.getServletContext()).doGetServiceInstance(instanceId,"Service Instance id"); +// return new ResponseEntity(HttpStatus.FORBIDDEN); +// } + String methodName = "createVnf"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + //RequestDetails mso_request = retrieveRequestObject (request); + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VNF_INSTANCE); + + if (p == null || p.isEmpty()) { + throw new Exception("Vnf instance path is not defined"); + } + // /serviceInstances/v2//vnfs + String vnf_path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + MsoResponseWrapper w = createInstance(mso_request, vnf_path); + + // always return OK, the MSO status code is embedded in the body + + return (new ResponseEntity(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 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); + + //RequestDetails mso_request = retrieveRequestObject (request); + + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); + + if (p == null || p.isEmpty()) { + throw new Exception("Network instance path is not defined"); + } + // /serviceInstances/v2//networks/ + + String nw_path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + MsoResponseWrapper w = createInstance(mso_request, nw_path); + + // always return OK, the MSO status code is embedded in the body + + return (new ResponseEntity(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 createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId, + HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception { + String methodName = "createVolumeGroupInstance"; + if (!userIsPermmited(request, mso_request)) { + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + //RequestDetails mso_request = retrieveRequestObject (request); + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); + + if (p == null || p.isEmpty()) { + throw new Exception("Volume group instance path is not defined"); + } + String path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + path = path.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + + MsoResponseWrapper w = createInstance(mso_request, path); + + // always return OK, the MSO status code is embedded in the body + return (new ResponseEntity(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 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"); + if (!userIsPermmited(request, mso_request)) { + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + //RequestDetails mso_request = retrieveRequestObject (request); + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); + + if (p == null || p.isEmpty()) { + throw new Exception("VF module instance path is not defined"); + } + // /serviceInstances/v2//vnfs//vfmodules + String path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + path = path.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + + MsoResponseWrapper w = createInstance(mso_request, path); + + // always return OK, the MSO status code is embedded in the body + + return (new ResponseEntity(w.getResponse(), HttpStatus.OK)); + } + + /** + * Creates the instance. + * + * @param request the request + * @param path the path + * @return the mso response wrapper + * @throws Exception the exception + */ + protected MsoResponseWrapper createInstance(RequestDetails request, String path) throws Exception { + String methodName = "createInstance"; + logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance(); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Post, request = (" + request + ")"); + + RestObject restObjStr = new RestObject(); + String str = new String(); + restObjStr.set(str); + restController.Post(str, request, "", path, restObjStr); + MsoResponseWrapper w = MsoUtil.wrapResponse(restObjStr); + + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + return w; + } 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; + } + } + + /** + * 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 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"); + + //RequestDetails mso_request = retrieveRequestObject (request); + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); + String path = p + "/" + serviceInstanceId; + MsoResponseWrapper w = deleteInstance(mso_request, path); + + 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(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 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"); + if (!userIsPermmited(request, mso_request)) { + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + //RequestDetails mso_request = retrieveRequestObject (request); + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VNF_INSTANCE); + if (p == null || p.isEmpty()) { + throw new Exception("Vnf instance path is not defined"); + } + // /serviceInstances/v2//vnfs/ + String vnf_path = p.replaceFirst(SVC_INSTANCE_ID, vnfInstanceId); + MsoResponseWrapper w = deleteInstance(mso_request, vnf_path + "/" + vnfInstanceId); + + // always return OK, the MSO status code is embedded in the body + return (new ResponseEntity(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 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"); + if (!userIsPermmited(request, mso_request)) { + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + //RequestDetails mso_request = new RequestDetails(); + //mso_request = retrieveRequestObject (request); + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); + if (p == null || p.isEmpty()) { + throw new Exception("VF Module instance path is not defined"); + } + // /serviceInstances/v2//vnfs//vfmodules + String path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + path = path.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + MsoResponseWrapper w = deleteInstance(mso_request, path + "/" + vfModuleId); + + // always return OK, the MSO status code is embedded in the body + return (new ResponseEntity(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 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"); + if (!userIsPermmited(request, mso_request)) { + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); + if (p == null || p.isEmpty()) { + throw new Exception("Volume group instance path is not defined"); + } + // /serviceInstances/v2/{serviceInstanceId}/volumeGroups + String path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + path = path.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); + MsoResponseWrapper w = deleteInstance(mso_request, path + "/" + volumeGroupId); + + // always return OK, the MSO status code is embedded in the body + return (new ResponseEntity(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 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"); + + //RequestDetails mso_request = retrieveRequestObject (request); + if (!userIsPermmited(request, mso_request)) { + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); + if (p == null || p.isEmpty()) { + throw new Exception("Network instance path is not defined"); + } + // /serviceInstances/v2//networks + String path = p.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); + MsoResponseWrapper w = deleteInstance(mso_request, path + "/" + networkInstanceId); + + // always return OK, the MSO status code is embedded in the body + return (new ResponseEntity(w.getResponse(), HttpStatus.OK)); + + } + + /** + * Delete instance. + * + * @param request the request + * @param path the path + * @return the mso response wrapper + * @throws Exception the exception + */ + protected MsoResponseWrapper deleteInstance(RequestDetails request, String path) throws Exception { + String methodName = "deleteInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance(); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]"); + + RestObject restObjStr = new RestObject(); + String str = new String(); + restObjStr.set(str); + restController.Delete(str, request, "", path, restObjStr); + MsoResponseWrapper w = MsoUtil.wrapResponse(restObjStr); + + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + return w; + + } 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; + } + + } + + /** + * 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 getOrchestrationRequest(@PathVariable("requestId") String requestId, + HttpServletRequest request) throws Exception { + + String methodName = "getOrchestrationRequest"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + MsoResponseWrapper w = null; + try { + MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance(); + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ); + String path = p + "/" + requestId; + + RestObject restObjStr = new RestObject(); + String str = new String(); + restObjStr.set(str); + + restController.Get(str, "", path, restObjStr); + + w = MsoUtil.wrapResponse(restObjStr); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + // always return OK, the MSO status code is embedded in the body + + } 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; + } + // always return OK, the MSO status code is embedded in the body + return (new ResponseEntity(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 getOrchestrationRequests(@PathVariable("filterString") String filterString, + HttpServletRequest request) throws Exception { + + String methodName = "getOrchestrationRequests"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + MsoResponseWrapper w = null; + try { + MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance(); + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS); + String path = p + filterString; + + RestObject restObjStr = new RestObject(); + String str = new String(); + restObjStr.set(str); + + restController.Get(str, "", path, restObjStr); + + w = MsoUtil.wrapResponse(restObjStr); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + } 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; + } + // always return OK, the MSO status code is embedded in the body + return (new ResponseEntity(w.getResponse(), HttpStatus.OK)); + } + + /** + * Gets the orchestration requests for svc instance. + * + * @param svc_instance_id the svc instance id + * @return the orchestration requests for svc instance + * @throws Exception the exception + */ + public MsoResponseWrapper getOrchestrationRequestsForSvcInstance(String svc_instance_id) throws Exception { + + String methodName = "getOrchestrationRequestsForSvcInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + MsoResponseWrapper w = null; + + try { + MsoRestInterfaceIfc restController = MsoRestInterfaceFactory.getInstance(); + String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS); + String path = p + svc_instance_id; + + RestObject restObjStr = new RestObject(); + String str = new String(); + restObjStr.set(str); + + restController.Get(str, "", path, restObjStr); + w = MsoUtil.wrapResponse(restObjStr); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + + } 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; + } + return w; + } + + /** + * 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. @@ -633,129 +641,126 @@ public class MsoController extends RestrictedBaseController{ * 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()); + + 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); + e.printStackTrace(System.err); - response.setContentType("application/json; charset=UTF-8"); - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + 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()); + ExceptionResponse exceptionResponse = new ExceptionResponse(); + exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", "")); + exceptionResponse.setMessage(e.getMessage()); - response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse)); + response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse)); - response.flushBuffer(); + response.flushBuffer(); - } + } - /** - * Parses the orchestration requests for svc instance. - * - * @param resp the resp - * @return the list - * @throws ParseException the parse exception - * @throws Exception the exception - */ - @SuppressWarnings("unchecked") - public List parseOrchestrationRequestsForSvcInstance ( ClientResponse resp ) throws org.json.simple.parser.ParseException, Exception { - - String methodName = "parseOrchestrationRequestsForSvcInstance"; - - ArrayList json_list = new ArrayList(); - - String rlist_str = resp.readEntity (String.class); - logger.debug (EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + " Response string: " + rlist_str); - - JSONParser parser = new JSONParser(); - try { - Object obj = parser.parse(rlist_str); - - JSONObject jsonObject = (JSONObject) obj; - - JSONArray requestList = (JSONArray) jsonObject.get("requestList"); - - if ( requestList != null && ! (requestList.isEmpty()) ) - for ( Object container : requestList) { - - JSONObject containerJsonObj = (JSONObject) container; - //logger.debug(dateFormat.format(new Date()) + "<== " + "." + methodName + " reqJsonObj: " + containerJsonObj.toJSONString()); - JSONObject reqJsonObj = (JSONObject) containerJsonObj.get("request"); - - //logger.debug(dateFormat.format(new Date()) + "<== " + "." + methodName + " reqJsonObj.requestId: " + - // reqJsonObj.get("requestId") ); - JSONObject result = new JSONObject(); - - result.put("requestId", reqJsonObj.get ("requestId")); - if ( reqJsonObj.get("requestType") != null ) { - result.put("requestType", (reqJsonObj.get("requestType").toString())); - } - JSONObject req_status = (JSONObject)reqJsonObj.get("requestStatus"); - if ( req_status != null ) { - result.put("timestamp", (req_status.get("timestamp"))); - result.put("requestState", (req_status.get("requestState"))); - result.put("statusMessage", (req_status.get("statusMessage"))); - result.put("percentProgress", (req_status.get("percentProgress"))); - } - json_list.add (result); - } - } catch (org.json.simple.parser.ParseException pe) { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + " Parse exception: " + pe.toString()); - throw pe; - } catch (Exception e) { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + " Exception: " + e.toString()); - throw e; - } - return ( json_list ); - } - - /** - * Retrieve request object. - * - * @param request the request - * @return the request details - * @throws Exception the exception - */ - public RequestDetails retrieveRequestObject ( HttpServletRequest request, @RequestBody RequestDetails mso_request ) throws Exception { - - String methodName = "retrieveRequestObject"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start" ); - - ObjectMapper mapper = new ObjectMapper(); - //JSON from String to Object - //RequestDetails mso_request; - - try { - //mso_request = new RequestDetails(); - //mso_request = mapper.readValue(request.getInputStream(), RequestDetails.class); - } - catch ( Exception e ) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " Unable to read json object RequestDetails e=" + e.getMessage()); - throw e; - } - if ( mso_request == null) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " mso_request is null"); - throw new Exception ("RequestDetails is missing"); - } - try { - String json_req = mapper.writeValueAsString(mso_request); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " request=[" + json_req + "]"); - } - catch ( Exception e ) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " Unable to convert RequestDetails to json string e=" + e.getMessage()); - throw e; - } - return (mso_request); - } + /** + * Parses the orchestration requests for svc instance. + * + * @param resp the resp + * @return the list + * @throws Exception the exception + */ + @SuppressWarnings("unchecked") + public List parseOrchestrationRequestsForSvcInstance(ClientResponse resp) throws org.json.simple.parser.ParseException, Exception { + + String methodName = "parseOrchestrationRequestsForSvcInstance"; + + ArrayList json_list = new ArrayList(); + + String rlist_str = resp.readEntity(String.class); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + " Response string: " + rlist_str); + + JSONParser parser = new JSONParser(); + try { + Object obj = parser.parse(rlist_str); + + JSONObject jsonObject = (JSONObject) obj; + + JSONArray requestList = (JSONArray) jsonObject.get("requestList"); + + if (requestList != null && !(requestList.isEmpty())) + for (Object container : requestList) { + + JSONObject containerJsonObj = (JSONObject) container; + //logger.debug(dateFormat.format(new Date()) + "<== " + "." + methodName + " reqJsonObj: " + containerJsonObj.toJSONString()); + JSONObject reqJsonObj = (JSONObject) containerJsonObj.get("request"); + + //logger.debug(dateFormat.format(new Date()) + "<== " + "." + methodName + " reqJsonObj.requestId: " + + // reqJsonObj.get("requestId") ); + JSONObject result = new JSONObject(); + + result.put("requestId", reqJsonObj.get("requestId")); + if (reqJsonObj.get("requestType") != null) { + result.put("requestType", (reqJsonObj.get("requestType").toString())); + } + JSONObject req_status = (JSONObject) reqJsonObj.get("requestStatus"); + if (req_status != null) { + result.put("timestamp", (req_status.get("timestamp"))); + result.put("requestState", (req_status.get("requestState"))); + result.put("statusMessage", (req_status.get("statusMessage"))); + result.put("percentProgress", (req_status.get("percentProgress"))); + } + json_list.add(result); + } + } catch (org.json.simple.parser.ParseException pe) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + " Parse exception: " + pe.toString()); + throw pe; + } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + " Exception: " + e.toString()); + throw e; + } + return (json_list); + } + + /** + * Retrieve request object. + * + * @param request the request + * @return the request details + * @throws Exception the exception + */ + public RequestDetails retrieveRequestObject(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception { + + String methodName = "retrieveRequestObject"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + ObjectMapper mapper = new ObjectMapper(); + //JSON from String to Object + //RequestDetails mso_request; + + try { + //mso_request = new RequestDetails(); + //mso_request = mapper.readValue(request.getInputStream(), RequestDetails.class); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " Unable to read json object RequestDetails e=" + e.getMessage()); + throw e; + } + if (mso_request == null) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " mso_request is null"); + throw new Exception("RequestDetails is missing"); + } + try { + String json_req = mapper.writeValueAsString(mso_request); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " request=[" + json_req + "]"); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " Unable to convert RequestDetails to json string e=" + e.getMessage()); + throw e; + } + return (mso_request); + } } diff --git a/vid-app-common/src/main/java/org/openecomp/vid/controller/VidController.java b/vid-app-common/src/main/java/org/openecomp/vid/controller/VidController.java index 9972ae5d..838793a7 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/controller/VidController.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/controller/VidController.java @@ -24,18 +24,22 @@ 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.openecomp.vid.asdc.AsdcCatalogException; +import org.openecomp.vid.asdc.beans.SecureServices; import org.openecomp.vid.exceptions.VidServiceUnavailableException; import org.openecomp.vid.model.ServiceModel; +import org.openecomp.vid.roles.Role; +import org.openecomp.vid.roles.RoleProvider; +import org.openecomp.vid.roles.RoleValidator; +import org.openecomp.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 org.openecomp.vid.services.*; import javax.servlet.http.HttpServletRequest; -import java.util.Collection; +import java.util.List; import java.util.Map; //import org.openecomp.vid.model.Service; @@ -61,10 +65,15 @@ public class VidController extends RestrictedBaseController { * @throws VidServiceUnavailableException the vid service unavailable exception */ @RequestMapping(value={"/rest/models/services"}, method = RequestMethod.GET) - public Collection getServices(HttpServletRequest request) throws VidServiceUnavailableException { + public SecureServices getServices(HttpServletRequest request) throws VidServiceUnavailableException { try { + SecureServices secureServices = new SecureServices(); + RoleProvider roleProvider = new RoleProvider(); Map requestParams = request.getParameterMap(); - return service.getServices(requestParams); + List roles = new RoleProvider().getUserRoles(request); + 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); @@ -83,8 +92,9 @@ public class VidController extends RestrictedBaseController { * @throws VidServiceUnavailableException the vid service unavailable exception */ @RequestMapping(value={"/rest/models/services/{uuid}"}, method = RequestMethod.GET) - public ServiceModel getServices(@PathVariable("uuid") String uuid) throws VidServiceUnavailableException { + public ServiceModel getServices(@PathVariable("uuid") String uuid, HttpServletRequest request) throws VidServiceUnavailableException { try { +// RoleValidator roleValidator = new RoleValidator(new RoleProvider().getUserRoles(request)); return service.getService(uuid); } catch (AsdcCatalogException e) { LOG.error("Failed to retrieve service definitions from SDC", e); diff --git a/vid-app-common/src/main/java/org/openecomp/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/openecomp/vid/controller/WebConfig.java index 9a258a10..1e13d0eb 100644 --- a/vid-app-common/src/main/java/org/openecomp/vid/controller/WebConfig.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/controller/WebConfig.java @@ -4,13 +4,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.IOUtils; import org.json.JSONObject; import org.json.JSONTokener; +import org.openecomp.vid.aai.AaiClient; +import org.openecomp.vid.aai.AaiClientInterface; import org.openecomp.vid.asdc.AsdcClient; import org.openecomp.vid.asdc.local.LocalAsdcClient; import org.openecomp.vid.asdc.memory.InMemoryAsdcClient; -import org.openecomp.vid.asdc.rest.RestfulAsdcClient; import org.openecomp.vid.asdc.parser.ToscaParserImpl2; +import org.openecomp.vid.asdc.rest.RestfulAsdcClient; import org.openecomp.vid.properties.AsdcClientConfiguration; import org.openecomp.vid.properties.AsdcClientConfiguration.AsdcClientType; +import org.openecomp.vid.services.AaiService; +import org.openecomp.vid.services.AaiServiceImpl; import org.openecomp.vid.services.VidService; import org.openecomp.vid.services.VidServiceImpl; import org.springframework.context.annotation.Bean; @@ -40,11 +44,23 @@ public class WebConfig { 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()) { diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java b/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java new file mode 100644 index 00000000..f0208185 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java @@ -0,0 +1,45 @@ +/** + * + */ +package org.openecomp.vid.model; + +/** + * The Class ModelUtil. + * + */ +public class ModelUtil { + /** + * Gets the tags for the given element according to the configured namespace + * @param namespaces the namespace list from the configuration + * @param constantValue the constant portion of the tag name, i.e. resource.vf... + * @return the tags + */ + public static String[] getTags ( String[] namespaces, String constantValue ) { + String[] tags; + if ( namespaces == null || namespaces.length == 0 ) { + return null; + } + int le = namespaces.length; + tags = new String[le]; + for ( int i = 0; i < le; i++ ) { + tags[i] = namespaces[i] + constantValue; + } + return (tags); + } + /** + * Determine if a note template type matches a set of configurable tags + * @param type the node template type + * @param tags the model configurable namespaces + * @return true if type starts with a tag in the array, false otherwise + */ + public static boolean isType ( String type, String[] tags ) { + if ( (tags != null) && (tags.length > 0) ) { + for ( int i = 0; i < tags.length; i++ ) { + if ( type.startsWith (tags[i]) ) { + return (true); + } + } + } + return (false); + } +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/ProxyResponse.java b/vid-app-common/src/main/java/org/openecomp/vid/model/ProxyResponse.java new file mode 100644 index 00000000..132c54ad --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/ProxyResponse.java @@ -0,0 +1,21 @@ +package org.openecomp.vid.model; + +/** + * Created by Oren on 7/10/17. + */ +public class ProxyResponse { + + protected String errorMessage; + + protected int httpCode; + + public String getErrorMessage() { + return errorMessage; + } + + + public int getHttpCode() { + return httpCode; + } + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/Service.java b/vid-app-common/src/main/java/org/openecomp/vid/model/Service.java index f3c6e4da..c6269b97 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/model/Service.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/Service.java @@ -48,6 +48,12 @@ public class Service { /** The category. */ private String category; + + /** The Service Type. */ + private String serviceType; + + /** The Service Role */ + private String serviceRole; /** The description. */ private String description; @@ -238,6 +244,23 @@ public class Service { return (service.getUuid().equals(getUuid())); } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceRole() { + return serviceRole; + } + + public void setServiceRole(String serviceRole) { + this.serviceRole = serviceRole; + } + /*public static void extractVfModuleCustomizationUUID (Service s, String vnfCustomizationName, VfModule vfMod ) { //Look for vnfCustomizationName..vfModuleCustomizationName diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/Subscriber.java b/vid-app-common/src/main/java/org/openecomp/vid/model/Subscriber.java new file mode 100644 index 00000000..c5db6fda --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/Subscriber.java @@ -0,0 +1,26 @@ +package org.openecomp.vid.model; + + +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Created by Oren on 7/4/17. + */ +public class Subscriber { + + @JsonProperty("global-customer-id") + public String globalCustomerId; + + @JsonProperty("subscriber-name") + public String subscriberName; + + @JsonProperty("subscriber-type") + public String subscriberType; + + @JsonProperty("resource-version") + public String resourceVersion; + + + + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/SubscriberList.java b/vid-app-common/src/main/java/org/openecomp/vid/model/SubscriberList.java new file mode 100644 index 00000000..7f593e4d --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/SubscriberList.java @@ -0,0 +1,15 @@ +package org.openecomp.vid.model; + +import org.openecomp.portalsdk.core.web.support.UserUtils; + +import java.util.List; + +/** + * Created by Oren on 7/4/17. + */ +public class SubscriberList { + + public List customer; + + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/roles/EcompRole.java b/vid-app-common/src/main/java/org/openecomp/vid/roles/EcompRole.java new file mode 100644 index 00000000..5242f5aa --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/roles/EcompRole.java @@ -0,0 +1,5 @@ +package org.openecomp.vid.roles; + +public enum EcompRole { + READ; +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/roles/Role.java b/vid-app-common/src/main/java/org/openecomp/vid/roles/Role.java new file mode 100644 index 00000000..d4ded530 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/roles/Role.java @@ -0,0 +1,48 @@ +package org.openecomp.vid.roles; + + +/** + * Created by Oren on 7/1/17. + */ +public class Role { + + private EcompRole ecompRole; + + private String subscribeName; + + private String serviceType; + + private String tenant; + + public Role(EcompRole ecompRole, String serviceName, String serviceType, String tenant) { + this.ecompRole = ecompRole; + this.subscribeName = serviceName; + this.serviceType = serviceType; + this.tenant = tenant; + } + + public EcompRole getEcompRole() { + return ecompRole; + } + + + public String getSubscribeName() { + return subscribeName; + } + + public void setSubscribeName(String subscribeName) { + this.subscribeName = subscribeName; + } + + public String getServiceType() { + return serviceType; + } + + + public String getTenant() { + return tenant; + } + + + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/roles/RoleProvider.java b/vid-app-common/src/main/java/org/openecomp/vid/roles/RoleProvider.java new file mode 100644 index 00000000..99645a10 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/roles/RoleProvider.java @@ -0,0 +1,62 @@ +package org.openecomp.vid.roles; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.web.support.UserUtils; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * Created by Oren on 7/1/17. + */ +public class RoleProvider { + + private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(RoleProvider.class); + final String readPermissionString = "read"; + + public static List extractRoleFromSession(HttpServletRequest request) { + + return new ArrayList(); + + } + + public List getUserRoles(HttpServletRequest request) { + List roleList = new ArrayList<>(); + HashMap roles = UserUtils.getRoles(request); + for (Object role : roles.keySet()) { + org.openecomp.portalsdk.core.domain.Role sdkRol = (org.openecomp.portalsdk.core.domain.Role) roles.get(role); + try { + if (sdkRol.getName().contains(readPermissionString)) + continue; + String[] roleParts = splitRole((sdkRol.getName())); + roleList.add(createRoleFromStringArr(roleParts)); + } catch (Exception e) { + LOG.error("Failed to parse permission", e); + + } + } + + return roleList; + } + + public String[] splitRole(String roleAsString) { + return roleAsString.split("_"); + } + + public boolean userPermissionIsReadOnly(List roles) { + + return (!(roles.size() > 0)); + } + + public Role createRoleFromStringArr(String[] roleParts) { + if (roleParts.length > 2) { + return new Role(EcompRole.READ, roleParts[0], roleParts[1], roleParts[2]); + } else { + return new Role(EcompRole.READ, roleParts[0], roleParts[1], null); + } + } + +} + diff --git a/vid-app-common/src/main/java/org/openecomp/vid/roles/RoleValidator.java b/vid-app-common/src/main/java/org/openecomp/vid/roles/RoleValidator.java new file mode 100644 index 00000000..e26c5231 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/roles/RoleValidator.java @@ -0,0 +1,57 @@ +package org.openecomp.vid.roles; + +import org.openecomp.vid.mso.rest.RequestDetails; + +import java.util.List; +import java.util.Map; + +/** + * Created by Oren on 7/12/17. + */ +public class RoleValidator { + + private List userRoles; + + public RoleValidator(List roles) { + this.userRoles = roles; + } + + public boolean isSubscriberPermitted(String subscriberName) { + for (Role role : userRoles) { + if (role.getSubscribeName().equals(subscriberName)) + return true; + } + return false; + } + + public boolean isServicePermitted(String subscriberName, String serviceType) { + for (Role role : userRoles) { + if (role.getSubscribeName().equals(subscriberName) && role.getServiceType().equals(serviceType)) + return true; + } + return false; + } + + public boolean isMsoRequestValid(RequestDetails mso_request) { + try { + String globalSubscriberIdRequested = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("subscriberInfo")).get("globalSubscriberId"); + String serviceType = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("requestParameters")).get("subscriptionServiceType"); + return isServicePermitted(globalSubscriberIdRequested, serviceType); + } catch (Exception e) { + //Until we'll get the exact information regarding the tenants and the global customer id, we'll return true on unknown requests to mso + return true; + } +// return false; + } + + public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenant) { + for (Role role : userRoles) { + if (role.getSubscribeName().equals(globalCustomerId) + && role.getServiceType().equals(serviceType) + && (role.getTenant() == null || role.getTenant().equals(tenant))) { + return true; + } + } + return false; + } +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/AaiService.java b/vid-app-common/src/main/java/org/openecomp/vid/services/AaiService.java new file mode 100644 index 00000000..274419fb --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/AaiService.java @@ -0,0 +1,25 @@ +package org.openecomp.vid.services; + +import org.openecomp.vid.aai.AaiResponse; +import org.openecomp.vid.aai.SubscriberFilteredResults; +import org.openecomp.vid.aai.model.AaiGetTenatns.GetTenantsResponse; +import org.openecomp.vid.roles.RoleValidator; + +import java.util.List; + +/** + * Created by Oren on 7/4/17. + */ +public interface AaiService { + + + SubscriberFilteredResults getFullSubscriberList(RoleValidator roleValidator); + + AaiResponse getSubscriberData(String subscriberId, RoleValidator roleValidator); + + AaiResponse getServices(RoleValidator roleValidator); + + AaiResponse getAaiZones(); + + AaiResponse getTenants(String globalCustomerId, String serviceType, RoleValidator roleValidator); +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java new file mode 100644 index 00000000..38b670fe --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java @@ -0,0 +1,70 @@ +package org.openecomp.vid.services; + +import org.ecomp.aai.model.AaiAICZones.AicZones; +import org.openecomp.vid.aai.*; +import org.openecomp.vid.aai.model.AaiGetServicesRequestModel.*; +import org.openecomp.vid.aai.model.AaiGetTenatns.GetTenantsResponse; +import org.openecomp.vid.model.*; +import org.openecomp.vid.roles.RoleValidator; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +/** + * Created by Oren on 7/4/17. + */ +public class AaiServiceImpl implements AaiService { + + + @Autowired + private AaiClientInterface aaiClient; + + + @Override + public SubscriberFilteredResults getFullSubscriberList(RoleValidator roleValidator) { + AaiResponse subscriberResponse = aaiClient.getAllSubscribers(); + SubscriberFilteredResults subscriberFilteredResults = + new SubscriberFilteredResults(roleValidator,subscriberResponse.getT(), + subscriberResponse.getErrorMessage(), + subscriberResponse.getHttpCode()); + + return subscriberFilteredResults; + } + + @Override + public AaiResponse getSubscriberData(String subscriberId, RoleValidator roleProvider) { + AaiResponse subscriberResponse = aaiClient.getSubscriberData(subscriberId); + String subscriberGlobalId = subscriberResponse.getT().globalCustomerId; + for (ServiceSubscription serviceSubscription : subscriberResponse.getT().serviceSubscriptions.serviceSubscription) { + String serviceType = serviceSubscription.serviceType; + serviceSubscription.isPermitted = roleProvider.isServicePermitted(subscriberGlobalId,serviceType);; + } + return subscriberResponse; + + } + + @Override + public AaiResponse getServices(RoleValidator roleValidator) { + AaiResponse subscriberResponse = aaiClient.getServices(); + for (org.openecomp.vid.aai.model.AaiGetServicesRequestModel.Service service :subscriberResponse.getT().service){ + service.isPermitted = true; + } + return subscriberResponse; + } + + @Override + public AaiResponse getTenants(String globalCustomerId, String serviceType, RoleValidator roleValidator) { + AaiResponse aaiGetTenantsResponse = aaiClient.getTenants(globalCustomerId,serviceType); + GetTenantsResponse[] tenants = aaiGetTenantsResponse.getT(); + for (int i=0;i response = aaiClient.getAllAicZones(); + return response; + } +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java b/vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java index 9844842f..f647af45 100644 --- a/vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java @@ -14,9 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.nio.file.Path; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.Map; -import java.util.UUID; +import java.util.*; /** * The Class VidController. diff --git a/vid-app-common/src/main/resources/csar3933948645405128424.zip b/vid-app-common/src/main/resources/csar3933948645405128424.zip new file mode 100644 index 00000000..b92d5339 Binary files /dev/null and b/vid-app-common/src/main/resources/csar3933948645405128424.zip differ diff --git a/vid-app-common/src/main/resources/pnf.csar b/vid-app-common/src/main/resources/pnf.csar new file mode 100644 index 00000000..eb424846 Binary files /dev/null and b/vid-app-common/src/main/resources/pnf.csar differ diff --git a/vid-app-common/src/main/resources/roles.json b/vid-app-common/src/main/resources/roles.json new file mode 100644 index 00000000..159be82f --- /dev/null +++ b/vid-app-common/src/main/resources/roles.json @@ -0,0 +1,8 @@ +{ + "roles": [ + "VID_Subscriber_serviceType1_Tenant1", + "VID_Subscriber_serviceType1_Tenant2", + "read_motorola_epost_tow", + "read_motorola_epost" + ] +} \ No newline at end of file diff --git a/vid-app-common/src/main/resources/sdcservices.json b/vid-app-common/src/main/resources/sdcservices.json index 9ef37c30..e80caa66 100644 --- a/vid-app-common/src/main/resources/sdcservices.json +++ b/vid-app-common/src/main/resources/sdcservices.json @@ -1,22 +1,39 @@ { "services": [ { - "uuid": "f430728a-4530-42be-a577-1206b9484cef", + "uuid": "48a52540-8772-4368-9cdb-1f124ea5c931", "invariantUUID": "f430728a-4530-42be-a577-1206b9484cef", - "name": "1707vidnf", + "name": "4-27_vMME_Service", "version": "1.0", "toscaModelURL": "./service-vf-csar.zip", "category": "Mobility", "lifecycleState": "CERTIFIED", - "lastUpdaterUserId": "sa997j", - "distributionStatus": "DISTRIBUTED" + "lastUpdaterUserId": "rg276b", + "lastUpdaterFullName": null, + "distributionStatus": "DISTRIBUTED", + "artifacts": null, + "resources": null + }, + { + "uuid": "cb49608f-5a24-4789-b0f7-2595473cb997", + "invariantUUID": "0311f998-9268-4fd6-bbba-afff15087b72", + "name": "4-27_vMME_Service", + "version": "1.0", + "toscaModelURL": "./service-vl-csar.zip", + "category": "Mobility", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rg276b", + "lastUpdaterFullName": null, + "distributionStatus": "DISTRIBUTED", + "artifacts": null, + "resources": null }, { - "uuid": "f430728a-4530-42be-a577-1206b9484cef", + "uuid": "73e1322a-8a9a-49dc-9558-b0c5c5770e4a", "invariantUUID": "f430728a-4530-42be-a577-1206b9484cef", "name": "4-27_vMME_Service", "version": "1.0", - "toscaModelURL": "./service-vf-csar.zip", + "toscaModelURL": "./pnf.csar", "category": "Mobility", "lifecycleState": "CERTIFIED", "lastUpdaterUserId": "rg276b", diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js index e7cbc486..f88ee9c3 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js @@ -50,7 +50,8 @@ appDS2.constant("COMPONENT", (function() { SDN_L3_BONDING : "SDN-L3-BONDING", SDN_ETHERNET_INTERNET : "SDN-ETHERNET-INTERNET", SERVICE : "service", - SERVICE_TYPE : "serviceType", + OLDVERSION : 'oldversion', + SERVICE_TYPE : "serviceType", SHOW_COMPONENT_DETAILS : "showComponentDetails", STATUS : "status", SUBSCRIBER_NAME : "subscriberName", @@ -65,9 +66,10 @@ appDS2.constant("COMPONENT", (function() { VNF_ROLE : "vnfRole", VNF_TYPE : "vnfType", VOLUME_GROUP : "volumeGroup", - - - // IDs + IS_PERMITTED: "is-permitted", + + + // IDs CIDR_MASK_1 : "255.255.255.000", //COMPONENT_LIST_NAMED_QUERY_ID : "ed0a0f5b-cf79-4784-88b2-911cd726cd3d", CUSTOMER_ID_1 : "icore9883749", @@ -96,7 +98,8 @@ appDS2.constant("COMPONENT", (function() { ASSIGN : "?r=", AAI_GET_SERVICE_INSTANCE_PATH : "aai_get_service_instance/", AAI_GET_SERVICES : "aai_get_services", - AAI_GET_SERVICES_BY_TYPE : "aai_get_models_by_service_type", + AAI_GET_AIC_ZONES :"aai_get_aic_zones", + AAI_GET_SERVICES_BY_TYPE : "aai_get_models_by_service_type", AAI_GET_TENANTS : "aai_get_tenants/", AAI_SUB_DETAILS_PATH : "aai_sub_details/", AAI_SUB_VIEWEDIT_PATH : "aai_sub_viewedit", @@ -128,8 +131,9 @@ appDS2.constant("COMPONENT", (function() { SUBDETAILS_SELECTEDSUBSCRIBER : "#subdetails?selectedSubscriber=", SUBSCRIBERNAME_SUB_PATH : "&subscriberName=", WELCOME_PATH : "welcome.htm", - - //Template Urls + IS_PERMITTED_SUB_PATH: "&isPermitted=", + + //Template Urls AAI_GET_SUBS_URL : "app/vid/scripts/view-models/aaiGetSubs.htm", AAI_GET_SUBSCRIBER_URL : "app/vid/scripts/view-models/aaiGetSubscriberList.htm", AAI_SERVICE_TYPES_URL : "app/vid/scripts/view-models/aaiServiceTypes.htm", diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js index 03ec788b..9d337fa1 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js @@ -20,116 +20,122 @@ "use strict"; -appDS2.factory("FIELD", [ "PARAMETER", function(PARAMETER) { +appDS2.factory("FIELD", ["PARAMETER", function (PARAMETER) { /* * ID values are typically used internally. */ var ID = { - AVAILABLE_VOLUME_GROUP : "availableVolumeGroup", - INSTANCE_NAME : "instanceName", - LCP_REGION : "lcpRegion", - LCP_REGION_TEXT : "lcpRegionText", - PRODUCT_FAMILY : "productFamily", - SERVICE_TYPE : "serviceType", - SUBSCRIBER_NAME : "subscriberName", - SUPPRESS_ROLLBACK : "suppressRollback", - TENANT : "tenant", - VNF_TARGETPROVSTATUS : "target", - - AAI_GET_FULL_SUBSCRIBERS : "aai_get_full_subscribers", - AAI_REFRESH_FULL_SUBSCRIBERS : "aai_refresh_full_subscribers", - AAI_GET_SERVICES : "aai_get_services", - AAI_GET_SUBSCRIBERS : "aai_get_subscribers", - AAI_GET_TENTANTS : "aai_get_tenants", - AAI_REFRESH_SUBSCRIBERS : "aai_refresh_subscribers", - AAI_SUB_DETAILS : "aai_sub_details", - AAI_SUB_VIEWEDIT : "aai_sub_viewedit", - ANGULAR_UI_TREE_COLLAPSEALL : "angular-ui-tree:collapse-all", - ANGULAR_UI_TREE_EXPANDALL : "angular-ui-tree:expand-all", - CATEGORY : "category", - COLOR_8F8 : "#8F8", - COLOR_F88 : "#F88", - COLOR_NONE : "none", - CUSTOMER : "customer", - CUSTOMIZATION_UUID : "customizationUuid", - DESCRIPTION : "description", - GENERIC_VNF : "generic-vnf", - GLOBAL_CUSTOMER_ID : "global-customer-id", - GLOBAL_CUST_ID : "globalCustomerId", - IN_MAINT : "in-maint", - INVENTORY_RESPONSE_ITEMS : "inventory-response-items", - INVENTORY_RESPONSE_ITEM : "inventory-response-item", - L3_NETWORK : "l3-network", - SUB_NET : "subnet", - SUBNET_NAME : "subnet-name", - SUBNET_ID : "subnet-id", - GATEWAY_ADDRESS : "gateway-address", - NETWORK_START_ADDRESS : "network-start-address", - CIDR_MASK : "cidr-mask", - MODEL_CUSTOMIZATION_ID : "model-customization-id", - MODEL_CUSTOMIZATION_NAME : "modelCustomizationName", - MODEL_INVARIANT_ID : "modelInvariantId", - MODEL_INVAR_ID : "model-invariant-id", - MODEL_NAME : "modelName", - MODEL_NAME_VERSION_ID : "modelNameVersionId", - MODEL_VERSION : "modelVersion", - MODEL_VERSION_ID : "model-version-id", - NETWORK_NAME : "network-name", - NETWORK_ID : "network-id", - NETWORK_TYPE : "network-type", - NETWORKS : "networks", - OPERATIONAL_STATUS : "operational-status", - ORCHESTRATION_STATUS : "orchestration-status", - PERCENT_PROGRESS : "precentProgress", - PERSONA_MODEL_ID : "persona-model-id", - PERSONA_MODEL_VERSION : "persona-model-version", - PERSONA_MODEL_CUSTOMIZATION_ID : "persona-model-customization-id", - PROV_STATUS : "prov-status", - REQUEST : "request", - REQUEST_ID : "requestId", - REQUEST_LIST : "requestList", - REQUEST_TYPE : "requestType", - REQUEST_REFERENCES : "requestReferences", - REQUEST_STATE : "requestState", - REQUEST_STATUS : "requestStatus", - RESOURCE_LINK : "resource-link", - RESULT_DATA : "result-data", - SERVICE_DESCRIPTION : "service-description", - SERVICE_ID : "service-id", - SERVICE_INSTANCE : "service-instance", - SERVICE_INSTANCES : "service-instances", - SERVICE_INSTANCE_ID : "service-instance-id", - SERVICE_INSTANCE_NAME : "service-instance-name", - SERVICE_SUBSCRIPTION : "service-subscription", - SERVICE_SUBSCRIPTIONS : "service-subscriptions", - SERVICETYPE : "service-type", - STATUS_MESSAGE : "statusMessage", - SUBNAME : "subscriber-name", - TIMESTAMP : "timestamp", - VF_MODULE : "vf-module", - VF_MODULES : "vfModules", - VF_MODULE_ID : "vf-module-id", - VF_MODULE_NAME : "vf-module-name", - VID : "VID", - VNF_ID : "vnf-id", - VNF_NAME : "vnf-name", - VNF_TYPE : "vnf-type", - VNFS : "vnfs", - AVAILABLEVOLUMEGROUPS : "availableVolumeGroups", - VOLUMEGROUPS : "volumeGroups", - VOLUME_GROUP : "volume-group", - VOLUME_GROUP_ID : "volume-group-id", - VOLUME_GROUP_NAME : "volume-group-name", - SDN_C_PRELOAD : "sdncPreload", - UPLOAD_SUPPLEMENTORY_DATA_FILE : "uploadSupplementoryDataFile", - SUPPLEMENTORY_DATA_FILE : "supplementoryDataFile" + AVAILABLE_VOLUME_GROUP: "availableVolumeGroup", + INSTANCE_NAME: "instanceName", + LCP_REGION: "lcpRegion", + LCP_REGION_TEXT: "lcpRegionText", + PRODUCT_FAMILY: "productFamily", + AIC_ZONES : "aic_zone", + SERVICE_TYPE: "serviceType", + SERVICE_ROLE: "serviceRole", + SUBSCRIBER_NAME: "subscriberName", + SUPPRESS_ROLLBACK: "suppressRollback", + TENANT: "tenant", + VNF_TARGETPROVSTATUS: "target", + + AAI_GET_FULL_SUBSCRIBERS: "aai_get_full_subscribers", + AAI_REFRESH_FULL_SUBSCRIBERS: "aai_refresh_full_subscribers", + AAI_GET_SERVICES: "aai_get_services", + AAI_GET_SUBSCRIBERS: "aai_get_subscribers", + AAI_GET_TENTANTS: "aai_get_tenants", + AAI_REFRESH_SUBSCRIBERS: "aai_refresh_subscribers", + AAI_SUB_DETAILS: "aai_sub_details", + AAI_SUB_VIEWEDIT: "aai_sub_viewedit", + ANGULAR_UI_TREE_COLLAPSEALL: "angular-ui-tree:collapse-all", + ANGULAR_UI_TREE_EXPANDALL: "angular-ui-tree:expand-all", + CATEGORY: "category", + COLOR_8F8: "#8F8", + COLOR_F88: "#F88", + COLOR_NONE: "none", + CUSTOMER: "customer", + CUSTOMIZATION_UUID: "customizationUuid", + DESCRIPTION: "description", + GENERIC_VNF: "generic-vnf", + GLOBAL_CUSTOMER_ID: "global-customer-id", + GLOBAL_CUST_ID: "globalCustomerId", + IN_MAINT: "in-maint", + INVENTORY_RESPONSE_ITEMS: "inventory-response-items", + INVENTORY_RESPONSE_ITEM: "inventory-response-item", + L3_NETWORK: "l3-network", + SUB_NET: "subnet", + SUBNET_NAME: "subnet-name", + SUBNET_ID: "subnet-id", + GATEWAY_ADDRESS: "gateway-address", + NETWORK_START_ADDRESS: "network-start-address", + CIDR_MASK: "cidr-mask", + MODEL_CUSTOMIZATION_ID: "model-customization-id", + MODEL_CUSTOMIZATION_NAME: "modelCustomizationName", + MODEL_INVARIANT_ID: "modelInvariantId", + MODEL_INVAR_ID: "model-invariant-id", + MODEL_NAME: "modelName", + MODEL_NAME_VERSION_ID: "modelNameVersionId", + MODEL_VERSION: "modelVersion", + MODEL_VERSION_ID: "model-version-id", + NETWORK_NAME: "network-name", + NETWORK_ID: "network-id", + NETWORK_TYPE: "network-type", + NETWORKS: "networks", + OPERATIONAL_STATUS: "operational-status", + ORCHESTRATION_STATUS: "orchestration-status", + PERCENT_PROGRESS: "precentProgress", + PERSONA_MODEL_ID: "persona-model-id", + PERSONA_MODEL_VERSION: "persona-model-version", + PERSONA_MODEL_CUSTOMIZATION_ID: "persona-model-customization-id", + PROV_STATUS: "prov-status", + REQUEST: "request", + REQUEST_ID: "requestId", + REQUEST_LIST: "requestList", + REQUEST_TYPE: "requestType", + REQUEST_REFERENCES: "requestReferences", + REQUEST_STATE: "requestState", + REQUEST_STATUS: "requestStatus", + RESOURCE_LINK: "resource-link", + RESULT_DATA: "result-data", + SERVICE_DESCRIPTION: "service-description", + SERVICE_ID: "service-id", + SERVICE_INSTANCE: "service-instance", + SERVICE_INSTANCES: "service-instances", + SERVICE_INSTANCE_ID: "service-instance-id", + SERVICE_INSTANCE_NAME: "service-instance-name", + SERVICE_SUBSCRIPTION: "service-subscription", + SERVICE_SUBSCRIPTIONS: "service-subscriptions", + SERVICETYPE: "service-type", + STATUS_MESSAGE: "statusMessage", + SUBNAME: "subscriber-name", + IS_PERMITTED: "is-permitted", + TIMESTAMP: "timestamp", + VF_MODULE: "vf-module", + VF_MODULES: "vfModules", + VF_MODULE_ID: "vf-module-id", + VF_MODULE_NAME: "vf-module-name", + VID: "VID", + VNF_ID: "vnf-id", + VNF_NAME: "vnf-name", + VNF_TYPE: "vnf-type", + VNFS: "vnfs", + AVAILABLEVOLUMEGROUPS: "availableVolumeGroups", + VOLUMEGROUPS: "volumeGroups", + VOLUME_GROUP: "volume-group", + VOLUME_GROUP_ID: "volume-group-id", + VOLUME_GROUP_NAME: "volume-group-name", + SDN_C_PRELOAD: "sdncPreload", + UPLOAD_SUPPLEMENTORY_DATA_FILE: "uploadSupplementoryDataFile", + SUPPLEMENTORY_DATA_FILE: "supplementoryDataFile", + ZONE_ID:"zone-id", + ZONE_NAME:"zone-name", + }; var KEY = { - LCP_REGION_TEXT : "AAIAIC25" + LCP_REGION_TEXT: "AAIAIC25" }; - + /* * NAME values are displayed on GUI pages. */ @@ -150,6 +156,7 @@ appDS2.factory("FIELD", [ "PARAMETER", function(PARAMETER) { MODEL_VNF_CODE: "NF Naming Code", MODEL_CUSTOMIZATION_NAME: "Resource Name", PRODUCT_FAMILY : "Product Family", + AIC_ZONES: "AIC Zone", RESOURCE_DESCRIPTION : "Resource Description", RESOURCE_NAME : "Resource Name", SERVICE_CATEGORY : "Service Category", @@ -163,9 +170,10 @@ appDS2.factory("FIELD", [ "PARAMETER", function(PARAMETER) { SERVICE_UUID : "Service UUID", SERVICE_VERSION : "Service Version", SUBSCRIBER_NAME : "Subscriber Name", + MOBILITY : "Mobility", SUPPRESS_ROLLBACK : "Suppress Rollback on Failure", SDN_C_PRELOAD : "SDN-C Pre-Load", - UPLOAD_SUPPLEMENTORY_DATA_FILE : "Upload Supplementory Data file", + UPLOAD_SUPPLEMENTORY_DATA_FILE : "Upload Supplementary Data file", SUPPLEMENTORY_DATA_FILE : "Supplementory Data file (JSON format)", TENANT : "Tenant", USER_SERVICE_INSTANCE_NAME : "User Service Instance Name", @@ -189,74 +197,75 @@ appDS2.factory("FIELD", [ "PARAMETER", function(PARAMETER) { * PROMPT values are initial values displayed in select lists. */ var PROMPT = { - AVAILABLE_VOLUME_GROUP : "Select Volume Group", - DEFAULT_A : "A default", - DEFAULT_B : "B default", - LCP_REGION : "Select LCP Region", - NO_SERVICE_INSTANCE : "No Service Instance Found", - NO_SERVICE_SUB : "No Service Subscription Found", - PRODUCT_FAMILY : "Select Product Family", - REGION : "Please choose a region", - SERVICE_TYPE : "Select Service Type", - SUBSCRIBER_NAME : "Select Subscriber Name", - TARGETPROVSTATUS : "Select Target Prov Status", - TENANT : "Select Tenant Name", - TEXT_INPUT : "Enter data", - SELECT_SERVICE : "Select a service type", - SELECT_SUB : "Select a subscriber name", - FETCHING_SUBS : " Fetching subscriber list from A&AI", - REFRESH_SUB_LIST : "Refreshing subscriber list from A&AI...", - VAR_DESCRIPTION_A : "This variable is 'a'", - VAR_DESCRIPTION_B : "This variable is 'b'", - + AVAILABLE_VOLUME_GROUP: "Select Volume Group", + DEFAULT_A: "A default", + DEFAULT_B: "B default", + LCP_REGION: "Select LCP Region", + NO_SERVICE_INSTANCE: "No Service Instance Found", + NO_SERVICE_SUB: "No Service Subscription Found", + PRODUCT_FAMILY: "Select Product Family", + AIC_ZONES: "Select AIC Zone", + REGION: "Please choose a region", + SERVICE_TYPE: "Select Service Type", + SUBSCRIBER_NAME: "Select Subscriber Name", + TARGETPROVSTATUS: "Select Target Prov Status", + TENANT: "Select Tenant Name", + TEXT_INPUT: "Enter data", + SELECT_SERVICE: "Select a service type", + SELECT_SUB: "Select a subscriber name", + FETCHING_SUBS: " Fetching subscriber list from A&AI", + REFRESH_SUB_LIST: "Refreshing subscriber list from A&AI...", + VAR_DESCRIPTION_A: "This variable is 'a'", + VAR_DESCRIPTION_B: "This variable is 'b'", + }; - + var STATUS = { - // Status - ALL : "ALL", - COMPLETE : "Complete", - DONE : "Done", - ERROR : "Error", - FAILED : "Failed", - FAILED_SERVICE_MODELS_ASDC : "Failed to get service models from SDC.", - FETCHING_SERVICE_TYPES : "Fetching service types list from A&AI", - FETCHING_SERVICE_CATALOG : "Fetching service catalog from AAI. Please wait.", - FETCHING_SERVICE_CATALOG_ASDC : "Fetching service catalog from SDC. Please wait.", - FETCHING_SUB_DETAILS : "Fetching subscriber details from A&AI for ", - FETCHING_SERVICE_INST_DATA : "Fetching service instance data from A&AI for service-instance-id=", - FETCHING_SUBSCRIBER_LIST_AAI : "Fetching subscriber list from A&AI...", - IN_PROGRESS : "In Progress", - IS_SUCCESSFUL : " isSuccessful: ", - MSO_FAILURE : "msoFailure", - NONE : "None", - NOT_FOUND : "Not Found", - NO_SERVICE_SUBSCRIPTION_FOUND : "No Service Subscription Found", - SUBMITTING_REQUEST : "Submitting Request", - SUCCESS_VNF_PROV_STATUS : "Successfully set the VNF's Prov_Status to ", - UNLOCKED : "Unlocked", - + // Status + ALL: "ALL", + COMPLETE: "Complete", + DONE: "Done", + ERROR: "Error", + FAILED: "Failed", + FAILED_SERVICE_MODELS_ASDC: "Failed to get service models from SDC.", + FETCHING_SERVICE_TYPES: "Fetching service types list from A&AI", + FETCHING_SERVICE_CATALOG: "Fetching service catalog from AAI. Please wait.", + FETCHING_SERVICE_CATALOG_ASDC: "Fetching service catalog from SDC. Please wait.", + FETCHING_SUB_DETAILS: "Fetching subscriber details from A&AI for ", + FETCHING_SERVICE_INST_DATA: "Fetching service instance data from A&AI for service-instance-id=", + FETCHING_SUBSCRIBER_LIST_AAI: "Fetching subscriber list from A&AI...", + IN_PROGRESS: "In Progress", + IS_SUCCESSFUL: " isSuccessful: ", + MSO_FAILURE: "msoFailure", + NONE: "None", + NOT_FOUND: "Not Found", + NO_SERVICE_SUBSCRIPTION_FOUND: "No Service Subscription Found", + SUBMITTING_REQUEST: "Submitting Request", + SUCCESS_VNF_PROV_STATUS: "Successfully set the VNF's Prov_Status to ", + UNLOCKED: "Unlocked", + }; - + var STYLE = { - TABLE : "width: auto; margin: 0 auto; border-collapse: collapse; border: none;", - NAME : "width: 220px; text-align: left; vertical-align: middle; font-weight: bold; padding: 3px 5px; border: none;", - VALUE : "width: 400px; text-align: left; vertical-align: middle; padding: 3px 5px; border: none;", - CHECKBOX_VALUE : "width: 400px; text-align: center; vertical-align: middle; padding: 3px 5px; border: none;", - TEXT_INPUT : "height: 25px; padding: 2px 5px;", - CHECKBOX_INPUT : "height: 18px; width: 18px; padding: 2px 5px;", - SELECT : "height: 25px; padding: 2px; text-align: center;", - REQUIRED_LABEL : "width: 25px; padding: 5px 10px 10px 5px;", - - DISABLED : "disabled", - BTN_INACTIVE : "button--inactive", - BTN_PRIMARY : "button--primary", - BTN_TYPE : "btn-type", - MSO_CTRL_BTN : "div[ng-controller=msoCommitController] button", - PRIMARY : "primary", - PROGRESS_BAR_INFO : "progress-bar progress-bar-info", - PROGRESS_BAR_SUCCESS : "progress-bar progress-bar-success", + TABLE: "width: auto; margin: 0 auto; border-collapse: collapse; border: none;", + NAME: "width: 220px; text-align: left; vertical-align: middle; font-weight: bold; padding: 3px 5px; border: none;", + VALUE: "width: 400px; text-align: left; vertical-align: middle; padding: 3px 5px; border: none;", + CHECKBOX_VALUE: "width: 400px; text-align: center; vertical-align: middle; padding: 3px 5px; border: none;", + TEXT_INPUT: "height: 25px; padding: 2px 5px;", + CHECKBOX_INPUT: "height: 18px; width: 18px; padding: 2px 5px;", + SELECT: "height: 25px; padding: 2px; text-align: center;", + REQUIRED_LABEL: "width: 25px; padding: 5px 10px 10px 5px;", + + DISABLED: "disabled", + BTN_INACTIVE: "button--inactive", + BTN_PRIMARY: "button--primary", + BTN_TYPE: "btn-type", + MSO_CTRL_BTN: "div[ng-controller=msoCommitController] button", + PRIMARY: "primary", + PROGRESS_BAR_INFO: "progress-bar progress-bar-info", + PROGRESS_BAR_SUCCESS: "progress-bar progress-bar-success", } - + var ERROR = { AAI : "A&AI failure - see log below for details", AAI_ERROR : "A&AI Error", @@ -280,7 +289,8 @@ appDS2.factory("FIELD", [ "PARAMETER", function(PARAMETER) { SERVICE_INST_DNE : "That service instance does not exist. Please try again.", SYSTEM_FAILURE : "System failure", INVALID_DATA_FORMAT : 'Invalid data format.Please check your file content whether it is not in json or not.', - + MISSING_FILE : 'Please Select JSON File.', + } /* @@ -289,143 +299,150 @@ appDS2.factory("FIELD", [ "PARAMETER", function(PARAMETER) { */ var PARAMETER = { - AVAILABLE_VOLUME_GROUP : { - name : NAME.AVAILABLE_VOLUME_GROUP, - id : ID.AVAILABLE_VOLUME_GROUP, - type : PARAMETER.SELECT, - prompt : PROMPT.AVAILABLE_VOLUME_GROUP, - isRequired : true - }, - INSTANCE_NAME : { - name : NAME.INSTANCE_NAME, - id : ID.INSTANCE_NAME, - isRequired : true - }, - LCP_REGION : { - name : NAME.LCP_REGION, - id : ID.LCP_REGION, - type : PARAMETER.SELECT, - prompt : PROMPT.LCP_REGION, - isRequired : true - }, - VNF_TARGET_PROVSTATUS : { - name : NAME.VNF_Target_Prov_Status, - id : ID.VNF_TARGETPROVSTATUS, - type : PARAMETER.SELECT, - prompt : PROMPT.TARGETPROVSTATUS, - isRequired : true - }, - LCP_REGION_TEXT_HIDDEN : { - id : ID.LCP_REGION_TEXT, - isVisible : false - }, - LCP_REGION_TEXT_VISIBLE : { - name : NAME.LCP_REGION_TEXT, - id : ID.LCP_REGION_TEXT, - isRequired : true, - isVisible : true - }, - PRODUCT_FAMILY : { - name : NAME.PRODUCT_FAMILY, - id : ID.PRODUCT_FAMILY, - type : PARAMETER.SELECT, - prompt : PROMPT.PRODUCT_FAMILY, - isRequired : true - }, - SERVICE_TYPE : { - name : NAME.SERVICE_TYPE, - id : ID.SERVICE_TYPE, - type : PARAMETER.SELECT, - prompt : PROMPT.SERVICE_TYPE, - isRequired : true - }, - SERVICE_TYPE_DISABLED : { - name : NAME.SERVICE_TYPE, - id : ID.SERVICE_TYPE, - type : PARAMETER.SELECT, - isEnabled : false, - isRequired : true - }, - SUPPRESS_ROLLBACK : { - name : NAME.SUPPRESS_ROLLBACK, - id : ID.SUPPRESS_ROLLBACK, - type : PARAMETER.BOOLEAN, - value : false - }, - SDN_C_PRELOAD_CHECKED : { - name : NAME.SDN_C_PRELOAD, - id : ID.SDN_C_PRELOAD, - type : PARAMETER.CHECKBOX, - value : true, - isVisible:true, - isRequired:false - }, - SDN_C_PRELOAD_UNCHECKED : { - name : NAME.SDN_C_PRELOAD, - id : ID.SDN_C_PRELOAD, - type : PARAMETER.CHECKBOX, - value : false, - isVisible:true, - isRequired:false - }, - UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED : { - name : NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE, - id : ID.UPLOAD_SUPPLEMENTORY_DATA_FILE, - type : PARAMETER.CHECKBOX, - value : true, - isVisible:true, - isRequired:false - }, - UPLOAD_SUPPLEMENTORY_DATA_FILE_UNCHECKED : { - name : NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE, - id : ID.UPLOAD_SUPPLEMENTORY_DATA_FILE, - type : PARAMETER.CHECKBOX, - value : false, - isVisible:true, - isRequired:false - }, - SUPPLEMENTORY_DATA_FILE : { - name : NAME.SUPPLEMENTORY_DATA_FILE, - id : ID.SUPPLEMENTORY_DATA_FILE, - type : PARAMETER.FILE, - isRequired : false, - isVisible : true, - fileData:'' - }, + AVAILABLE_VOLUME_GROUP: { + name: NAME.AVAILABLE_VOLUME_GROUP, + id: ID.AVAILABLE_VOLUME_GROUP, + type: PARAMETER.SELECT, + prompt: PROMPT.AVAILABLE_VOLUME_GROUP, + isRequired: true + }, + INSTANCE_NAME: { + name: NAME.INSTANCE_NAME, + id: ID.INSTANCE_NAME, + isRequired: true + }, + LCP_REGION: { + name: NAME.LCP_REGION, + id: ID.LCP_REGION, + type: PARAMETER.SELECT, + prompt: PROMPT.LCP_REGION, + isRequired: true + }, + VNF_TARGET_PROVSTATUS: { + name: NAME.VNF_Target_Prov_Status, + id: ID.VNF_TARGETPROVSTATUS, + type: PARAMETER.SELECT, + prompt: PROMPT.TARGETPROVSTATUS, + isRequired: true + }, + LCP_REGION_TEXT_HIDDEN: { + id: ID.LCP_REGION_TEXT, + isVisible: false + }, + LCP_REGION_TEXT_VISIBLE: { + name: NAME.LCP_REGION_TEXT, + id: ID.LCP_REGION_TEXT, + isRequired: true, + isVisible: true + }, + PRODUCT_FAMILY: { + name: NAME.PRODUCT_FAMILY, + id: ID.PRODUCT_FAMILY, + type: PARAMETER.SELECT, + prompt: PROMPT.PRODUCT_FAMILY, + isRequired: true + }, + AIC_ZONES: { + name: NAME.AIC_ZONES, + id: ID.AIC_ZONES, + type: PARAMETER.SELECT, + prompt: PROMPT.AIC_ZONES, + isRequired: false + }, + SERVICE_TYPE: { + name: NAME.SERVICE_TYPE, + id: ID.SERVICE_TYPE, + type: PARAMETER.SELECT, + prompt: PROMPT.SERVICE_TYPE, + isRequired: true + }, + SERVICE_TYPE_DISABLED: { + name: NAME.SERVICE_TYPE, + id: ID.SERVICE_TYPE, + type: PARAMETER.SELECT, + isEnabled: false, + isRequired: true + }, + SUPPRESS_ROLLBACK: { + name: NAME.SUPPRESS_ROLLBACK, + id: ID.SUPPRESS_ROLLBACK, + type: PARAMETER.BOOLEAN, + value: false + }, + SDN_C_PRELOAD_CHECKED: { + name: NAME.SDN_C_PRELOAD, + id: ID.SDN_C_PRELOAD, + type: PARAMETER.CHECKBOX, + value: true, + isVisible: true, + isRequired: false + }, + SDN_C_PRELOAD_UNCHECKED: { + name: NAME.SDN_C_PRELOAD, + id: ID.SDN_C_PRELOAD, + type: PARAMETER.CHECKBOX, + value: false, + isVisible: true, + isRequired: false + }, + UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED: { + name: NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE, + id: ID.UPLOAD_SUPPLEMENTORY_DATA_FILE, + type: PARAMETER.CHECKBOX, + value: true, + isVisible: true, + isRequired: false + }, + UPLOAD_SUPPLEMENTORY_DATA_FILE_UNCHECKED: { + name: NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE, + id: ID.UPLOAD_SUPPLEMENTORY_DATA_FILE, + type: PARAMETER.CHECKBOX, + value: false, + isVisible: true, + isRequired: false + }, + SUPPLEMENTORY_DATA_FILE: { + name: NAME.SUPPLEMENTORY_DATA_FILE, + id: ID.SUPPLEMENTORY_DATA_FILE, + type: PARAMETER.FILE, + isRequired: false, + isVisible: true, + fileData: '' + }, - SUBSCRIBER_NAME : { - name : NAME.SUBSCRIBER_NAME, - id : ID.SUBSCRIBER_NAME, - type : PARAMETER.SELECT, - prompt : PROMPT.SUBSCRIBER_NAME, + SUBSCRIBER_NAME: { + name: NAME.SUBSCRIBER_NAME, + id: ID.SUBSCRIBER_NAME, + type: PARAMETER.SELECT, + prompt: PROMPT.SUBSCRIBER_NAME, isRequired : true, isSingleOptionAutoSelected : false - }, - TENANT_DISABLED : { - name : NAME.TENANT, - id : ID.TENANT, - type : PARAMETER.SELECT, - isEnabled : false, - isRequired : true - }, - TENANT_ENABLED : { - name : NAME.TENANT, - id : ID.TENANT, - type : PARAMETER.SELECT, - isEnabled : true, - prompt : PROMPT.TENANT, - isRequired : true - } + }, + TENANT_DISABLED: { + name: NAME.TENANT, + id: ID.TENANT, + type: PARAMETER.SELECT, + isEnabled: false, + isRequired: true + }, + TENANT_ENABLED: { + name: NAME.TENANT, + id: ID.TENANT, + type: PARAMETER.SELECT, + isEnabled: true, + prompt: PROMPT.TENANT, + isRequired: true + } }; return { - ID : ID, - KEY : KEY, - NAME : NAME, - PARAMETER : PARAMETER, - PROMPT : PROMPT, - STATUS : STATUS, - STYLE : STYLE, - ERROR : ERROR, + ID: ID, + KEY: KEY, + NAME: NAME, + PARAMETER: PARAMETER, + PROMPT: PROMPT, + STATUS: STATUS, + STYLE: STYLE, + ERROR: ERROR, } -} ]); +}]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/vidConfiguration.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/vidConfiguration.js index f5606616..4341a4ca 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/vidConfiguration.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/vidConfiguration.js @@ -91,7 +91,10 @@ appDS2.constant("VIDCONFIGURATION", (function() { * */ var COMPONENT_LIST_NAMED_QUERY_ID = "0367193e-c785-4d5f-9cb8-7bc89dc9ddb7"; - var MACRO_SERVICES = []; + var MACRO_SERVICES = ["93150ffa-00c6-4ea0-85f2-3536ca46ebd2", + "2b54297f-72e7-4a94-b451-72df88d0be0b", + "d27e42cf-087e-4d31-88ac-6c4b7585f800", + "ec0c4bab-c272-4dab-b087-875031bb0c9f","0311f998-9268-4fd6-bbba-afff15087b72"]; return { ASDC_MODEL_STATUS : ASDC_MODEL_STATUS, MSO_MAX_POLLS : MSO_MAX_POLLS, diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js index dcbf3e6e..b0fcb11e 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js @@ -33,8 +33,9 @@ $scope.defaultBaseUrl = ""; $scope.responseTimeoutMsec = 60000; $scope.properties = UtilityService.getProperties(); - $scope.init = function() { + $scope.isPermitted = $location.search().isPermitted; + $scope.init = function() { /* * These 2 statements should be included in non-test code. */ @@ -46,7 +47,7 @@ var polls = PropertyService.retrieveMsoMaxPolls(); PropertyService.setMsoMaxPolls(polls); - PropertyService.setServerResponseTimeoutMsec(10000); + PropertyService.setServerResponseTimeoutMsec(30000); /* * Common parameters that shows an example of how the view edit screen @@ -224,11 +225,17 @@ console.log("Removing Service " + $scope.service.instance.name); - DataService.setALaCarte (true); + if ( $scope.isMacro() ) { + DataService.setALaCarte (false); + } + else { + DataService.setALaCarte (true); + } + DataService.setMacro($scope.isMacro()); DataService.setInventoryItem(serviceInstance); DataService.setModelInfo(COMPONENT.SERVICE, { - "modelInvariantId": serviceInstance[FIELD.ID.MODEL_INVAR_ID], + "modelInvariantId": $scope.service.model.service.invariantUuid, "modelVersion": $scope.service.model.service.version, "modelNameVersionId": $scope.service.model.service.uuid, "modelName": $scope.service.model.service.name, @@ -345,6 +352,9 @@ $scope.deleteVnf = function(serviceObject, vnf) { + + debugger; + console.log("Removing VNF " + vnf.name); var serviceInstance = serviceObject.object; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js index dd2cf73f..731c2f2e 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js @@ -39,8 +39,9 @@ $http.get(pathQuery) .then(function successCallback(response) { $scope.services = []; - if (angular.isArray(response.data)) { - $scope.services = response.data; + if (angular.isArray(response.data.services)) { + wholeData = response.data.services; + $scope.services = $scope.filterDataWithHigerVersion(wholeData); $scope.viewPerPage=10; $scope.totalPage=$scope.services.length/$scope.viewPerPage; $scope.sortBy=COMPONENT.NAME; @@ -56,11 +57,72 @@ $scope.error = true; $scope.isSpinnerVisible = false; } + $scope.deployButtonType = response.data.readOnly ? 'disabled' : 'primary'; }, function errorCallback(response) { console.log("Error: " + response); }); } - + $scope.isFiltered=function(arr,obj){ + var filtered = false; + if(arr.length>0){ + for(var i=0;i=parseFloat(serviceData[i].version.trim()))){ + var data = $scope.isThisHigher(fiterDataServices,serviceData[j]); + if(data.isHigher){ + fiterDataServices[data.index] = serviceData[j]; + } + } + } + } + } + return fiterDataServices; + } + + $scope.isThisHigher = function(arr,obj){ + var returnObj = { + isHigher:false, + index:0 + }; + if(arr.length>0){ + var isNotMatched = true; + for(var i=0;i0){ + for(var i=0;i=parseFloat(serviceData[i]['extra-properties']['extra-property'][6]['property-value']))){ + var data = $scope.isThisHigher(fiterDataServices,serviceData[j]); + if(data.isHigher){ + fiterDataServices[data.index] = serviceData[j]; } - $scope.service.instance[FIELD.ID.NETWORKS].push(l3Network); } - - if (subInventoryResponseItem[FIELD.ID.GENERIC_VNF] != null) { - var genericVnfObject = subInventoryResponseItem[FIELD.ID.GENERIC_VNF]; - - var genericVnf = { - "name": genericVnfObject[FIELD.ID.VNF_NAME], - "id": $scope.counter++, - "itemType": COMPONENT.VNF, - "nodeType": genericVnfObject[FIELD.ID.VNF_TYPE], - "nodeId": genericVnfObject[FIELD.ID.VNF_ID], - "nodeStatus": genericVnfObject[FIELD.ID.ORCHESTRATION_STATUS], - "object": genericVnfObject, - "vfModules": [], - "volumeGroups": [], - "availableVolumeGroups": [] - }; - $scope.service.instance[FIELD.ID.VNFS].push(genericVnf); - - // look for volume-groups - if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { - angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function(vfmodules, key) { - - if (vfmodules[FIELD.ID.VOLUME_GROUP] != null) { - var volumeGroupObject = vfmodules[FIELD.ID.VOLUME_GROUP]; - var volumeGroup = { "id": $scope.counter++, - "name": volumeGroupObject[FIELD.ID.VOLUME_GROUP_NAME], - "itemType": FIELD.ID.VOLUME_GROUP, - "nodeId": volumeGroupObject[FIELD.ID.VOLUME_GROUP_ID], - "nodeType": volumeGroupObject[FIELD.ID.VNF_TYPE], - "nodeStatus": volumeGroupObject[FIELD.ID.ORCHESTRATION_STATUS], - "object": volumeGroupObject, - "nodes": [] - }; - genericVnf[FIELD.ID.VOLUMEGROUPS].push(volumeGroup); - genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS].push(volumeGroup); - } - }); - } - // now we've loaded up the availableVolumeGroups, we can use it - if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { - angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function(vfmodules, key) { - - if (vfmodules[FIELD.ID.VF_MODULE] != null) { - var vfModuleObject = vfmodules[FIELD.ID.VF_MODULE]; - var vfModule = { "id": $scope.counter++, - "name": vfModuleObject[FIELD.ID.VF_MODULE_NAME], - "itemType": FIELD.ID.VF_MODULE, - "nodeType": FIELD.ID.VF_MODULE, - "nodeStatus": vfModuleObject[FIELD.ID.ORCHESTRATION_STATUS], - "volumeGroups": [], - "object": vfModuleObject, - "networks": [] - }; - genericVnf[FIELD.ID.VF_MODULES].push(vfModule); - if (vfmodules[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { - angular.forEach(vfmodules[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function(networks, key) { - if (networks[FIELD.ID.L3_NETWORK] != null) { - var l3NetworkObject = networks[FIELD.ID.L3_NETWORK]; - var l3Network = { "id": $scope.counter++, - "name": l3NetworkObject[FIELD.ID.NETWORK_NAME], - "itemType": FIELD.ID.L3_NETWORK, - "nodeId": l3NetworkObject[FIELD.ID.NETWORK_ID], - "nodeType": l3NetworkObject[FIELD.ID.NETWORK_TYPE], - "nodeStatus": l3NetworkObject[FIELD.ID.ORCHESTRATION_STATUS], - "object": l3NetworkObject, - "nodes": [] - }; - vfModule[FIELD.ID.NETWORKS].push(l3Network); - } - if (networks[FIELD.ID.VOLUME_GROUP] != null) { - var volumeGroupObject = networks[FIELD.ID.VOLUME_GROUP]; - - var volumeGroup = { "id": $scope.counter++, - "name": volumeGroupObject[FIELD.ID.VOLUME_GROUP_NAME], - "itemType": FIELD.ID.VOLUME_GROUP, - "nodeId": volumeGroupObject[FIELD.ID.VOLUME_GROUP_ID], - "nodeType": volumeGroupObject[FIELD.ID.VNF_TYPE], - "nodeStatus": volumeGroupObject[FIELD.ID.ORCHESTRATION_STATUS], - "object": volumeGroupObject, - "nodes": [] - }; - var tmpVolGroup = []; - - angular.forEach(genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS], function(avgroup, key) { - if (avgroup.name != volumeGroup.name) { - tmpVolGroup.push(avgroup); - } - }); - - genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS] = tmpVolGroup; - - vfModule[FIELD.ID.VOLUMEGROUPS].push(volumeGroup); - } - - }); - } - } - }); - } - } - }); + } } - }); - }); - } - - $scope.handleInitialResponse = function(response) { - try { - $scope.enableCloseButton(true); - $scope.updateLog(response); - if (response.data.status < 200 || response.data.status > 202) { - $scope.showError(FIELD.ERROR.MSO); - $scope.status = FIELD.ERROR.AAI_FETCHING_CUST_DATA + response.data.status; - - return; } - - $scope.setProgress(100); // done - $scope.status = FIELD.STATUS.DONE; - $scope.isSpinnerVisible = false; - - $scope.customer = response.data.customer; // get data from json - - $scope.customerList = []; - - angular.forEach($scope.customer, function(subVal, subKey) { - var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] }; - $scope.customerList.push(cust); - }); - - } catch (error) { - $scope.showContentError(error); + return fiterDataServices; } - } - - $scope.autoGetSubs = function() { - /* - * Optionally comment in / out one of these method calls (or add a similar - * entry) to auto-invoke an entry when the test screen is redrawn. - */ - $scope.getSubs(); - - } - $scope.updateLog = function(response) { -// $scope.log = UtilityService.getCurrentTime() + " HTTP Status: " + -// UtilityService.getHttpStatusText(response.data.status) + "\n" + -// angular.toJson(response.data.entity, true) + "\n\n" + $scope.log; -// UtilityService.checkUndefined("entity", response.data.entity); -// UtilityService.checkUndefined("status", response.data.status); - } - - $scope.handleServerError = function(response, status) { - $scope.enableCloseButton(true); - var message = UtilityService.getHttpErrorMessage(response); - if (message != ""){ - message = " (" + message + ")"; - } - $scope.showError(FIELD.ERROR.SYSTEM_ERROR + message); - } - - $scope.showContentError = function(message) { - // $log.debug(message); - console.log(message); - if (UtilityService.hasContents(message)) { - $scope.showError("System failure (" + message + ")"); - } else { - $scope.showError(FIELD.ERROR.SYSTEM_ERROR); - } - } - - $scope.showError = function(message) { - $scope.isSpinnerVisible = false; - $scope.isProgressVisible = false; - $scope.error = message; - $scope.status = FIELD.STATUS.ERROR; - } - - $scope.close = function() { - if ($scope.timer != undefined) { - $timeout.cancel($scope.timer); + $scope.isThisHigher = function(arr,obj){ + var returnObj = { + isHigher:false, + index:0 + }; + if(arr.length>0){ + var isNotMatched = true; + for(var i=0;i 202) { + $scope.showError(FIELD.ERROR.MSO); + $scope.status = FIELD.ERROR.AAI_FETCHING_CUST_DATA + response.data.status; - if (isEnabled) { - $(selector).addClass(FIELD.STYLE.BTN_PRIMARY).removeClass(FIELD.STYLE.BTN_INACTIVE).attr(FIELD.STYLE.BTN_TYPE, FIELD.STYLE.PRIMARY); - } else { - $(selector).removeClass(FIELD.STYLE.BTN_PRIMARY).addClass(FIELD.STYLE.BTN_INACTIVE).attr(FIELD.STYLE.BTN_TYPE, FIELD.STYLE.DISABLED); - } - } + return; + } - $scope.resetProgress = function() { - $scope.percentProgress = 0; - $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_INFO; - } + $scope.setProgress(100); // done + $scope.status = FIELD.STATUS.DONE; + $scope.isSpinnerVisible = false; - $scope.setProgress = function(percentProgress) { - percentProgress = parseInt(percentProgress); - if (percentProgress >= 100) { - $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_SUCCESS; - } + $scope.customer = response.data.customer; // get data from json - if (percentProgress < $scope.percentProgress) { - return; - } + $scope.customerList = []; - $scope.percentProgress = percentProgress; - $scope.progressWidth = {width: percentProgress + "%"}; - if (percentProgress >= 5) { - $scope.progressText = percentProgress + " %"; - } else { - // Hidden since color combination is barely visible when progress portion is narrow. - $scope.progressText = ""; - } - } + angular.forEach($scope.customer, function (subVal, subKey) { + var cust = { + "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], + "subscriberName": subVal[FIELD.ID.SUBNAME], + "isPermitted": subVal[FIELD.ID.IS_PERMITTED] + }; - $scope.reloadRoute = function() { - $route.reload(); - } + $scope.customerList.push(cust); + }); - $scope.prevPage = function() { - $scope.currentPage--; - } + } catch (error) { + $scope.showContentError(error); + } + } - $scope.nextPage = function() { - $scope.currentPage++; - } - $scope.serviceInstanceses = [{"sinstance":FIELD.NAME.SERVICE_INSTANCE_Id},{"sinstance":FIELD.NAME.SERVICE_INSTANCE_NAME}] - $scope.getSubscriberDet = function(selectedCustomer,selectedserviceinstancetype,selectedServiceInstance){ - - var sintype =selectedserviceinstancetype; - if (selectedServiceInstance != "" && selectedServiceInstance != undefined) { - selectedServiceInstance.trim(); - - // check with A&AI - $http.get(COMPONENT.AAI_GET_SERVICE_INSTANCE_PATH + selectedServiceInstance+"/"+sintype + "?r=" + Math.random(), { - - },{ - timeout: $scope.responseTimeoutMsec - }).then(function(response) { - var notFound = true; - if (angular.isArray(response.data[FIELD.ID.RESULT_DATA])) { - var item = []; - var urlParts = []; - item = response.data[FIELD.ID.RESULT_DATA][0]; - var url = item[FIELD.ID.RESOURCE_LINK]; - var globalCustomerId = ""; - var serviceSubscription = ""; - // split it and find the customer Id and service-subscription - urlParts = url.split("/"); - if (urlParts[7] === FIELD.ID.CUSTOMER) { - globalCustomerId = urlParts[8]; - } - if (urlParts[10] === FIELD.ID.SERVICE_SUBSCRIPTION) { - serviceSubscription = urlParts[11]; - } + $scope.autoGetSubs = function () { + /* + * Optionally comment in / out one of these method calls (or add a similar + * entry) to auto-invoke an entry when the test screen is redrawn. + */ + $scope.getSubs(); - if (globalCustomerId !== "") { - notFound = false; - window.location.href = COMPONENT.SELECTED_SERVICE_SUB_PATH + serviceSubscription + COMPONENT.SELECTEDSUBSCRIBER_SUB_PATH + globalCustomerId + COMPONENT.SELECTEDSERVICEINSTANCE_SUB_PATH + selectedServiceInstance; - } - } - if (notFound) { - alert(FIELD.ERROR.SERVICE_INST_DNE); - } - }); // add a failure callback... - } else if (selectedCustomer != null) { - window.location.href = COMPONENT.SELECTED_SUB_PATH + selectedCustomer; - } else { - alert(FIELD.ERROR.SELECT); - } - }; - }]).directive('restrictInput', function(){ - - return { - - restrict: 'A', - require: 'ngModel', - link: function($scope, element, attr, ctrl){ - ctrl.$parsers.unshift(function(viewValue){ - - var types = $scope.$eval(attr.restrictInput); - if(!types.regex && types.type){ - - switch(types.type){ - case 'Service Instance Name' : types.regex = '^[a-zA-Z0-9-_]*$'; break; - default: types.regex= ''; - } - } - var reg = new RegExp(types.regex); - if(reg.test(viewValue)){ - return viewValue; - } else { - var overrideValue = (reg.test(viewValue) ? viewValue : ''); - element.val(overrideValue); - return overrideValue; - } - }); - } - }; + } + $scope.updateLog = function (response) { +// $scope.log = UtilityService.getCurrentTime() + " HTTP Status: " + +// UtilityService.getHttpStatusText(response.data.status) + "\n" + +// angular.toJson(response.data.entity, true) + "\n\n" + $scope.log; +// UtilityService.checkUndefined("entity", response.data.entity); +// UtilityService.checkUndefined("status", response.data.status); + } + + $scope.handleServerError = function (response, status) { + $scope.enableCloseButton(true); + var message = UtilityService.getHttpErrorMessage(response); + if (message != "") { + message = " (" + message + ")"; + } + $scope.showError(FIELD.ERROR.SYSTEM_ERROR + message); + } + + $scope.showContentError = function (message) { + // $log.debug(message); + console.log(message); + if (UtilityService.hasContents(message)) { + $scope.showError("System failure (" + message + ")"); + } else { + $scope.showError(FIELD.ERROR.SYSTEM_ERROR); + } + } + + $scope.showError = function (message) { + $scope.isSpinnerVisible = false; + $scope.isProgressVisible = false; + $scope.error = message; + $scope.status = FIELD.STATUS.ERROR; + } + + $scope.close = function () { + if ($scope.timer != undefined) { + $timeout.cancel($scope.timer); + } + $scope.isPopupVisible = false; + } + + + /* + * Consider converting the progress bar mechanism, the disabled button handling + * and the following methods to generic Angular directive(s) and/or approach. + */ + + $scope.enableCloseButton = function (isEnabled) { + var selector = FIELD.STYLE.MSO_CTRL_BTN; + + $scope.isCloseEnabled = isEnabled; + + if (isEnabled) { + $(selector).addClass(FIELD.STYLE.BTN_PRIMARY).removeClass(FIELD.STYLE.BTN_INACTIVE).attr(FIELD.STYLE.BTN_TYPE, FIELD.STYLE.PRIMARY); + } else { + $(selector).removeClass(FIELD.STYLE.BTN_PRIMARY).addClass(FIELD.STYLE.BTN_INACTIVE).attr(FIELD.STYLE.BTN_TYPE, FIELD.STYLE.DISABLED); + } + } + + $scope.resetProgress = function () { + $scope.percentProgress = 0; + $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_INFO; + } + + $scope.setProgress = function (percentProgress) { + percentProgress = parseInt(percentProgress); + if (percentProgress >= 100) { + $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_SUCCESS; + } + + if (percentProgress < $scope.percentProgress) { + return; + } + + $scope.percentProgress = percentProgress; + $scope.progressWidth = {width: percentProgress + "%"}; + if (percentProgress >= 5) { + $scope.progressText = percentProgress + " %"; + } else { + // Hidden since color combination is barely visible when progress portion is narrow. + $scope.progressText = ""; + } + } + + $scope.reloadRoute = function () { + $route.reload(); + } + + $scope.prevPage = function () { + $scope.currentPage--; + } + + $scope.nextPage = function () { + $scope.currentPage++; + } + $scope.serviceInstanceses = [{"sinstance": FIELD.NAME.SERVICE_INSTANCE_Id}, {"sinstance": FIELD.NAME.SERVICE_INSTANCE_NAME}] + $scope.getSubscriberDet = function (selectedCustomer, selectedserviceinstancetype, selectedServiceInstance) { + + var sintype = selectedserviceinstancetype; + if (selectedServiceInstance != "" && selectedServiceInstance != undefined) { + selectedServiceInstance.trim(); + + // check with A&AI + $http.get(COMPONENT.AAI_GET_SERVICE_INSTANCE_PATH + selectedServiceInstance + "/" + sintype + "?r=" + Math.random(), {}, { + timeout: $scope.responseTimeoutMsec + }).then(function (response) { + var notFound = true; + if (angular.isArray(response.data[FIELD.ID.RESULT_DATA])) { + var item = []; + var urlParts = []; + item = response.data[FIELD.ID.RESULT_DATA][0]; + var url = item[FIELD.ID.RESOURCE_LINK]; + var globalCustomerId = ""; + var serviceSubscription = ""; + // split it and find the customer Id and service-subscription + urlParts = url.split("/"); + if (urlParts[7] === FIELD.ID.CUSTOMER) { + globalCustomerId = urlParts[8]; + } + if (urlParts[10] === FIELD.ID.SERVICE_SUBSCRIPTION) { + serviceSubscription = urlParts[11]; + } + + if (globalCustomerId !== "") { + notFound = false; + window.location.href = COMPONENT.SELECTED_SERVICE_SUB_PATH + serviceSubscription + COMPONENT.SELECTEDSUBSCRIBER_SUB_PATH + globalCustomerId + COMPONENT.SELECTEDSERVICEINSTANCE_SUB_PATH + selectedServiceInstance; + } + } + if (notFound) { + alert(FIELD.ERROR.SERVICE_INST_DNE); + } + }); // add a failure callback... + } else if (selectedCustomer != null) { + window.location.href = COMPONENT.SELECTED_SUB_PATH + selectedCustomer; + } else { + alert(FIELD.ERROR.SELECT); + } + }; + }]).directive('restrictInput', function () { + + return { + + restrict: 'A', + require: 'ngModel', + link: function ($scope, element, attr, ctrl) { + ctrl.$parsers.unshift(function (viewValue) { + + var types = $scope.$eval(attr.restrictInput); + if (!types.regex && types.type) { + + switch (types.type) { + case 'Service Instance Name' : + types.regex = '^[a-zA-Z0-9-_]*$'; + break; + default: + types.regex = ''; + } + } + var reg = new RegExp(types.regex); + if (reg.test(viewValue)) { + return viewValue; + } else { + var overrideValue = (reg.test(viewValue) ? viewValue : ''); + element.val(overrideValue); + return overrideValue; + } }); + } + }; + +}); appDS2.controller('TreeCtrl', ['$scope', function ($scope) { - $scope.remove = function (scope) { - scope.remove(); - }; - - $scope.toggle = function (scope) { - scope.toggle(); - }; - - $scope.moveLastToTheBeginning = function () { - var a = $scope.data.pop(); - $scope.data.splice(0, 0, a); - }; - - $scope.newSubItem = function (scope) { - var nodeData = scope.$modelValue; - nodeData.nodes.push({ - id: nodeData.id * 10 + nodeData.nodes.length, - title: nodeData.title + '.' + (nodeData.nodes.length + 1), - nodes: [] - }); - }; - - $scope.collapseAll = function () { - $scope.$broadcast(FIELD.ID.ANGULAR_UI_TREE_COLLAPSEALL); - }; - - $scope.expandAll = function () { - $scope.$broadcast(FIELD.ID.ANGULAR_UI_TREE_EXPANDALL); - }; + $scope.remove = function (scope) { + scope.remove(); + }; + + $scope.toggle = function (scope) { + scope.toggle(); + }; + + $scope.moveLastToTheBeginning = function () { + var a = $scope.data.pop(); + $scope.data.splice(0, 0, a); + }; + + $scope.newSubItem = function (scope) { + var nodeData = scope.$modelValue; + nodeData.nodes.push({ + id: nodeData.id * 10 + nodeData.nodes.length, + title: nodeData.title + '.' + (nodeData.nodes.length + 1), + nodes: [] + }); + }; + + $scope.collapseAll = function () { + $scope.$broadcast(FIELD.ID.ANGULAR_UI_TREE_COLLAPSEALL); + }; + + $scope.expandAll = function () { + $scope.$broadcast(FIELD.ID.ANGULAR_UI_TREE_EXPANDALL); + }; }]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js index b400cc6e..3d8cba5c 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js @@ -111,16 +111,21 @@ var creationDialogController = function( COMPONENT, FIELD, PARAMETER, $scope, $h var isUploadAvailable = false; var uploadIndex =0; var paramList = $scope.userProvidedControl.getList(); - + var isAnyError = false; for (var i = 0; i < paramList.length; i++) { if (paramList[i].id === FIELD.ID.SUPPLEMENTORY_DATA_FILE) { isUploadAvailable = true; uploadIndex=i; - break; + } + if (paramList[i].id === FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE && paramList[i].value && document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE).value=='' ) { + isAnyError = true; } } - if(isUploadAvailable){ + if(isUploadAvailable && isAnyError ){ + showError(FIELD.ERROR.MISSING_DATA, FIELD.ERROR.MISSING_FILE); + return; + }else if(isUploadAvailable && document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE).value!='' ){ var errorMsg = ""; var fileInput = document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE); var file = fileInput.files[0]; @@ -128,8 +133,7 @@ var creationDialogController = function( COMPONENT, FIELD, PARAMETER, $scope, $h reader.onload = function(e) { try{ paramList[uploadIndex].value = JSON.parse(reader.result); - FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value'] = JSON.stringify(paramList[uploadIndex].value); - $scope.userProvidedControl.updateList([ FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE ]); + FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value'] = paramList[uploadIndex].value; var instanceName = ""; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/deletionDialogController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/deletionDialogController.js index 137673d4..499a1ec0 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/deletionDialogController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/deletionDialogController.js @@ -80,6 +80,10 @@ var deletionDialogController = function( COMPONENT, FIELD, $scope, $http, $timeo var requestDetails = DeletionService.getMsoRequestDetails($scope.userProvidedControl.getList()); + + if(DeletionService.isMacro === true){ + requestDetails.requestParameters.aLaCarte = false; + } $scope.isDialogVisible = false; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/previousVersionContoller.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/previousVersionContoller.js new file mode 100644 index 00000000..eb0dac64 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/previousVersionContoller.js @@ -0,0 +1,40 @@ +"use strict"; + +var previousVersionContoller = function( COMPONENT, FIELD, $scope, $http, $timeout, $log, + CreationService, UtilityService, DataService,VIDCONFIGURATION) { + $scope.isTableDialogVisible = false; + $scope.summaryControl = {}; + $scope.userProvidedControl = {}; + + var callbackFunction = undefined; + var componentId = undefined; + + $scope.$on("createTableComponent", function(event, request) { + + $scope.isTableSpinnerVisible = true; + $scope.isTableErrorVisible = false; + $scope.isTableDialogVisible = true; + $scope.popup.isTablePopUpVisible = true; + componentId = request.componentId; + CreationService.initializeComponent(request.componentId); + callbackFunction = request.callbackFunction; + CreationService.setHttpErrorHandler(function(response) { + showError("System failure", UtilityService + .getHttpErrorMessage(response)); + }); + $scope.isTableSpinnerVisible = false; + }); + + + $scope.cancelTable = function(){ + $scope.isTableDialogVisible = false; + $scope.popup.isTablePopUpVisible = false; + } + + +} + +app + .controller("previousVersionContoller", [ "COMPONENT", "FIELD", "$scope", "$http", + "$timeout", "$log", "CreationService", "UtilityService", "DataService","VIDCONFIGURATION", + previousVersionContoller ]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/previousVersionDialogController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/previousVersionDialogController.js new file mode 100644 index 00000000..d11f432e --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/previousVersionDialogController.js @@ -0,0 +1,40 @@ +"use strict"; + +var previousVersionDialogController = function( COMPONENT, FIELD, $scope, $http, $timeout, $log, + CreationService, UtilityService, DataService,VIDCONFIGURATION) { + $scope.isTableDialogVisible = false; + $scope.summaryControl = {}; + $scope.userProvidedControl = {}; + + var callbackFunction = undefined; + var componentId = undefined; + + $scope.$on("createTableComponent", function(event, request) { + + $scope.isTableSpinnerVisible = true; + $scope.isTableErrorVisible = false; + $scope.isTableDialogVisible = true; + $scope.popup.isTablePopUpVisible = true; + componentId = request.componentId; + CreationService.initializeComponent(request.componentId); + callbackFunction = request.callbackFunction; + CreationService.setHttpErrorHandler(function(response) { + showError("System failure", UtilityService + .getHttpErrorMessage(response)); + }); + $scope.isTableSpinnerVisible = false; + }); + + + $scope.cancelTable = function(){ + $scope.isTableDialogVisible = false; + $scope.popup.isTablePopUpVisible = false; + } + + +} + +app + .controller("previousVersionDialogController", [ "COMPONENT", "FIELD", "$scope", "$http", + "$timeout", "$log", "CreationService", "UtilityService", "DataService","VIDCONFIGURATION", + previousVersionDialogController ]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js index de156667..0d067ff1 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js @@ -130,7 +130,7 @@ var statusDialogController = function(COMPONENT, FIELD, $scope, $http, $timeout, var polls = PropertyService.retrieveMsoMaxPolls(); PropertyService.setMsoMaxPolls(polls); - PropertyService.setServerResponseTimeoutMsec(10000) + PropertyService.setServerResponseTimeoutMsec(30000); $scope.isSpinnerVisible = true; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js index 06cbf058..029860f8 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js @@ -64,7 +64,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log var polls = PropertyService.retrieveMsoMaxPolls(); PropertyService.setMsoMaxPolls(polls); - PropertyService.setServerResponseTimeoutMsec(10000); + PropertyService.setServerResponseTimeoutMsec(30000); // These two properties only added for testing properties.msoDefaultBaseUrl = $scope.baseUrl; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js b/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js index 69a0ae52..e57b43ec 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js @@ -49,355 +49,377 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService) { var checkboxInputStyle = "height: 18px; width: 18px; padding: 2px 5px;"; var selectStyle = "height: 25px; padding: 2px; text-align: center;"; var requiredLabelStyle = "width: 25px; padding: 5px 10px 10px 5px;"; - + var getParameterHtml = function(parameter, editable) { - var style = valueStyle; - var attributeString = ""; - if (parameter.type === PARAMETER.BOOLEAN) { - style = checkboxValueStyle; - } - if (UtilityService.hasContents(parameter.description)) { - attributeString += " title=' " + parameter.description + " '"; - } - var rowstyle=''; - if(parameter.type == 'file' && !parameter.isVisiblity){ - rowstyle = ' style="display:none;"'; - } - var html = "" - + getNameHtml(parameter) + ""; - if (editable === undefined) { - if (UtilityService.hasContents(parameter.value)) { - html += parameter.value; - } - } else { - html += getValueHtml(parameter); - } - html += ""; - return html; + var style = valueStyle; + var attributeString = ""; + if (parameter.type === PARAMETER.BOOLEAN) { + style = checkboxValueStyle; + } + if (UtilityService.hasContents(parameter.description)) { + attributeString += " title=' " + parameter.description + " '"; + } + var rowstyle=''; + if(parameter.type == 'file' && !parameter.isVisiblity){ + rowstyle = ' style="display:none;"'; + } + var html = "" + + getNameHtml(parameter) + ""; + if (editable === undefined) { + if (UtilityService.hasContents(parameter.value)) { + html += "" + parameter.value; + } else { + html += ""; + } + } else { + html += "" + getValueHtml(parameter); + } + html += ""; + return html; }; var updateParameter = function(parameter, element, editable) { - $(element).parent().parent().children("td").first().html( - getNameHtml(parameter)); - if (editable === undefined) { - $(element).html(parameter.value); - } else { - $(element).parent().html(getValueHtml(parameter)); - } + $(element).parent().parent().children("td").first().html( + getNameHtml(parameter)); + if (editable === undefined) { + $(element).html(parameter.value); + } else { + $(element).parent().html(getValueHtml(parameter)); + } }; var getNameHtml = function(parameter) { - if (parameter.isVisible === false) { - return ""; - } - var name = ""; - if (UtilityService.hasContents(parameter.name)) { - name = parameter.name; - } else { - name = parameter.id; - } - var requiredLabel = ""; - if (parameter.isRequired) { - requiredLabel = ""; - } - return name + ":" + requiredLabel; + if (parameter.isVisible === false) { + return ""; + } + var name = getParameterName(parameter); + + var requiredLabel = ""; + if (parameter.isRequired) { + requiredLabel = ""; + } + return name + ":" + requiredLabel; }; + var getParameterName = function(parameter) { + var name = ""; + if (UtilityService.hasContents(parameter.name)) { + name = parameter.name; + } else { + name = parameter.id; + } + return name; + } + var getValueHtml = function(parameter) { - - var textInputPrompt = "Enter data"; - var attributeString = " parameter-id='" + parameter.id + "'"; - var additionalStyle = ""; - if (parameter.isEnabled === false) { - attributeString += " disabled='disabled'"; - } - if (parameter.isRequired) { - attributeString += " is-required='true'"; - } - if (UtilityService.hasContents(parameter.description)) { - attributeString += " title=' " + parameter.description + " '"; - } - if (UtilityService.hasContents(parameter.isReadOnly) && (parameter.isReadOnly === true)) { - attributeString += " readonly"; - } - if ( (UtilityService.hasContents(parameter.maxLength)) && (UtilityService.hasContents(parameter.minLength)) ) { - attributeString += " pattern='.{" + parameter.minLength + "," + parameter.maxLength + "}' required"; - } - else if (UtilityService.hasContents(parameter.maxLength)) { - attributeString += " maxlength='" + parameter.maxLength + "'"; - } - else if (UtilityService.hasContents(parameter.minLength)) { - attributeString += " pattern='.{" + parameter.minLength + ",}'" - } - if (parameter.isVisible === false) { - additionalStyle = " visibility: hidden;"; - } - - var name = ""; - if (UtilityService.hasContents(parameter.name)) { - name = parameter.name; - } else { - name = parameter.id; - } - attributeString += " parameter-name='" + name + "'"; - - if ( parameter.type === PARAMETER.MAP ) { - textInputPrompt = "{: ,\.\.\.,: }"; - } - - if ( parameter.type === PARAMETER.LIST ) { - textInputPrompt = "[,\.\.\.,]"; - } - - switch (parameter.type) { - case PARAMETER.BOOLEAN: - if (parameter.value) { - return "" + "" - + ""; - + ""; - }else{ - return "" + "" - + "" - + ""; - } - break; - case PARAMETER.CHECKBOX: - if (parameter.value) { - return ""; - }else{ - return ""; - } - break; - case PARAMETER.FILE: - return ""; - break; - case PARAMETER.NUMBER: - var value=parameter.value; - var parameterSpec = ""; - } else { - //integer - return ""; - }*/ - return (parameterSpec); - break; - case PARAMETER.SELECT: - if (UtilityService.hasContents(parameter.prompt)) { - attributeString += " prompt='" + parameter.prompt + "'"; - } - return "" + getOptionListHtml(parameter) - + ""; - break; - case PARAMETER.STRING: - default: - var value = ""; - if (UtilityService.hasContents(parameter.value)) { - value = " value='" + parameter.value + "'"; - } - if (UtilityService.hasContents(parameter.prompt)) { - attributeString += " placeholder='" + parameter.prompt + "'"; - } else if (textInputPrompt !== "") { - attributeString += " placeholder='" + textInputPrompt + "'"; - } - var finalString = ""; - return finalString; - } + + var textInputPrompt = "Enter data"; + var attributeString = " data-tests-id='" + parameter.id +"' parameter-id='" + parameter.id + "'"; + var additionalStyle = ""; + if (parameter.isEnabled === false) { + attributeString += " disabled='disabled'"; + } + if (parameter.isRequired) { + attributeString += " is-required='true'"; + } + if (UtilityService.hasContents(parameter.description)) { + attributeString += " title=' " + parameter.description + " '"; + } + if (UtilityService.hasContents(parameter.isReadOnly) && (parameter.isReadOnly === true)) { + attributeString += " readonly"; + } + if ( (UtilityService.hasContents(parameter.maxLength)) && (UtilityService.hasContents(parameter.minLength)) ) { + attributeString += " pattern='.{" + parameter.minLength + "," + parameter.maxLength + "}' required"; + } + else if (UtilityService.hasContents(parameter.maxLength)) { + attributeString += " maxlength='" + parameter.maxLength + "'"; + } + else if (UtilityService.hasContents(parameter.minLength)) { + attributeString += " pattern='.{" + parameter.minLength + ",}'" + } + if (parameter.isVisible === false) { + additionalStyle = " visibility: hidden;"; + } + + var name = ""; + if (UtilityService.hasContents(parameter.name)) { + name = parameter.name; + } else { + name = parameter.id; + } + attributeString += " parameter-name='" + name + "'"; + + if ( parameter.type === PARAMETER.MAP ) { + textInputPrompt = "{: ,\.\.\.,: }"; + } + + if ( parameter.type === PARAMETER.LIST ) { + textInputPrompt = "[,\.\.\.,]"; + } + + switch (parameter.type) { + case PARAMETER.BOOLEAN: + if (parameter.value) { + return "" + "" + + ""; + + ""; + }else{ + return "" + "" + + "" + + ""; + } + break; + case PARAMETER.CHECKBOX: + if (parameter.value) { + return ""; + }else{ + return ""; + } + break; + case PARAMETER.FILE: + return ""; + break; + case PARAMETER.NUMBER: + var value=parameter.value; + var parameterSpec = ""; + } else { + //integer + return ""; + }*/ + return (parameterSpec); + break; + case PARAMETER.SELECT: + if (UtilityService.hasContents(parameter.prompt)) { + attributeString += " prompt='" + parameter.prompt + "'"; + } + return "" + getOptionListHtml(parameter) + + ""; + break; + case PARAMETER.STRING: + default: + var value = ""; + if (UtilityService.hasContents(parameter.value)) { + value = " value='" + parameter.value + "'"; + } + if (UtilityService.hasContents(parameter.prompt)) { + attributeString += " placeholder='" + parameter.prompt + "'"; + } else if (textInputPrompt !== "") { + attributeString += " placeholder='" + textInputPrompt + "'"; + } + var finalString = ""; + return finalString; + } }; - - + + var getBooleanListHtml = function(parameter){ - var html = ""; - + var html = ""; + }; var getOptionListHtml = function(parameter) { - var html = ""; + var html = ""; - if (!angular.isArray(parameter.optionList) - || parameter.optionList.length === 0) { - return ""; - } + if (!angular.isArray(parameter.optionList) + || parameter.optionList.length === 0) { + return ""; + } - if (UtilityService.hasContents(parameter.prompt)) { + if (UtilityService.hasContents(parameter.prompt)) { if (!(IS_SINGLE_OPTION_AUTO_SELECTED && parameter.optionList.length === 1) || !(parameter.isSingleOptionAutoSelected && parameter.optionList.length === 1)) { - html += ""; - } - } - - for (var i = 0; i < parameter.optionList.length; i++) { - var option = parameter.optionList[i]; - var name = option.name; - var value = ""; - if (option.id === undefined) { - value = option.name; - } else { - if (name === undefined) { - name = option.id; - } - value = option.id; - } - if (option.isDefault === undefined || option.isDefault === false ) { - html += ""; - } - else { - html += ""; - } - } - return html; + html += ""; + } + } + + for (var i = 0; i < parameter.optionList.length; i++) { + var option = parameter.optionList[i]; + var name = option.name; + var value = ""; + if (option.id === undefined) { + value = option.name; + } else { + if (name === undefined) { + name = option.id; + } + value = option.id; + } + html += getOptionHtml(option.isPermitted, option.isDataLoading, value, name, parameter); + } + return html; }; + function getOptionHtml(isPermitted, isDefault, value, name, parameter) { + var html = ""; + if (isDefault === undefined || isDefault === false ) { + if(isPermitted) + html = ""; + else { + html = ""; + } + } + else { + if(isPermitted) + html = ""; + else { + html = ""; + } + } + return html; + } + var getParameter = function(element, expectedId) { - var id = $(element).attr("parameter-id"); - if (expectedId !== undefined && expectedId !== id) { - return undefined; - } - var parameter = { - id : id - }; - if ($(element).prop("type") === "checkbox") { - parameter.value = $(element).prop("checked"); - }else if ($(element).prop("type") === "file") { - parameter.value = $('#'+id).attr("value"); - - } else { - if ($(element).prop("type") === "text") { - $(element).val($(element).val().trim()); - } - parameter.value = $(element).val(); - } - if ($(element).prop("selectedIndex") === undefined) { - parameter.selectedIndex = -1; - } else { - parameter.selectedIndex = $(element).prop("selectedIndex"); - if (UtilityService.hasContents($(element).attr("prompt"))) { - parameter.selectedIndex--; - } - } - return parameter; + var id = $(element).attr("parameter-id"); + if (expectedId !== undefined && expectedId !== id) { + return undefined; + } + var parameter = { + id : id + }; + if ($(element).prop("type") === "checkbox") { + parameter.value = $(element).prop("checked"); + }else if ($(element).prop("type") === "file") { + parameter.value = $('#'+id).attr("value"); + + } else { + if ($(element).prop("type") === "text") { + $(element).val($(element).val().trim()); + } + parameter.value = $(element).val(); + } + if ($(element).prop("selectedIndex") === undefined) { + parameter.selectedIndex = -1; + } else { + parameter.selectedIndex = $(element).prop("selectedIndex"); + if (UtilityService.hasContents($(element).attr("prompt"))) { + parameter.selectedIndex--; + } + } + return parameter; }; var getRequiredField = function(element) { - if ($(element).prop("type") === "text") { - $(element).val($(element).val().trim()); - } - if ($(element).val() === "" || $(element).val() === null) { - return '"' + $(element).attr("parameter-name") + '"'; - } else { - return ""; - } + if ($(element).prop("type") === "text") { + $(element).val($(element).val().trim()); + } + if ($(element).val() === "" || $(element).val() === null) { + return '"' + $(element).attr("parameter-name") + '"'; + } else { + return ""; + } }; var callback = function(element, scope) { - scope.callback({ - id : $(element).attr("parameter-id") - }); + scope.callback({ + id : $(element).attr("parameter-id") + }); }; return { - restrict : "EA", - replace : true, - template : "

", - scope : { - control : "=", - callback : "&" - }, - link : function(scope, element, attrs) { - - var control = scope.control || {}; - - control.setList = function(parameterList) { - var html = ""; - for (var i = 0; i < parameterList.length; i++) { - html += getParameterHtml(parameterList[i], attrs.editable); - } - element.html(html); - element.find("input, select").bind("change", function() { - callback(this, scope); - }); - } - - control.updateList = function(parameterList) { - element.find("input, select").each( - function() { - for (var i = 0; i < parameterList.length; i++) { - if (parameterList[i].id === $(this).attr( - "parameter-id")) { - updateParameter(parameterList[i], this, - attrs.editable); - } - } - }); - element.find("input, select").bind("change", function() { - callback(this, scope); - }); - } - - control.getList = function(expectedId) { - var parameterList = new Array(); - element.find("input, select").each(function() { - var parameter = getParameter(this, expectedId); - if (parameter !== undefined) { - parameterList.push(parameter); - } - }); - return parameterList; - } - - control.getRequiredFields = function() { - var requiredFields = ""; - var count = 0; - element.find("input, select").each(function() { - if ($(this).attr("is-required") === "true") { - var requiredField = getRequiredField(this); - if (requiredField !== "") { - if (++count == 1) { - requiredFields = requiredField; - } - } - } - }); - if (--count <= 0) { - return requiredFields; - } else if (count == 1) { - return requiredFields + " and 1 other field"; - } else { - return requiredFields + " and " + count + " other fields"; - } - } - } + restrict : "EA", + replace : true, + template : "
", + scope : { + control : "=", + callback : "&" + }, + link : function(scope, element, attrs) { + + var control = scope.control || {}; + + control.setList = function(parameterList) { + var html = ""; + for (var i = 0; i < parameterList.length; i++) { + html += getParameterHtml(parameterList[i], attrs.editable); + } + element.html(html); + element.find("input, select").bind("change", function() { + callback(this, scope); + }); + } + + control.updateList = function(parameterList) { + element.find("input, select").each( + function() { + for (var i = 0; i < parameterList.length; i++) { + if (parameterList[i].id === $(this).attr( + "parameter-id")) { + updateParameter(parameterList[i], this, + attrs.editable); + } + } + }); + element.find("input, select").bind("change", function() { + callback(this, scope); + }); + } + + control.getList = function(expectedId) { + var parameterList = new Array(); + element.find("input, select").each(function() { + var parameter = getParameter(this, expectedId); + if (parameter !== undefined) { + parameterList.push(parameter); + } + }); + return parameterList; + } + + control.getRequiredFields = function() { + var requiredFields = ""; + var count = 0; + element.find("input, select").each(function() { + if ($(this).attr("is-required") === "true") { + var requiredField = getRequiredField(this); + if (requiredField !== "") { + if (++count == 1) { + requiredFields = requiredField; + } + } + } + }); + if (--count <= 0) { + return requiredFields; + } else if (count == 1) { + return requiredFields + " and 1 other field"; + } else { + return requiredFields + " and " + count + " other fields"; + } + } + } } } appDS2.directive('parameterBlock', [ "$log", "PARAMETER", "UtilityService", - parameterBlockDirective ]); + parameterBlockDirective ]); appDS2.directive('onlyIntegers', function () { @@ -416,7 +438,7 @@ appDS2.directive('onlyIntegers', function () { } else if (event.which >= 96 && event.which <= 105) { // numpad number return true; - } + } // else if ([110, 190].indexOf(event.which) > -1) { // // dot and numpad dot // return true; @@ -435,13 +457,13 @@ appDS2.directive('onlyFloat', function () { restrict: 'A', link: function (scope, elm, attrs, ctrl) { elm.on('keydown', function (event) { - if ([110, 190].indexOf(event.which) > -1) { + if ([110, 190].indexOf(event.which) > -1) { // dot and numpad dot event.preventDefault(); return true; } else{ - return false; + return false; } }); } diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js.orig b/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js.orig new file mode 100644 index 00000000..0e937826 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js.orig @@ -0,0 +1,507 @@ +/*- + * ============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========================================================= + */ + +"use strict"; + +var parameterBlockDirective = function($log, PARAMETER, UtilityService) { + /* + * If "IS_SINGLE_OPTION_AUTO_SELECTED" is set to "true" ... + * + * IF these 3 conditions all exist: + * + * 1) The parameter type is PARAMETER.SELECT + * + * 2) AND the "prompt" attribute is set to a string. + * + * 3) AND the optionList" only contains a single entry + * + * THEN the "prompt" will not be displayed as an initial select option. + */ + + var IS_SINGLE_OPTION_AUTO_SELECTED = true; + + /* + * Optionally remove "nameStyle" and "valueStyle" "width" entries to set + * dynamic sizing. + */ + var tableStyle = "width: auto; margin: 0 auto; border-collapse: collapse; border: none;"; + var nameStyle = "width: 220px; text-align: left; vertical-align: middle; font-weight: bold; padding: 3px 5px; border: none;"; + var valueStyle = "width: 400px; text-align: left; vertical-align: middle; padding: 3px 5px; border: none;"; + var checkboxValueStyle = "width: 400px; text-align: center; vertical-align: middle; padding: 3px 5px; border: none;" + var textInputStyle = "height: 25px; padding: 2px 5px;"; + var checkboxInputStyle = "height: 18px; width: 18px; padding: 2px 5px;"; + var selectStyle = "height: 25px; padding: 2px; text-align: center;"; + var requiredLabelStyle = "width: 25px; padding: 5px 10px 10px 5px;"; + + + var getParameterHtml = function(parameter, editable) { + var style = valueStyle; + var attributeString = ""; + if (parameter.type === PARAMETER.BOOLEAN) { + style = checkboxValueStyle; + } + if (UtilityService.hasContents(parameter.description)) { + attributeString += " title=' " + parameter.description + " '"; + } + var rowstyle=''; + if(parameter.type == 'file' && !parameter.isVisiblity){ + rowstyle = ' style="display:none;"'; + } + var html = "" + + getNameHtml(parameter) + ""; + if (editable === undefined) { + if (UtilityService.hasContents(parameter.value)) { + html += "" + parameter.value; + } else { + html += ""; + } + } else { + html += "" + getValueHtml(parameter); + } + html += ""; + return html; + }; + + var updateParameter = function(parameter, element, editable) { + $(element).parent().parent().children("td").first().html( + getNameHtml(parameter)); + if (editable === undefined) { + $(element).html(parameter.value); + } else { + $(element).parent().html(getValueHtml(parameter)); + } + }; + + var getNameHtml = function(parameter) { + if (parameter.isVisible === false) { + return ""; + } + var name = getParameterName(parameter); + + var requiredLabel = ""; + if (parameter.isRequired) { + requiredLabel = ""; + } + return name + ":" + requiredLabel; + }; + + var getParameterName = function(parameter) { + var name = ""; + if (UtilityService.hasContents(parameter.name)) { + name = parameter.name; + } else { + name = parameter.id; + } + return name; + } + + var getValueHtml = function(parameter) { + + var textInputPrompt = "Enter data"; + var attributeString = " data-tests-id='" + parameter.id +"' parameter-id='" + parameter.id + "'"; + var additionalStyle = ""; + if (parameter.isEnabled === false) { + attributeString += " disabled='disabled'"; + } + if (parameter.isRequired) { + attributeString += " is-required='true'"; + } + if (UtilityService.hasContents(parameter.description)) { + attributeString += " title=' " + parameter.description + " '"; + } + if (UtilityService.hasContents(parameter.isReadOnly) && (parameter.isReadOnly === true)) { + attributeString += " readonly"; + } + if ( (UtilityService.hasContents(parameter.maxLength)) && (UtilityService.hasContents(parameter.minLength)) ) { + attributeString += " pattern='.{" + parameter.minLength + "," + parameter.maxLength + "}' required"; + } + else if (UtilityService.hasContents(parameter.maxLength)) { + attributeString += " maxlength='" + parameter.maxLength + "'"; + } + else if (UtilityService.hasContents(parameter.minLength)) { + attributeString += " pattern='.{" + parameter.minLength + ",}'" + } + if (parameter.isVisible === false) { + additionalStyle = " visibility: hidden;"; + } + + var name = ""; + if (UtilityService.hasContents(parameter.name)) { + name = parameter.name; + } else { + name = parameter.id; + } + attributeString += " parameter-name='" + name + "'"; + + if ( parameter.type === PARAMETER.MAP ) { + textInputPrompt = "{: ,\.\.\.,: }"; + } + + if ( parameter.type === PARAMETER.LIST ) { + textInputPrompt = "[,\.\.\.,]"; + } + + switch (parameter.type) { + case PARAMETER.BOOLEAN: + if (parameter.value) { + return "" + "" + + ""; + + ""; + }else{ + return "" + "" + + "" + + ""; + } + break; + case PARAMETER.CHECKBOX: + if (parameter.value) { + return ""; + }else{ + return ""; + } + break; + case PARAMETER.FILE: + return ""; + break; + case PARAMETER.NUMBER: + var value=parameter.value; + var parameterSpec = ""; + } else { + //integer + return ""; + }*/ + return (parameterSpec); + break; + case PARAMETER.SELECT: + if (UtilityService.hasContents(parameter.prompt)) { + attributeString += " prompt='" + parameter.prompt + "'"; + } + return "" + getOptionListHtml(parameter) + + ""; + break; + case PARAMETER.STRING: + default: + var value = ""; + if (UtilityService.hasContents(parameter.value)) { + value = " value='" + parameter.value + "'"; + } + if (UtilityService.hasContents(parameter.prompt)) { + attributeString += " placeholder='" + parameter.prompt + "'"; + } else if (textInputPrompt !== "") { + attributeString += " placeholder='" + textInputPrompt + "'"; + } + var finalString = ""; + return finalString; + } + }; + + + var getBooleanListHtml = function(parameter){ + var html = ""; + + }; + + var getOptionListHtml = function(parameter) { + +<<<<<<< HEAD + var html = ""; + + if (!angular.isArray(parameter.optionList) + || parameter.optionList.length === 0) { + return ""; + } + + if (UtilityService.hasContents(parameter.prompt)) { + if (!(IS_SINGLE_OPTION_AUTO_SELECTED && parameter.optionList.length === 1) || !(parameter.isSingleOptionAutoSelected && parameter.optionList.length === 1)) { + html += ""; + } + } + + for (var i = 0; i < parameter.optionList.length; i++) { + var option = parameter.optionList[i]; + var name = option.name; + var value = ""; + if (option.id === undefined) { + value = option.name; + } else { + if (name === undefined) { + name = option.id; + } + value = option.id; + } + if (option.isDefault === undefined || option.isDefault === false ) { + html += ""; + } + else { + html += ""; + } + } + return html; +======= + var html = ""; + + if (!angular.isArray(parameter.optionList) + || parameter.optionList.length === 0) { + return ""; + } + + if (UtilityService.hasContents(parameter.prompt)) { + if (!(IS_SINGLE_OPTION_AUTO_SELECTED && parameter.optionList.length === 1)) { + html += ""; + } + } + + for (var i = 0; i < parameter.optionList.length; i++) { + var option = parameter.optionList[i]; + var name = option.name; + var value = ""; + if (option.id === undefined) { + value = option.name; + } else { + if (name === undefined) { + name = option.id; + } + value = option.id; + } + html += getOptionHtml(option.isPermitted, option.isDataLoading, value, name, parameter); + } + return html; +>>>>>>> 7e45cad... merge + }; + + function getOptionHtml(isPermitted, isDefault, value, name, parameter) { + var html = ""; + if (isDefault === undefined || isDefault === false ) { + if(isPermitted) + html = ""; + else { + html = ""; + } + } + else { + if(isPermitted) + html = ""; + else { + html = ""; + } + } + return html; + } + + var getParameter = function(element, expectedId) { + var id = $(element).attr("parameter-id"); + if (expectedId !== undefined && expectedId !== id) { + return undefined; + } + var parameter = { + id : id + }; + if ($(element).prop("type") === "checkbox") { + parameter.value = $(element).prop("checked"); + }else if ($(element).prop("type") === "file") { + parameter.value = $('#'+id).attr("value"); + + } else { + if ($(element).prop("type") === "text") { + $(element).val($(element).val().trim()); + } + parameter.value = $(element).val(); + } + if ($(element).prop("selectedIndex") === undefined) { + parameter.selectedIndex = -1; + } else { + parameter.selectedIndex = $(element).prop("selectedIndex"); + if (UtilityService.hasContents($(element).attr("prompt"))) { + parameter.selectedIndex--; + } + } + return parameter; + }; + + var getRequiredField = function(element) { + if ($(element).prop("type") === "text") { + $(element).val($(element).val().trim()); + } + if ($(element).val() === "" || $(element).val() === null) { + return '"' + $(element).attr("parameter-name") + '"'; + } else { + return ""; + } + }; + + var callback = function(element, scope) { + scope.callback({ + id : $(element).attr("parameter-id") + }); + }; + + return { + restrict : "EA", + replace : true, + template : "
", + scope : { + control : "=", + callback : "&" + }, + link : function(scope, element, attrs) { + + var control = scope.control || {}; + + control.setList = function(parameterList) { + var html = ""; + for (var i = 0; i < parameterList.length; i++) { + html += getParameterHtml(parameterList[i], attrs.editable); + } + element.html(html); + element.find("input, select").bind("change", function() { + callback(this, scope); + }); + } + + control.updateList = function(parameterList) { + element.find("input, select").each( + function() { + for (var i = 0; i < parameterList.length; i++) { + if (parameterList[i].id === $(this).attr( + "parameter-id")) { + updateParameter(parameterList[i], this, + attrs.editable); + } + } + }); + element.find("input, select").bind("change", function() { + callback(this, scope); + }); + } + + control.getList = function(expectedId) { + var parameterList = new Array(); + element.find("input, select").each(function() { + var parameter = getParameter(this, expectedId); + if (parameter !== undefined) { + parameterList.push(parameter); + } + }); + return parameterList; + } + + control.getRequiredFields = function() { + var requiredFields = ""; + var count = 0; + element.find("input, select").each(function() { + if ($(this).attr("is-required") === "true") { + var requiredField = getRequiredField(this); + if (requiredField !== "") { + if (++count == 1) { + requiredFields = requiredField; + } + } + } + }); + if (--count <= 0) { + return requiredFields; + } else if (count == 1) { + return requiredFields + " and 1 other field"; + } else { + return requiredFields + " and " + count + " other fields"; + } + } + } + } +} + +appDS2.directive('parameterBlock', [ "$log", "PARAMETER", "UtilityService", + parameterBlockDirective ]); + + +appDS2.directive('onlyIntegers', function () { + return { + restrict: 'A', + link: function (scope, elm, attrs, ctrl) { + elm.on('keydown', function (event) { + if(event.shiftKey){event.preventDefault(); return false;} + //console.log(event.which); + if ([8, 13, 27, 37, 38, 39, 40].indexOf(event.which) > -1) { + // backspace, enter, escape, arrows + return true; + } else if (event.which >= 49 && event.which <= 57) { + // numbers + return true; + } else if (event.which >= 96 && event.which <= 105) { + // numpad number + return true; + } + // else if ([110, 190].indexOf(event.which) > -1) { + // // dot and numpad dot + // return true; + // } + else { + event.preventDefault(); + return false; + } + }); + } + } +}); + +appDS2.directive('onlyFloat', function () { + return { + restrict: 'A', + link: function (scope, elm, attrs, ctrl) { + elm.on('keydown', function (event) { + if ([110, 190].indexOf(event.which) > -1) { + // dot and numpad dot + event.preventDefault(); + return true; + } + else{ + return false; + } + }); + } + } +}); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js index ee99547b..09c70eb5 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js @@ -20,339 +20,365 @@ "use strict"; -var AaiService = function($http, $log, PropertyService, UtilityService, COMPONENT, FIELD) { +var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONENT, FIELD) { return { - getSubscriberName : function(globalCustomerId, - successCallbackFunction) { - $log - .debug("AaiService:getSubscriberName: globalCustomerId: " - + globalCustomerId); - $http.get( - COMPONENT.AAI_SUB_DETAILS_PATH - + globalCustomerId + COMPONENT.ASSIGN + Math.random(), - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(function(response) { - var subName = ""; - if (response.data) { - subName = response.data[FIELD.ID.SUBNAME]; - } - successCallbackFunction(subName); - })["catch"] - (UtilityService.runHttpErrorHandler); - }, + getSubscriberName: function (globalCustomerId, + successCallbackFunction) { + $log + .debug("AaiService:getSubscriberName: globalCustomerId: " + + globalCustomerId); + $http.get( + COMPONENT.AAI_SUB_DETAILS_PATH + + globalCustomerId + COMPONENT.ASSIGN + Math.random(), + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + var subName = ""; + if (response.data) { + subName = response.data[FIELD.ID.SUBNAME]; + } + successCallbackFunction(subName); + })["catch"] + (UtilityService.runHttpErrorHandler); + }, - - runNamedQuery : function (namedQueryId, globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) { - - var url = COMPONENT.AAI_SUB_VIEWEDIT_PATH + - COMPONENT.FORWARD_SLASH + encodeURIComponent(namedQueryId) + - COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) + - COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) + - COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId); - $http.get(url, { - },{ - timeout : PropertyService.getServerResponseTimeoutMsec() - }).then(function(response) { - if (response.data != null) { - successCallback(response); - } else { - errorCallback(response); - } - }, function(response) { - errorCallback(response); - }); - }, - - - getSubDetails : function(selectedSubscriber, selectedServiceInstance, successCallback, errorCallback) { - var subscriber; - var displayData; - $http.get( COMPONENT.AAI_SUB_DETAILS_PATH + selectedSubscriber, { + runNamedQuery: function (namedQueryId, globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) { - },{ - timeout : PropertyService.getServerResponseTimeoutMsec() - }).then(function(response) { - displayData = []; - subscriber = response.data; - var subscriberName = subscriber[FIELD.ID.SUBNAME]; - if (subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) { - angular.forEach(subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) { - var serviceInstanceId = []; - var serviceType = ""; - if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) { - serviceType = serviceSubscription[FIELD.ID.SERVICETYPE]; - } else { - serviceType = FIELD.PROMPT.NO_SERVICE_SUB; - } - if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) { - angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) { - // put them together, i guess - var inst = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], - "aaiModelInvariantId": instValue[FIELD.ID.MODEL_INVAR_ID], - "aaiModelVersionId": instValue[FIELD.ID.MODEL_VERSION_ID], - "serviceInstanceName": instValue[FIELD.ID.SERVICE_INSTANCE_NAME] - }; - if (selectedServiceInstance != null) { - if ((instValue[FIELD.ID.SERVICE_INSTANCE_ID] == selectedServiceInstance ) || (instValue[FIELD.ID.SERVICE_INSTANCE_NAME] == selectedServiceInstance)) { - serviceInstanceId.push(inst); - } - } else { - serviceInstanceId.push(inst); - } - }); - } else { - if (serviceInstanceId == []) { - serviceInstanceId = [ FIELD.PROMPT.NO_SERVICE_INSTANCE ]; - } - } - angular.forEach(serviceInstanceId, function(subVal, subKey) { - displayData.push({ - globalCustomerId : selectedSubscriber, - subscriberName : subscriberName, - serviceType : serviceType, - serviceInstanceId : subVal.serviceInstanceId, - aaiModelInvariantId : subVal.aaiModelInvariantId, - aaiModelVersionId - : subVal.aaiModelVersionId, - serviceInstanceName : subVal.serviceInstanceName - }); - }); - }); - } else { - displayData.push({ - globalCustomerId : selectedSubscriber, - subscriberName : selectedSubscriberName, - serviceType : FIELD.PROMPT.NO_SERVICE_SUB, - serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE - }); - } - successCallback(displayData, subscriberName); - }, function(response) { - errorCallback(response); - }); - }, - getSubList : function(successCallback, errorCallback ) { + var url = COMPONENT.AAI_SUB_VIEWEDIT_PATH + + COMPONENT.FORWARD_SLASH + encodeURIComponent(namedQueryId) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId); + $http.get(url, {}, { + timeout: PropertyService.getServerResponseTimeoutMsec() + }).then(function (response) { + if (response.data != null) { + successCallback(response); + } else { + errorCallback(response); + } + }, function (response) { + errorCallback(response); + }); + }, - $http.get( FIELD.ID.AAI_GET_FULL_SUBSCRIBERS, { - },{ - timeout : PropertyService.getServerResponseTimeoutMsec() - }).then(function(response) { - var customerList = []; - if (response.data.customer != null) { - angular.forEach(response.data.customer, function(subVal, subKey) { - var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] }; - customerList.push(cust); - }); - successCallback(customerList); - } else { - errorCallback(response); - } - },function(response) { - errorCallback(response); - }); - }, - - getServices2 : function(successCallback, errorCallback ) { + getSubDetails: function (selectedSubscriber, selectedServiceInstance, successCallback, errorCallback) { + var subscriber; + var displayData; + $http.get(COMPONENT.AAI_SUB_DETAILS_PATH + selectedSubscriber, {}, { + timeout: PropertyService.getServerResponseTimeoutMsec() + }).then(function (response) { + displayData = []; + subscriber = response.data; + var subscriberName = subscriber[FIELD.ID.SUBNAME]; + if (subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) { + angular.forEach(subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function (serviceSubscription, key) { + var serviceInstanceId = []; + var serviceType = ""; + if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) { + serviceType = serviceSubscription[FIELD.ID.SERVICETYPE]; + } else { + serviceType = FIELD.PROMPT.NO_SERVICE_SUB; + } + if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) { + angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function (instValue, instKey) { + // put them together, i guess + var inst = { + "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], + "aaiModelInvariantId": instValue[FIELD.ID.MODEL_INVAR_ID], + "aaiModelVersionId": instValue[FIELD.ID.MODEL_VERSION_ID], + "serviceInstanceName": instValue[FIELD.ID.SERVICE_INSTANCE_NAME] + }; + if (selectedServiceInstance != null) { + if ((instValue[FIELD.ID.SERVICE_INSTANCE_ID] == selectedServiceInstance ) || (instValue[FIELD.ID.SERVICE_INSTANCE_NAME] == selectedServiceInstance)) { + serviceInstanceId.push(inst); + } + } else { + serviceInstanceId.push(inst); + } + }); + } else { + if (serviceInstanceId == []) { + serviceInstanceId = [FIELD.PROMPT.NO_SERVICE_INSTANCE]; + } + } + angular.forEach(serviceInstanceId, function (subVal, subKey) { + displayData.push({ + globalCustomerId: selectedSubscriber, + subscriberName: subscriberName, + serviceType: serviceType, + serviceInstanceId: subVal.serviceInstanceId, + aaiModelInvariantId: subVal.aaiModelInvariantId, + aaiModelVersionId: subVal.aaiModelVersionId, + serviceInstanceName: subVal.serviceInstanceName, + isPermitted: serviceSubscription[FIELD.ID.IS_PERMITTED] + }); + }); + }); + } else { + displayData.push({ + globalCustomerId: selectedSubscriber, + subscriberName: selectedSubscriberName, + serviceType: FIELD.PROMPT.NO_SERVICE_SUB, + serviceInstanceId: FIELD.PROMPT.NO_SERVICE_INSTANCE + }); + } + successCallback(displayData, subscriberName); + }, function (response) { + errorCallback(response); + }); + }, + getSubList: function (successCallback, errorCallback) { - $http.get( FIELD.ID.AAI_GET_SERVICES, { + $http.get(FIELD.ID.AAI_GET_FULL_SUBSCRIBERS, {}, { + timeout: PropertyService.getServerResponseTimeoutMsec() + }).then(function (response) { + var customerList = []; + if (response.data.customer != null) { + angular.forEach(response.data.customer, function (subVal, subKey) { + var cust = { + "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], + "subscriberName": subVal[FIELD.ID.SUBNAME], + "isPermitted": subVal[FIELD.ID.IS_PERMITTED], + }; + customerList.push(cust); + }); + successCallback(customerList); + } else { + errorCallback(response); + } + }, function (response) { + errorCallback(response); + }); + }, - },{ - timeout : PropertyService.getServerResponseTimeoutMsec() - }).then(function(response) { - var customerList = []; - if (response.data != null) { - var serviceIdList = []; - angular.forEach(response.data, function(value, key) { - angular.forEach(value, function(subVal, key) { - var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] }; - serviceIdList.push(newVal); - }); - }); - successCallback(serviceIdList); - } else { - errorCallback(response); - } - },function(response) { - errorCallback(response); - }); - }, - - getSubscriptionServiceTypeList : function(globalCustomerId, - successCallbackFunction) { - $log - .debug("AaiService:getSubscriptionServiceTypeList: globalCustomerId: " - + globalCustomerId); - if ( UtilityService.hasContents(globalCustomerId) ) { - $http.get( - COMPONENT.AAI_SUB_DETAILS_PATH - + globalCustomerId + COMPONENT.ASSIGN + Math.random(), - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(function(response) { - if (response.data && response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS]) { - var serviceTypes = []; - var serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION]; - - for (var i = 0; i < serviceSubscriptions.length; i++) { - serviceTypes.push(serviceSubscriptions[i][FIELD.ID.SERVICETYPE]); - } - successCallbackFunction(serviceTypes); - } else { - successCallbackFunction([]); - } - })["catch"] - (UtilityService.runHttpErrorHandler); - } - }, - getLcpCloudRegionTenantList : function(globalCustomerId, serviceType, - successCallbackFunction) { - $log - .debug("AaiService:getLcpCloudRegionTenantList: globalCustomerId: " - + globalCustomerId); - var url = COMPONENT.AAI_GET_TENANTS - + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random(); - - $http.get(url, - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(function(response) { - var lcpCloudRegionTenants = []; - var aaiLcpCloudRegionTenants = response.data; - - lcpCloudRegionTenants.push({ - "cloudRegionId": "", - "tenantName": FIELD.PROMPT.REGION, - "tenantId": "" - }); - - for (var i = 0; i < aaiLcpCloudRegionTenants.length; i++) { - lcpCloudRegionTenants.push({ - "cloudRegionId": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_REGION_ID], - "tenantName": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_NAME], - "tenantId": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_ID] - }); - } - - successCallbackFunction(lcpCloudRegionTenants); - })["catch"] - (UtilityService.runHttpErrorHandler); - }, - getSubscribers : function(successCallbackFunction) { - $log - .debug("AaiService:getSubscribers"); - var url = FIELD.ID.AAI_GET_SUBSCRIBERS + COMPONENT.ASSIGN + Math.random(); - - $http.get(url, - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(function(response) { - if (response.data) { - successCallbackFunction(response.data.customer); - } else { - successCallbackFunction([]); - } - })["catch"] - (UtilityService.runHttpErrorHandler); - }, - getProvOptionsFromSystemProp : function(successCallbackFunction) { - $log - .debug("AaiService:getProvOptionsFromSystemProp"); - var url = COMPONENT.GET_SYSTEM_PROP_VNF_PROV_STATUS_PATH; - - $http.get(url, - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(function(response) { - if (response.data) { - successCallbackFunction(response); - } else { - successCallbackFunction([]); - } - })["catch"] - (UtilityService.runHttpErrorHandler); - }, - getLoggedInUserID : function(successCallbackFunction) { - $log - .debug("AaiService:getLoggedInUserID"); - var url = COMPONENT.GET_USER_ID; - - $http.get(url, - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(function(response) { - if (response.data) { - successCallbackFunction(response); - } else { - successCallbackFunction([]); - } - })["catch"] - (UtilityService.runHttpErrorHandler); - }, - getServices : function(successCallbackFunction) { - $log - .debug("AaiService:getServices"); - var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.ASSIGN + Math.random(); - - $http.get(url, - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(function(response) { - if (response.data) { - successCallbackFunction(response); - } else { - successCallbackFunction([]); - } - })["catch"] - (UtilityService.runHttpErrorHandler); - }, - getServiceModels : function(globalCustomerId,serviceType,successCallbackFunction) { - $log - .debug("AaiService:getServices"); - var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.FORWARD_SLASH+globalCustomerId+ COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random(); + getServices2: function (successCallback, errorCallback) { - $http.get(url, - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(function(response) { - if (response.data) { - successCallbackFunction(response); - } else { - successCallbackFunction([]); - } - })["catch"] - (UtilityService.runHttpErrorHandler); -}, -getServiceModelsByServiceType : function(namedQueryId,globalCustomerId,serviceType,successCallbackFunction) { - $log - .debug("AaiService:getServiceModelsByServiceType"); - var url = COMPONENT.AAI_GET_SERVICES_BY_TYPE+COMPONENT.FORWARD_SLASH+namedQueryId+COMPONENT.FORWARD_SLASH+globalCustomerId+COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random(); - - $http.get(url, - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(function(response) { - if (response.data) { - successCallbackFunction(response); - } else { - successCallbackFunction([]); - } - })["catch"] - (UtilityService.runHttpErrorHandler); - } + $http.get(FIELD.ID.AAI_GET_SERVICES, {}, { + timeout: PropertyService.getServerResponseTimeoutMsec() + }).then(function (response) { + var customerList = []; + if (response.data != null) { + var serviceIdList = []; + angular.forEach(response.data, function (value, key) { + angular.forEach(value, function (subVal, key) { + var newVal = { + "id": subVal[FIELD.ID.SERVICE_ID], + "description": subVal[FIELD.ID.SERVICE_DESCRIPTION], + "isPermitted" : subVal[FIELD.ID.IS_PERMITTED] + + }; + serviceIdList.push(newVal); + }); + }); + successCallback(serviceIdList); + } else { + errorCallback(response); + } + }, function (response) { + errorCallback(response); + }); + }, + + getSubscriptionServiceTypeList: function (globalCustomerId, + successCallbackFunction) { + $log + .debug("AaiService:getSubscriptionServiceTypeList: globalCustomerId: " + + globalCustomerId); + if (UtilityService.hasContents(globalCustomerId)) { + $http.get( + COMPONENT.AAI_SUB_DETAILS_PATH + + globalCustomerId + COMPONENT.ASSIGN + Math.random(), + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + if (response.data && response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS]) { + var serviceTypes = []; + var serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION]; + + for (var i = 0; i < serviceSubscriptions.length; i++) { + serviceTypes.push({ + "name": serviceSubscriptions[i][FIELD.ID.SERVICETYPE], + "isPermitted": serviceSubscriptions[i][FIELD.ID.IS_PERMITTED], + "id": i + }); + } + successCallbackFunction(serviceTypes); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + } + }, + getLcpCloudRegionTenantList: function (globalCustomerId, serviceType, + successCallbackFunction) { + $log + .debug("AaiService:getLcpCloudRegionTenantList: globalCustomerId: " + + globalCustomerId); + var url = COMPONENT.AAI_GET_TENANTS + + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + var lcpCloudRegionTenants = []; + var aaiLcpCloudRegionTenants = response.data; + + lcpCloudRegionTenants.push({ + "cloudRegionId": "", + "tenantName": FIELD.PROMPT.REGION, + "tenantId": "" + }); + + for (var i = 0; i < aaiLcpCloudRegionTenants.length; i++) { + lcpCloudRegionTenants.push({ + "cloudRegionId": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_REGION_ID], + "tenantName": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_NAME], + "tenantId": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_ID], + "isPermitted": aaiLcpCloudRegionTenants[i][COMPONENT.IS_PERMITTED] + }); + } + + successCallbackFunction(lcpCloudRegionTenants); + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + getSubscribers: function (successCallbackFunction) { + $log + .debug("AaiService:getSubscribers"); + var url = FIELD.ID.AAI_GET_SUBSCRIBERS + COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + if (response.data) { + successCallbackFunction(response.data.customer); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + getProvOptionsFromSystemProp: function (successCallbackFunction) { + $log + .debug("AaiService:getProvOptionsFromSystemProp"); + var url = COMPONENT.GET_SYSTEM_PROP_VNF_PROV_STATUS_PATH; + + $http.get(url, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + getLoggedInUserID: function (successCallbackFunction) { + $log + .debug("AaiService:getLoggedInUserID"); + var url = COMPONENT.GET_USER_ID; + + $http.get(url, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + getServices: function (successCallbackFunction) { + $log + .debug("AaiService:getServices"); + var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + + getAicZones: function (successCallbackFunction) { + $log + .debug("getAicZones:getAicZones"); + var url = COMPONENT.AAI_GET_AIC_ZONES + COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + getServiceModels: function (globalCustomerId, serviceType, successCallbackFunction) { + $log + .debug("AaiService:getServices"); + var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.FORWARD_SLASH + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + getServiceModelsByServiceType: function (namedQueryId, globalCustomerId, serviceType, successCallbackFunction) { + $log + .debug("AaiService:getServiceModelsByServiceType"); + var url = COMPONENT.AAI_GET_SERVICES_BY_TYPE + COMPONENT.FORWARD_SLASH + namedQueryId + COMPONENT.FORWARD_SLASH + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + } } } -appDS2.factory("AaiService", [ "$http", "$log", "PropertyService", - "UtilityService", "COMPONENT", "FIELD", AaiService ]); +appDS2.factory("AaiService", ["$http", "$log", "PropertyService", + "UtilityService", "COMPONENT", "FIELD", AaiService]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/componentService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/componentService.js index 391c6ba1..ea46dcb9 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/componentService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/componentService.js @@ -30,7 +30,9 @@ var ComponentService = function($log, COMPONENT, UtilityService) { }, { id : COMPONENT.SERVICE, displayName : "Service Instance" - }, { + }, {id : COMPONENT.OLDVERSION, + displayName : "Previous Version" + }, { id : COMPONENT.VNF, displayName : "Virtual Network Function" }, { diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js index 11e61b3a..9309ce6c 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js @@ -39,7 +39,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON getLoggedInUserID(); switch (_this.componentId) { case COMPONENT.SERVICE: - return [ getSubscribers, getServices ]; + return [ getSubscribers, getServices,getAicZones ]; case COMPONENT.NETWORK: return [ getLcpCloudRegionTenantList ]; case COMPONENT.VNF: @@ -121,6 +121,13 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON .getModelInfo(_this.componentId)[FIELD.ID.DESCRIPTION]); addToList(FIELD.NAME.SERVICE_CATEGORY, DataService .getModelInfo(_this.componentId)[FIELD.ID.CATEGORY]); + if (DataService.getModelInfo(_this.componentId)[FIELD.ID.SERVICE_TYPE] != "null") { + addToList(FIELD.NAME.SERVICE_TYPE, DataService + .getModelInfo(_this.componentId)[FIELD.ID.SERVICE_TYPE]); + addToList(FIELD.NAME.SERVICE_ROLE, DataService + .getModelInfo(_this.componentId)[FIELD.ID.SERVICE_ROLE]); + } + break; case COMPONENT.VF_MODULE: addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService @@ -209,14 +216,18 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON if(!isInTop){ if (isUserProvidedNaming) { parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ]; - + } parameterList = parameterList.concat([ getSubscribersParameter() ]); parameterList = parameterList.concat([ getServiceId(), FIELD.PARAMETER.SERVICE_TYPE, FIELD.PARAMETER.LCP_REGION, FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN, - FIELD.PARAMETER.TENANT_DISABLED ]); + FIELD.PARAMETER.TENANT_DISABLED, + ]); + parameterList = parameterList.concat([ getAICZones() ]); + + }else{ parameterList = parameterList.concat([ getServiceId(), FIELD.PARAMETER.LCP_REGION, @@ -263,23 +274,27 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON } parameterList.push(FIELD.PARAMETER.SUPPRESS_ROLLBACK); if(_this.componentId === COMPONENT.VF_MODULE ){ - parameterList.push({name: "SDN-C Pre-Load", - id: "sdncPreload", + if(DataService.getSubscriberName() === FIELD.NAME.MOBILITY){ + parameterList.push({name: FIELD.NAME.SDN_C_PRELOAD, + id: FIELD.ID.SDN_C_PRELOAD, type: "checkbox", isEnabled: true, - isRequired: false + isRequired: false, + hideFieldAndLabel: true } ); - parameterList.push({name: "Upload Supplementory Data file", - id: "uploadSupplementoryDataFile", + } + parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE, + id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE, type: "checkbox", isEnabled: true, - isRequired: false + isRequired: false, + value:false } ); - parameterList.push({name: "Supplemetory file (JSON format)", - id: "supplementoryDataFile", + parameterList.push({name: FIELD.NAME.SUPPLEMENTORY_DATA_FILE, + id: FIELD.ID.SUPPLEMENTORY_DATA_FILE, type: "file", isRequired: false, isVisiblity: false @@ -288,16 +303,16 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON } if( VIDCONFIGURATION.UPLOAD_SUPPLEMENTARY_STATUS_CHECK_ENABLED && _this.componentId === COMPONENT.VOLUME_GROUP){ - parameterList.push({name: "Upload Supplementory Data file", - id: "uploadSupplementoryDataFile", + parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE, + id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE, type: "checkbox", isEnabled: true, isRequired: false } ); - parameterList.push({name: "Supplemetory file (JSON format)", - id: "supplementoryDataFile", + parameterList.push({name: FIELD.NAME.SUPPLEMENTORY_DATA_FILE, + id: FIELD.ID.SUPPLEMENTORY_DATA_FILE, type: "file", isRequired: false, isVisiblity: false @@ -584,7 +599,12 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON break; case COMPONENT.VF_MODULE: - break; + requestDetails.requestParameters.usePreload = getValueFromList( + FIELD.ID.SDN_C_PRELOAD, parameterList); + if(_this.componentId == COMPONENT.VF_MODULE &&(requestDetails.requestParameters.usePreload== null || requestDetails.requestParameters.usePreload === '')){ + requestDetails.requestParameters.usePreload = true; + } + break; case COMPONENT.VOLUME_GROUP: break; } @@ -716,12 +736,24 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON break; case FIELD.ID.SUBSCRIBER_NAME: break; + case FIELD.ID.SDN_C_PRELOAD: + break; + case FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE: + break; + case FIELD.ID.SUPPLEMENTORY_DATA_FILE: + arbitraryParameters = FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value']; + arbitraryArray=arbitraryParameters; + FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value']=[]; + break; + default: - arbitraryParameters = { - name : parameter.id, - value : parameter.value + if (parameter.value != '') { + arbitraryParameters = { + name: parameter.id, + value: parameter.value + } + arbitraryArray.push(arbitraryParameters); } - arbitraryArray.push(arbitraryParameters); } } return (arbitraryArray); @@ -766,15 +798,40 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON var serviceIdList = []; angular.forEach(response.data, function(value, key) { angular.forEach(value, function(subVal, key) { - var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] }; + var newVal = { + "id" : subVal[FIELD.ID.SERVICE_ID], + "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION], + "isPermitted" : subVal[FIELD.ID.IS_PERMITTED], + }; serviceIdList.push(newVal); DataService.setServiceIdList(serviceIdList); }); }); - + UtilityService.startNextAsyncOperation(); }); }; + var getAicZones = function() { + AaiService.getAicZones(function(response) { + var serviceIdList = []; + angular.forEach(response.data, function(value, key) { + angular.forEach(value, function(subVal, key) { + var newVal = { + "id" : subVal[FIELD.ID.ZONE_ID], + "name" : subVal[FIELD.ID.ZONE_NAME], + }; + serviceIdList.push(newVal); + DataService.setAicZones(serviceIdList); + }); + }); + + UtilityService.startNextAsyncOperation(); + }); + + }; + + + var getLcpCloudRegionTenantList = function() { AaiService.getLcpCloudRegionTenantList(DataService .getGlobalCustomerId(), DataService.getServiceType(), function( @@ -802,7 +859,8 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON for (var i = 0; i < subscribers.length; i++) { parameter.optionList.push({ id : subscribers[i][FIELD.ID.GLOBAL_CUSTOMER_ID], - name : subscribers[i][FIELD.ID.SUBNAME] + name : subscribers[i][FIELD.ID.SUBNAME], + isPermitted : subscribers[i][FIELD.ID.IS_PERMITTED] }) } } @@ -819,7 +877,8 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON for (var i = 0; i < serviceIdList.length; i++) { parameter.optionList.push({ id : serviceIdList[i].id, - name : serviceIdList[i].description + name : serviceIdList[i].description, + isPermitted : serviceIdList[i].isPermitted }); } } @@ -827,6 +886,26 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON return parameter; }; + var getAICZones = function() { + var aicList = DataService.getAicZones(); + var parameter = FIELD.PARAMETER.AIC_ZONES; + parameter.optionList = new Array(); + if ( UtilityService.hasContents(aicList) ) { + // load them all + for (var i = 0; i < aicList.length; i++) { + parameter.optionList.push({ + id : aicList[i].id, + name : aicList[i].name, + isPermitted : true + + }); + } + } + + return parameter; + }; + + var getLcpRegion = function() { var cloudRegionTenantList = DataService.getCloudRegionTenantList(); console.log ( "cloudRegionTenantList="); @@ -838,14 +917,17 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON for (var i = 0; i < cloudRegionTenantList.length; i++) { for (var j = 0; j < parameter.optionList.length; j++) { if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionId) { - break; - } + parameter.optionList[j].isPermitted = + parameter.optionList[j].isPermitted || cloudRegionTenantList[i].isPermitted; + break; + } } if (j < parameter.optionList.length) { continue; } parameter.optionList.push({ - id : cloudRegionTenantList[i].cloudRegionId + id : cloudRegionTenantList[i].cloudRegionId, + isPermitted : cloudRegionTenantList[i].isPermitted }); } } @@ -862,8 +944,10 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON if (cloudRegionTenantList[i].cloudRegionId === cloudRegionId) { parameter.optionList.push({ id : cloudRegionTenantList[i].tenantId, - name : cloudRegionTenantList[i].tenantName - }); + name : cloudRegionTenantList[i].tenantName, + isPermitted : cloudRegionTenantList[i].isPermitted + + }); } } } @@ -878,7 +962,8 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON } for (var i = 0; i < optionSimpleArray.length; i++) { optionList.push({ - name : optionSimpleArray[i] + name : optionSimpleArray[i], + isPermitted :true, }); } parameter.optionList = optionList; @@ -918,6 +1003,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON .updateList([ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED ]); }else{ $('input[parameter-id="'+FIELD.ID.SUPPLEMENTORY_DATA_FILE+'"]').closest('tr').hide(); + FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED.value=false; parameterListControl .updateList([ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_UNCHECKED ]); } @@ -959,9 +1045,11 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON for (var i = 0; i < response.length; i++) { serviceTypeParameters.optionList.push({ - "id" : response[i], - "name" : response[i] - }); + "id" : response[i].name, + "name" : response[i].name, + "isPermitted" :response[i].isPermitted + + }); } console.log ( "updateUserParameterList: service type parameters " ); console.log ( JSON.stringify (serviceTypeParameters, null, 4)); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js index bb5adad3..2d7fa6ca 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js @@ -94,6 +94,12 @@ var DataService = function($log, DataService) { setServiceIdList : function(serviceIdList) { _this.serviceIdList = serviceIdList; }, + setAicZones : function(aicZones) { + _this.aicZones = aicZones; + }, + getAicZones : function(){ + return _this.aicZones; + }, getServiceInstanceId : function() { return _this.serviceInstanceId; }, @@ -249,6 +255,15 @@ var DataService = function($log, DataService) { } return _this.aLaCarte; }, + setMacro : function(aval) { + _this.macro = aval; + }, + getMacro : function() { + if (_this.macro === undefined) { + return false; + } + return _this.macro; + }, getResources : function() { return _this.resources; }, diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/deletionService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/deletionService.js index 62c2b19c..79282997 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/deletionService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/deletionService.js @@ -380,15 +380,19 @@ var DeletionService = function($log, AaiService, AsdcService, DataService, for (var i = 0; i < cloudRegionTenantList.length; i++) { for (var j = 0; j < parameter.optionList.length; j++) { if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionId) { - break; + parameter.optionList[j].isPermitted = + parameter.optionList[j].isPermitted || cloudRegionTenantList[i].isPermitted; + break; } } if (j < parameter.optionList.length) { continue; } parameter.optionList.push({ - id : cloudRegionTenantList[i].cloudRegionId - }); + id : cloudRegionTenantList[i].cloudRegionId, + isPermitted : cloudRegionTenantList[i].isPermitted + + }); } } return parameter; @@ -404,8 +408,9 @@ var DeletionService = function($log, AaiService, AsdcService, DataService, if (cloudRegionTenantList[i].cloudRegionId === cloudRegionId) { parameter.optionList.push({ id : cloudRegionTenantList[i].tenantId, - name : cloudRegionTenantList[i].tenantName - }); + name : cloudRegionTenantList[i].tenantName, + isPermitted : cloudRegionTenantList[i].isPermitted + }); } } } @@ -465,8 +470,8 @@ var DeletionService = function($log, AaiService, AsdcService, DataService, for (var i = 0; i < response.length; i++) { serviceTypeParameters.optionList.push({ - "id" : response[i], - "name" : response[i] + "id" : response[i].name, + "name" : response[i].name }); } parameterListControl.updateList([ serviceTypeParameters ]); @@ -493,7 +498,8 @@ var DeletionService = function($log, AaiService, AsdcService, DataService, }, updateUserParameterList : updateUserParameterList, getMsoRequestDetails : getMsoRequestDetails, - getMsoUrl : getMsoUrl + getMsoUrl : getMsoUrl, + isMacro : DataService.getMacro() } } diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js index 836279b9..3fc04ba0 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js @@ -41,21 +41,42 @@ var VnfService = function($http, $log, VIDCONFIGURATION, FIELD, UtilityService) if ( ( UtilityService.hasContents ( vnfInstance.object[FIELD.ID.ORCHESTRATION_STATUS] ) ) && ( UtilityService.hasContents ( vnfInstance.object[FIELD.ID.IN_MAINT] ) ) && ( UtilityService.hasContents ( vnfInstance.object[FIELD.ID.PROV_STATUS] ) ) ) { - + status.provStatus = vnfInstance.object[FIELD.ID.PROV_STATUS].toLowerCase(); + console.log ("PROVSTATUS: " + vnfInstance.object[FIELD.ID.PROV_STATUS].toLowerCase()); + status.orchestrationStatus = vnfInstance.object[FIELD.ID.ORCHESTRATION_STATUS].toLowerCase(); + console.log ("ORCHESTRATION STATUS: " + vnfInstance.object[FIELD.ID.ORCHESTRATION_STATUS].toLowerCase()); + status.inMaint = vnfInstance.object[FIELD.ID.IN_MAINT]; - + console.log ("IN MAINT: " + vnfInstance.object[FIELD.ID.IN_MAINT]); + if ( UtilityService.hasContents(vnfInstance.object[FIELD.ID.OPERATIONAL_STATUS]) ) { status.operationalStatus = vnfInstance.object[FIELD.ID.OPERATIONAL_STATUS].toLowerCase(); } - - if ( UtilityService.arrayContains ( VIDCONFIGURATION.VNF_VALID_STATUS_LIST, status ) ) { - return (""); - } - else { - return (errorInvalidCombinationMsg); - } + var i = VIDCONFIGURATION.VNF_VALID_STATUS_LIST.length; + if ( i > 0 ) { + while (i--) { + var item = VIDCONFIGURATION.VNF_VALID_STATUS_LIST[i]; + if ( (item.provStatus === status.provStatus) && (item.inMaint === status.inMaint ) + && (item.orchestrationStatus === status.orchestrationStatus) ) { + if (UtilityService.hasContents(vnfInstance.object[FIELD.ID.OPERATIONAL_STATUS])) { + if (status.operationalStatus === "") { status.operationalStatus = null } + if ( item.operationalStatus === status.operationalStatus ) { + return (""); + } + } + else { + // no contents + if ( item.operationalStatus === null ) { + return (""); + } + } + } + } + } + + return (errorInvalidCombinationMsg); } else { return (errorAaiStatusMsg); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiGetSubs.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiGetSubs.htm index d22e3d91..c5c5ccaa 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiGetSubs.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiGetSubs.htm @@ -18,66 +18,85 @@ ============LICENSE_END========================================================= --> - - + +
-
-
- - {{status}} -
+
+
+ + {{status}} +
-
{{errorMsg}}
{{errorDetails | json}}
- -

Search Existing Service Instances

-
- Please search by the Subscriber name or enter Service Instance Id or Service Instance Name below: 

- - - - - - - - - - - - - - - - -
-
- -
-
-
- -    -
-
-
- -
-
-
- -
-
- -
- -
-
- - -
+
{{errorMsg}} +
{{errorDetails | json}}
+
+ +

+
Search Existing Service Instances
+

+
+ Please search by the Subscriber name or enter Service Instance Id or Service Instance Name below: 

+ + + + + + + + + + + + + + + + +
+
+ +
+
+
+ + + + + +    +
+
+
+ +
+
+
+ +
+
+ +
+ + +
+
+ + +
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiGetSubscriberList.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiGetSubscriberList.htm index 6a911be1..16357dde 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiGetSubscriberList.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiGetSubscriberList.htm @@ -42,8 +42,10 @@
- +   
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiServiceTypes.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiServiceTypes.htm index 6711bfaf..06a53c3e 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiServiceTypes.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiServiceTypes.htm @@ -41,7 +41,7 @@
- +
@@ -55,8 +55,10 @@
- +   
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiSubDetails.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiSubDetails.htm index 2426f152..3471fcb9 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiSubDetails.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiSubDetails.htm @@ -54,15 +54,14 @@ - - + - + diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiSubViewEdit.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiSubViewEdit.htm index a7ea8336..40bd1488 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiSubViewEdit.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiSubViewEdit.htm @@ -20,128 +20,144 @@
-
-
-
-
-
- -
-
- - {{status}} -
- -

-
VIEW/EDIT SERVICE INSTANCE
-

- - -
- - -
- - - - - - - - - -
SUBSCRIBER: - {{globalCustomerId}}SERVICE TYPE: - {{serviceType}}SERVICE INSTANCE - ID: {{serviceInstanceId}}
Service Instance - Name: {{serviceInstanceName || "Not defined"}} -
- -
- - -
- -
- - EXISTING -
-
-
-
    -
  1. -
-
-
- -
- AVAILABLE - - + EXISTING +
+
+
+
    +
  1. +
+
+
+ +
+ AVAILABLE + + - -
-
-
-
    -
  1. -
-
-
-
-
-
- - - -
+                    
{{node.nodeType}}
+
{{node.nodeId}}
+
{{node.nodeStatus}}
+ + + + + + + + + +
+
    +
  1. +
  2. +
+ + +
+
+
+
    +
  1. +
+
+
+
+
+
+ + + +
   				{{inventoryResponseItem | json}}
 			
-
-
+ + diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/createInstanceServiceModels.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/createInstanceServiceModels.htm index 4d02ae80..0f694612 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/createInstanceServiceModels.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/createInstanceServiceModels.htm @@ -19,6 +19,9 @@ --> +
+
+
@@ -37,13 +40,13 @@ -
+
- +
@@ -57,7 +60,7 @@
- +
@@ -68,7 +71,7 @@
Filter: - +
@@ -89,14 +92,19 @@ - + - + + + +   diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/creationDialog.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/creationDialog.htm index ff79d707..4449285d 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/creationDialog.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/creationDialog.htm @@ -31,7 +31,7 @@
- diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/instantiate.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/instantiate.htm index e4bb67ff..27622ff6 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/instantiate.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/instantiate.htm @@ -20,24 +20,24 @@
-
+
-
+
-
+
{{status}} -
- -
{{errorMsg}}
{{errorDetails | json}}
- -

View/Edit Service Instance

- - +
+ +
{{errorMsg}}
{{errorDetails | json}}
+ +

{{isPermitted == "true" ? "View/Edit" : "View"}} Service Instance

+ +
@@ -58,191 +58,191 @@
- -
- -
    -
  1. -
    - - - - SERVICE INSTANCE: {{aService.instance.name}} - - - -
    - - -
    - - -
    - - - -
    - - - -
    -
      -
    1. -
      - - - - VNF: {{vnf.name}} | TYPE: {{vnf.nodeType}} | ORCH STATUS: {{vnf.nodeStatus}} - - - - -
      - - - -
      - - -
      - - - - -
      - -
      - - - -
      - -
      - - - - -
      - - - - - + +
      + +
        +
      1. +
        + + + + SERVICE INSTANCE: {{aService.instance.name}} + + + +
        + +
        -
          -
        1. -
          - - - - VFMODULE: {{vfModule.name}} | TYPE: {{vfModule.nodeType}} | ORCH STATUS: {{vfModule.nodeStatus}} - - - - -
          - -
          - - - + + +
          + + + +
          + + + +
          +
            +
          1. +
            + + + + VNF: {{vnf.name}} | TYPE: {{vnf.nodeType}} | ORCH STATUS: {{vnf.nodeStatus}} + + + + + +
            + + +
            -
              -
            1. -
              - VOLUME GROUP: {{volumeGroup.name}} | TYPE: {{volumeGroup.nodeType}} | ORCH STATUS: {{volumeGroup.nodeStatus}} - - - - -
              -
            2. -
            -
          2. -
          -
            -
          1. -
            - VOLUME GROUP: {{volumeGroup.name}} | TYPE: {{volumeGroup.nodeType}} | ORCH STATUS: {{volumeGroup.nodeStatus}} - - - - - - + + +
            + + + +
            -
          2. -
          -
        2. -
        -
          -
        1. -
          - NETWORK: {{network.name}} | TYPE: {{network.nodeType}} | ORCH STATUS: {{network.nodeStatus}} - - - - - - - - -
          -
        2. -
        -
      2. -
      + +
      + + +
      + +
      + + + + +
      + + + + + +
      +
        +
      1. +
        + + + + VFMODULE: {{vfModule.name}} | TYPE: {{vfModule.nodeType}} | ORCH STATUS: {{vfModule.nodeStatus}} + + + + +
        + +
        + + + +
        +
          +
        1. +
          + VOLUME GROUP: {{volumeGroup.name}} | TYPE: {{volumeGroup.nodeType}} | ORCH STATUS: {{volumeGroup.nodeStatus}} + + + + +
          +
        2. +
        +
      2. +
      +
        +
      1. +
        + VOLUME GROUP: {{volumeGroup.name}} | TYPE: {{volumeGroup.nodeType}} | ORCH STATUS: {{volumeGroup.nodeStatus}} + + + + + + +
        +
      2. +
      +
    2. +
    +
      +
    1. +
      + NETWORK: {{network.name}} | TYPE: {{network.nodeType}} | ORCH STATUS: {{network.nodeStatus}} + + + + + + + + +
      +
    2. +
    +
  2. +
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/msoCommit.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/msoCommit.htm index e3f415c4..48268248 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/msoCommit.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/msoCommit.htm @@ -41,7 +41,7 @@
{{log}}
-
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/previousVersion.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/previousVersion.htm new file mode 100644 index 00000000..dd604632 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/previousVersion.htm @@ -0,0 +1,44 @@ +
+ +
+
+ +

{{componentName}} - {{createType}}

+
+ +
+ {{error}} +
+ + + + + + + + + + + + + + + + + + + + + + + +
ActionService NameService DescriptionService TypeService UUIDService Invariant UUIDService Version
+ + +
+ +
+
+
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/previousVersionDialog.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/previousVersionDialog.htm new file mode 100644 index 00000000..2912c70b --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/previousVersionDialog.htm @@ -0,0 +1,48 @@ +
+ +
+
+ +

{{componentName}} - {{createType}}

+
+ +
+ {{error}} +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
ActionUUIDInvariant UUIDNameVersionCategoryDistribution StatusLast Updated ByTosca Model
+ + +
+ +
+
+
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceModels.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceModels.htm index 00b8972f..3cba8719 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceModels.htm +++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceModels.htm @@ -19,6 +19,9 @@ --> +
+
+
@@ -34,7 +37,7 @@
Filter: - +

Browse SDC Service Models

@@ -57,7 +60,7 @@ - + @@ -66,7 +69,8 @@ - + +   diff --git a/vid-app-common/src/main/webapp/app/vid/test/testMso.js b/vid-app-common/src/main/webapp/app/vid/test/testMso.js index 884ba8d8..f6ebed46 100755 --- a/vid-app-common/src/main/webapp/app/vid/test/testMso.js +++ b/vid-app-common/src/main/webapp/app/vid/test/testMso.js @@ -41,7 +41,7 @@ app.controller("testController", [ "$scope", "$timeout", "$cookieStore", "$log", setTestMsoMode($cookieStore.get(TEST_MODE_COOKIE)); PropertyService.setMsoMaxPollingIntervalMsec(1000); PropertyService.setMsoMaxPolls(7); - PropertyService.setServerResponseTimeoutMsec(10000); + PropertyService.setServerResponseTimeoutMsec(30000); }; $scope.testMsoModeChanged = function() { diff --git a/vid-app-common/src/main/webapp/app/vid/test/testViewEdit.js b/vid-app-common/src/main/webapp/app/vid/test/testViewEdit.js index 73da4db7..7ddc3dec 100755 --- a/vid-app-common/src/main/webapp/app/vid/test/testViewEdit.js +++ b/vid-app-common/src/main/webapp/app/vid/test/testViewEdit.js @@ -90,7 +90,7 @@ var testViewEditController = function(COMPONENT, DataService, PropertyService, PropertyService.setAsdcBaseUrl("testasdc"); PropertyService.setMsoMaxPollingIntervalMsec(1000); PropertyService.setMsoMaxPolls(7); - PropertyService.setServerResponseTimeoutMsec(10000); + PropertyService.setServerResponseTimeoutMsec(30000); }; $scope.testMsoModeChanged = function() { -- cgit 1.2.3-korg