use of org.wso2.carbon.apimgt.api.APIManagementException in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImpl method updateBlockConditionStateByUUID.
@Override
public boolean updateBlockConditionStateByUUID(String uuid, Boolean state) throws APIManagementException {
try {
if (policyDAO.updateBlockConditionStateByUUID(uuid, state)) {
BlockConditions blockConditions = getBlockConditionByUUID(uuid);
apiGateway.updateBlockCondition(blockConditions);
return true;
} else {
return false;
}
} catch (APIMgtDAOException e) {
String errorMessage = "Couldn't update block condition with UUID: " + uuid + ", state: " + state;
log.error(errorMessage, e);
throw new APIManagementException(errorMessage, ExceptionCodes.APIMGT_DAO_EXCEPTION);
}
}
use of org.wso2.carbon.apimgt.api.APIManagementException in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImpl method addApplicationPolicy.
@Override
public String addApplicationPolicy(ApplicationPolicy 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.addApplicationPolicy(policy);
PolicyValidationData policyValidationData = new PolicyValidationData(policyUuid, policy.getPolicyName(), false);
apiGateway.addPolicy(policyValidationData);
return policyUuid;
} catch (APIMgtDAOException e) {
String errorMessage = "Couldn't add Application for uuid: " + policy.getUuid();
log.error(errorMessage, e);
throw new APIManagementException(errorMessage, e, e.getErrorHandler());
}
}
use of org.wso2.carbon.apimgt.api.APIManagementException 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());
}
}
use of org.wso2.carbon.apimgt.api.APIManagementException 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());
}
}
use of org.wso2.carbon.apimgt.api.APIManagementException 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());
}
}
Aggregations