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);
}
}
}
}
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;
}
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);
}
}
}
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;
}
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;
}
Aggregations