Search in sources :

Example 46 with APIRevisionDeployment

use of org.wso2.carbon.apimgt.api.model.APIRevisionDeployment in project carbon-apimgt by wso2.

the class SolaceNotifierUtils method checkWhetherAPIDeployedToSolaceUsingRevision.

/**
 * Check whether the given API is already deployed in the Solace using revision
 *
 * @param api Name of the API
 * @return returns true if the given API is already deployed
 * @throws APIManagementException If an error occurs when checking API product availability
 */
public static boolean checkWhetherAPIDeployedToSolaceUsingRevision(API api) throws APIManagementException {
    apiMgtDAO = ApiMgtDAO.getInstance();
    Map<String, Environment> gatewayEnvironments = APIUtil.getReadOnlyGatewayEnvironments();
    List<APIRevisionDeployment> deployments = apiMgtDAO.getAPIRevisionDeploymentsByApiUUID(api.getUuid());
    for (APIRevisionDeployment deployment : deployments) {
        if (deployment.isDisplayOnDevportal()) {
            String environmentName = deployment.getDeployment();
            if (gatewayEnvironments.containsKey(environmentName)) {
                Environment deployedEnvironment = gatewayEnvironments.get(environmentName);
                if (SolaceConstants.SOLACE_ENVIRONMENT.equalsIgnoreCase(deployedEnvironment.getProvider())) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Environment(org.wso2.carbon.apimgt.api.model.Environment) APIRevisionDeployment(org.wso2.carbon.apimgt.api.model.APIRevisionDeployment)

Example 47 with APIRevisionDeployment

use of org.wso2.carbon.apimgt.api.model.APIRevisionDeployment in project carbon-apimgt by wso2.

the class SolaceNotifierUtils method getDeployedSolaceEnvironmentsFromRevisionDeployments.

/**
 * Get deployed solace environment name form the revision deployments
 *
 * @param api Name of the API
 * @return List<ThirdPartyEnvironment> List of deployed solace environments
 * @throws APIManagementException is error occurs when getting the list of solace environments
 */
public static List<Environment> getDeployedSolaceEnvironmentsFromRevisionDeployments(API api) throws APIManagementException {
    apiMgtDAO = ApiMgtDAO.getInstance();
    List<Environment> deployedSolaceEnvironments = new ArrayList<>();
    Map<String, Environment> gatewayEnvironments = APIUtil.getReadOnlyGatewayEnvironments();
    List<APIRevisionDeployment> deployments = apiMgtDAO.getAPIRevisionDeploymentsByApiUUID(api.getUuid());
    for (APIRevisionDeployment deployment : deployments) {
        String environmentName = deployment.getDeployment();
        if (gatewayEnvironments.containsKey(environmentName)) {
            Environment deployedEnvironment = gatewayEnvironments.get(environmentName);
            if (SolaceConstants.SOLACE_ENVIRONMENT.equalsIgnoreCase(deployedEnvironment.getProvider())) {
                deployedSolaceEnvironments.add(deployedEnvironment);
            }
        }
    }
    return deployedSolaceEnvironments;
}
Also used : ArrayList(java.util.ArrayList) Environment(org.wso2.carbon.apimgt.api.model.Environment) APIRevisionDeployment(org.wso2.carbon.apimgt.api.model.APIRevisionDeployment)

Example 48 with APIRevisionDeployment

use of org.wso2.carbon.apimgt.api.model.APIRevisionDeployment in project carbon-apimgt by wso2.

the class SolaceNotifierUtils method getThirdPartySolaceBrokerEnvironmentNameOfAPIDeployment.

/**
 * Get third party Solace broker environment Name for API deployment
 *
 * @param api Name of the API
 * @return String of the name of environment in Solace broker
 * @throws APIManagementException is error occurs when getting the name of the environment name
 */
private String getThirdPartySolaceBrokerEnvironmentNameOfAPIDeployment(API api) throws APIManagementException {
    apiMgtDAO = ApiMgtDAO.getInstance();
    Map<String, Environment> gatewayEnvironments = APIUtil.getReadOnlyGatewayEnvironments();
    List<APIRevisionDeployment> deployments = apiMgtDAO.getAPIRevisionDeploymentsByApiUUID(api.getUuid());
    for (APIRevisionDeployment deployment : deployments) {
        String environmentName = deployment.getDeployment();
        if (gatewayEnvironments.containsKey(environmentName)) {
            Environment deployedEnvironment = gatewayEnvironments.get(environmentName);
            if (SolaceConstants.SOLACE_ENVIRONMENT.equalsIgnoreCase(deployedEnvironment.getProvider())) {
                return environmentName;
            }
        }
    }
    return null;
}
Also used : Environment(org.wso2.carbon.apimgt.api.model.Environment) APIRevisionDeployment(org.wso2.carbon.apimgt.api.model.APIRevisionDeployment)

Aggregations

APIRevisionDeployment (org.wso2.carbon.apimgt.api.model.APIRevisionDeployment)45 ArrayList (java.util.ArrayList)20 Environment (org.wso2.carbon.apimgt.api.model.Environment)17 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)15 APIRevision (org.wso2.carbon.apimgt.api.model.APIRevision)12 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)11 APIMgtResourceNotFoundException (org.wso2.carbon.apimgt.api.APIMgtResourceNotFoundException)10 DeployedAPIRevision (org.wso2.carbon.apimgt.api.model.DeployedAPIRevision)10 APIRevisionDeploymentDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO)10 Connection (java.sql.Connection)9 PreparedStatement (java.sql.PreparedStatement)9 SQLException (java.sql.SQLException)9 HashSet (java.util.HashSet)8 LinkedHashSet (java.util.LinkedHashSet)8 HashMap (java.util.HashMap)6 Response (javax.ws.rs.core.Response)6 API (org.wso2.carbon.apimgt.api.model.API)6 APIStateChangeResponse (org.wso2.carbon.apimgt.api.model.APIStateChangeResponse)6 SubscribedAPI (org.wso2.carbon.apimgt.api.model.SubscribedAPI)6 List (java.util.List)5