use of org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException in project carbon-identity-framework by wso2.
the class WorkflowDAO method listWorkflows.
/**
* Retrieve all the Workflows for a tenant
*
* @param tenantId Tenant ID
* @return List<Workflow>
* @throws InternalWorkflowException
*/
public List<Workflow> listWorkflows(int tenantId) throws InternalWorkflowException {
Connection connection = IdentityDatabaseUtil.getDBConnection(false);
PreparedStatement prepStmt = null;
ResultSet rs = null;
List<Workflow> workflowList = new ArrayList<>();
String query = SQLConstants.LIST_WORKFLOWS_QUERY;
try {
prepStmt = connection.prepareStatement(query);
prepStmt.setInt(1, tenantId);
rs = prepStmt.executeQuery();
while (rs.next()) {
String id = rs.getString(SQLConstants.ID_COLUMN);
String name = rs.getString(SQLConstants.WF_NAME_COLUMN);
String description = rs.getString(SQLConstants.DESCRIPTION_COLUMN);
String templateId = rs.getString(SQLConstants.TEMPLATE_ID_COLUMN);
String templateImplId = rs.getString(SQLConstants.TEMPLATE_IMPL_ID_COLUMN);
Workflow workflowDTO = new Workflow();
workflowDTO.setWorkflowId(id);
workflowDTO.setWorkflowName(name);
workflowDTO.setWorkflowDescription(description);
workflowDTO.setTemplateId(templateId);
workflowDTO.setWorkflowImplId(templateImplId);
workflowList.add(workflowDTO);
}
} catch (SQLException e) {
throw new InternalWorkflowException(errorMessage, e);
} finally {
IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
}
return workflowList;
}
use of org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException in project carbon-identity-framework by wso2.
the class WorkflowDAO method removeWorkflowParams.
/**
* Clear all the parameters that stored under workflow Id
*
* @param workflowId WorkflowId
* @throws InternalWorkflowException
*/
public void removeWorkflowParams(String workflowId) throws InternalWorkflowException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
String query = SQLConstants.DELETE_WORKFLOW_PARAMS_QUERY;
try {
prepStmt = connection.prepareStatement(query);
prepStmt.setString(1, workflowId);
prepStmt.executeUpdate();
IdentityDatabaseUtil.commitTransaction(connection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(connection);
throw new InternalWorkflowException(errorMessage, e);
} finally {
IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
}
}
use of org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException in project carbon-identity-framework by wso2.
the class WorkflowDAO method removeWorkflows.
/**
* Remove all workflows of a given tenant id.
*
* @param tenantId The id of the tenant.
* @throws InternalWorkflowException throws when an error occurs in removing workflows.
*/
public void removeWorkflows(int tenantId) throws InternalWorkflowException {
try (Connection connection = IdentityDatabaseUtil.getDBConnection(true)) {
try (PreparedStatement prepStmt = connection.prepareStatement(SQLConstants.DELETE_WORKFLOW_BY_TENANT_ID_QUERY)) {
prepStmt.setInt(1, tenantId);
prepStmt.executeUpdate();
IdentityDatabaseUtil.commitTransaction(connection);
} catch (SQLException e) {
throw new InternalWorkflowException(errorMessage, e);
}
} catch (SQLException e) {
throw new InternalWorkflowException(errorMessage, e);
}
}
use of org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException in project carbon-identity-framework by wso2.
the class WorkflowDAO method removeWorkflow.
/**
* Remove Workflow from the DB
*
* @param workflowId workflow Id
* @throws InternalWorkflowException
*/
public void removeWorkflow(String workflowId) throws InternalWorkflowException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
String query = SQLConstants.DELETE_WORKFLOW_QUERY;
try {
prepStmt = connection.prepareStatement(query);
prepStmt.setString(1, workflowId);
prepStmt.executeUpdate();
IdentityDatabaseUtil.commitTransaction(connection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(connection);
throw new InternalWorkflowException(errorMessage, e);
} finally {
IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
}
}
use of org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException in project carbon-identity-framework by wso2.
the class WorkflowRequestAssociationDAO method updateStatusOfRelationshipsOfPendingRequest.
/**
* Update state of workflow of a request
*
* @param requestId requestId to update relationships of.
* @throws InternalWorkflowException
*/
public void updateStatusOfRelationshipsOfPendingRequest(String requestId, String status) throws InternalWorkflowException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
String query = SQLConstants.UPDATE_STATUS_OF_RELATIONSHIPS_OF_REQUEST;
try {
Timestamp updatedDateStamp = new Timestamp(System.currentTimeMillis());
prepStmt = connection.prepareStatement(query);
prepStmt.setString(1, status);
prepStmt.setTimestamp(2, updatedDateStamp);
prepStmt.setString(3, requestId);
prepStmt.setString(4, WFConstant.HT_STATE_PENDING);
prepStmt.execute();
IdentityDatabaseUtil.commitTransaction(connection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(connection);
throw new InternalWorkflowException("Error when executing the sql query:" + query, e);
} finally {
IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
}
}
Aggregations