Search in sources :

Example 81 with Task

use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-apimgt by wso2.

the class WorkflowDAOIT method testGetPendinExternalWorkflowReferenceForApprovedasks.

@Test
public void testGetPendinExternalWorkflowReferenceForApprovedasks() throws Exception {
    WorkflowDAO workflowDAO = DAOFactory.getWorkflowDAO();
    String workflowExtRefId = UUID.randomUUID().toString();
    String applicationId = UUID.randomUUID().toString();
    Workflow workflow = SampleTestObjectCreator.createWorkflow(workflowExtRefId);
    workflow.setWorkflowType(WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION);
    workflow.setWorkflowReference(applicationId);
    workflow.setStatus(WorkflowStatus.APPROVED);
    workflowDAO.addWorkflowEntry(workflow);
    Optional<String> externalRefFromDb = workflowDAO.getExternalWorkflowReferenceForPendingTask(applicationId, WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION);
    Assert.assertFalse(externalRefFromDb.isPresent(), "Should return only if the wf task is in CREATED state");
}
Also used : WorkflowDAO(org.wso2.carbon.apimgt.core.dao.WorkflowDAO) Workflow(org.wso2.carbon.apimgt.core.workflow.Workflow) Test(org.testng.annotations.Test)

Example 82 with Task

use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project siddhi by wso2.

the class SiddhiAppRuntime method persist.

public PersistenceReference persist() {
    try {
        // first, pause all the event sources
        sourceMap.values().forEach(list -> list.forEach(Source::pause));
        // take snapshots of execution units
        byte[] snapshots = siddhiAppContext.getSnapshotService().snapshot();
        // start the snapshot persisting task asynchronously
        AsyncSnapshotPersistor asyncSnapshotPersistor = new AsyncSnapshotPersistor(snapshots, siddhiAppContext.getSiddhiContext().getPersistenceStore(), siddhiAppContext.getName());
        String revision = asyncSnapshotPersistor.getRevision();
        Future future = siddhiAppContext.getExecutorService().submit(asyncSnapshotPersistor);
        return new PersistenceReference(future, revision);
    } finally {
        // at the end, resume the event sources
        sourceMap.values().forEach(list -> list.forEach(Source::resume));
    }
}
Also used : AsyncSnapshotPersistor(org.wso2.siddhi.core.util.snapshot.AsyncSnapshotPersistor) Future(java.util.concurrent.Future) PersistenceReference(org.wso2.siddhi.core.util.snapshot.PersistenceReference)

Example 83 with Task

use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.

the class EventListener method onEvent.

public void onEvent(BpelEvent bpelEvent) {
    if (isCoordinationEnabled) {
        if (bpelEvent instanceof ProcessTerminationEvent) {
            ProcessTerminationEvent event = (ProcessTerminationEvent) bpelEvent;
            ProcessConfigurationImpl processConf = getProcessConfiguration(event);
            if (processConf != null && processConf.isB4PTaskIncluded()) {
                if (log.isDebugEnabled()) {
                    log.debug("TERMINATED Process instance " + event.getProcessInstanceId() + " has a B4P activity. Initiating Exit Protocol Messages to task(s).");
                }
                TerminationTask terminationTask = new TerminationTask(Long.toString(event.getProcessInstanceId()));
                terminationTask.setTenantID(processConf.getTenantId());
                B4PContentHolder.getInstance().getCoordinationController().runTask(terminationTask);
            }
        } else if (bpelEvent instanceof ProcessInstanceStateChangeEvent) {
            ProcessInstanceStateChangeEvent instanceStateChangeEvent = (ProcessInstanceStateChangeEvent) bpelEvent;
            if (ProcessState.STATE_COMPLETED_WITH_FAULT == instanceStateChangeEvent.getNewState()) {
                ProcessConfigurationImpl processConf = getProcessConfiguration(instanceStateChangeEvent);
                if (processConf != null && processConf.isB4PTaskIncluded()) {
                    if (log.isDebugEnabled()) {
                        log.debug("Process Instance, COMPLETED WITH FAULT " + instanceStateChangeEvent.getProcessInstanceId() + " has a B4P activity. Initiating Exit Protocol Messages to task(s)");
                    }
                    TerminationTask terminationTask = new TerminationTask(Long.toString(instanceStateChangeEvent.getProcessInstanceId()));
                    terminationTask.setTenantID(processConf.getTenantId());
                    B4PContentHolder.getInstance().getCoordinationController().runTask(terminationTask);
                }
            }
        }
    }
}
Also used : ProcessInstanceStateChangeEvent(org.apache.ode.bpel.evt.ProcessInstanceStateChangeEvent) ProcessTerminationEvent(org.apache.ode.bpel.evt.ProcessTerminationEvent) ProcessConfigurationImpl(org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl)

Example 84 with Task

use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.

the class PeopleActivity method extractStandardElementType.

/**
 * In a peopleActivity element there can be exist only one standard element. eg - Standard Elements are 1. task 2.
 * localTask 3. remoteTask 4. remoteNotification etc.
 * <p/>
 * This method verify there's only one standard element exist and return the type of that standard element
 *
 * @return
 */
