Search in sources :

Example 36 with APIGatewayAdmin

use of org.wso2.carbon.apimgt.gateway.service.APIGatewayAdmin in project carbon-apimgt by wso2.

the class InMemoryAPIDeployer method unDeployAPI.

private void unDeployAPI(APIGatewayAdmin apiGatewayAdmin, DeployAPIInGatewayEvent gatewayEvent) throws AxisFault {
    if (gatewayArtifactSynchronizerProperties.isRetrieveFromStorageEnabled()) {
        GatewayAPIDTO gatewayAPIDTO = new GatewayAPIDTO();
        gatewayAPIDTO.setName(gatewayEvent.getName());
        gatewayAPIDTO.setVersion(gatewayEvent.getVersion());
        gatewayAPIDTO.setProvider(gatewayEvent.getProvider());
        gatewayAPIDTO.setTenantDomain(gatewayEvent.getTenantDomain());
        gatewayAPIDTO.setApiId(gatewayEvent.getUuid());
        setClientCertificatesToRemoveIntoGatewayDTO(gatewayAPIDTO);
        if (APIConstants.API_PRODUCT.equals(gatewayEvent.getApiType())) {
            APIProductIdentifier apiProductIdentifier = new APIProductIdentifier(gatewayEvent.getProvider(), gatewayEvent.getName(), gatewayEvent.getVersion());
            Set<APIEvent> associatedApis = gatewayEvent.getAssociatedApis();
            for (APIEvent associatedApi : associatedApis) {
                GatewayUtils.setCustomSequencesToBeRemoved(apiProductIdentifier, associatedApi.getUuid(), gatewayAPIDTO);
                GatewayUtils.setEndpointsToBeRemoved(apiProductIdentifier, associatedApi.getUuid(), gatewayAPIDTO);
            }
        } else {
            API api = new API(new APIIdentifier(gatewayEvent.getProvider(), gatewayEvent.getName(), gatewayEvent.getVersion()));
            if (APIConstants.APITransportType.GRAPHQL.toString().equalsIgnoreCase(gatewayEvent.getApiType())) {
                gatewayAPIDTO.setLocalEntriesToBeRemove(org.wso2.carbon.apimgt.impl.utils.GatewayUtils.addStringToList(gatewayEvent.getUuid().concat("_graphQL"), gatewayAPIDTO.getLocalEntriesToBeRemove()));
                DataHolder.getInstance().getApiToGraphQLSchemaDTOMap().remove(gatewayEvent.getUuid());
            }
            if (APIConstants.APITransportType.WS.toString().equalsIgnoreCase(gatewayEvent.getApiType())) {
                org.wso2.carbon.apimgt.gateway.utils.GatewayUtils.setWebsocketEndpointsToBeRemoved(gatewayAPIDTO, gatewayEvent.getTenantDomain());
            } else {
                GatewayUtils.setEndpointsToBeRemoved(gatewayAPIDTO.getName(), gatewayAPIDTO.getVersion(), gatewayAPIDTO);
            }
            GatewayUtils.setCustomSequencesToBeRemoved(api, gatewayAPIDTO);
        }
        gatewayAPIDTO.setLocalEntriesToBeRemove(GatewayUtils.addStringToList(gatewayEvent.getUuid(), gatewayAPIDTO.getLocalEntriesToBeRemove()));
        apiGatewayAdmin.unDeployAPI(gatewayAPIDTO);
        DataHolder.getInstance().getApiToCertificatesMap().remove(gatewayEvent.getUuid());
        DataHolder.getInstance().removeKeyManagerToAPIMapping(gatewayAPIDTO.getApiId());
    }
}
Also used : GatewayAPIDTO(org.wso2.carbon.apimgt.api.gateway.GatewayAPIDTO) APIProductIdentifier(org.wso2.carbon.apimgt.api.model.APIProductIdentifier) APIEvent(org.wso2.carbon.apimgt.impl.notifier.events.APIEvent) API(org.wso2.carbon.apimgt.api.model.API) APIIdentifier(org.wso2.carbon.apimgt.api.model.APIIdentifier)

Aggregations

Test (org.junit.Test)32 RESTAPIAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy)28 EndpointAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy)12 SequenceAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy)8 APIData (org.wso2.carbon.rest.api.APIData)4 OMElement (org.apache.axiom.om.OMElement)3 GatewayAPIDTO (org.wso2.carbon.apimgt.api.gateway.GatewayAPIDTO)3 APIGatewayAdmin (org.wso2.carbon.apimgt.gateway.service.APIGatewayAdmin)3 ArtifactSynchronizerException (org.wso2.carbon.apimgt.impl.gatewayartifactsynchronizer.exception.ArtifactSynchronizerException)3 OMFactory (org.apache.axiom.om.OMFactory)2 AxisFault (org.apache.axis2.AxisFault)2 Gson (com.google.gson.Gson)1 IOException (java.io.IOException)1 API (org.wso2.carbon.apimgt.api.model.API)1 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)1 APIProductIdentifier (org.wso2.carbon.apimgt.api.model.APIProductIdentifier)1 APIEvent (org.wso2.carbon.apimgt.impl.notifier.events.APIEvent)1 ResourceData (org.wso2.carbon.rest.api.ResourceData)1