Search in sources :

Example 1 with WorkflowEvent

use of org.wso2.carbon.identity.workflow.mgt.dto.WorkflowEvent in project carbon-identity-framework by wso2.

the class WorkflowManagementServiceImpl method listWorkflowEvents.

@Override
public List<WorkflowEvent> listWorkflowEvents() {
    List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPreListWorkflowEvents();
        }
    }
    List<WorkflowRequestHandler> workflowRequestHandlers = WorkflowServiceDataHolder.getInstance().listRequestHandlers();
    List<WorkflowEvent> eventList = new ArrayList<>();
    if (workflowRequestHandlers != null) {
        for (WorkflowRequestHandler requestHandler : workflowRequestHandlers) {
            WorkflowEvent event = new WorkflowEvent();
            event.setEventId(requestHandler.getEventId());
            event.setEventFriendlyName(requestHandler.getFriendlyName());
            event.setEventDescription(requestHandler.getDescription());
            event.setEventCategory(requestHandler.getCategory());
            // note: parameters are not set at here in list operation. It's set only at get operation
            if (requestHandler.getParamDefinitions() != null) {
                Parameter[] parameterDTOs = new Parameter[requestHandler.getParamDefinitions().size()];
                int i = 0;
                for (Map.Entry<String, String> paramEntry : requestHandler.getParamDefinitions().entrySet()) {
                    Parameter parameterDTO = new Parameter();
                    parameterDTO.setParamName(paramEntry.getKey());
                    parameterDTO.setParamValue(paramEntry.getValue());
                    parameterDTOs[i] = parameterDTO;
                    i++;
                }
                event.setParameters(parameterDTOs);
            }
            eventList.add(event);
        }
    }
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            if (workflowListener.isEnable()) {
                workflowListener.doPostListWorkflowEvents(eventList);
            }
        }
    }
    return eventList;
}
Also used : ArrayList(java.util.ArrayList) WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener) WorkflowEvent(org.wso2.carbon.identity.workflow.mgt.dto.WorkflowEvent) Parameter(org.wso2.carbon.identity.workflow.mgt.bean.Parameter) Map(java.util.Map) WorkflowRequestHandler(org.wso2.carbon.identity.workflow.mgt.extension.WorkflowRequestHandler)

Example 2 with WorkflowEvent

use of org.wso2.carbon.identity.workflow.mgt.dto.WorkflowEvent in project carbon-identity-framework by wso2.

the class WorkflowManagementServiceImpl method getEvent.

@Override
public WorkflowEvent getEvent(String id) {
    List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPreGetEvent(id);
        }
    }
    WorkflowRequestHandler requestHandler = WorkflowServiceDataHolder.getInstance().getRequestHandler(id);
    WorkflowEvent event = null;
    if (requestHandler != null) {
        event = new WorkflowEvent();
        event.setEventId(requestHandler.getEventId());
        event.setEventFriendlyName(requestHandler.getFriendlyName());
        event.setEventDescription(requestHandler.getDescription());
        event.setEventCategory(requestHandler.getCategory());
        if (requestHandler.getParamDefinitions() != null) {
            Parameter[] parameters = new Parameter[requestHandler.getParamDefinitions().size()];
            int i = 0;
            for (Map.Entry<String, String> paramEntry : requestHandler.getParamDefinitions().entrySet()) {
                Parameter parameter = new Parameter();
                parameter.setParamName(paramEntry.getKey());
                parameter.setParamValue(paramEntry.getValue());
                parameters[i] = parameter;
                i++;
            }
            event.setParameters(parameters);
        }
    }
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPostGetEvent(id, event);
        }
    }
    return event;
}
Also used : WorkflowEvent(org.wso2.carbon.identity.workflow.mgt.dto.WorkflowEvent) Parameter(org.wso2.carbon.identity.workflow.mgt.bean.Parameter) WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener) Map(java.util.Map) WorkflowRequestHandler(org.wso2.carbon.identity.workflow.mgt.extension.WorkflowRequestHandler)

Aggregations

Map (java.util.Map)2 Parameter (org.wso2.carbon.identity.workflow.mgt.bean.Parameter)2 WorkflowEvent (org.wso2.carbon.identity.workflow.mgt.dto.WorkflowEvent)2 WorkflowRequestHandler (org.wso2.carbon.identity.workflow.mgt.extension.WorkflowRequestHandler)2 WorkflowListener (org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener)2 ArrayList (java.util.ArrayList)1