Search in sources :

Example 21 with Parameter

use of org.wso2.carbon.apimgt.api.doc.model.Parameter in project wso2-synapse by wso2.

the class VFSTransportListenerTest method testVFSTransportListenerBasics.

/**
 * Testcase to test basic functionality of {@link VFSTransportListener}
 * @throws Exception
 */
public void testVFSTransportListenerBasics() throws Exception {
    MockFileHolder.getInstance().clear();
    String fileUri = "test1:///foo/bar/test-" + System.currentTimeMillis() + "/DIR/IN/";
    String moveAfterFailure = "test1:///foo/bar/test-" + System.currentTimeMillis() + "/DIR/FAIL/";
    AxisService axisService = new AxisService("testVFSService");
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_FILE_URI, fileUri));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_CONTENT_TYPE, "text/xml"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_FILE_NAME_PATTERN, ".*\\.txt"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_ACTION_AFTER_PROCESS, VFSTransportListener.MOVE));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_ACTION_AFTER_FAILURE, VFSTransportListener.MOVE));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_MOVE_AFTER_FAILURE, moveAfterFailure));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_MOVE_AFTER_FAILED_MOVE, moveAfterFailure));
    axisService.addParameter(new Parameter(VFSConstants.STREAMING, "false"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_LOCKING, VFSConstants.TRANSPORT_FILE_LOCKING_ENABLED));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_INTERVAL, "1000"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_COUNT, "1"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE, "true"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE_INTERVAL, "20000"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE_SAME_NODE, "true"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_DISTRIBUTED_LOCK, "true"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_DISTRIBUTED_LOCK_TIMEOUT, "20000"));
    axisService.addParameter(new Parameter(VFSConstants.FILE_SORT_PARAM, VFSConstants.FILE_SORT_VALUE_NAME));
    axisService.addParameter(new Parameter(VFSConstants.FILE_SORT_ORDER, "true"));
    TransportDescriptionFactory transportDescriptionFactory = new VFSTransportDescriptionFactory();
    TransportInDescription transportInDescription = null;
    try {
        transportInDescription = transportDescriptionFactory.createTransportInDescription();
    } catch (Exception e) {
        Assert.fail("Error occurred while creating transport in description");
    }
    VFSTransportListener vfsTransportListener = getListener(transportInDescription);
    // initialize listener
    vfsTransportListener.init(new ConfigurationContext(new AxisConfiguration()), transportInDescription);
    // Initialize VFSTransportListener
    vfsTransportListener.doInit();
    // Start listener
    vfsTransportListener.start();
    // Create poll entry
    PollTableEntry pollTableEntry = vfsTransportListener.createEndpoint();
    Assert.assertTrue("Global file locking not applied to created poll entry", pollTableEntry.isFileLockingEnabled());
    // Load configuration of poll entry
    pollTableEntry.loadConfiguration(axisService);
    populatePollTableEntry(pollTableEntry, axisService, vfsTransportListener);
    vfsTransportListener.poll(pollTableEntry);
    MockFile targetDir = MockFileHolder.getInstance().getFile(fileUri);
    Assert.assertNotNull("Failed target directory creation", targetDir);
    Assert.assertEquals("Created target directory is not Folder type", targetDir.getName().getType(), FileType.FOLDER);
    MockFile failDir = MockFileHolder.getInstance().getFile(moveAfterFailure);
    Assert.assertNotNull("Fail to create expected directory to move files when failure", failDir);
    MockFileHolder.getInstance().clear();
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) MockFile(org.wso2.carbon.inbound.endpoint.protocol.file.MockFile) AxisService(org.apache.axis2.description.AxisService) Parameter(org.apache.axis2.description.Parameter) TransportInDescription(org.apache.axis2.description.TransportInDescription) TransportDescriptionFactory(org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory)

Example 22 with Parameter

use of org.wso2.carbon.apimgt.api.doc.model.Parameter in project ballerina by ballerina-lang.

the class SignatureHelpUtil method getSignatureInformation.

/**
 * Get the signature information for the given Ballerina function.
 *
 * @param bInvokableSymbol BLang Invokable symbol
 * @param signatureContext Signature operation context
 * @return {@link SignatureInformation}     Signature information for the function
 */
