use of org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException in project carbon-identity-framework by wso2.
the class WorkflowDAO method updateWorkflow.
/**
* Update current workflow
*
* @param workflow Workflow object
* @throws InternalWorkflowException
*/
public void updateWorkflow(Workflow workflow) throws InternalWorkflowException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
String query = SQLConstants.UPDATE_WORKFLOW_QUERY;
try {
prepStmt = connection.prepareStatement(query);
prepStmt.setString(1, workflow.getWorkflowName());
prepStmt.setString(2, workflow.getWorkflowDescription());
prepStmt.setString(3, workflow.getTemplateId());
prepStmt.setString(4, workflow.getWorkflowImplId());
prepStmt.setString(5, workflow.getWorkflowId());
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 WorkflowManagementAdminService method listAllAssociations.
/**
* List all associations
*
* @return
* @throws WorkflowException
*/
public Association[] listAllAssociations() throws WorkflowException {
List<Association> associations;
try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
associations = WorkflowServiceDataHolder.getInstance().getWorkflowService().listAllAssociations(tenantId);
} catch (InternalWorkflowException e) {
log.error("Server error when listing all associations", e);
throw new WorkflowException("Server error when listing associations");
}
if (CollectionUtils.isEmpty(associations)) {
return new Association[0];
}
return associations.toArray(new Association[associations.size()]);
}
use of org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException in project carbon-identity-framework by wso2.
the class WorkflowManagementAdminService method listWorkflows.
/**
* List workflows
*
* @return
* @throws WorkflowException
*/
public WorkflowWizard[] listWorkflows() throws WorkflowException {
List<WorkflowWizard> workflowWizards = new ArrayList<>();
List<Workflow> workflowBeans = null;
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
try {
workflowBeans = WorkflowServiceDataHolder.getInstance().getWorkflowService().listWorkflows(tenantId);
for (Workflow workflow : workflowBeans) {
WorkflowWizard workflowTmp = getWorkflow(workflow);
workflowWizards.add(workflowTmp);
}
} catch (InternalWorkflowException e) {
log.error("Server error when listing workflows", e);
throw new WorkflowException("Server error occurred when listing workflows");
}
return workflowWizards.toArray(new WorkflowWizard[workflowWizards.size()]);
}
use of org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException in project carbon-identity-framework by wso2.
the class WorkflowManagementServiceImpl method listEntityNames.
/**
* Retrieve List of associated Entity-types of the workflow requests.
*
* @param wfOperationType Operation Type of the Work-flow.
* @param wfStatus Current Status of the Work-flow.
* @param entityType Entity Type of the Work-flow.
* @param tenantID Tenant ID of the currently Logged user.
* @param idFilter Entity ID filter to search
* @return
* @throws InternalWorkflowException
*/
@Override
public List<String> listEntityNames(String wfOperationType, String wfStatus, String entityType, int tenantID, String idFilter) throws WorkflowException {
List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
for (WorkflowListener workflowListener : workflowListenerList) {
if (workflowListener.isEnable()) {
workflowListener.doPreListEntityNames(wfOperationType, wfStatus, entityType, tenantID, idFilter);
}
}
List<String> requestEntities = requestEntityRelationshipDAO.getEntityNamesOfRequest(wfOperationType, wfStatus, entityType, idFilter, tenantID);
for (WorkflowListener workflowListener : workflowListenerList) {
if (workflowListener.isEnable()) {
workflowListener.doPostListEntityNames(wfOperationType, wfStatus, entityType, tenantID, idFilter, requestEntities);
}
}
return requestEntities;
}
use of org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException in project carbon-identity-framework by wso2.
the class WorkflowManagementServiceImpl method addAssociation.
@Override
public void addAssociation(String associationName, String workflowId, String eventId, String condition) throws WorkflowException {
List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
for (WorkflowListener workflowListener : workflowListenerList) {
if (workflowListener.isEnable()) {
workflowListener.doPreAddAssociation(associationName, workflowId, eventId, condition);
}
}
if (StringUtils.isBlank(workflowId)) {
log.error("Null or empty string given as workflow id to be associated to event.");
throw new InternalWorkflowException("Service alias cannot be null");
}
if (StringUtils.isBlank(eventId)) {
log.error("Null or empty string given as 'event' to be associated with the service.");
throw new InternalWorkflowException("Event type cannot be null");
}
if (StringUtils.isBlank(condition)) {
log.error("Null or empty string given as condition expression when associating " + workflowId + " to event " + eventId);
throw new InternalWorkflowException("Condition cannot be null");
}
// check for xpath syntax errors
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
try {
xpath.compile(condition);
associationDAO.addAssociation(associationName, workflowId, eventId, condition);
} catch (XPathExpressionException e) {
log.error("The condition:" + condition + " is not an valid xpath expression.", e);
throw new WorkflowRuntimeException("The condition is not a valid xpath expression.");
}
for (WorkflowListener workflowListener : workflowListenerList) {
if (workflowListener.isEnable()) {
workflowListener.doPostAddAssociation(associationName, workflowId, eventId, condition);
}
}
}
Aggregations