From 29a8dd5fdee5f547a3c1e11e09f80de75b1d27d2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 6 Jun 2023 11:17:29 +0530 Subject: [PATCH] Add API app registering refactored code --- .../APIManagementProviderServiceImpl.java | 35 +++++++++++++++++++ ...ApplicationManagerExtensionDataHolder.java | 7 ---- ...ationManagerExtensionServiceComponent.java | 8 ++++- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 0808f11963..67a6f21f16 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -41,6 +41,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.App import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.RegistrationProfile; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -119,6 +120,40 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, isAllowedAllDomains, validityTime, tokenInfo); } + @Override + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) throws APIManagerException { + + + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + + /* + + */ + + try { + consumerRESTAPIServices.getAllApplications(null, null, null); + } catch (APIServicesException e) { + e.printStackTrace(); + } catch (BadRequestException e) { + e.printStackTrace(); + } catch (UnexpectedResponseException e) { + e.printStackTrace(); + } + + return null; + + + } + + + /** + * {@inheritDoc} + */ @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index c8608b4fc8..978a46c13a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -39,12 +39,8 @@ public class APIApplicationManagerExtensionDataHolder { private TenantIndexingLoader indexLoader; private JWTClientManagerService jwtClientManagerService; private ConsumerRESTAPIServices consumerRESTAPIServices; -<<<<<<< HEAD private APIApplicationServices apiApplicationServices; private MetadataManagementService metadataManagementService; -======= ->>>>>>> 9fc055cd4f (Add Consumer REST API integration) - private APIApplicationManagerExtensionDataHolder() { } @@ -121,7 +117,6 @@ public class APIApplicationManagerExtensionDataHolder { public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { this.consumerRESTAPIServices = consumerRESTAPIServices; } -<<<<<<< HEAD public APIApplicationServices getApiApplicationServices() { return apiApplicationServices; @@ -138,6 +133,4 @@ public class APIApplicationManagerExtensionDataHolder { public void setMetadataManagementService(MetadataManagementService metadataManagementService) { this.metadataManagementService = metadataManagementService; } -======= ->>>>>>> 9fc055cd4f (Add Consumer REST API integration) } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 78e0867d78..ffb576295d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -55,12 +55,18 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRealmService" * unbind="unsetRealmService" - * @scr.reference name="io.entgra.device.mgt.core.apimgt.extension.rest.api" + * @scr.reference name="apimgt.extension.ConsumerRESTAPIServices" * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" * cardinality="0..1" * policy="dynamic" * bind="setConsumerRESTAPIServices" * unbind="unsetConsumerRESTAPIServices" + * @scr.reference name="apimgt.extension.APIApplicationService" + * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices" + * cardinality="0..1" + * policy="dynamic" + * bind="setAPIApplicationServices" + * unbind="unsetAPIApplicationServices" */ public class APIApplicationManagerExtensionServiceComponent {