Search in sources :

Example 46 with Operation

use of org.wso2.ballerinalang.compiler.semantics.model.iterable.Operation in project carbon-business-process by wso2.

the class BPELServerConfiguration method populateDataSourceConfigFields.

private void populateDataSourceConfigFields() {
    TDataBaseConfig databaseConfig = bpsConfigDocument.getWSO2BPS().getDataBaseConfig();
    if (databaseConfig != null) {
        // Now we do not have concept called EMBEDDED. All the DBs are configured as EXTERNAL.
        // This way users can modify the default db config as well. And also support the
        // -Dsetup
        dsType = DataSourceType.EXTERNAL;
        if (databaseConfig.getDataSource().getName() != null && databaseConfig.getDataSource().getName().length() > 0) {
            dataSourceName = databaseConfig.getDataSource().getName();
        } else {
            throw new RuntimeException("Data Source name cannot be null, " + "when data source mode is external.");
        }
        if (databaseConfig.getDataSource().isSetJNDI()) {
            TDataBaseConfig.DataSource.JNDI jndiConfig = databaseConfig.getDataSource().getJNDI();
            if (jndiConfig.getContextFactory() != null && jndiConfig.getContextFactory().length() > 0 && jndiConfig.getProviderURL() != null && jndiConfig.getProviderURL().length() > 0) {
                dataSourceJNDIRepoInitialContextFactory = jndiConfig.getContextFactory().trim();
                dataSourceJNDIRepoProviderURL = jndiConfig.getProviderURL().trim();
                // Read Port Offset
                int portOffset = readPortOffset();
                // applying port offset operation
                String urlWithoutPort = dataSourceJNDIRepoProviderURL.substring(0, dataSourceJNDIRepoProviderURL.lastIndexOf(':') + 1);
                int dataSourceJNDIRepoProviderPort = Integer.parseInt(dataSourceJNDIRepoProviderURL.substring(urlWithoutPort.length())) + portOffset;
                dataSourceJNDIRepoProviderURL = urlWithoutPort + dataSourceJNDIRepoProviderPort;
            }
        }
    }
}
Also used : TDataBaseConfig(org.wso2.carbon.bpel.config.TDataBaseConfig)

Example 47 with Operation

use of org.wso2.ballerinalang.compiler.semantics.model.iterable.Operation in project carbon-business-process by wso2.

the class HumanTaskStore method createAxisService.

// Creates the AxisService object from the provided ServiceBuilder object.
private AxisService createAxisService(WSDL11ToAxisServiceBuilder serviceBuilder, HumanTaskBaseConfiguration config) throws AxisFault {
    AxisService axisService;
    axisService = serviceBuilder.populateService();
    axisService.setParent(getTenantAxisConfig());
    axisService.setWsdlFound(true);
    axisService.setCustomWsdl(true);
    // axisService.setFileName(new URL(taskConfig.getWsdlDefLocation()));
    axisService.setClassLoader(getTenantAxisConfig().getServiceClassLoader());
    Utils.setEndpointsToAllUsedBindings(axisService);
    axisService.addParameter(new Parameter("modifyUserWSDLPortAddress", "true"));
    /* Setting service type to use in service management*/
    axisService.addParameter(ServerConstants.SERVICE_TYPE, "humantask");
    /* Fix for losing of security configuration  when updating human-task package*/
    axisService.addParameter(new Parameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, "true"));
    Iterator operations = axisService.getOperations();
    AxisHumanTaskMessageReceiver msgReceiver = new AxisHumanTaskMessageReceiver();
    msgReceiver.setHumanTaskEngine(HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine());
    // Setting the task configuration to the message receiver. Hence no need to search for task configuration, when
    // the actual task invocation happens, we will already have the task configuration attached to the message receiver
    // itself
    msgReceiver.setTaskBaseConfiguration(config);
    while (operations.hasNext()) {
        AxisOperation operation = (AxisOperation) operations.next();
        // Setting Message Receiver even if operation has a message receiver specified.
        // This is to fix the issue when build service configuration using services.xml(Always RPCMessageReceiver
        // is set to operations).
        operation.setMessageReceiver(msgReceiver);
        getTenantAxisConfig().getPhasesInfo().setOperationPhases(operation);
    }
    Set<String> exposedTransports = getTenantAxisConfig().getTransportsIn().keySet();
    // Add the transports to axis2 service by reading from the tenant transport config
    for (String transport : exposedTransports) {
        axisService.addExposedTransport(transport);
    }
    if (HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().isHtCoordinationEnabled() && HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().isTaskRegistrationEnabled() && config.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.TASK) {
        // Only Engage coordination module in-case of Tasks. Coordination module is not required for notifications
        axisService.engageModule(getConfigContext().getAxisConfiguration().getModule("htcoordination"));
    }
    return axisService;
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) AxisService(org.apache.axis2.description.AxisService) Iterator(java.util.Iterator) Parameter(org.apache.axis2.description.Parameter) AxisHumanTaskMessageReceiver(org.wso2.carbon.humantask.core.integration.AxisHumanTaskMessageReceiver)

