Search in sources :

Example 1 with WorkflowRuntimeException

use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.

the class ActionListDAOOjbImpl method getCount.

public int getCount(final String workflowId) {
    return (Integer) getPersistenceBrokerTemplate().execute(new PersistenceBrokerCallback() {

        public Object doInPersistenceBroker(PersistenceBroker broker) {
            PreparedStatement statement = null;
            ResultSet resultSet = null;
            try {
                Connection connection = broker.serviceConnectionManager().getConnection();
                statement = connection.prepareStatement(ACTION_LIST_COUNT_QUERY);
                statement.setString(1, workflowId);
                resultSet = statement.executeQuery();
                if (!resultSet.next()) {
                    throw new WorkflowRuntimeException("Error determining Action List Count.");
                }
                return resultSet.getInt(1);
            } catch (SQLException | LookupException e) {
                throw new WorkflowRuntimeException("Error determining Action List Count.", e);
            } finally {
                if (statement != null) {
                    try {
                        statement.close();
                    } catch (SQLException e) {
                    // should we be logging something?
                    }
                }
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    // should we be logging something?
                    }
                }
            }
        }
    });
}
Also used : PersistenceBroker(org.apache.ojb.broker.PersistenceBroker) LookupException(org.apache.ojb.broker.accesslayer.LookupException) SQLException(java.sql.SQLException) PersistenceBrokerCallback(org.springmodules.orm.ojb.PersistenceBrokerCallback) ResultSet(java.sql.ResultSet) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException)

Example 2 with WorkflowRuntimeException

use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.

the class DocumentOperationAction method queueActionInvocation.

public ActionForward queueActionInvocation(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try {
        DocumentOperationForm docForm = (DocumentOperationForm) form;
        String principalId = KEWServiceLocator.getIdentityHelperService().getIdForPrincipalName(docForm.getActionInvocationUser());
        ActionInvocation invocation = ActionInvocation.create(ActionType.fromCode(docForm.getActionInvocationActionCode()), docForm.getActionInvocationActionItemId());
        DocumentRouteHeaderValue document = docForm.getRouteHeader();
        ActionInvocationQueue actionInvocationQueue = KewApiServiceLocator.getActionInvocationProcessorService(document.getDocumentId());
        actionInvocationQueue.invokeAction(principalId, docForm.getRouteHeader().getDocumentId(), invocation);
        ActionMessages messages = new ActionMessages();
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Action Invocation Processor was successfully scheduled"));
        saveMessages(request, messages);
        return mapping.findForward("basic");
    } catch (Exception e) {
        throw new WorkflowRuntimeException(e);
    }
}
Also used : ActionMessages(org.apache.struts.action.ActionMessages) ActionInvocation(org.kuali.kfs.kew.api.action.ActionInvocation) ActionInvocationQueue(org.kuali.kfs.kew.api.action.ActionInvocationQueue) ActionMessage(org.apache.struts.action.ActionMessage) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) DocumentRouteHeaderValue(org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue) ServletException(javax.servlet.ServletException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) ParseException(java.text.ParseException) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) IOException(java.io.IOException)

Example 3 with WorkflowRuntimeException

use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.

the class DocumentOperationAction method blanketApproveDocument.

public ActionForward blanketApproveDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try {
        DocumentOperationForm docForm = (DocumentOperationForm) form;
        String blanketApproverUser = docForm.getBlanketApproveUser();
        if (StringUtils.isBlank(blanketApproverUser)) {
            throw new WorkflowServiceErrorException("No user was provided in the Blanket Approve User field", new WorkflowServiceErrorImpl("No user was provided in the Blanket Approve User field", "docoperation.operation.invalid"));
        }
        String principalId = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(docForm.getBlanketApproveUser()).getPrincipalId();
        Set<String> nodeNames = new HashSet<>();
        if (StringUtils.isNotBlank(docForm.getBlanketApproveNodes())) {
            String[] nodeNameArray = docForm.getBlanketApproveNodes().split(",");
            for (String nodeName : nodeNameArray) {
                nodeNames.add(nodeName.trim());
            }
        }
        DocumentRouteHeaderValue document = docForm.getRouteHeader();
        DocumentOrchestrationQueue blanketApprove = KewApiServiceLocator.getDocumentOrchestrationQueue(document.getDocumentId());
        DocumentOrchestrationConfig documentOrchestrationConfig = DocumentOrchestrationConfig.create(docForm.getBlanketApproveActionTakenId(), nodeNames);
        DocumentProcessingOptions options = DocumentProcessingOptions.createDefault();
        blanketApprove.orchestrateDocument(docForm.getRouteHeader().getDocumentId(), principalId, documentOrchestrationConfig, options);
        ActionMessages messages = new ActionMessages();
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Blanket Approve Processor was successfully scheduled"));
        saveMessages(request, messages);
        return mapping.findForward("basic");
    } catch (Exception e) {
        throw new WorkflowRuntimeException(e);
    }
}
Also used : WorkflowServiceErrorImpl(org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) DocumentOrchestrationQueue(org.kuali.kfs.kew.api.document.DocumentOrchestrationQueue) DocumentRouteHeaderValue(org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue) ServletException(javax.servlet.ServletException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) ParseException(java.text.ParseException) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) IOException(java.io.IOException) DocumentProcessingOptions(org.kuali.kfs.kew.api.document.DocumentProcessingOptions) ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage) DocumentOrchestrationConfig(org.kuali.kfs.kew.api.document.DocumentOrchestrationConfig) HashSet(java.util.HashSet)