private static SignatureInformation getSignatureInformation(BInvokableSymbol bInvokableSymbol, TextDocumentServiceContext signatureContext) {
    List<ParameterInformation> parameterInformationList = new ArrayList<>();
    SignatureInformation signatureInformation = new SignatureInformation();
    SignatureInfoModel signatureInfoModel = getSignatureInfoModel(bInvokableSymbol, signatureContext);
    String functionName = bInvokableSymbol.getName().getValue();
    // Join the function parameters to generate the function's signature
    String paramsJoined = signatureInfoModel.getParameterInfoModels().stream().map(parameterInfoModel -> {
        // For each of the parameters, create a parameter info instance
        ParameterInformation parameterInformation = new ParameterInformation(parameterInfoModel.paramValue, parameterInfoModel.description);
        parameterInformationList.add(parameterInformation);
        return parameterInfoModel.toString();
    }).collect(Collectors.joining(", "));
    signatureInformation.setLabel(functionName + "(" + paramsJoined + ")");
    signatureInformation.setParameters(parameterInformationList);
    signatureInformation.setDocumentation(signatureInfoModel.signatureDescription);
    return signatureInformation;
}
Also used : Arrays(java.util.Arrays) HashMap(java.util.HashMap) BLangRecordLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral) Stack(java.util.Stack) ArrayList(java.util.ArrayList) DocTag(org.ballerinalang.model.elements.DocTag) SymbolInfo(org.ballerinalang.langserver.completions.SymbolInfo) Map(java.util.Map) Position(org.eclipse.lsp4j.Position) BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol) DocumentServiceKeys(org.ballerinalang.langserver.DocumentServiceKeys) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef) TextDocumentServiceContext(org.ballerinalang.langserver.TextDocumentServiceContext) ParameterInformation(org.eclipse.lsp4j.ParameterInformation) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression) BLangDocumentation(org.wso2.ballerinalang.compiler.tree.BLangDocumentation) BLangFunction(org.wso2.ballerinalang.compiler.tree.BLangFunction) SignatureInformation(org.eclipse.lsp4j.SignatureInformation) Collectors(java.util.stream.Collectors) SignatureHelp(org.eclipse.lsp4j.SignatureHelp) Objects(java.util.Objects) List(java.util.List) BLangLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral) UtilSymbolKeys(org.ballerinalang.langserver.common.UtilSymbolKeys) CompilerContext(org.wso2.ballerinalang.compiler.util.CompilerContext) SignatureInformation(org.eclipse.lsp4j.SignatureInformation) ArrayList(java.util.ArrayList) ParameterInformation(org.eclipse.lsp4j.ParameterInformation)

Example 23 with Parameter

use of org.wso2.carbon.apimgt.api.doc.model.Parameter in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method fillPartnerLinks.

// private java.lang.String[] getServiceLocationForProcess(QName processId)
// throws ProcessManagementException {
// AxisConfiguration axisConf = getConfigContext().getAxisConfiguration();
// Map<String, AxisService> services = axisConf.getServices();
// ArrayList<String> serviceEPRs = new ArrayList<String>();
// 
// for (AxisService service : services.values()) {
// Parameter pIdParam = service.getParameter(BPELConstants.PROCESS_ID);
// if (pIdParam != null) {
// if (pIdParam.getValue().equals(processId)) {
// serviceEPRs.addAll(Arrays.asList(service.getEPRs()));
// }
// }
// }
// 
// if (serviceEPRs.size() > 0) {
// return serviceEPRs.toArray(new String[serviceEPRs.size()]);
// }
// 
// String errMsg = "Cannot find service for process: " + processId;
// log.error(errMsg);
// throw new ProcessManagementException(errMsg);
// }
private void fillPartnerLinks(ProcessInfoType pInfo, TDeployment.Process processInfo) throws ProcessManagementException {
    if (processInfo.getProvideList() != null) {
        EndpointReferencesType eprsType = new EndpointReferencesType();
        for (TProvide provide : processInfo.getProvideList()) {
            String plinkName = provide.getPartnerLink();
            TService service = provide.getService();
            /* NOTE:Service cannot be null for provider partner link*/
            if (service == null) {
                String errorMsg = "Error in <provide> element for process " + processInfo.getName() + " partnerlink" + plinkName + " did not identify an endpoint";
                log.error(errorMsg);
                throw new ProcessManagementException(errorMsg);
            }
            if (log.isDebugEnabled()) {
                log.debug("Processing <provide> element for process " + processInfo.getName() + ": partnerlink " + plinkName + " --> " + service.getName() + " : " + service.getPort());
            }
            QName serviceName = service.getName();
            EndpointRef_type0 eprType = new EndpointRef_type0();
            eprType.setPartnerLink(plinkName);
            eprType.setService(serviceName);
            ServiceLocation sLocation = new ServiceLocation();
            try {
                String url = Utils.getTryitURL(serviceName.getLocalPart(), getConfigContext());
                sLocation.addServiceLocation(url);
                String[] wsdls = Utils.getWsdlInformation(serviceName.getLocalPart(), getConfigContext().getAxisConfiguration());
                if (wsdls.length == 2) {
                    if (wsdls[0].endsWith("?wsdl")) {
                        sLocation.addServiceLocation(wsdls[0]);
                    } else {
                        sLocation.addServiceLocation(wsdls[1]);
                    }
                }
            } catch (AxisFault axisFault) {
                String errMsg = "Error while getting try-it url for the service: " + serviceName;
                log.error(errMsg, axisFault);
                throw new ProcessManagementException(errMsg, axisFault);
            }
            eprType.setServiceLocations(sLocation);
            eprsType.addEndpointRef(eprType);
        }
        pInfo.setEndpoints(eprsType);
    }
// if (processInfo.getInvokeList() != null) {
// for (TInvoke invoke : processInfo.getInvokeList()) {
// String plinkName = invoke.getPartnerLink();
// TService service = invoke.getService();
// /* NOTE:Service can be null for partner links*/
// if (service == null) {
// continue;
// }
// if (log.isDebugEnabled()) {
// log.debug("Processing <invoke> element for process " + processInfo.getName() + ": partnerlink" +
// plinkName + " -->" + service);
// }
// 
// QName serviceName = service.getName();
// }
// }
}
Also used : AxisFault(org.apache.axis2.AxisFault) QName(javax.xml.namespace.QName) ServiceLocation(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ServiceLocation) EndpointReferencesType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EndpointReferencesType) EndpointRef_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EndpointRef_type0) TProvide(org.apache.ode.bpel.dd.TProvide) TService(org.apache.ode.bpel.dd.TService) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException)