Example 48 with Operation

use of org.wso2.ballerinalang.compiler.semantics.model.iterable.Operation in project carbon-business-process by wso2.

the class HumanTaskPackageManagementSkeleton method listTasksInPackage.

/**
 * Lists the tasks in the given package name.
 *
 * @param packageName : The name of the package to list task definitions.
 * @return : The Task_type0 array containing the task definition information.
 */
public Task_type0[] listTasksInPackage(String packageName) throws PackageManagementException {
    if (StringUtils.isEmpty(packageName)) {
        throw new IllegalArgumentException("The provided package name is empty!");
    }
    try {
        List<SimpleTaskDefinitionInfo> taskDefsInPackage = getTenantTaskStore().getTaskConfigurationInfoListForPackage(packageName);
        Task_type0[] taskDefArray = new Task_type0[taskDefsInPackage.size()];
        int i = 0;
        for (SimpleTaskDefinitionInfo taskDefinitionInfo : taskDefsInPackage) {
            taskDefArray[i] = createTaskTypeObject(taskDefinitionInfo);
            i++;
        }
        return taskDefArray;
    } catch (Exception ex) {
        String errMsg = "listTasksInPackage operation failed";
        log.error(errMsg, ex);
        throw new PackageManagementException(errMsg, ex);
    }
}
Also used : SimpleTaskDefinitionInfo(org.wso2.carbon.humantask.core.deployment.SimpleTaskDefinitionInfo) PackageManagementException(org.wso2.carbon.humantask.skeleton.mgt.services.PackageManagementException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) PackageManagementException(org.wso2.carbon.humantask.skeleton.mgt.services.PackageManagementException)

Example 49 with Operation

use of org.wso2.ballerinalang.compiler.semantics.model.iterable.Operation in project carbon-business-process by wso2.

the class CallBackServiceImpl method sendProtocolMessage.

private void sendProtocolMessage(long taskID, String headerValue, String value) throws AxisFault {
    final MessageContext mctx = new MessageContext();
    ServiceInvocationContext invocationContext = new ServiceInvocationContext();
    invocationContext.setInMessageContext(mctx);
    invocationContext.setUep(uep);
    invocationContext.setService(serviceName);
    invocationContext.setPort(portName);
    invocationContext.setCaller(taskName.getLocalPart());
    invocationContext.setWsdlBindingForCurrentMessageFlow(binding);
    invocationContext.setOperationName(operation);
    if (mctx.getEnvelope() == null) {
        mctx.setEnvelope(getSoapFactory().createSOAPEnvelope());
    }
    if (mctx.getEnvelope().getBody() == null) {
        getSoapFactory().createSOAPBody(mctx.getEnvelope());
    }
    if (mctx.getEnvelope().getHeader() == null) {
        getSoapFactory().createSOAPHeader(mctx.getEnvelope());
    }
    // Creating Dummy Element
    // Extracting MessageName
    List bindingOperations = binding.getBindingOperations();
    String messageName = "";
    OMNamespace serviceNS = null;
    BindingOperation oper;
    for (int i = 0; i < bindingOperations.size(); i++) {
        oper = (BindingOperation) bindingOperations.get(i);
        if (operation.equals(oper.getName())) {
            Message message = oper.getOperation().getInput().getMessage();
            messageName = message.getQName().getLocalPart();
            for (Object ob : message.getParts().keySet()) {
                // Here we don't support RPC messages.
                Part part = (Part) message.getParts().get(ob);
                serviceNS = OMAbstractFactory.getSOAP11Factory().createOMNamespace(part.getElementName().getNamespaceURI(), part.getElementName().getPrefix());
                break;
            }
            break;
        }
    }
    OMElement payload = OMAbstractFactory.getOMFactory().createOMElement(messageName, serviceNS);
    mctx.getEnvelope().getBody().addChild(payload);
    OMNamespace htpNS = OMAbstractFactory.getSOAP11Factory().createOMNamespace(HumanTaskConstants.HT_PROTOCOL_NAMESPACE, HumanTaskConstants.HT_PROTOCOL_DEFAULT_PREFIX);
    SOAPHeaderBlock protocolHeader = mctx.getEnvelope().getHeader().addHeaderBlock(headerValue, htpNS);
    protocolHeader.setText(value);
    protocolHeader.addAttribute(HumanTaskConstants.B4P_CORRELATION_HEADER_ATTRIBUTE, Long.toString(taskID), htpNS);
    OMNamespace b4pNS = OMAbstractFactory.getSOAP11Factory().createOMNamespace(HumanTaskConstants.B4P_NAMESPACE, "b4p");
    SOAPHeaderBlock header = mctx.getEnvelope().getHeader().addHeaderBlock(HumanTaskConstants.B4P_CORRELATION_HEADER, b4pNS);
    header.addAttribute(HumanTaskConstants.B4P_CORRELATION_HEADER_ATTRIBUTE, Long.toString(taskID), b4pNS);
    AxisServiceUtils.invokeService(invocationContext, HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantId).getConfigContext());
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) List(java.util.List) OMElement(org.apache.axiom.om.OMElement) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) MessageContext(org.apache.axis2.context.MessageContext) ServiceInvocationContext(org.wso2.carbon.humantask.core.integration.utils.ServiceInvocationContext) UnifiedEndpoint(org.wso2.carbon.unifiedendpoint.core.UnifiedEndpoint)

