use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method getFailedActivitiesForInstance.
/**
* Get Failed Activities for give instance id.
*
* @param instanceID
* @return
* @throws InstanceManagementException
*/
@Override
public ActivityRecoveryInfoType[] getFailedActivitiesForInstance(final long instanceID) throws InstanceManagementException {
try {
isOperationIsValidForTheCurrentTenant(instanceID);
} catch (IllegalAccessException ex) {
handleError(ex);
}
ActivityRecoveryInfoType[] activityRecoveryInfoTypes = null;
try {
BpelDatabase bpelDb = bpelServer.getODEBPELServer().getBpelDb();
Object result = bpelDb.exec(new BpelDatabase.Callable<Object>() {
public Object run(BpelDAOConnection conn) throws InstanceManagementException {
ProcessInstanceDAO instance = conn.getInstance(instanceID);
Collection<ActivityRecoveryDAO> activityRecoveries = instance.getActivityRecoveries();
return activityRecoveries;
}
});
ArrayList<ActivityRecoveryDAO> activityRecoveryDAOs = (ArrayList<ActivityRecoveryDAO>) result;
if (activityRecoveryDAOs != null) {
activityRecoveryInfoTypes = new ActivityRecoveryInfoType[activityRecoveryDAOs.size()];
for (int i = 0; i < activityRecoveryDAOs.size(); i++) {
ActivityRecoveryDAO activityRecovery = activityRecoveryDAOs.get(i);
ActivityRecoveryInfoType info = new ActivityRecoveryInfoType();
info.setActions(activityRecovery.getActions());
info.setActivityID(activityRecovery.getActivityId());
info.setDateTime(String.valueOf(activityRecovery.getDateTime()));
info.setInstanceID(instanceID);
info.setReason(activityRecovery.getReason());
info.setRetires(activityRecovery.getRetries());
activityRecoveryInfoTypes[i] = info;
}
}
} catch (Exception e) {
String errMsg = "Error occurred while retrieving failed activity information for instance id " + instanceID;
log.error(errMsg, e);
throw new InstanceManagementException(errMsg, e);
}
return activityRecoveryInfoTypes;
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method isOperationIsValidForTheCurrentTenant.
/**
* Check whether the instance belongs to the current tenant. If not, don't allow any operations.
*
* @param iid instance id
* @throws IllegalAccessException if instance doesn't belong to the current tenant
* @throws ProcessingException if there a error getting instance data
* @throws InstanceManagementException if the processId does not exist
*/
private void isOperationIsValidForTheCurrentTenant(final long iid) throws IllegalAccessException, ProcessingException, InstanceManagementException {
QName processId = getProcess(iid);
TenantProcessStoreImpl processStore = getTenantProcessForCurrentSession();
if (processId != null) {
if (!processStore.containsProcess(processId)) {
log.error("Trying to invoke a illegal operation. Instance ID:" + iid);
throw new IllegalAccessException("Operation is not permitted.");
}
} else {
throw new InstanceManagementException("Process instance for instance ID " + iid + " does not exist");
}
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method resumeInstance.
/**
* Resume a suspended instance
*
* @param iid Instance Id
* @throws InstanceManagementException If the instance cannot be resumed due to the
* unavailability of Debugger support
*/
public void resumeInstance(long iid) throws InstanceManagementException {
try {
isOperationIsValidForTheCurrentTenant(iid);
} catch (IllegalAccessException ex) {
handleError(ex);
}
/*
We need debugger support in order to resume (since we have to force
a reduction. If one is not available the getDebugger() method should
throw a ProcessingException
*/
DebuggerSupport debugSupport = getDebugger(iid);
if (debugSupport == null) {
String errMsg = "Cannot resume the instance " + iid + ", Debugger support not available";
log.error(errMsg);
throw new InstanceManagementException(errMsg);
}
debugSupport.resume(iid);
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method createLimitedInstanceInfoObject.
private LimitedInstanceInfoType createLimitedInstanceInfoObject(ProcessInstanceDAO instanceDAO) throws InstanceManagementException {
LimitedInstanceInfoType instanceInfo = new LimitedInstanceInfoType();
instanceInfo.setIid(Long.toString(instanceDAO.getInstanceId()));
instanceInfo.setPid(instanceDAO.getProcess().getProcessId().toString());
instanceInfo.setStatus(odeInstanceStatusToManagementAPIStatus(instanceDAO.getState()));
instanceInfo.setDateLastActive(toCalendar(instanceDAO.getLastActiveTime()));
instanceInfo.setDateStarted(toCalendar(instanceDAO.getCreateTime()));
return instanceInfo;
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method getScopeInfo.
private ScopeInfoType getScopeInfo(ScopeDAO scope) throws InstanceManagementException {
final ScopeInfoType scopeInfo = new ScopeInfoType();
/*ScopeDAO scope = conn.getScopeEagerly(siid);*/
if (scope == null) {
// String errMsg = "Scope " + siid +" not found.";
String errMsg = "Scope " + " not found.";
log.error(errMsg);
throw new InstanceManagementException(errMsg);
}
fillScopeInfo(scopeInfo, scope);
return scopeInfo;
}
Aggregations