use of org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy in project carbon-apimgt by wso2.
the class GatewayUtils method retrieveDeployedAPI.
public static String retrieveDeployedAPI(String apiName, String version, String tenantDomain) throws APIManagementException {
try {
MessageContext.setCurrentMessageContext(createAxis2MessageContext());
RESTAPIAdminServiceProxy restapiAdminServiceProxy = new RESTAPIAdminServiceProxy(tenantDomain);
String qualifiedName = GatewayUtils.getQualifiedApiName(apiName, version);
OMElement api = restapiAdminServiceProxy.getApiContent(qualifiedName);
if (api != null) {
return api.toString();
}
return null;
} catch (AxisFault axisFault) {
throw new APIManagementException("Error while retrieving API Artifacts", axisFault, ExceptionCodes.INTERNAL_ERROR);
} finally {
MessageContext.destroyCurrentMessageContext();
}
}
use of org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy in project carbon-apimgt by wso2.
the class APIGatewayAdmin method unDeployAPI.
private void unDeployAPI(CertificateManager certificateManager, SequenceAdminServiceProxy sequenceAdminServiceProxy, RESTAPIAdminServiceProxy restapiAdminServiceProxy, LocalEntryServiceProxy localEntryServiceProxy, EndpointAdminServiceProxy endpointAdminServiceProxy, GatewayAPIDTO gatewayAPIDTO, MediationSecurityAdminServiceProxy mediationSecurityAdminServiceProxy) throws AxisFault {
if (log.isDebugEnabled()) {
log.debug("Start to undeploy default api " + gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion());
}
// Delete Default API
String qualifiedDefaultApiName = GatewayUtils.getQualifiedDefaultApiName(gatewayAPIDTO.getName());
if (restapiAdminServiceProxy.getApi(qualifiedDefaultApiName) != null) {
restapiAdminServiceProxy.deleteApi(qualifiedDefaultApiName);
}
if (log.isDebugEnabled()) {
log.debug(gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion() + " Default API Definition " + "undeployed successfully");
log.debug("Start to undeploy API Definition" + gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion());
}
// Delete API
String qualifiedName = GatewayUtils.getQualifiedApiName(gatewayAPIDTO.getName(), gatewayAPIDTO.getVersion());
if (restapiAdminServiceProxy.getApi(qualifiedName) != null) {
restapiAdminServiceProxy.deleteApi(qualifiedName);
}
if (log.isDebugEnabled()) {
log.debug(gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion() + " API Definition undeployed " + "successfully");
log.debug("Start to undeploy custom sequences" + gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion());
}
// Remove Sequences to be remove.
if (gatewayAPIDTO.getSequencesToBeRemove() != null) {
for (String sequenceName : gatewayAPIDTO.getSequencesToBeRemove()) {
if (sequenceAdminServiceProxy.isExistingSequence(sequenceName)) {
sequenceAdminServiceProxy.deleteSequence(sequenceName);
}
}
}
if (log.isDebugEnabled()) {
log.debug(gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion() + " custom sequences undeployed " + "successfully");
log.debug("Start to undeploy endpoints" + gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion());
}
// Remove endpoints
if (gatewayAPIDTO.getEndpointEntriesToBeRemove() != null) {
for (String endpoint : gatewayAPIDTO.getEndpointEntriesToBeRemove()) {
if (endpointAdminServiceProxy.isEndpointExist(endpoint)) {
endpointAdminServiceProxy.deleteEndpoint(endpoint);
}
}
}
if (log.isDebugEnabled()) {
log.debug(gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion() + " endpoints undeployed " + "successfully");
log.debug("Start to undeploy client certificates" + gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion());
}
// Remove clientCertificates
if (gatewayAPIDTO.getClientCertificatesToBeRemove() != null) {
for (String alias : gatewayAPIDTO.getClientCertificatesToBeRemove()) {
certificateManager.deleteClientCertificateFromGateway(alias);
}
}
if (log.isDebugEnabled()) {
log.debug(gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion() + " client certificates undeployed " + "successfully");
log.debug("Start to undeploy local entries" + gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion());
}
// Remove Local Entries if Exist
if (gatewayAPIDTO.getLocalEntriesToBeRemove() != null) {
for (String localEntryKey : gatewayAPIDTO.getLocalEntriesToBeRemove()) {
if (localEntryServiceProxy.isEntryExists(localEntryKey)) {
localEntryServiceProxy.deleteEntry(localEntryKey);
}
}
}
if (log.isDebugEnabled()) {
log.debug(gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion() + " Local entries undeployed " + "successfully");
log.debug("Start to remove vault entries" + gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion());
}
if (gatewayAPIDTO.getCredentialsToBeRemove() != null) {
for (String alias : gatewayAPIDTO.getCredentialsToBeRemove()) {
try {
if (mediationSecurityAdminServiceProxy.isAliasExist(alias)) {
GatewayUtils.deleteRegistryProperty(alias, APIConstants.API_SYSTEM_CONFIG_SECURE_VAULT_LOCATION, gatewayAPIDTO.getTenantDomain());
}
} catch (APIManagementException e) {
String msg = "Error while checking existence of vault entry";
log.error(msg, e);
throw new AxisFault(msg, e);
}
}
}
if (log.isDebugEnabled()) {
log.debug(gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion() + " Vault entries removed " + "successfully");
log.debug(gatewayAPIDTO.getName() + ":" + gatewayAPIDTO.getVersion() + "undeployed successfully");
}
}
use of org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy in project carbon-apimgt by wso2.
the class APIGatewayAdmin method updateDefaultApi.
public boolean updateDefaultApi(String apiName, String version, String apiConfig) throws AxisFault {
RESTAPIAdminServiceProxy restClient = getRestapiAdminClient(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
String qualifiedName = GatewayUtils.getQualifiedDefaultApiName(apiName);
return restClient.updateApi(qualifiedName, apiConfig);
}
use of org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy in project carbon-apimgt by wso2.
the class APIGatewayAdmin method deleteApi.
public boolean deleteApi(String apiProviderName, String apiName, String version) throws AxisFault {
RESTAPIAdminServiceProxy restClient = getRestapiAdminClient(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
// Delete secure vault alias properties if exists
deleteRegistryProperty(apiProviderName, apiName, version, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
String qualifiedName = GatewayUtils.getQualifiedApiName(apiName, version);
return restClient.deleteApi(qualifiedName);
}
use of org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy in project carbon-apimgt by wso2.
the class APIGatewayAdmin method getDefaultApiForTenant.
public org.wso2.carbon.apimgt.gateway.dto.APIData getDefaultApiForTenant(String apiName, String version, String tenantDomain) throws AxisFault {
RESTAPIAdminServiceProxy restClient = getRestapiAdminClient(tenantDomain);
String qualifiedName = GatewayUtils.getQualifiedDefaultApiName(apiName);
APIData apiData = restClient.getApi(qualifiedName);
return convert(apiData);
}
Aggregations