Package org.joget.workflow.model.dao

Examples of org.joget.workflow.model.dao.WorkflowHelper


    public static List<String> getAssignmentUsers(String packageId, String procDefId, String procId, String version, String actId, String requesterUsername, String participantId) {
        List<String> resultList = null;

        try {
            WorkflowHelper workflowMapper = (WorkflowHelper) appContext.getBean("workflowHelper");
            resultList = workflowMapper.getAssignmentUsers(packageId, procDefId, procId, version, actId, requesterUsername, participantId);
        } catch (Exception ex) {
            LogUtil.error(WorkflowUtil.class.getName(), ex, "");
        } finally {
            // remove duplicates
            if (resultList != null) {
View Full Code Here


    public static String processVariable(String content, String formDataTable, WorkflowAssignment wfAssignment, String escapeFormat, Map<String, String> replaceMap) {

        String result = content;
        try {
            WorkflowHelper workflowMapper = (WorkflowHelper) appContext.getBean("workflowHelper");
            result = workflowMapper.processHashVariable(content, wfAssignment, escapeFormat, replaceMap);
        } catch (Exception e) {
            LogUtil.error(WorkflowUtil.class.getName(), e, "Error processing hash variable for: " + content);
        }
        return result;
    }
View Full Code Here

        return result;
    }

    public static void addAuditTrail(String clazz, String method, String message) {
        try {
            WorkflowHelper workflowMapper = (WorkflowHelper) appContext.getBean("workflowHelper");
            workflowMapper.addAuditTrail(clazz, method, message);
        } catch (Exception e) {
            LogUtil.error(WorkflowUtil.class.getName(), e, "Error add audit trail");
        }
    }
View Full Code Here

                }

                // add success to audit trail
                boolean authenticated = result.isAuthenticated();
                LogUtil.info(getClass().getName(), "Authentication for user " + username + ": " + authenticated);
                WorkflowHelper workflowHelper = (WorkflowHelper) AppUtil.getApplicationContext().getBean("workflowHelper");
                workflowHelper.addAuditTrail("DirectoryJsonController", "authenticate", "Authentication for user " + username + ": " + authenticated);               

            } catch (AuthenticationException e) {
                // add failure to audit trail
                if (username != null) {
                    LogUtil.info(getClass().getName(), "Authentication for user " + username + ": false");
                    WorkflowHelper workflowHelper = (WorkflowHelper) AppUtil.getApplicationContext().getBean("workflowHelper");
                    workflowHelper.addAuditTrail("DirectoryJsonController", "authenticate", "Authentication for user " + username + ": false");
                }
            }
        }
       
        if (WorkflowUtil.isCurrentUserAnonymous()) {
View Full Code Here

                        authenticationEntryPoint.commence(request, response, failed);
                    }

                    // CUSTOM: add failure to audit trail
                    LogUtil.info(getClass().getName(), "Authentication for user " + username + ": false");
                    WorkflowHelper workflowHelper = (WorkflowHelper) AppUtil.getApplicationContext().getBean("workflowHelper");
                    workflowHelper.addAuditTrail("WorkflowBasicProcessingFilter", "authenticate", "Authentication for user " + username + ": false")
                   
                    return;
                }

                // Authentication success
                if (logger.isDebugEnabled()) {
                    logger.debug("Authentication success: " + authResult.toString());
                }

                SecurityContextHolder.getContext().setAuthentication(authResult);

                rememberMeServices.loginSuccess(request, response, authResult);

                onSuccessfulAuthentication(request, response, authResult);
               
                // CUSTOM: add success to audit trail
                LogUtil.info(getClass().getName(), "Authentication for user " + username + ": true");
                WorkflowHelper workflowHelper = (WorkflowHelper) AppUtil.getApplicationContext().getBean("workflowHelper");
                workflowHelper.addAuditTrail("WorkflowBasicProcessingFilter", "authenticate", "Authentication for user " + username + ": true");               
            }
        }

        chain.doFilter(request, response);
    }