Example 4 with WorkflowRuntimeException

use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.

the class DocumentOperationAction method moveDocument.

public ActionForward moveDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try {
        DocumentOperationForm docForm = (DocumentOperationForm) form;
        String principalId = KEWServiceLocator.getIdentityHelperService().getIdForPrincipalName(docForm.getBlanketApproveUser());
        Set<String> nodeNames = new HashSet<>();
        if (StringUtils.isNotBlank(docForm.getBlanketApproveNodes())) {
            String[] nodeNameArray = docForm.getBlanketApproveNodes().split(",");
            for (String nodeName : nodeNameArray) {
                nodeNames.add(nodeName.trim());
            }
        }
        DocumentRouteHeaderValue document = docForm.getRouteHeader();
        DocumentOrchestrationQueue orchestrationQueue = KewApiServiceLocator.getDocumentOrchestrationQueue(document.getDocumentId());
        DocumentOrchestrationConfig documentOrchestrationConfig = DocumentOrchestrationConfig.create(docForm.getBlanketApproveActionTakenId(), nodeNames);
        DocumentProcessingOptions options = DocumentProcessingOptions.create(true, true, false);
        orchestrationQueue.orchestrateDocument(docForm.getDocumentId(), principalId, documentOrchestrationConfig, options);
        ActionMessages messages = new ActionMessages();
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Move Document Processor was successfully scheduled"));
        saveMessages(request, messages);
        return mapping.findForward("basic");
    } catch (Exception e) {
        throw new WorkflowRuntimeException(e);
    }
}
Also used : WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) DocumentOrchestrationQueue(org.kuali.kfs.kew.api.document.DocumentOrchestrationQueue) DocumentRouteHeaderValue(org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue) ServletException(javax.servlet.ServletException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) ParseException(java.text.ParseException) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) IOException(java.io.IOException) DocumentProcessingOptions(org.kuali.kfs.kew.api.document.DocumentProcessingOptions) ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage) DocumentOrchestrationConfig(org.kuali.kfs.kew.api.document.DocumentOrchestrationConfig) HashSet(java.util.HashSet)

Example 5 with WorkflowRuntimeException

use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.

the class DocumentOperationAction method queueDocument.

public ActionForward queueDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try {
        DocumentOperationForm docForm = (DocumentOperationForm) form;
        DocumentRouteHeaderValue document = docForm.getRouteHeader();
        DocumentProcessingQueue documentProcessingQueue = KewApiServiceLocator.getDocumentProcessingQueue(document.getDocumentId());
        documentProcessingQueue.process(docForm.getDocumentId());
        ActionMessages messages = new ActionMessages();
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Document was successfully queued"));
        saveMessages(request, messages);
        return mapping.findForward("basic");
    } catch (Exception e) {
        throw new WorkflowRuntimeException(e);
    }
}
Also used : ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) DocumentRouteHeaderValue(org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue) ServletException(javax.servlet.ServletException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) ParseException(java.text.ParseException) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) IOException(java.io.IOException) DocumentProcessingQueue(org.kuali.kfs.kew.api.document.DocumentProcessingQueue)

Aggregations

WorkflowRuntimeException (org.kuali.kfs.kew.api.WorkflowRuntimeException)12 Connection (java.sql.Connection)6 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6 SQLException (java.sql.SQLException)6 PersistenceBroker (org.apache.ojb.broker.PersistenceBroker)6 IOException (java.io.IOException)4 ParseException (java.text.ParseException)4 ServletException (javax.servlet.ServletException)4 LookupException (org.apache.ojb.broker.accesslayer.LookupException)4 ActionMessage (org.apache.struts.action.ActionMessage)4 ActionMessages (org.apache.struts.action.ActionMessages)4 WorkflowServiceErrorException (org.kuali.kfs.kew.exception.WorkflowServiceErrorException)4 DocumentRouteHeaderValue (org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue)4 PersistenceBrokerCallback (org.springmodules.orm.ojb.PersistenceBrokerCallback)4 ArrayList (java.util.ArrayList)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Timestamp (java.sql.Timestamp)2 HashSet (java.util.HashSet)2 OptimisticLockException (org.apache.ojb.broker.OptimisticLockException)2