use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance in project carbon-business-process by wso2.
the class HumanTaskAppDeployer method undeployArtifacts.
/**
* Check the artifact type and if it is a HumanTask, delete the file from the HumanTask
* deployment hot folder
*
* @param carbonApp - CarbonApplication instance to check for HumanTask artifacts
* @param axisConfig - - axisConfig of the current tenant
*/
public void undeployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) {
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
// loop through all dependencies
for (Artifact.Dependency dep : artifacts) {
Deployer deployer;
Artifact artifact = dep.getArtifact();
if (artifact == null) {
continue;
}
if (HUMANTASK_TYPE.equals(artifact.getType())) {
deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, HUMANTASK_DIR, "zip");
} else {
continue;
}
List<CappFile> files = artifact.getFiles();
if (files.size() != 1) {
log.error("A HumanTask artifact must have a single file. But " + files.size() + " files found.");
continue;
}
if (deployer != null && AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED.equals(artifact.getDeploymentStatus())) {
String fileName = artifact.getFiles().get(0).getName();
String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
try {
deployer.undeploy(artifactPath);
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_PENDING);
} catch (DeploymentException e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
log.error("Error occured while trying to un deploy : " + artifact.getName());
}
}
}
}
use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance 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.core.ode.integration.jmx.Instance 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.core.ode.integration.jmx.Instance 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.core.ode.integration.jmx.Instance in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method fillFaultAndFailure.
/**
* Use fillFaultAndFailure(ProcessInstanceDAO, InstanceInfoType) to fill the
* instanceInfoWithEvents
*
* @param instance Process Instance DAO
* @param instanceInfoWithEvents Instance info with events
*/
private void fillFaultAndFailure(ProcessInstanceDAO instance, InstanceInfoWithEventsType instanceInfoWithEvents) {
InstanceInfoType instanceInfo = new InstanceInfoType();
fillFaultAndFailure(instance, instanceInfo);
if (instance.getFault() != null) {
instanceInfoWithEvents.setFaultInfo(instanceInfo.getFaultInfo());
}
if (instance.getActivityFailureCount() > 0) {
instanceInfoWithEvents.setFailuresInfo(instanceInfo.getFailuresInfo());
}
}
Aggregations