Add API app registering refactored code

remotes/1728937285237262521/master
Dharmakeerthi Lasantha 1 year ago
parent 22f4da908f
commit 2d37dcb340

@ -50,6 +50,11 @@ public interface APIManagementProviderService {
String keyType, String username, boolean isAllowedAllDomains,
String validityTime) throws APIManagerException;
ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[],
String keyType, String username,
boolean isAllowedAllDomains,
String validityTime, String password) throws APIManagerException;
/**
* Remove APIM Application.
*/

@ -18,6 +18,11 @@
package io.entgra.device.mgt.core.apimgt.application.extension;
import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices;
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;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -96,6 +101,37 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
}
@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}
*/

@ -18,6 +18,7 @@
package io.entgra.device.mgt.core.apimgt.application.extension.internal;
import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService;
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices;
import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService;
@ -37,6 +38,7 @@ public class APIApplicationManagerExtensionDataHolder {
private TenantIndexingLoader indexLoader;
private JWTClientManagerService jwtClientManagerService;
private ConsumerRESTAPIServices consumerRESTAPIServices;
private APIApplicationServices apiApplicationServices;
private APIApplicationManagerExtensionDataHolder() {
}
@ -113,4 +115,12 @@ public class APIApplicationManagerExtensionDataHolder {
public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) {
this.consumerRESTAPIServices = consumerRESTAPIServices;
}
public APIApplicationServices getApiApplicationServices() {
return apiApplicationServices;
}
public void setApiApplicationServices(APIApplicationServices apiApplicationServices) {
this.apiApplicationServices = apiApplicationServices;
}
}

@ -17,6 +17,7 @@
*/
package io.entgra.device.mgt.core.apimgt.application.extension.internal;
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices;
import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -49,12 +50,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 {
@ -128,7 +135,7 @@ public class APIApplicationManagerExtensionServiceComponent {
*/
protected void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) {
if (log.isDebugEnabled()) {
log.debug("Setting Realm Service");
log.debug("Setting APIM Consumer REST API Service");
}
APIApplicationManagerExtensionDataHolder.getInstance().setConsumerRESTAPIServices(consumerRESTAPIServices);
}
@ -140,9 +147,34 @@ public class APIApplicationManagerExtensionServiceComponent {
*/
protected void unsetConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) {
if (log.isDebugEnabled()) {
log.debug("Unsetting Realm Service");
log.debug("Unsetting APIM Consumer REST API Service");
}
APIApplicationManagerExtensionDataHolder.getInstance().setConsumerRESTAPIServices(null);
}
/**
* Sets DCR REST API service.
*
* @param apiApplicationServices An instance of APIApplicationServices
*/
protected void setAPIApplicationServices(APIApplicationServices apiApplicationServices) {
if (log.isDebugEnabled()) {
log.debug("Setting DCR REST API Service");
}
APIApplicationManagerExtensionDataHolder.getInstance().setApiApplicationServices(apiApplicationServices);
}
/**
* Unset DCR REST API service
*
* @param apiApplicationServices An instance of APIApplicationServices
*/
protected void unsetAPIApplicationServices(APIApplicationServices apiApplicationServices) {
if (log.isDebugEnabled()) {
log.debug("Unsetting DCR REST API Service");
}
APIApplicationManagerExtensionDataHolder.getInstance().setApiApplicationServices(null);
}
}

Loading…
Cancel
Save