Example 24 with Parameter

use of org.wso2.carbon.apimgt.api.doc.model.Parameter 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 25 with Parameter

use of org.wso2.carbon.apimgt.api.doc.model.Parameter in project carbon-business-process by wso2.

the class ActivitiDAO method querySubstituteInfo.

/**
 * Return the list of substitute info based on query parameters.
 * @param model model with only required query parameter values. Leave others as null. By default enabled=false.
 * @return List<SubstitutesDataModel> Result set of substitute info
 */
public List<SubstitutesDataModel> querySubstituteInfo(final PaginatedSubstitutesDataModel model) {
    final RowBounds rw = new RowBounds(model.getStart(), model.getSize());
    CustomSqlExecution<SubstitutesMapper, List<SubstitutesDataModel>> customSqlExecution = new AbstractCustomSqlExecution<SubstitutesMapper, List<SubstitutesDataModel>>(SubstitutesMapper.class) {

        public List<SubstitutesDataModel> execute(SubstitutesMapper substitutesMapper) {
            return substitutesMapper.querySubstitutes(rw, model);
        }
    };
    return managementService.executeCustomSql(customSqlExecution);
}
Also used : PaginatedSubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel) SubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.SubstitutesDataModel) AbstractCustomSqlExecution(org.activiti.engine.impl.cmd.AbstractCustomSqlExecution) RowBounds(org.apache.ibatis.session.RowBounds) List(java.util.List) SubstitutesMapper(org.wso2.carbon.bpmn.core.internal.mapper.SubstitutesMapper)

Aggregations

HashMap (java.util.HashMap)35 ArrayList (java.util.ArrayList)32 Parameter (org.apache.axis2.description.Parameter)14 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)14 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)13 JSONDecoder (org.wso2.charon3.core.encoder.JSONDecoder)11 BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)11 CharonException (org.wso2.charon3.core.exceptions.CharonException)11 InternalErrorException (org.wso2.charon3.core.exceptions.InternalErrorException)11 NotFoundException (org.wso2.charon3.core.exceptions.NotFoundException)11 SCIMResponse (org.wso2.charon3.core.protocol.SCIMResponse)11 SCIMResourceTypeSchema (org.wso2.charon3.core.schema.SCIMResourceTypeSchema)11 List (java.util.List)10 Map (java.util.Map)10 ConstantExpressionExecutor (org.wso2.siddhi.core.executor.ConstantExpressionExecutor)9 IOException (java.io.IOException)8 PreparedStatement (java.sql.PreparedStatement)8 ResultSet (java.sql.ResultSet)8 Test (org.testng.annotations.Test)8 BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)8