Search in sources :

Example 16 with PolicyValidationData

use of org.wso2.carbon.apimgt.core.models.PolicyValidationData in project carbon-apimgt by wso2.

the class APIMgtAdminServiceImpl method deletePolicy.

@Override
public void deletePolicy(String policyName, PolicyLevel policyLevel) throws APIManagementException {
    try {
        Policy policy = policyDAO.getPolicyByLevelAndName(policyLevel, policyName);
        policyDAO.deletePolicy(policyLevel, policyName);
        PolicyValidationData policyValidationData = new PolicyValidationData(policy.getUuid(), policy.getPolicyName(), false);
        apiGateway.deletePolicy(policyValidationData);
    } catch (APIMgtDAOException e) {
        String errorMessage = "Couldn't delete policy with name: " + policyName + ", level: " + policyLevel;
        log.error(errorMessage, e);
        throw new APIManagementException(errorMessage, e, e.getErrorHandler());
    }
}
Also used : ThreatProtectionPolicy(org.wso2.carbon.apimgt.core.models.policy.ThreatProtectionPolicy) ApplicationPolicy(org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy) SubscriptionPolicy(org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy) Policy(org.wso2.carbon.apimgt.core.models.policy.Policy) APIPolicy(org.wso2.carbon.apimgt.core.models.policy.APIPolicy) CustomPolicy(org.wso2.carbon.apimgt.core.models.policy.CustomPolicy) APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException) PolicyValidationData(org.wso2.carbon.apimgt.core.models.PolicyValidationData)

Aggregations

PolicyValidationData (org.wso2.carbon.apimgt.core.models.PolicyValidationData)12 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)9 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)9 PolicyEvent (org.wso2.carbon.apimgt.core.models.events.PolicyEvent)3 LinkedHashSet (java.util.LinkedHashSet)2 Test (org.testng.annotations.Test)2 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)2 APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)2 ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)2 SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1