Search in sources :

Example 1 with WorkflowListener

use of org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener in project carbon-identity-framework by wso2.

the class WorkflowManagementServiceImpl method removeWorkflow.

@Override
public void removeWorkflow(String workflowId) throws WorkflowException {
    Workflow workflow = workflowDAO.getWorkflow(workflowId);
    // Deleting the role that is created for per workflow
    if (workflow != null) {
        List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
        for (WorkflowListener workflowListener : workflowListenerList) {
            if (workflowListener.isEnable()) {
                workflowListener.doPreDeleteWorkflow(workflow);
            }
        }
        WorkflowManagementUtil.deleteWorkflowRole(StringUtils.deleteWhitespace(workflow.getWorkflowName()));
        workflowDAO.removeWorkflowParams(workflowId);
        workflowDAO.removeWorkflow(workflowId);
        for (WorkflowListener workflowListener : workflowListenerList) {
            if (workflowListener.isEnable()) {
                workflowListener.doPostDeleteWorkflow(workflow);
            }
        }
    }
}
Also used : AbstractWorkflow(org.wso2.carbon.identity.workflow.mgt.workflow.AbstractWorkflow) Workflow(org.wso2.carbon.identity.workflow.mgt.bean.Workflow) WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener)

Example 2 with WorkflowListener

use of org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener in project carbon-identity-framework by wso2.

the class WorkflowManagementServiceImpl method getAssociationsForWorkflow.

@Override
public List<Association> getAssociationsForWorkflow(String workflowId) throws WorkflowException {
    List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPreGetAssociationsForWorkflow(workflowId);
        }
    }
    List<Association> associations = associationDAO.listAssociationsForWorkflow(workflowId);
    for (Iterator<Association> iterator = associations.iterator(); iterator.hasNext(); ) {
        Association association = iterator.next();
        WorkflowRequestHandler requestHandler = WorkflowServiceDataHolder.getInstance().getRequestHandler(association.getEventId());
        if (requestHandler != null) {
            association.setEventName(requestHandler.getFriendlyName());
        } else {
            // invalid reference, probably event id is renamed or removed
            iterator.remove();
        }
    }
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPostGetAssociationsForWorkflow(workflowId, associations);
        }
    }
    return associations;
}
Also used : WorkflowRequestAssociation(org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequestAssociation) Association(org.wso2.carbon.identity.workflow.mgt.dto.Association) WorkflowAssociation(org.wso2.carbon.identity.workflow.mgt.bean.WorkflowAssociation) WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener) WorkflowRequestHandler(org.wso2.carbon.identity.workflow.mgt.extension.WorkflowRequestHandler)

Example 3 with WorkflowListener

use of org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener in project carbon-identity-framework by wso2.

the class WorkflowManagementServiceImpl method deleteWorkflowRequestCreatedByAnyUser.

/**
 * Move workflow request created by any user to DELETED state.
 *
 * @param requestId Request ID
 * @throws WorkflowException
 */
@Override
public void deleteWorkflowRequestCreatedByAnyUser(String requestId) throws WorkflowException {
    List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
    WorkflowRequest workflowRequest = new WorkflowRequest();
    workflowRequest.setRequestId(requestId);
    workflowRequest.setCreatedBy(workflowRequestDAO.retrieveCreatedUserOfRequest(requestId));
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPreDeleteWorkflowRequest(workflowRequest);
        }
    }
    workflowRequestDAO.updateStatusOfRequest(requestId, WorkflowRequestStatus.DELETED.toString());
    workflowRequestAssociationDAO.updateStatusOfRelationshipsOfPendingRequest(requestId, WFConstant.HT_STATE_SKIPPED);
    requestEntityRelationshipDAO.deleteRelationshipsOfRequest(requestId);
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPostDeleteWorkflowRequest(workflowRequest);
        }
    }
}
Also used : WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener) WorkflowRequest(org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequest)

Example 4 with WorkflowListener

use of org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener in project carbon-identity-framework by wso2.

the class WorkflowManagementServiceImpl method getRequestsFromFilter.