Example 50 with Operation

use of org.wso2.ballerinalang.compiler.semantics.model.iterable.Operation in project carbon-business-process by wso2.

the class CallBackServiceImpl method invoke.

@Override
public void invoke(OMElement payload, long taskId) throws AxisFault {
    final MessageContext mctx = new MessageContext();
    ServiceInvocationContext invocationContext = new ServiceInvocationContext();
    invocationContext.setInMessageContext(mctx);
    invocationContext.setUep(uep);
    invocationContext.setService(serviceName);
    invocationContext.setPort(portName);
    invocationContext.setCaller(taskName.getLocalPart());
    invocationContext.setWsdlBindingForCurrentMessageFlow(binding);
    invocationContext.setOperationName(operation);
    if (mctx.getEnvelope() == null) {
        mctx.setEnvelope(getSoapFactory().createSOAPEnvelope());
    }
    if (mctx.getEnvelope().getBody() == null) {
        getSoapFactory().createSOAPBody(mctx.getEnvelope());
    }
    if (mctx.getEnvelope().getHeader() == null) {
        getSoapFactory().createSOAPHeader(mctx.getEnvelope());
    }
    mctx.getEnvelope().getBody().addChild(payload);
    OMNamespace ns = OMAbstractFactory.getSOAP11Factory().createOMNamespace(HumanTaskConstants.B4P_NAMESPACE, "b4p");
    SOAPHeaderBlock header = mctx.getEnvelope().getHeader().addHeaderBlock(HumanTaskConstants.B4P_CORRELATION_HEADER, ns);
    header.addAttribute(HumanTaskConstants.B4P_CORRELATION_HEADER_ATTRIBUTE, Long.toString(taskId), ns);
    AxisServiceUtils.invokeService(invocationContext, HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantId).getConfigContext());
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) MessageContext(org.apache.axis2.context.MessageContext) ServiceInvocationContext(org.wso2.carbon.humantask.core.integration.utils.ServiceInvocationContext)

Aggregations

Test (org.testng.annotations.Test)34 HttpResponse (org.wso2.carbon.automation.test.utils.http.client.HttpResponse)29 HashMap (java.util.HashMap)19 ArrayList (java.util.ArrayList)16 BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)15 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)12 QueryVariable (org.wso2.carbon.bpmn.rest.engine.variable.QueryVariable)11 List (java.util.List)10 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)10 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)9 Map (java.util.Map)8 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)8 Operation (io.swagger.models.Operation)7 Attribute (org.wso2.charon3.core.attributes.Attribute)7 ComplexAttribute (org.wso2.charon3.core.attributes.ComplexAttribute)7 MultiValuedAttribute (org.wso2.charon3.core.attributes.MultiValuedAttribute)7 SimpleAttribute (org.wso2.charon3.core.attributes.SimpleAttribute)7 Operation (org.wso2.ballerinalang.compiler.semantics.model.iterable.Operation)6 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)6 AttributeSchema (org.wso2.charon3.core.schema.AttributeSchema)6