public ProcessInfoDocument getProcessInfoCustom(final QName pid, final ProcessInfoCustomizer custom) { try { return _db.exec(new BpelDatabase.Callable<ProcessInfoDocument>() { public ProcessInfoDocument run(BpelDAOConnection conn) { return genProcessInfoDocument(conn, pid, custom); } }); } catch (Exception ex) { __log.error("Exception in getProcessInfoCustom()", ex); throw new ManagementException("Exception in getProcessInfoCustom(): " + ex.toString()); } }
/** * Execute a database transaction, unwrapping nested * {@link ManagementException}s. * * @param runnable * action to run * @return * @throws ManagementException */ protected <T> T dbexec(BpelProcessDatabase.Callable<T> runnable) throws ManagementException { try { return runnable.exec(); } catch (ManagementException me) { throw me; } catch (Exception e) { __log.error("Exception during database operation", e); throw new ManagementException("Exception during database operation: " + e.toString()); } }
public ProcessInfoDocument activate(QName pid) { try { _store.setState(pid, org.apache.ode.bpel.iapi.ProcessState.ACTIVE); } catch (Exception ex) { __log.error("Exception while setting process state", ex); throw new ManagementException("Error setting process state: " + ex.toString()); } return getProcessInfoCustom(pid, ProcessInfoCustomizer.NONE); }
/** * Execute a database transaction, unwrapping nested * {@link ManagementException}s. * * @param callable * action to run * @return * @throws ManagementException */ protected <T> T dbexec(BpelDatabase.Callable<T> callable) throws ManagementException { try { return _db.exec(callable); } catch (ManagementException me) { // Passthrough. throw me; } catch (Exception ex) { __log.error("Exception during database operation", ex); throw new ManagementException("Exception during database operation" + ex.toString()); } }
public GetCommunicationResponseDocument getCommunication(final GetCommunication request) throws ManagementException { final Throwable[] e = new Throwable[1]; try { GetCommunicationResponseDocument response = _db.exec(new BpelDatabase.Callable<GetCommunicationResponseDocument>() { public GetCommunicationResponseDocument run(BpelDAOConnection conn) throws Exception { try { Replayer replayer = new Replayer(); GetCommunicationResponseDocument responseDoc = GetCommunicationResponseDocument.Factory.newInstance(); responseDoc.setGetCommunicationResponse(replayer.getCommunication(request, conn)); return responseDoc; } catch (Throwable e2) { e[0] = e2; throw new Exception("", e2); } } }); if (e[0] != null) { __log.debug("throwing pending exception"); throw e[0]; } return response; } catch (Throwable e2) { throw new ManagementException("", e2); } }
public EventInfoListDocument getEvents(final Long iid, final int startIdx, final int count) throws ManagementException { // TODO: this is a bit of hack, if there are two events with exactly the // same timestamp, we can have more events returned then requested. List<String> timeline; try { timeline = getEventTimeline("iid="+iid,null); } catch (Exception ex) { throw new ManagementException("Unable to retrieve timeline.", ex); } if (startIdx >= timeline.size()) return EventInfoListDocument.Factory.newInstance(); timeline = timeline.subList(startIdx,Math.min(timeline.size(),startIdx+count)); String startdt = timeline.get(0); String enddt = timeline.get(timeline.size()-1); return listEvents("iid="+iid,"timestamp>="+startdt +" " +"timestamp<="+enddt,0); }
public ReplayResponseDocument replay(final Replay request) throws ManagementException { final Throwable[] e = new Throwable[1]; try { ReplayResponseDocument response = _db.exec(new BpelDatabase.Callable<ReplayResponseDocument>() { public ReplayResponseDocument run(BpelDAOConnection conn) throws Exception { try { ReplayResponse response = ReplayResponse.Factory.newInstance(); Replayer replayer = new Replayer(); List<Long> iids = replayer.replayInstances(request, _server.getEngine(), conn); for (Long iid : iids) { response.addRestoredIID(iid); } ReplayResponseDocument responseDoc = ReplayResponseDocument.Factory.newInstance(); responseDoc.setReplayResponse(response); return responseDoc; } catch (Throwable t) { e[0] = t; throw new Exception("", t); } } }); if (e[0] != null) { __log.debug("throwing pending exception"); throw e[0]; } return response; } catch (Throwable e2) { throw new ManagementException("", e2); } }
public static List<Long> delete(String filter) { log.info("Instance filter for instance deletion:" + filter); final InstanceFilter instanceFilter = new InstanceFilter(filter); final List<Long> ret = new LinkedList<Long>(); try { dbexec(new BpelDatabase.Callable<Object>() { public Object run(BpelDAOConnection conn) { Collection<ProcessInstanceDAO> instances = conn.instanceQuery(instanceFilter); for (ProcessInstanceDAO instance : instances) { instance.delete(EnumSet.allOf(ProcessConf.CLEANUP_CATEGORY.class), true); ret.add(instance.getInstanceId()); } return null; } }); } catch (Exception e) { String errMsg = "Exception during instance deletion. Filter: " + filter; log.error(errMsg, e); throw new ManagementException(errMsg, e); } return ret; }
} catch (Exception e) { String errMsg = "Exception during instance count for deletion. Filter: " + filter; throw new ManagementException(errMsg, e);
private CorrelationSetDAO findCorrelationSetDAO(ProcessInstanceDAO instance, Long scopeId, String correlationSet) throws ManagementException { ScopeDAO scope = instance.getScope(scopeId); CorrelationSetDAO corr = null; do { corr = scope.getCorrelationSet(correlationSet); if(corr != null) break; scope = scope.getParentScope(); } while(scope != null); if(corr == null) throw new ManagementException("CorrelationSetNotFound:" + correlationSet); return corr; }
/** * Execute a database transaction, unwrapping nested * {@link org.apache.ode.bpel.pmapi.ManagementException}s. * * @param callable action to run * @return object of type T * @throws org.apache.ode.bpel.pmapi.ManagementException if exception occurred during transaction */ private static <T> T dbexec(BpelDatabase.Callable<T> callable) throws ManagementException { try { BPELServerImpl bpelServer = (BPELServerImpl) BPELServiceComponent.getBPELServer(); BpelDatabase bpelDb = bpelServer.getODEBPELServer().getBpelDb(); return bpelDb.exec(callable); } catch (ManagementException me) { // Passthrough. throw me; } catch (Exception ex) { log.error("Exception during database operation", ex); throw new ManagementException("Exception during database operation", ex); } }