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());
}
}
Aggregations