use of org.apache.ode.bpel.pmapi.ManagementException in project carbon-business-process by wso2.
the class Utils method getInstanceCountForProcess.
/**
* Return the instances in the given processes list
*
* @param processesInPackage
* @return Instance count
* @throws ManagementException
*/
public static long getInstanceCountForProcess(List<QName> processesInPackage) throws ManagementException {
if (processesInPackage != null) {
String filter = null;
for (QName q : processesInPackage) {
if (filter == null) {
filter = "pid=" + q.toString();
} else {
filter += "|" + q.toString();
}
}
try {
final InstanceFilter instanceFilter = new InstanceFilter(filter);
long count = (long) dbexec(new BpelDatabase.Callable<Object>() {
public Object run(BpelDAOConnection conn) {
return conn.instanceCount(instanceFilter);
}
});
return count;
} catch (Exception e) {
String errMsg = "Exception during instance count for deletion. Filter: " + filter;
throw new ManagementException(errMsg, e);
}
} else {
return 0;
}
}
use of org.apache.ode.bpel.pmapi.ManagementException in project carbon-business-process by wso2.
the class Utils method dbexec.
/**
* 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);
}
}
use of org.apache.ode.bpel.pmapi.ManagementException in project carbon-business-process by wso2.
the class Utils method delete.
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;
}
Aggregations