View Full Code Here

                            auth = new UsernamePasswordAuthenticationToken(user, user.getUsername(), user.getAuthorities());
                            super.setDetails(request, (UsernamePasswordAuthenticationToken) auth);
                        } else {
                            LogUtil.info(getClass().getName(), "Authentication for user " + loginAs + ": " + false);
           
                            WorkflowHelper workflowHelper = (WorkflowHelper) AppUtil.getApplicationContext().getBean("workflowHelper");
                            workflowHelper.addAuditTrail("WorkflowHttpAuthProcessingFilter", "authenticate", "Authentication for user " + loginAs + ": " + false);
                       
                            throw new BadCredentialsException("");
                        }
                    }
                }
            } else {
                if (loginHash != null) {
                    password = loginHash;
                }
                if (password != null) {
                    // use existing authentication manager
                    try {
                        UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username.trim(), password.trim());
                        super.setDetails(request, authRequest);

                        auth = getAuthenticationManager().authenticate(authRequest);

                        // no direct way in Spring Security 2, so use reflection to clear password in token
                        Field field = null;
                        try {
                            field = auth.getClass().getDeclaredField("credentials");
                            field.setAccessible(true);
                            field.set(auth, null);
                        } catch (Exception ex) {
                            LogUtil.error(getClass().getName(), ex, "Error clearing credentials in token");
                        } finally {
                            if (field != null) {
                                field.setAccessible(false);
                            }
                        }
                       
                        if (auth.isAuthenticated()) {
                            currentUser = directoryManager.getUserByUsername(username);
                        }
                    } catch (BadCredentialsException be) {
                        LogUtil.info(getClass().getName(), "Authentication for user " + ((loginAs == null) ? username : loginAs) + ": " + false);
           
                        WorkflowHelper workflowHelper = (WorkflowHelper) AppUtil.getApplicationContext().getBean("workflowHelper");
                        workflowHelper.addAuditTrail("WorkflowHttpAuthProcessingFilter", "authenticate", "Authentication for user " + ((loginAs == null) ? username : loginAs) + ": " + false);
           
                        throw be;
                    }
                }
            }

            if (currentUser != null) {
                workflowUserManager.setCurrentThreadUser(currentUser.getUsername());
            }

            if (!"/WEB-INF/jsp/unauthorized.jsp".equals(request.getServletPath())) {
                LogUtil.info(getClass().getName(), "Authentication for user " + ((loginAs == null) ? username : loginAs) + ": " + true);
                WorkflowHelper workflowHelper = (WorkflowHelper) AppUtil.getApplicationContext().getBean("workflowHelper");
                workflowHelper.addAuditTrail("WorkflowHttpAuthProcessingFilter", "authenticate", "Authentication for user " + ((loginAs == null) ? username : loginAs) + ": " + true);
            }
        } else {
            if (us != null && us.getAuthenticateAllApi()) {
                throw new BadCredentialsException("");
            }
View Full Code Here

            processDefId = processDefId.replaceAll(":", "#");
        }
       
        if (processDefId != null && processDefId.contains(LATEST)) {
            ApplicationContext appContext = WorkflowUtil.getApplicationContext();
            WorkflowHelper workflowMapper = (WorkflowHelper) appContext.getBean("workflowHelper");
       
            String currentVersion = workflowMapper.getPublishedPackageVersion(processDefId.split("#")[0]);

            if (currentVersion != null && currentVersion.trim().length() > 0) {
                processDefId = processDefId.replace(LATEST, currentVersion);
            }
        }
