Search in sources :

Example 1 with InstanceManagementException

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;
}
Also used : BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) ArrayList(java.util.ArrayList) ActivityRecoveryInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivityRecoveryInfoType) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) ProcessNotFoundException(org.apache.ode.bpel.pmapi.ProcessNotFoundException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessingException(org.apache.ode.bpel.pmapi.ProcessingException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessInstanceDAO(org.apache.ode.bpel.dao.ProcessInstanceDAO) ActivityRecoveryDAO(org.apache.ode.bpel.dao.ActivityRecoveryDAO) Collection(java.util.Collection)

Example 2 with InstanceManagementException

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");
    }
}
Also used : InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) QName(javax.xml.namespace.QName) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)

Example 3 with InstanceManagementException

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);
}
Also used : InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) DebuggerSupport(org.apache.ode.bpel.engine.DebuggerSupport)

Example 4 with InstanceManagementException

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;
}
Also used : LimitedInstanceInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.LimitedInstanceInfoType)

Example 5 with InstanceManagementException

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;
}
Also used : InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ScopeInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ScopeInfoType)

Aggregations

InstanceManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException)16 BpelDAOConnection (org.apache.ode.bpel.dao.BpelDAOConnection)10 BpelDatabase (org.apache.ode.bpel.engine.BpelDatabase)10 ProcessInstanceDAO (org.apache.ode.bpel.dao.ProcessInstanceDAO)9 ProcessNotFoundException (org.apache.ode.bpel.pmapi.ProcessNotFoundException)6 ProcessingException (org.apache.ode.bpel.pmapi.ProcessingException)6 TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)6 Collection (java.util.Collection)5 InstanceFilter (org.apache.ode.bpel.common.InstanceFilter)5 LimitedInstanceInfoType (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.LimitedInstanceInfoType)5 ArrayList (java.util.ArrayList)3 DebuggerSupport (org.apache.ode.bpel.engine.DebuggerSupport)3 PaginatedInstanceList (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PaginatedInstanceList)3 QName (javax.xml.namespace.QName)2 ActivityRecoveryDAO (org.apache.ode.bpel.dao.ActivityRecoveryDAO)2 LinkedList (java.util.LinkedList)1 AxisFault (org.apache.axis2.AxisFault)1 BpelEngineImpl (org.apache.ode.bpel.engine.BpelEngineImpl)1 BpelProcess (org.apache.ode.bpel.engine.BpelProcess)1 ProcessConf (org.apache.ode.bpel.iapi.ProcessConf)1