Search in sources :

Example 1 with WorkflowServiceErrorImpl

use of org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl in project cu-kfs by CU-CommunityApps.

the class ActionTakenServiceImpl method validateActionTaken.

public void validateActionTaken(ActionTaken actionTaken) {
    LOG.debug("Enter validateActionTaken(..)");
    List<WorkflowServiceErrorImpl> errors = new ArrayList<WorkflowServiceErrorImpl>();
    String documentId = actionTaken.getDocumentId();
    if (documentId == null) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken documentid null.", "actiontaken.documentid.empty", actionTaken.getActionTakenId().toString()));
    } else if (getRouteHeaderService().getRouteHeader(documentId) == null) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken documentid invalid.", "actiontaken.documentid.invalid", actionTaken.getActionTakenId().toString()));
    }
    String principalId = actionTaken.getPrincipalId();
    if (StringUtils.isBlank(principalId)) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken personid null.", "actiontaken.personid.empty", actionTaken.getActionTakenId().toString()));
    } else {
        Principal principal = KimApiServiceLocator.getIdentityService().getPrincipal(principalId);
        if (principal == null) {
            errors.add(new WorkflowServiceErrorImpl("ActionTaken personid invalid.", "actiontaken.personid.invalid", actionTaken.getActionTakenId().toString()));
        }
    }
    String actionTakenCd = actionTaken.getActionTaken();
    if (actionTakenCd == null || actionTakenCd.trim().equals("")) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken cd null.", "actiontaken.actiontaken.empty", actionTaken.getActionTakenId().toString()));
    } else if (!KewApiConstants.ACTION_TAKEN_CD.containsKey(actionTakenCd)) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken invalid.", "actiontaken.actiontaken.invalid", actionTaken.getActionTakenId().toString()));
    }
    if (actionTaken.getActionDate() == null) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken actiondate null.", "actiontaken.actiondate.empty", actionTaken.getActionTakenId().toString()));
    }
    if (actionTaken.getDocVersion() == null) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken docversion null.", "actiontaken.docverion.empty", actionTaken.getActionTakenId().toString()));
    }
    LOG.debug("Exit validateActionRequest(..) ");
    if (!errors.isEmpty()) {
        throw new WorkflowServiceErrorException("ActionRequest Validation Error", errors);
    }
}
Also used : WorkflowServiceErrorImpl(org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) ArrayList(java.util.ArrayList) Principal(org.kuali.kfs.kim.impl.identity.principal.Principal)

Example 2 with WorkflowServiceErrorImpl

use of org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl 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 3 with WorkflowServiceErrorImpl

use of org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl in project cu-kfs by CU-CommunityApps.

the class PreferencesServiceImpl method validate.

private void validate(Preferences preferences) {
    LOG.debug("validating preferences");
    List<WorkflowServiceError> errors = new ArrayList<>();
    try {
        Integer.valueOf(preferences.getRefreshRate().trim());
    } catch (NumberFormatException | NullPointerException e) {
        errors.add(new WorkflowServiceErrorImpl("ActionList Refresh Rate must be in whole " + "minutes", Preferences.KEYS.ERR_KEY_REFRESH_RATE_WHOLE_NUM));
    }
    try {
        if (Integer.parseInt(preferences.getPageSize().trim()) == 0) {
            errors.add(new WorkflowServiceErrorImpl("ActionList Page Size must be non-zero ", Preferences.KEYS.ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM));
        }
    } catch (NumberFormatException | NullPointerException e) {
        errors.add(new WorkflowServiceErrorImpl("ActionList Page Size must be in whole " + "minutes", Preferences.KEYS.ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM));
    }
    LOG.debug("end validating preferences");
    if (!errors.isEmpty()) {
        throw new WorkflowServiceErrorException("Preference Validation Error", errors);
    }
}
Also used : WorkflowServiceErrorImpl(org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) WorkflowServiceError(org.kuali.kfs.kew.exception.WorkflowServiceError) ArrayList(java.util.ArrayList)

Example 4 with WorkflowServiceErrorImpl

use of org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl in project cu-kfs by CU-CommunityApps.

the class DocumentOperationAction method save.

