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/openecomp/vid/services/AaiServiceImpl.java | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java (limited to 'vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java') 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; + } +} -- cgit 1.2.3-korg