/**
 * get requests list according to createdUser, createdTime, and lastUpdatedTime
 *
 * @param user         User to get requests of, empty String to retrieve requests of all users
 * @param beginDate    lower limit of date range to filter
 * @param endDate      upper limit of date range to filter
 * @param dateCategory filter by created time or last updated time ?
 * @param tenantId     tenant id of currently logged in user
 * @return
 * @throws WorkflowException
 */
@Override
public WorkflowRequest[] getRequestsFromFilter(String user, String beginDate, String endDate, String dateCategory, int tenantId, String status) throws WorkflowException {
    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_FOR_FILTERING);
    Timestamp beginTime;
    Timestamp endTime;
    List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPreGetRequestsFromFilter(user, beginDate, endDate, dateCategory, tenantId, status);
        }
    }
    try {
        Date parsedBeginDate = dateFormat.parse(beginDate);
        beginTime = new java.sql.Timestamp(parsedBeginDate.getTime());
    } catch (ParseException e) {
        long millis = 0;
        Date parsedBeginDate = new Date(millis);
        beginTime = new java.sql.Timestamp(parsedBeginDate.getTime());
    }
    try {
        Date parsedEndDate = dateFormat.parse(endDate);
        endTime = new java.sql.Timestamp(parsedEndDate.getTime());
    } catch (ParseException e) {
        Date parsedEndDate = new Date();
        endTime = new java.sql.Timestamp(parsedEndDate.getTime());
    }
    WorkflowRequest[] resultList;
    if (StringUtils.isBlank(user)) {
        resultList = workflowRequestDAO.getRequestsFilteredByTime(beginTime, endTime, dateCategory, tenantId, status);
    } else {
        resultList = workflowRequestDAO.getRequestsOfUserFilteredByTime(user, beginTime, endTime, dateCategory, tenantId, status);
    }
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPostGetRequestsFromFilter(user, beginDate, endDate, dateCategory, tenantId, status, resultList);
        }
    }
    return resultList;
}
Also used : Timestamp(java.sql.Timestamp) ParseException(java.text.ParseException) WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener) SimpleDateFormat(java.text.SimpleDateFormat) Timestamp(java.sql.Timestamp) Date(java.util.Date) WorkflowRequest(org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequest)

Example 5 with WorkflowListener

use of org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener 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)

Aggregations

WorkflowListener (org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener)27 AbstractWorkflow (org.wso2.carbon.identity.workflow.mgt.workflow.AbstractWorkflow)7 Parameter (org.wso2.carbon.identity.workflow.mgt.bean.Parameter)5 Workflow (org.wso2.carbon.identity.workflow.mgt.bean.Workflow)5 WorkflowAssociation (org.wso2.carbon.identity.workflow.mgt.bean.WorkflowAssociation)5 WorkflowRequest (org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequest)4 WorkflowRequestAssociation (org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequestAssociation)4 WorkflowRequestHandler (org.wso2.carbon.identity.workflow.mgt.extension.WorkflowRequestHandler)4 ArrayList (java.util.ArrayList)3 Association (org.wso2.carbon.identity.workflow.mgt.dto.Association)3 Map (java.util.Map)2 WorkflowRequestAssociationDAO (org.wso2.carbon.identity.workflow.mgt.dao.WorkflowRequestAssociationDAO)2 WorkflowRequestDAO (org.wso2.carbon.identity.workflow.mgt.dao.WorkflowRequestDAO)2 Template (org.wso2.carbon.identity.workflow.mgt.dto.Template)2 WorkflowEvent (org.wso2.carbon.identity.workflow.mgt.dto.WorkflowEvent)2 WorkflowImpl (org.wso2.carbon.identity.workflow.mgt.dto.WorkflowImpl)2 WorkflowRequest (org.wso2.carbon.identity.workflow.mgt.dto.WorkflowRequest)2 InternalWorkflowException (org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException)2 WorkflowExecutorManagerListener (org.wso2.carbon.identity.workflow.mgt.listener.WorkflowExecutorManagerListener)2 AbstractTemplate (org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate)2