}
ProcessLookup pl = new ProcessLookup();
ProcessDefinitionDirectory procDefDir
= wfs.processDefinitionDirectory();
if ( packageID != null && processID != null ) {
ProcessMgr mgr = null;
try {
mgr = procDefDir.processMgr(packageID, processID);
} catch (InvalidKeyException e) {
throw new ProcessingException
(HttpServletResponse.SC_BAD_REQUEST,
e.getMessage());
}
String mgrName = mgr.name();
if (dataItemName != null && dataItemValue != null) {
// Try to connect to existing process
Collection procs = mgr
.findByDataItem(dataItemName, dataItemValue);
if (procs.size() == 1) {
pl.process = (WfProcess)procs.iterator().next();
pl.procKey = pl.process.key();
pl.packageId = packageID;
pl.processId = processID;
if ( session != null) {
session.setAttribute("WfM_mgrName", mgr.name());
session.setAttribute("WfM_procKey", pl.procKey);
}
return pl;
}
if (procs.size() > 1) {
logger.error
("More than one process found for " + mgr.name()
+ ", data item: " + dataItemName + " = "
+ dataItemValue);
throw new ProcessingException
(HttpServletResponse.SC_CONFLICT,
"More than one matching process found");