public boolean onCommitChanges() { /*-CONFIG-*/ String m = "onCommitChanges-"; /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "get State Transition config", null, null); StateTransitionConfigFactory config = StateTransitionConfigFactory.getSTConfig(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "get MRCS config task definition", null, null); MrcsWorkflowTask t = config.getMrcsWorkflowTask(m_mrcsapp, m_processname, m_taskname); boolean canCommit = false; try { AutoSelectSinglePath(); // perform basic CFR part 11 checks: must have valid user/pass/reason, user is user that is // logged in, password is valid, reason is not empty/null /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "check form and user/pass/reason validations", null, null); String validation = performValidation(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, m + "result: " + (validation == null ? "valid" : validation), null, null); if (validation != null) { /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "User/Pass/Reason error detected: " + validation, null, null); setErrorMessage(validation); return false; } /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "get refs to signing controls", null, null); Text usernameCtrl = (Text) getControl(QADocForwardWFT.USERNAME_CONTROL_NAME, Text.class); Password passwordCtrl = (Password) getControl(QADocForwardWFT.PASSWORD_CONTROL_NAME, Password.class); DropDownList rsnListCtrl = (DropDownList) getControl(QADocForwardWFT.REASONSELECT_CONTROL_NAME, DropDownList.class); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "get refs to signing controls", null, null); String username = usernameCtrl.getValue(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + " -- user: "******" -- pass: "******"null" : "#########"), null, null); String reason = rsnListCtrl.getValue(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + " -- reason: " + reason, null, null); // HACK the class hierarchy: set Password on superclass, otherwise it won't successfully // complete when calling super.onCommitChanges() Password passwdCtrl = (Password) getControl("__PASSWORD_CONTROL_NAME"); passwdCtrl.setValue(password); try { /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "check for signature validations", null, null); if (t.MethodConfiguration != null && t.MethodConfiguration.containsKey("SignatureValidations")) { /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "signature validations detected", null, null); List signvalidations = (List) t.MethodConfiguration.get("SignatureValidations"); Map context = new HashMap(); List errmsgs = new ArrayList(); boolean vflag = false; for (int i = 0; i < signvalidations.size(); i++) { /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "running signing validation plugin #" + i, null, null); MrcsPlugin plugin = (MrcsPlugin) signvalidations.get(i); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "-- instantiating - " + plugin.PluginClassName, null, null); // we'll reuse IMrcsWorkflowValidation as the plugin interface, even though it lacks the // task name, which I guess we could hardcode in the MRCS config for the task if need // be... ISignatureValidation vplug = (ISignatureValidation) Class.forName(plugin.PluginClassName).newInstance(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "-- exec", null, null); if (!vplug.validate( getDfSession().getSessionManager(), getDfSession().getDocbaseName(), m_mrcsapp, m_processname, m_task, m_primarypackage, username, password, reason, errmsgs, plugin.PluginConfiguration, context)) { // break immediately? Or run through all of them? vflag = false; /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "-- VALIDATION FAILURE", null, null); break; } } if (vflag) // validation failed if true... { for (int ii = 0; ii < errmsgs.size(); ii++) setErrorMessage((String) errmsgs.get(ii)); return false; } } } catch (Exception e) { /*-ERROR-*/ DfLogger.error(this, m + "Error in Signature Validations", null, e); throw new WrapperRuntimeException(e); } // now, I'm pretty sure that super.canCommitChanges() is a dangerous point-of-no-return call // that actually has side effects, despite its stateless-implying name, // so we should make sure as we can that the signing info has been verified at this point, by // checking audit records, rendition presence, number of signatures, etc if (super.canCommitChanges()) { // I'm pretty sure this super.onCommitChanges call is point-of-no-return: the task will be // completed and the workflow will proceed with the next task // if they are automatic. This can create race conditions with stuff that happens after the // task is done, such as workflow plugins, etc. If you get an error // message with "can't find object reference" of something like 4d017f38XXXXX, then the // workflow completed and cleaned itself before the plugins/signing // could complete in time. // THEREFORE, we will sign first (signing multiple documents can take...awhile...), THEN // commit changes if (m_task.isSignOffRequired()) { /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, m + "onCommitChanges is signing the document - I don't think this should ever happen for FinishWFT", null, null); try { if (t.MethodConfiguration != null && t.MethodConfiguration.containsKey("SignatureService")) { MrcsPlugin signingplugin = (MrcsPlugin) t.MethodConfiguration.get("SignatureService"); ISignatureService signplug = (ISignatureService) Class.forName(signingplugin.PluginClassName).newInstance(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "-- exec signing", null, null); signplug.sign( getDfSession().getSessionManager(), getDfSession().getDocbaseName(), m_mrcsapp, m_processname, m_task, m_primarypackage, username, password, reason, signingplugin.PluginConfiguration, null); } } catch (Exception e) { /*-ERROR-*/ DfLogger.error(this, m + "Error in Signature Service", null, e); throw new WrapperRuntimeException(e); } } canCommit = super.onCommitChanges(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, m + "canCommit (after validation and performing super call) : " + canCommit, null, null); } else { canCommit = false; } if (canCommit) { // uses Actions as a pluginlayer... // IN GENERAL these are a bad idea, due to the race conditions documented in the comments // above... /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, " MRCS:FinishWFT: onCommitChanges : get ref to workflow defn", null, null); IDfId workflowid = m_task.getWorkflowId(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, " MRCS:FinishWFT: onCommitChanges : look up workflow object (IDfWorkflow)", null, null); IDfWorkflow workflow = (IDfWorkflow) getDfSession().getObject(workflowid); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, " MRCS:FinishWFT: onCommitChanges : look up process object (IDfProcess)", null, null); IDfProcess wfdef = (IDfProcess) getDfSession().getObject(workflow.getProcessId()); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, " MRCS:FinishWFT: onCommitChanges : workflow name: " + wfdef.getObjectName(), null, null); MrcsWorkflowTask mrcstask = config.getMrcsWorkflowTask(m_mrcsapp, wfdef.getObjectName(), m_task.getTaskName()); if (mrcstask.Actions != null) { Map context = new HashMap(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, " MRCS:FinishWFT: onCommitChanges : executing client-side plugins", null, null); for (int k = 0; k < mrcstask.Actions.size(); k++) { try { /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, " MRCS:FinishWFT: onCommitChanges : executing plugin " + (k + 1), null, null); MrcsPlugin plugin = (MrcsPlugin) mrcstask.Actions.get(k); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, " MRCS:FinishWFT: onCommitChanges : -- class: " + plugin.PluginClassName, null, null); IMrcsWorkflowActionPlugin wfaction = (IMrcsWorkflowActionPlugin) Class.forName(plugin.PluginClassName).newInstance(); wfaction.execute( getDfSession().getSessionManager(), getDfSession().getDocbaseName(), m_task, workflow, m_mrcsapp, plugin.PluginConfiguration, context); } catch (Exception e) { /*-ERROR-*/ DfLogger.error( this, m + "error in MRCS 4.2 client-side workflow actions", null, e); setErrorMessage("MSG_UNEXPECTED_ERROR", new Object[] {e.getMessage()}, e); throw new WrapperRuntimeException("error in MRCS workflow actions", e); } } } if (canCommit) setMessage("MSG_FINISH_SUCCESS", new Object[] {super.getString("MSG_OBJECT")}); } // commit & esign ends } catch (DfException e1) { /*-ERROR-*/ DfLogger.error( this, "MRCS:FinishWFT.onCommitChanges - DfException occurred: ", null, e1); canCommit = false; try { if (m_task.getCompleteErrStatus() == 4) { /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "Exception occurred:Incorrect Password " + e1, null, null); setErrorMessage("MSG_INCORRECT_PASSWORD"); return false; } /* * else if(){ [DM_SYSOBJECT_E_ESIGN_SIGNATURE_METHOD_FAILED } */ else { /*-ERROR-*/ DfLogger.error( this, "MRCS:FinishWFT.onCommitChanges - Exception occurred:Unexpected Error ", null, e1); setErrorMessage("MSG_UNEXPECTED_ERROR", new Object[] {e1.getMessage()}, e1); return false; } } catch (DfException e2) { /*-ERROR-*/ DfLogger.error(this, m + "error in exception handling code", null, e2); throw new WrapperRuntimeException(e2); } } return canCommit; }