/** * Convert instance status from the internal database representation to * the process management API enumerations. * @param instancestate internal database state code * @return API-compliant enumeration */ TInstanceStatus.Enum cvtInstanceStatus(short instancestate) { switch (instancestate) { case ProcessState.STATE_NEW: case ProcessState.STATE_READY: case ProcessState.STATE_ACTIVE: return TInstanceStatus.ACTIVE; case ProcessState.STATE_COMPLETED_OK: return TInstanceStatus.COMPLETED; case ProcessState.STATE_COMPLETED_WITH_FAULT: return TInstanceStatus.FAILED; case ProcessState.STATE_SUSPENDED: return TInstanceStatus.SUSPENDED; case ProcessState.STATE_TERMINATED: return TInstanceStatus.TERMINATED; } // TODO: How do we determine if the process is in an "ERROR" state. // The above should have been exhaustive. throw new ProcessingException("Encountered unexpected instance state: " + instancestate); }
public ScopeInfoDocument getScopeInfoWithActivity(final String siid, final boolean includeActivityInfo) { try { return _db.exec(new BpelDatabase.Callable<ScopeInfoDocument>() { public ScopeInfoDocument run(BpelDAOConnection conn) throws Exception { return genScopeInfoDocument(conn, siid, includeActivityInfo); } }); } catch (Exception e) { __log.error("Exception while retrieving scope info", e); throw new ProcessingException("Exception while retrieving scope info: " + e.toString()); } }
public InstanceInfoDocument getInstanceInfo(final Long iid) throws InstanceNotFoundException { try { return _db.exec(new BpelDatabase.Callable<InstanceInfoDocument>() { public InstanceInfoDocument run(BpelDAOConnection conn) { return genInstanceInfoDocument(conn, iid); } }); } catch (Exception e) { __log.error("Exception while retrieving instance info", e); throw new ProcessingException("Exception while retrieving instance info: " + e.toString()); } }
/** * @see BpelManagementFacade#getProcessDef(String) * @param procid */ public OProcess getProcessDef(String procid) throws ManagementException { if (_server._engine == null) throw new ProcessingException("ServiceProvider required for debugger operation."); BpelProcess process = _server._engine._activeProcesses.get(QName.valueOf(procid)); if (process == null) throw new InvalidRequestException("The process \"" + procid + "\" is not available. Please make sure it is deployed and encompassing System is activated." ); return process.getOProcess(); }
/** * Get the {@link org.apache.ode.bpel.engine.DebuggerSupport} object for the given instance identifier. * Debugger support is required for operations that resume execution in some * way or manipulate the breakpoints. * * @param iid instance identifier * @return associated debugger support object * @throws ManagementException */ private QName getProcess(final Long iid) { QName processId; try { processId = dbexec(new BpelDatabase.Callable<QName>() { public QName run(BpelDAOConnection conn) throws Exception { ProcessInstanceDAO instance = conn.getInstance(iid); return instance == null ? null : instance.getProcess().getProcessId(); } }); } catch (Exception e) { String errMsg = "Exception during instance: " + iid + " retrieval"; log.error(errMsg, e); throw new ProcessingException(errMsg + ": " + e.toString(), e); } return processId; }
public Collection<Long> delete(String filter) { final InstanceFilter instanceFilter = new InstanceFilter(filter); final List<Long> ret = new LinkedList<Long>(); try { _db.exec(new BpelDatabase.Callable<Object>() { public Object run(BpelDAOConnection conn) { Collection<ProcessInstanceDAO> instances = conn.instanceQuery(instanceFilter); for (ProcessInstanceDAO instance : instances) { ProcessConf proc = _store.getProcessConfiguration(instance.getProcess().getProcessId()); if (proc == null) throw new ProcessNotFoundException("ProcessNotFound:" + instance.getProcess().getProcessId()); // delete the instance and all related data instance.delete(EnumSet.allOf(CLEANUP_CATEGORY.class)); ret.add(instance.getInstanceId()); } return null; } }); } catch (Exception e) { __log.error("Exception during instance deletion", e); throw new ProcessingException("Exception during instance deletion: " + e.toString()); } return ret; }
public InstanceInfoDocument recoverActivity(final Long iid, final Long aid, final String action) { try { _db.exec(new BpelDatabase.Callable<QName>() { public QName run(BpelDAOConnection conn) throws Exception { ProcessInstanceDAO instance = conn.getInstance(iid); if (instance == null) return null; for (ActivityRecoveryDAO recovery : instance.getActivityRecoveries()) { if (recovery.getActivityId() == aid) { BpelProcess process = _server._engine._activeProcesses.get(instance.getProcess().getProcessId()); if (process != null) { process.recoverActivity(instance, recovery.getChannel(), aid, action, null); break; } } } return instance.getProcess().getProcessId(); } }); } catch (Exception e) { __log.error("Exception during activity recovery", e); throw new ProcessingException("Exception during activity recovery" + e.toString()); } return getInstanceInfo(iid); }
/** * Get the {@link DebuggerSupport} object for the given instance identifier. * Debugger support is required for operations that resume execution in some * way or manipulate the breakpoints. * * @param iid * instance identifier * @return associated debugger support object * @throws ManagementException */ protected final DebuggerSupport getDebugger(final Long iid) { QName processId; try { processId = _db.exec(new BpelDatabase.Callable<QName>() { public QName run(BpelDAOConnection conn) throws Exception { ProcessInstanceDAO instance = conn.getInstance(iid); return instance == null ? null : instance.getProcess().getProcessId(); } }); } catch (Exception e) { __log.error("Exception during instance retrieval", e); throw new ProcessingException("Exception during instance retrieval: " + e.toString()); } return getDebugger(processId); }
} catch (Exception ex) { __log.error("ProcessingEx", ex); throw new ProcessingException(ex.getMessage(),ex);
/** * @see org.apache.ode.bpel.pmapi.InstanceManagement#queryInstances(java.lang.String) */ public InstanceInfoListDocument queryInstances(final String query) { InstanceInfoListDocument ret = InstanceInfoListDocument.Factory.newInstance(); final TInstanceInfoList infolist = ret.addNewInstanceInfoList(); try { _db.exec(new BpelDatabase.Callable<Object>() { public Object run(BpelDAOConnection conn) { Collection<ProcessInstanceDAO> instances = conn.instanceQuery(query); for (ProcessInstanceDAO instance : instances) { fillInstanceInfo(infolist.addNewInstanceInfo(), instance); } return null; } }); } catch (Exception e) { __log.error("Exception while querying instances", e); throw new ProcessingException("Exception while querying instances: " + e.toString()); } return ret; }
public InstanceInfoListDocument listInstances(String filter, String order, int limit) { InstanceInfoListDocument ret = InstanceInfoListDocument.Factory.newInstance(); final TInstanceInfoList infolist = ret.addNewInstanceInfoList(); final InstanceFilter instanceFilter = new InstanceFilter(filter, order, limit); try { _db.exec(new BpelDatabase.Callable<Object>() { public Object run(BpelDAOConnection conn) { Collection<ProcessInstanceDAO> instances = conn.instanceQuery(instanceFilter); for (ProcessInstanceDAO instance : instances) { fillInstanceInfo(infolist.addNewInstanceInfo(), instance); } return null; } }); } catch (Exception e) { __log.error("Exception while listing instances", e); throw new ProcessingException("Exception while listing instances: " + e.toString()); } return ret; }
} catch (Exception e) { __log.error("Exception while setting process property", e); throw new ProcessingException("Exception while setting process property" + e.toString());
} catch (Exception e) { __log.error("Exception while setting process property", e); throw new ProcessingException("Exception while setting process property: " + e.toString());
public InstanceInfoListDocument listInstancesSummary(String filter, String order, int limit) { InstanceInfoListDocument ret = InstanceInfoListDocument.Factory.newInstance(); final TInstanceInfoList infolist = ret.addNewInstanceInfoList(); final InstanceFilter instanceFilter = new InstanceFilter(filter, order, limit); try { _db.exec(new BpelDatabase.Callable<Object>() { public Object run(BpelDAOConnection conn) { Collection<ProcessInstanceDAO> instances = conn.instanceQuery(instanceFilter); Map<Long, Collection<CorrelationSetDAO>> icsets = conn.getCorrelationSets(instances); for (ProcessInstanceDAO instance : instances) { TInstanceInfo info = infolist.addNewInstanceInfo(); fillInstanceSummary(info, instance); Collection<CorrelationSetDAO> csets = icsets.get(instance.getInstanceId()); if (csets != null) { for (CorrelationSetDAO cset: csets) { Map<QName, String> props = cset.getProperties(); fillProperties(info, instance, props); } } } return null; } }); } catch (Exception e) { __log.error("Exception while listing instances", e); throw new ProcessingException("Exception while listing instances: " + e.toString()); } return ret; }
} catch (Exception e) { __log.error("Exception while listing processes", e); throw new ProcessingException("Exception while listing processes: " + e.toString());
private ProcessInfoDocument genProcessInfoDocument(BpelDAOConnection conn, QName procid, ProcessInfoCustomizer custom) throws ManagementException { if (procid == null) { throw new InvalidRequestException("Valid QName as process id expected."); } ProcessInfoDocument ret = ProcessInfoDocument.Factory.newInstance(); TProcessInfo pi = ret.addNewProcessInfo(); try { ProcessConf pconf = _store.getProcessConfiguration(procid); if (pconf == null) throw new ProcessNotFoundException("ProcessNotFound:" + procid); fillProcessInfo(pi, pconf, custom); fillProcessInfoSummary(conn, Collections.singletonList(pi), custom); } catch (ManagementException me) { throw me; } catch (Exception e) { __log.error("Exception while retrieving process information", e); throw new ProcessingException("Exception while retrieving process information: " + e.toString()); } return ret; }