Search in sources :

Example 96 with APIMgtDAOException

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

the class APIMgtAdminServiceImpl method updateApplicationPolicy.

@Override
public void updateApplicationPolicy(ApplicationPolicy policy) throws APIManagementException {
    try {
        policyDAO.updateApplicationPolicy(policy);
        PolicyValidationData policyValidationData = new PolicyValidationData(policy.getUuid(), policy.getPolicyName(), false);
        apiGateway.updatePolicy(policyValidationData);
    } catch (APIMgtDAOException e) {
        String errorMessage = "Couldn't update Application policy for uuid: " + policy.getUuid();
        log.error(errorMessage, e);
        throw new APIManagementException(errorMessage, e, e.getErrorHandler());
    }
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException) PolicyValidationData(org.wso2.carbon.apimgt.core.models.PolicyValidationData)

Example 97 with APIMgtDAOException

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

the class APIMgtAdminServiceImpl method updateSubscriptionPolicy.

@Override
public void updateSubscriptionPolicy(SubscriptionPolicy policy) throws APIManagementException {
    try {
        policyDAO.updateSubscriptionPolicy(policy);
        PolicyValidationData policyValidationData = new PolicyValidationData(policy.getUuid(), policy.getPolicyName(), policy.isStopOnQuotaReach());
        apiGateway.updatePolicy(policyValidationData);
    } catch (APIMgtDAOException e) {
        String errorMessage = "Couldn't update Subscription policy for uuid: " + policy.getUuid();
        log.error(errorMessage, e);
        throw new APIManagementException(errorMessage, e, e.getErrorHandler());
    }
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException) PolicyValidationData(org.wso2.carbon.apimgt.core.models.PolicyValidationData)

Example 98 with APIMgtDAOException

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

the class APIMgtAdminServiceImpl method deletePolicyByUuid.

@Override
public void deletePolicyByUuid(String uuid, PolicyLevel policyLevel) throws APIManagementException {
    try {
        policyDAO.deletePolicyByUuid(policyLevel, uuid);
        PolicyValidationData policyValidationData = new PolicyValidationData(uuid, "", false);
        apiGateway.deletePolicy(policyValidationData);
    } catch (APIMgtDAOException e) {
        String errorMessage = "Couldn't delete policy with id: " + uuid + ", level: " + policyLevel;
        log.error(errorMessage, e);
        throw new APIManagementException(errorMessage, e, e.getErrorHandler());
    }
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException) PolicyValidationData(org.wso2.carbon.apimgt.core.models.PolicyValidationData)

Example 99 with APIMgtDAOException

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

the class APIMgtAdminServiceImpl method addSubscriptionPolicy.

@Override
public String addSubscriptionPolicy(SubscriptionPolicy policy) throws APIManagementException {
    try {
        String policyUuid = policy.getUuid();
        if (policyUuid == null) {
            if (log.isDebugEnabled()) {
                log.debug("Policy id is null, hence generating a new UUID for the policy with name: " + policy.getPolicyName());
            }
            policyUuid = UUID.randomUUID().toString();
            policy.setUuid(policyUuid);
        }
        policyDAO.addSubscriptionPolicy(policy);
        PolicyValidationData policyValidationData = new PolicyValidationData(policyUuid, policy.getPolicyName(), policy.isStopOnQuotaReach());
        apiGateway.addPolicy(policyValidationData);
        return policyUuid;
    } catch (APIMgtDAOException e) {
        String errorMessage = "Couldn't add Subscription policy for uuid: " + policy.getUuid();
        log.error(errorMessage, e);
        throw new APIManagementException(errorMessage, e, e.getErrorHandler());
    }
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException) PolicyValidationData(org.wso2.carbon.apimgt.core.models.PolicyValidationData)

Example 100 with APIMgtDAOException

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

the class ServiceDiscovererKubernetes method initImpl.

/**
 * Initializes OpenShiftClient (extended KubernetesClient) and sets the necessary parameters
 *
 * @param implParameters implementation parameters added by the super class #initImpl(java.util.Map) method
 * @throws ServiceDiscoveryException if an error occurs while initializing the client
 */
@Override
public void initImpl(Map<String, String> implParameters) throws ServiceDiscoveryException {
    try {
        setClient(new DefaultOpenShiftClient(buildConfig(implParameters)));
    } catch (KubernetesClientException | APIMgtDAOException e) {
        String msg = "Error occurred while creating Kubernetes client";
        throw new ServiceDiscoveryException(msg, e, ExceptionCodes.ERROR_INITIALIZING_SERVICE_DISCOVERY);
    } catch (ArrayIndexOutOfBoundsException e) {
        String msg = "Error occurred while reading filtering criteria from the configuration";
        throw new ServiceDiscoveryException(msg, e, ExceptionCodes.ERROR_INITIALIZING_SERVICE_DISCOVERY);
    }
    includeClusterIP = Boolean.parseBoolean(implParameters.get(INCLUDE_CLUSTER_IPS));
    includeExternalNameTypeServices = Boolean.parseBoolean(implParameters.get(INCLUDE_EXTERNAL_NAME_SERVICES));
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) ServiceDiscoveryException(org.wso2.carbon.apimgt.core.exception.ServiceDiscoveryException) DefaultOpenShiftClient(io.fabric8.openshift.client.DefaultOpenShiftClient) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Aggregations

APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)333 SQLException (java.sql.SQLException)192 Connection (java.sql.Connection)146 PreparedStatement (java.sql.PreparedStatement)129 Test (org.testng.annotations.Test)84 ResultSet (java.sql.ResultSet)72 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)72 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)57 API (org.wso2.carbon.apimgt.core.models.API)57 ArrayList (java.util.ArrayList)50 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)35 Application (org.wso2.carbon.apimgt.core.models.Application)24 HashMap (java.util.HashMap)23 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)22 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)21 BeforeTest (org.testng.annotations.BeforeTest)21 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)20 Endpoint (org.wso2.carbon.apimgt.core.models.Endpoint)20 IOException (java.io.IOException)19 ApplicationDAO (org.wso2.carbon.apimgt.core.dao.ApplicationDAO)17