private String extractStandardElementType(Element parentElement) throws FaultException {
    NodeList taskList = parentElement.getChildNodes();
    String elementType = null;
    int standardElementCounter = 0;
    for (int i = 0; i < taskList.getLength(); i++) {
        if (taskList.item(i).getNodeType() == Node.ELEMENT_NODE) {
            try {
                elementType = getTypeOfStandardElement(taskList.item(i));
                standardElementCounter++;
                if (standardElementCounter > 1) {
                    throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "There is exist more than one standard child elements in " + BPEL4PeopleConstants.PEOPLE_ACTIVITY);
                }
            } catch (FaultException e) {
            // Do nothing
            }
        }
    }
    if (elementType != null) {
        return elementType;
    } else {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "There is no standard child elements defined in " + BPEL4PeopleConstants.PEOPLE_ACTIVITY);
    }
}
Also used : FaultException(org.apache.ode.bpel.common.FaultException) NodeList(org.w3c.dom.NodeList) WSDL11Endpoint(org.apache.ode.bpel.epr.WSDL11Endpoint) UnifiedEndpoint(org.wso2.carbon.unifiedendpoint.core.UnifiedEndpoint)

Example 85 with Task

use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.

the class TerminationTask method invokeProtocolHandler.

private synchronized void invokeProtocolHandler(ExitProtocolMessage message) {
    OMElement payload = message.toOM();
    Options options = new Options();
    options.setTo(new EndpointReference(message.getTaskProtocolHandlerURL()));
    options.setAction(WSConstants.WS_HT_COORDINATION_PROTOCOL_EXIT_ACTION);
    options.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTPS);
    ServiceClient serviceClient = null;
    try {
        serviceClient = new ServiceClient();
        serviceClient.setOptions(options);
        // Setting basic auth headers.
        String tenantDomain = MultitenantUtils.getTenantDomainFromUrl(message.getTaskProtocolHandlerURL());
        if (message.getTaskProtocolHandlerURL().equals(tenantDomain)) {
            // this is a Super tenant registration service
            CarbonUtils.setBasicAccessSecurityHeaders(CoordinationConfiguration.getInstance().getProtocolHandlerAdminUser(), CoordinationConfiguration.getInstance().getProtocolHandlerAdminPassword(), serviceClient);
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Sending exit protocol message to tenant domain: " + tenantDomain);
            }
            // Tenant's registration service
            String username = "";
            String password = "";
            try {
                UserRegistry configSystemRegistry = B4PContentHolder.getInstance().getRegistryService().getConfigSystemRegistry(tenantID);
                Resource taskCoordination = configSystemRegistry.get(REG_TASK_COORDINATION);
                if (taskCoordination != null) {
                    username = taskCoordination.getProperty(USERNAME);
                    password = taskCoordination.getProperty(PASSWORD);
                } else {
                    log.error("Task coordination is not configured for tenant : " + tenantDomain + ". Dropping Exit Coordination message. Affected Tasks ids : " + message.getTaskIDs());
                    return;
                }
            } catch (RegistryException e) {
                log.warn("Error while accessing Registry Service for tenant : " + tenantDomain + ". Dropping Exit Coordination message. Affected Tasks ids : " + message.getTaskIDs(), e);
                return;
            }
            CarbonUtils.setBasicAccessSecurityHeaders(username, password, serviceClient);
        }
        serviceClient.fireAndForget(payload);
        if (log.isDebugEnabled()) {
            log.debug("Sent exit protocol message to " + message.getTaskProtocolHandlerURL());
        }
    } catch (AxisFault axisFault) {
        log.error("Error occurred while invoking HT Protocol Handler " + message.getTaskProtocolHandlerURL() + ". Affected Tasks ids : " + message.getTaskIDs(), axisFault);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) Options(org.apache.axis2.client.Options) ServiceClient(org.apache.axis2.client.ServiceClient) Resource(org.wso2.carbon.registry.core.Resource) UserRegistry(org.wso2.carbon.registry.core.session.UserRegistry) OMElement(org.apache.axiom.om.OMElement) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Aggregations

HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)41 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)35 HumanTaskIllegalAccessException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)28 HumanTaskIllegalArgumentException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException)28 HumanTaskIllegalStateException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException)28 UserStoreException (org.wso2.carbon.user.core.UserStoreException)28 TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)27 HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)27 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)25 BaseTaskService (org.wso2.carbon.bpmn.rest.service.base.BaseTaskService)25 HumanTaskIllegalOperationException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException)25 ArrayList (java.util.ArrayList)14 RestVariable (org.wso2.carbon.bpmn.rest.engine.variable.RestVariable)13 Element (org.w3c.dom.Element)12 QName (javax.xml.namespace.QName)11 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)11 IOException (java.io.IOException)9 HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)9 AxisFault (org.apache.axis2.AxisFault)8 HumanTaskDeploymentException (org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)8