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");
}
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));
}
}
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);
}
}
}
}
}
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);
}
}
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);
}
}
Aggregations