use of org.wso2.carbon.apimgt.api.APIMgtDAOException 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.APIMgtDAOException in project carbon-apimgt by wso2.
the class WorkflowDAOImpl method retrieveUncompleteWorkflowsFromDB.
private List<Workflow> retrieveUncompleteWorkflowsFromDB() throws APIMgtDAOException, SQLException, ParseException {
final String getworkflowQuery = "SELECT * FROM AM_WORKFLOWS WHERE WF_STATUS=?";
List<Workflow> workflow;
try (Connection conn = DAOUtil.getConnection();
PreparedStatement ps = conn.prepareStatement(getworkflowQuery)) {
ps.setString(1, WorkflowStatus.CREATED.toString());
try (ResultSet rs = ps.executeQuery()) {
workflow = this.createWorkflowsFromResultSet(rs);
}
}
return workflow;
}
use of org.wso2.carbon.apimgt.api.APIMgtDAOException in project carbon-apimgt by wso2.
the class WorkflowDAOImpl method createWorkflowsFromResultSet.
private List<Workflow> createWorkflowsFromResultSet(ResultSet rs) throws SQLException, APIMgtDAOException, ParseException {
List<Workflow> workflows = new ArrayList<>();
while (rs.next()) {
String wfType = rs.getString("WF_TYPE");
Workflow workflow = WorkflowExecutorFactory.getInstance().createWorkflow(wfType);
workflow.setStatus(WorkflowStatus.valueOf(rs.getString("WF_STATUS")));
workflow.setExternalWorkflowReference(rs.getString("WF_EXTERNAL_REFERENCE"));
workflow.setWorkflowReference(rs.getString("WF_REFERENCE"));
workflow.setCreatedTime(rs.getTimestamp("WF_CREATED_TIME").toLocalDateTime());
workflow.setUpdatedTime(rs.getTimestamp("WF_UPDATED_TIME").toLocalDateTime());
workflow.setWorkflowReference(rs.getString("WF_REFERENCE"));
workflow.setWorkflowDescription(rs.getString("WF_STATUS_DESC"));
workflow.setAttributes(WorkflowUtils.jsonStringToMap(rs.getString("WF_ATTRIBUTES")));
workflows.add(workflow);
}
return workflows;
}
use of org.wso2.carbon.apimgt.api.APIMgtDAOException in project carbon-apimgt by wso2.
the class WorkflowDAOImpl method createWorkflowFromResultSet.
private Workflow createWorkflowFromResultSet(ResultSet rs) throws SQLException, APIMgtDAOException, ParseException {
Workflow workflow = null;
if (rs.next()) {
String wfType = rs.getString("WF_TYPE");
workflow = WorkflowExecutorFactory.getInstance().createWorkflow(wfType);
workflow.setStatus(WorkflowStatus.valueOf(rs.getString("WF_STATUS")));
workflow.setExternalWorkflowReference(rs.getString("WF_EXTERNAL_REFERENCE"));
workflow.setWorkflowReference(rs.getString("WF_REFERENCE"));
workflow.setCreatedTime(rs.getTimestamp("WF_CREATED_TIME").toLocalDateTime());
workflow.setUpdatedTime(rs.getTimestamp("WF_UPDATED_TIME").toLocalDateTime());
workflow.setWorkflowReference(rs.getString("WF_REFERENCE"));
workflow.setWorkflowDescription(rs.getString("WF_STATUS_DESC"));
workflow.setAttributes(WorkflowUtils.jsonStringToMap(rs.getString("WF_ATTRIBUTES")));
}
return workflow;
}
use of org.wso2.carbon.apimgt.api.APIMgtDAOException 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