public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    DocumentOperationForm docForm = (DocumentOperationForm) form;
    boolean change = false;
    String routeHeaderOp = docForm.getRouteHeaderOp();
    if (!KewApiConstants.UPDATE.equals(routeHeaderOp) && !KewApiConstants.NOOP.equals(routeHeaderOp)) {
        throw new WorkflowServiceErrorException("Document operation not defined", new WorkflowServiceErrorImpl("Document operation not defined", "docoperation.operation.invalid"));
    }
    if (KewApiConstants.UPDATE.equals(routeHeaderOp)) {
        setRouteHeaderTimestamps(docForm);
        DocumentRouteHeaderValue dHeader = docForm.getRouteHeader();
        String initials = docForm.getInitialNodeInstances();
        List<RouteNodeInstance> lInitials = new ArrayList<RouteNodeInstance>();
        if (StringUtils.isNotEmpty(initials)) {
            StringTokenizer tokenInitials = new StringTokenizer(initials, ",");
            while (tokenInitials.hasMoreTokens()) {
                String instanceId = tokenInitials.nextToken().trim();
                LOG.debug(instanceId);
                RouteNodeInstance instance = getRouteNodeService().findRouteNodeInstanceById(instanceId);
                lInitials.add(instance);
            }
        }
        dHeader.setInitialRouteNodeInstances(lInitials);
        /*
             * FINP-7381 changes from KualiCo patch release 2021-02-26 applied to
             * original KEW-to-KFS KualiCo patch release 2021-01-28 version of the file.
             */
        getRouteHeaderService().validateRouteHeader(dHeader);
        getRouteHeaderService().saveRouteHeader(dHeader);
        change = true;
    }
    for (Iterator actionRequestIter = docForm.getActionRequestOps().iterator(); actionRequestIter.hasNext(); ) {
        DocOperationIndexedParameter actionRequestOp = (DocOperationIndexedParameter) actionRequestIter.next();
        int index = actionRequestOp.getIndex();
        String opValue = actionRequestOp.getValue();
        ActionRequest actionRequest = docForm.getActionRequests().get(index);
        String createDateParamName = "actionRequests[" + index + "].createDateString";
        if (!KewApiConstants.UPDATE.equals(opValue) && !KewApiConstants.DELETE.equals(opValue) && !KewApiConstants.NOOP.equals(opValue)) {
            throw new WorkflowServiceErrorException("Action request operation not defined", new WorkflowServiceErrorImpl("Action request operation not defined", "docoperation.actionrequest.operation.invalid"));
        }
        if (KewApiConstants.UPDATE.equals(opValue)) {
            try {
                actionRequest.setCreateDate(new Timestamp(KFSConstants.getDefaultDateFormat().parse(request.getParameter(createDateParamName)).getTime()));
                actionRequest.setCreateDateString(KFSConstants.getDefaultDateFormat().format(actionRequest.getCreateDate()));
                actionRequest.setDocumentId(docForm.getRouteHeader().getDocumentId());
                if (StringUtils.isNotBlank(actionRequest.getParentActionRequestId())) {
                    actionRequest.setParentActionRequest(getActionRequestService().findByActionRequestId(actionRequest.getParentActionRequestId()));
                }
                if (StringUtils.isNotBlank(actionRequest.getActionTakenId())) {
                    actionRequest.setActionTaken(getActionTakenService().findByActionTakenId(actionRequest.getActionTakenId()));
                }
                if (actionRequest.getNodeInstance() != null && actionRequest.getNodeInstance().getRouteNodeInstanceId() == null) {
                    actionRequest.setNodeInstance(null);
                } else if (actionRequest.getNodeInstance() != null && actionRequest.getNodeInstance().getRouteNodeInstanceId() != null) {
                    actionRequest.setNodeInstance(KEWServiceLocator.getRouteNodeService().findRouteNodeInstanceById(actionRequest.getNodeInstance().getRouteNodeInstanceId()));
                }
                getActionRequestService().saveActionRequest(actionRequest);
                change = true;
            } catch (ParseException pe) {
                throw new WorkflowServiceErrorException("Action request create date parsing error", new WorkflowServiceErrorImpl("Action request create date parsing error", "docoperation.actionrequests.dateparsing.error", actionRequest.getActionRequestId()));
            }
        }
        if (KewApiConstants.DELETE.equals(opValue)) {
            getActionRequestService().deleteActionRequestGraph(actionRequest);
            change = true;
        }
    }
    for (Iterator actionTakenIter = docForm.getActionTakenOps().iterator(); actionTakenIter.hasNext(); ) {
        DocOperationIndexedParameter actionTakenOp = (DocOperationIndexedParameter) actionTakenIter.next();
        int index = actionTakenOp.getIndex();
        String opValue = actionTakenOp.getValue();
        String actionDateParamName = "actionsTaken[" + index + "].actionDateString";
        ActionTaken actionTaken = docForm.getActionsTaken().get(index);
        if (!KewApiConstants.UPDATE.equals(opValue) && !KewApiConstants.DELETE.equals(opValue) && !KewApiConstants.NOOP.equals(opValue)) {
            throw new WorkflowServiceErrorException("Action taken operation not defined", new WorkflowServiceErrorImpl("Action taken operation not defined", "docoperation.actiontaken.operation.invalid"));
        }
        if (KewApiConstants.UPDATE.equals(opValue)) {
            try {
                actionTaken.setActionDate(new Timestamp(KFSConstants.getDefaultDateFormat().parse(request.getParameter(actionDateParamName)).getTime()));
                actionTaken.setActionDateString(KFSConstants.getDefaultDateFormat().format(actionTaken.getActionDate()));
                getActionTakenService().saveActionTaken(actionTaken);
                change = true;
            } catch (ParseException pe) {
                throw new WorkflowServiceErrorException("Action taken action date parsing error", new WorkflowServiceErrorImpl("Action taken action date parse error", "docoperation.actionstaken.dateparsing.error", actionTaken.getActionTakenId()));
            }
        }
        if (KewApiConstants.DELETE.equals(opValue)) {
            getActionTakenService().delete(actionTaken);
            change = true;
        }
    }
    for (Iterator actionItemIter = docForm.getActionItemOps().iterator(); actionItemIter.hasNext(); ) {
        DocOperationIndexedParameter actionItemOp = (DocOperationIndexedParameter) actionItemIter.next();
        int index = actionItemOp.getIndex();
        String opValue = actionItemOp.getValue();
        String dateAssignedParamName = "actionItems[" + index + "].dateAssignedStringValue";
        ActionItem actionItem = docForm.getActionItems().get(index);
        if (!KewApiConstants.UPDATE.equals(opValue) && !KewApiConstants.DELETE.equals(opValue) && !KewApiConstants.NOOP.equals(opValue)) {
            throw new WorkflowServiceErrorException("Action Item operation not defined", new WorkflowServiceErrorImpl("Action Item operation not defined", "docoperation.operation.invalid"));
        }
        if (KewApiConstants.UPDATE.equals(opValue)) {
            try {
                actionItem.setDateAssigned(new Timestamp(KFSConstants.getDefaultDateFormat().parse(request.getParameter(dateAssignedParamName)).getTime()));
                actionItem.setDateAssignedStringValue(KFSConstants.getDefaultDateFormat().format(actionItem.getDateAssigned()));
                actionItem.setDocumentId(docForm.getRouteHeader().getDocumentId());
                getActionListService().saveActionItem(actionItem);
                change = true;
            } catch (ParseException pe) {
                throw new WorkflowServiceErrorException("Action item date assigned parsing error", new WorkflowServiceErrorImpl("Action item date assigned parse error", "docoperation.actionitem.dateassignedparsing.error", actionItem.getId()));
            }
        }
        if (KewApiConstants.DELETE.equals(opValue)) {
            try {
                actionItem.setDateAssigned(new Timestamp(KFSConstants.getDefaultDateFormat().parse(request.getParameter(dateAssignedParamName)).getTime()));
                actionItem.setDateAssignedStringValue(KFSConstants.getDefaultDateFormat().format(actionItem.getDateAssigned()));
                actionItem.setDocumentId(docForm.getRouteHeader().getDocumentId());
                getActionListService().deleteActionItem(actionItem);
                change = true;
            } catch (ParseException pe) {
                throw new WorkflowServiceErrorException("Action item date assigned parsing error", new WorkflowServiceErrorImpl("Action item date assigned parse error", "docoperation.actionitem.dateassignedparsing.error", actionItem.getId()));
            }
        }
    }
    List routeNodeInstances = (List) (request.getSession().getAttribute("routeNodeInstances"));
    String ids = (docForm.getNodeStatesDelete() != null) ? docForm.getNodeStatesDelete().trim() : null;
    List statesToBeDeleted = new ArrayList();
    if (ids != null && !"".equals(ids)) {
        StringTokenizer idSets = new StringTokenizer(ids);
        while (idSets.hasMoreTokens()) {
            String id = idSets.nextToken().trim();
            statesToBeDeleted.add(Long.valueOf(id));
        }
    }
    for (Iterator routeNodeInstanceIter = docForm.getRouteNodeInstanceOps().iterator(); routeNodeInstanceIter.hasNext(); ) {
        DocOperationIndexedParameter routeNodeInstanceOp = (DocOperationIndexedParameter) routeNodeInstanceIter.next();
        int index = routeNodeInstanceOp.getIndex();
        String opValue = routeNodeInstanceOp.getValue();
        LOG.debug(opValue);
        RouteNodeInstance routeNodeInstance = (RouteNodeInstance) (routeNodeInstances.get(index));
        RouteNodeInstance routeNodeInstanceNew = docForm.getRouteNodeInstance(index);
        if (!KewApiConstants.UPDATE.equals(opValue) && !KewApiConstants.DELETE.equals(opValue) && !KewApiConstants.NOOP.equals(opValue)) {
            throw new WorkflowServiceErrorException("Route Node Instance Operation not defined", new WorkflowServiceErrorImpl("Route Node Instance Operation not defined", "docoperation.routenodeinstance.operation.invalid"));
        }
        if (KewApiConstants.UPDATE.equals(opValue)) {
            routeNodeInstance.setActive(routeNodeInstanceNew.isActive());
            LOG.debug(Boolean.toString(routeNodeInstanceNew.isActive()));
            routeNodeInstance.setComplete(routeNodeInstanceNew.isComplete());
            routeNodeInstance.setInitial(routeNodeInstanceNew.isInitial());
            List<NodeState> nodeStates = routeNodeInstance.getState();
            List<NodeState> nodeStatesNew = routeNodeInstanceNew.getState();
            if (nodeStates != null) {
                for (int i = 0; i < nodeStates.size(); i++) {
                    NodeState nodeState = nodeStates.get(i);
                    NodeState nodeStateNew = nodeStatesNew.get(i);
                    if (nodeStateNew.getKey() != null && !nodeStateNew.getKey().trim().equals("")) {
                        nodeState.setKey(nodeStateNew.getKey());
                        LOG.debug(nodeState.getKey());
                        nodeState.setValue(nodeStateNew.getValue());
                        LOG.debug(nodeState.getValue());
                    }
                }
            }
            getRouteNodeService().save(routeNodeInstance);
            LOG.debug("saved");
            change = true;
        }
        if (KewApiConstants.DELETE.equals(opValue)) {
            List<NodeState> nodeStates = routeNodeInstance.getState();
            List<NodeState> nodeStatesNew = routeNodeInstanceNew.getState();
            if (nodeStates != null) {
                for (int i = 0; i < nodeStates.size(); i++) {
                    NodeState nodeState = nodeStates.get(i);
                    NodeState nodeStateNew = nodeStatesNew.get(i);
                    if (nodeStateNew.getKey() == null || nodeStateNew.getKey().trim().equals("")) {
                        statesToBeDeleted.remove(nodeState.getNodeStateId());
                    }
                }
            }
            getRouteNodeService().deleteByRouteNodeInstance(routeNodeInstance);
            LOG.debug(routeNodeInstance.getRouteNodeInstanceId() + " is deleted");
            change = true;
            break;
        }
        if (KewApiConstants.NOOP.equals(opValue)) {
            routeNodeInstanceNew.setActive(routeNodeInstance.isActive());
            routeNodeInstanceNew.setComplete(routeNodeInstance.isComplete());
            routeNodeInstanceNew.setInitial(routeNodeInstance.isInitial());
            List<NodeState> nodeStates = routeNodeInstance.getState();
            List<NodeState> nodeStatesNew = routeNodeInstanceNew.getState();
            if (nodeStates != null) {
                for (int i = 0; i < nodeStates.size(); i++) {
                    NodeState nodeState = nodeStates.get(i);
                    NodeState nodeStateNew = nodeStatesNew.get(i);
                    if (nodeStateNew.getKey() == null || nodeStateNew.getKey().trim().equals("")) {
                        statesToBeDeleted.remove(nodeState.getNodeStateId());
                    }
                    nodeStateNew.setKey(nodeState.getKey());
                    nodeStateNew.setValue(nodeState.getValue());
                }
            }
        }
    }
    if (statesToBeDeleted != null && statesToBeDeleted.size() > 0) {
        getRouteNodeService().deleteNodeStates(statesToBeDeleted);
    }
    List branches = (List) request.getSession().getAttribute("branches");
    String branchStateIds = (docForm.getBranchStatesDelete() != null) ? docForm.getBranchStatesDelete().trim() : null;
    List<Long> branchStatesToBeDeleted = new ArrayList<>();
    if (branchStateIds != null && !"".equals(branchStateIds)) {
        StringTokenizer idSets = new StringTokenizer(branchStateIds);
        while (idSets.hasMoreTokens()) {
            String id = idSets.nextToken().trim();
            branchStatesToBeDeleted.add(Long.valueOf(id));
        }
    }
    for (Iterator branchesOpIter = docForm.getBranchOps().iterator(); branchesOpIter.hasNext(); ) {
        DocOperationIndexedParameter branchesOp = (DocOperationIndexedParameter) branchesOpIter.next();
        int index = branchesOp.getIndex();
        String opValue = branchesOp.getValue();
        LOG.debug(opValue);
        Branch branch = (Branch) (branches.get(index));
        Branch branchNew = docForm.getBranche(index);
        if (!KewApiConstants.UPDATE.equals(opValue) && !KewApiConstants.NOOP.equals(opValue)) {
            throw new WorkflowServiceErrorException("Route Node Instance Operation not defined", new WorkflowServiceErrorImpl("Route Node Instance Operation not defined", "docoperation.routenodeinstance.operation.invalid"));
        }
        if (KewApiConstants.UPDATE.equals(opValue)) {
            branch.setName(branchNew.getName());
            List<BranchState> branchStates = branch.getBranchState();
            List<BranchState> branchStatesNew = branchNew.getBranchState();
            if (branchStates != null) {
                for (int i = 0; i < branchStates.size(); i++) {
                    BranchState branchState = branchStates.get(i);
                    if (i < branchStatesNew.size()) {
                        BranchState branchStateNew = branchStatesNew.get(i);
                        if (branchStateNew.getKey() != null && !branchStateNew.getKey().trim().equals("")) {
                            branchState.setKey(branchStateNew.getKey());
                            LOG.debug(branchState.getKey());
                            branchState.setValue(branchStateNew.getValue());
                            LOG.debug(branchState.getValue());
                        }
                    }
                }
            }
            getBranchService().save(branch);
            LOG.debug("branch saved");
            change = true;
        }
        if (KewApiConstants.NOOP.equals(opValue)) {
            branchNew.setName(branch.getName());
            List<BranchState> branchStates = branch.getBranchState();
            List<BranchState> branchStatesNew = branchNew.getBranchState();
            if (branchStates != null) {
                for (int i = 0; i < branchStates.size(); i++) {
                    BranchState branchState = branchStates.get(i);
                    BranchState branchStateNew = branchStatesNew.get(i);
                    if (branchStateNew.getKey() == null || branchStateNew.getKey().trim().equals("")) {
                        branchStatesToBeDeleted.remove(branchState.getBranchStateId());
                    }
                    branchStateNew.setKey(branchState.getKey());
                    LOG.debug(branchState.getKey());
                    branchStateNew.setValue(branchState.getValue());
                    LOG.debug(branchState.getValue());
                }
            }
        }
    }
    if (branchStatesToBeDeleted != null && branchStatesToBeDeleted.size() > 0) {
        List<BranchState> branchStatesToDelete = new ArrayList<>();
        List<String> branchStateIdsToBeDeleted = new ArrayList<>(branchStatesToBeDeleted.size());
        // Converting a list of Long values to list of String values
        for (Long branchStateToBeDeleted : branchStatesToBeDeleted) {
            branchStateIdsToBeDeleted.add(String.valueOf(branchStateToBeDeleted));
        }
        for (String branchStateId : branchStateIdsToBeDeleted) {
            BranchState branchState = getBusinessObjectService().findBySinglePrimaryKey(BranchState.class, branchStateId);
            branchStatesToDelete.add(branchState);
        }
        getBranchService().deleteBranchStates(branchStatesToDelete);
    }
    WorkflowDocument workflowDocument = WorkflowDocumentFactory.loadDocument(GlobalVariables.getUserSession().getPrincipalId(), docForm.getDocumentId());
    String annotation = docForm.getAnnotation();
    if (StringUtils.isEmpty(annotation)) {
        annotation = DEFAULT_LOG_MSG;
    }
    workflowDocument.logAnnotation(annotation);
    ActionMessages messages = new ActionMessages();
    String forward = null;
    if (change) {
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("docoperation.operation.saved"));
        docForm.setRouteHeader(getRouteHeaderService().getRouteHeader(docForm.getRouteHeader().getDocumentId()));
        forward = "summary";
    } else {
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("docoperation.operation.noop"));
        forward = "basic";
    }
    saveMessages(request, messages);
    return mapping.findForward(forward);
}
Also used : NodeState(org.kuali.kfs.kew.engine.node.NodeState) WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) ArrayList(java.util.ArrayList) RouteNodeInstance(org.kuali.kfs.kew.engine.node.RouteNodeInstance) Timestamp(java.sql.Timestamp) BranchState(org.kuali.kfs.kew.engine.node.BranchState) DocumentRouteHeaderValue(org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue) ActionMessages(org.apache.struts.action.ActionMessages) Branch(org.kuali.kfs.kew.engine.node.Branch) Iterator(java.util.Iterator) ActionMessage(org.apache.struts.action.ActionMessage) List(java.util.List) ArrayList(java.util.ArrayList) WorkflowServiceErrorImpl(org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl) ActionItem(org.kuali.kfs.kew.actionitem.ActionItem) StringTokenizer(java.util.StringTokenizer) ActionRequest(org.kuali.kfs.kew.actionrequest.ActionRequest) ParseException(java.text.ParseException) ActionTaken(org.kuali.kfs.kew.actiontaken.ActionTaken)

