diff options
author | 2017-09-20 13:20:42 +0300 | |
---|---|---|
committer | 2017-09-20 13:37:03 +0300 | |
commit | 9dfd7e28c1eb348fcb4a2de8c6faae2a01b34942 (patch) | |
tree | c273862f59b0b64c19ccfea5f59ab574071cb323 /vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java | |
parent | c3722d135481cfab5978c84853d8229d1e7d9cb3 (diff) |
Global Read only role, Support VID specific Roles
Issue-ID: VID-46 , VID-47
Change-Id: Ib100d20ac40a65d39e27a6e2741b19a173a2b8ea
Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java')
-rw-r--r-- | vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java | 70 |
1 files changed, 70 insertions, 0 deletions
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<SubscriberList> 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<Services> 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<GetServicesAAIRespone> subscriberResponse = aaiClient.getServices(); + for (org.openecomp.vid.aai.model.AaiGetServicesRequestModel.Service service :subscriberResponse.getT().service){ + service.isPermitted = true; + } + return subscriberResponse; + } + + @Override + public AaiResponse<GetTenantsResponse[]> getTenants(String globalCustomerId, String serviceType, RoleValidator roleValidator) { + AaiResponse<GetTenantsResponse[]> aaiGetTenantsResponse = aaiClient.getTenants(globalCustomerId,serviceType); + GetTenantsResponse[] tenants = aaiGetTenantsResponse.getT(); + for (int i=0;i<tenants.length;i++){ + tenants[i].isPermitted = roleValidator.isTenantPermitted(globalCustomerId,serviceType, tenants[i].tenantID); + } + return aaiGetTenantsResponse; + } + + @Override + public AaiResponse getAaiZones() { + AaiResponse<AicZones> response = aaiClient.getAllAicZones(); + return response; + } +} |