use of org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.ErrorMessage in project carbon-apimgt by wso2.
the class PolicyDAOImpl method addApiPolicy.
@Override
public void addApiPolicy(APIPolicy policy) throws APIMgtDAOException {
try (Connection connection = DAOUtil.getConnection()) {
try {
connection.setAutoCommit(false);
addApiPolicy(policy, connection);
connection.commit();
} catch (SQLException e) {
connection.rollback();
String errorMessage = "Error in adding API policy, policy name: " + policy.getPolicyName();
log.error(errorMessage, e);
throw new APIMgtDAOException(errorMessage, e);
} finally {
connection.setAutoCommit(DAOUtil.isAutoCommit());
}
} catch (SQLException e) {
String errorMsg = "Error in obtaining DB connection";
log.error(errorMsg, e);
throw new APIMgtDAOException(errorMsg, e);
}
}
use of org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.ErrorMessage in project carbon-apimgt by wso2.
the class PolicyDAOImpl method addApplicationPolicy.
@Override
public void addApplicationPolicy(ApplicationPolicy policy) throws APIMgtDAOException {
try (Connection connection = DAOUtil.getConnection()) {
try {
connection.setAutoCommit(false);
addApplicationPolicy(policy, connection);
connection.commit();
} catch (SQLException e) {
connection.rollback();
String errorMessage = "Error in adding Application policy, policy name: " + policy.getPolicyName();
log.error(errorMessage, e);
throw new APIMgtDAOException(errorMessage, e);
} finally {
connection.setAutoCommit(DAOUtil.isAutoCommit());
}
} catch (SQLException e) {
String errorMsg = "Error in obtaining DB connection";
log.error(errorMsg, e);
throw new APIMgtDAOException(errorMsg, e);
}
}
use of org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.ErrorMessage in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImpl method addApiPolicy.
@Override
public String addApiPolicy(APIPolicy 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.addApiPolicy(policy);
PolicyValidationData policyValidationData = new PolicyValidationData(policyUuid, policy.getPolicyName(), false);
apiGateway.addPolicy(policyValidationData);
return policyUuid;
} catch (APIMgtDAOException e) {
String errorMessage = "Couldn't add API policy for uuid: " + policy.getUuid();
log.error(errorMessage, e);
throw new APIManagementException(errorMessage, e, e.getErrorHandler());
}
}
use of org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.ErrorMessage 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.identity.api.server.application.management.common.ApplicationManagementConstants.ErrorMessage 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());
}
}
Aggregations