Example 5 with WorkflowServiceErrorImpl

use of org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl in project cu-kfs by CU-CommunityApps.

the class RuleAttributeServiceImpl method validate.

private void validate(RuleAttribute ruleAttribute) {
    LOG.debug("validating ruleAttribute");
    List<WorkflowServiceError> errors = new ArrayList<>();
    if (ruleAttribute.getName() == null || ruleAttribute.getName().trim().equals("")) {
        errors.add(new WorkflowServiceErrorImpl("Please enter a rule attribute name.", RULE_ATTRIBUTE_NAME_REQUIRED));
        LOG.error("Rule attribute name is missing");
    } else {
        ruleAttribute.setName(ruleAttribute.getName().trim());
        if (ruleAttribute.getId() == null) {
            RuleAttribute nameInUse = findByName(ruleAttribute.getName());
            if (nameInUse != null) {
                errors.add(new WorkflowServiceErrorImpl("Rule attribute name already in use", "routetemplate.ruleattribute.name.duplicate"));
                LOG.error("Rule attribute name already in use");
            }
        }
    }
    if (ruleAttribute.getResourceDescriptor() == null || ruleAttribute.getResourceDescriptor().trim().equals("")) {
        errors.add(new WorkflowServiceErrorImpl("Please enter a rule attribute class name.", RULE_ATTRIBUTE_CLASS_REQUIRED));
        LOG.error("Rule attribute class name is missing");
    } else {
        ruleAttribute.setResourceDescriptor(ruleAttribute.getResourceDescriptor().trim());
    }
    LOG.debug("end validating ruleAttribute");
    if (!errors.isEmpty()) {
        throw new WorkflowServiceErrorException("RuleAttribute Validation Error", errors);
    }
}
Also used : WorkflowServiceErrorImpl(org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl) RuleAttribute(org.kuali.kfs.kew.rule.bo.RuleAttribute) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) WorkflowServiceError(org.kuali.kfs.kew.exception.WorkflowServiceError) ArrayList(java.util.ArrayList)

Aggregations

WorkflowServiceErrorException (org.kuali.kfs.kew.exception.WorkflowServiceErrorException)5 WorkflowServiceErrorImpl (org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl)5 ArrayList (java.util.ArrayList)4 ParseException (java.text.ParseException)2 ActionMessage (org.apache.struts.action.ActionMessage)2 ActionMessages (org.apache.struts.action.ActionMessages)2 WorkflowServiceError (org.kuali.kfs.kew.exception.WorkflowServiceError)2 DocumentRouteHeaderValue (org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue)2 IOException (java.io.IOException)1 Timestamp (java.sql.Timestamp)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 StringTokenizer (java.util.StringTokenizer)1 ServletException (javax.servlet.ServletException)1 ActionItem (org.kuali.kfs.kew.actionitem.ActionItem)1 ActionRequest (org.kuali.kfs.kew.actionrequest.ActionRequest)1 ActionTaken (org.kuali.kfs.kew.actiontaken.ActionTaken)1 WorkflowDocument (org.kuali.kfs.kew.api.WorkflowDocument)1 WorkflowRuntimeException (org.kuali.kfs.kew.api.WorkflowRuntimeException)1