Search in sources :

Example 21 with InternalWorkflowException

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);
    }
}
Also used : SQLException(java.sql.SQLException) InternalWorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Example 22 with InternalWorkflowException

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()]);
}
Also used : WorkflowRequestAssociation(org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequestAssociation) Association(org.wso2.carbon.identity.workflow.mgt.dto.Association) InternalWorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException) InternalWorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException) WorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.WorkflowException)

Example 23 with InternalWorkflowException

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()]);
}
Also used : InternalWorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException) InternalWorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException) WorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.WorkflowException) ArrayList(java.util.ArrayList) AbstractWorkflow(org.wso2.carbon.identity.workflow.mgt.workflow.AbstractWorkflow) Workflow(org.wso2.carbon.identity.workflow.mgt.bean.Workflow) WorkflowWizard(org.wso2.carbon.identity.workflow.mgt.dto.WorkflowWizard)

Example 24 with InternalWorkflowException

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;
}
Also used : WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener)

Example 25 with InternalWorkflowException

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);
        }
    }
}
Also used : XPath(javax.xml.xpath.XPath) XPathFactory(javax.xml.xpath.XPathFactory) InternalWorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) WorkflowRuntimeException(org.wso2.carbon.identity.workflow.mgt.exception.WorkflowRuntimeException) WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener)

Aggregations

InternalWorkflowException (org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException)44 Connection (java.sql.Connection)39 PreparedStatement (java.sql.PreparedStatement)39 SQLException (java.sql.SQLException)39 ResultSet (java.sql.ResultSet)21 ArrayList (java.util.ArrayList)13 Timestamp (java.sql.Timestamp)6 WorkflowListener (org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener)6 IOException (java.io.IOException)5 Association (org.wso2.carbon.identity.workflow.mgt.dto.Association)4 WorkflowException (org.wso2.carbon.identity.workflow.mgt.exception.WorkflowException)4 Parameter (org.wso2.carbon.identity.workflow.mgt.bean.Parameter)3 Workflow (org.wso2.carbon.identity.workflow.mgt.bean.Workflow)3 WorkflowRequest (org.wso2.carbon.identity.workflow.mgt.dto.WorkflowRequest)3 WorkflowAssociation (org.wso2.carbon.identity.workflow.mgt.bean.WorkflowAssociation)2 WorkflowRequestAssociation (org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequestAssociation)2 WorkflowRequestDAO (org.wso2.carbon.identity.workflow.mgt.dao.WorkflowRequestDAO)2 WorkflowWizard (org.wso2.carbon.identity.workflow.mgt.dto.WorkflowWizard)2 AbstractWorkflow (org.wso2.carbon.identity.workflow.mgt.workflow.AbstractWorkflow)2 XPath (javax.xml.xpath.XPath)1