View Full Code Here

    protected Date getDueDateProceedByPlugin(String processId, String activityId, long limitInSecond, Date createdTime, Date startTime) {
        WorkflowDeadline deadline = new WorkflowDeadline();
        deadline.setDeadlineLimit((int) limitInSecond * 1000);

        ApplicationContext appContext = WorkflowUtil.getApplicationContext();
        WorkflowHelper workflowMapper = (WorkflowHelper) appContext.getBean("workflowHelper");

        WorkflowDeadline newDeadline = workflowMapper.executeDeadlinePlugin(processId, activityId, deadline, null, startTime, createdTime);

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(createdTime);
        calendar.add(Calendar.MILLISECOND, newDeadline.getDeadlineLimit());
        return calendar.getTime();
View Full Code Here

        if (context.containsKey(SharkConstants.PROCESS_STARTED_TIME)
                && context.containsKey(SharkConstants.ACTIVITY_ACCEPTED_TIME)
                && context.containsKey(SharkConstants.ACTIVITY_ACTIVATED_TIME)) {
           
            ApplicationContext appContext = WorkflowUtil.getApplicationContext();
            WorkflowHelper workflowMapper = (WorkflowHelper) appContext.getBean("workflowHelper");
           
            try {
                WorkflowDeadline workflowDeadline = new WorkflowDeadline();
                workflowDeadline.setContext(context);
                workflowDeadline.setDeadlineExpression(expr);

                WorkflowDeadline newDeadline = workflowMapper.executeDeadlinePlugin(procId, actId, workflowDeadline, (Date) context.get(SharkConstants.PROCESS_STARTED_TIME), (Date) context.get(SharkConstants.ACTIVITY_ACCEPTED_TIME), (Date) context.get(SharkConstants.ACTIVITY_ACTIVATED_TIME));

                expr = newDeadline.getDeadlineExpression();
            } catch (Exception e) {
                //ignore
            }
View Full Code Here

    @Override
    public void executeActivity(WMSessionHandle shandle, WfActivityInternal act) throws Exception, ToolAgentGeneralException {

        ApplicationContext appContext = WorkflowUtil.getApplicationContext();
        WorkflowHelper workflowMapper = (WorkflowHelper) appContext.getBean("workflowHelper");

        try {
            String processId = act.container(shandle).manager(shandle).name(shandle);
            String activityId = act.activity_definition_id(shandle);
            String version = act.container(shandle).manager(shandle).version(shandle);

            // retrieve assignment
            WorkflowAssignment workflowAssignment = new WorkflowAssignment();
            workflowAssignment.setProcessId(act.process_id(shandle));
            workflowAssignment.setProcessDefId(processId);
            workflowAssignment.setProcessName(act.container(shandle).name(shandle));
            workflowAssignment.setProcessVersion(version);
            workflowAssignment.setProcessRequesterId((String) shandle.getVendorData());
            workflowAssignment.setDescription(act.description(shandle));
            workflowAssignment.setActivityDefId(activityId);
            workflowAssignment.setActivityId(act.key(shandle));
            workflowAssignment.setActivityName(act.name(shandle));
            workflowAssignment.setAssigneeId(act.getPerformerId(shandle));

            // retrieve workflow variables
            List<WorkflowVariable> processVariableList = new ArrayList();
            Map variableMap = act.process_context(shandle);
            Iterator it = variableMap.entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry<String, String> pairs = (Map.Entry) it.next();
                WorkflowVariable var = new WorkflowVariable();
                var.setId(pairs.getKey());
                var.setVal(pairs.getValue());
                processVariableList.add(var);
            }
            workflowAssignment.setProcessVariableList(processVariableList);

            // execute tool
            WorkflowUtil.addAuditTrail(this.getClass().getName(), "executeTool", workflowAssignment.getActivityId());
            if(!workflowMapper.executeTool(workflowAssignment)){
                WorkflowUtil.addAuditTrail(this.getClass().getName(), "executeActivity", "Could not execute tool [processId=" + act.container(shandle).manager(shandle).name(shandle) + ", version=" + act.container(shandle).manager(shandle).version(shandle) + ", activityId=" + act.activity_definition_id(shandle) + "]");
            }else{
                WorkflowUtil.addAuditTrail(this.getClass().getName(), "executeToolCompleted", workflowAssignment.getActivityId());
            }

        } catch (Throwable ex) {
            workflowMapper.addAuditTrail(this.getClass().getName(), "executeActivity", "Could not execute tool [processId=" + act.container(shandle).manager(shandle).name(shandle) + ", version=" + act.container(shandle).manager(shandle).version(shandle) + ", activityId=" + act.activity_definition_id(shandle) + "]");
            LogUtil.error(getClass().getName(), ex, "Could not execute tool [processId=" + act.container(shandle).manager(shandle).name(shandle) + ", version=" + act.container(shandle).manager(shandle).version(shandle) + ", activityId=" + act.activity_definition_id(shandle) + "]");
        }
    }
View Full Code Here

TOP

Related Classes of org.joget.workflow.model.dao.WorkflowHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.