use of org.wso2.transport.http.netty.config.Parameter in project carbon-apimgt by wso2.
the class DynamicHtmlGenTestCase method testFromParameter.
@Test
public void testFromParameter() throws Exception {
Parameter parameter = new QueryParameter();
parameter.setName("query");
final String description = "Sample parameter description";
parameter.setDescription(description);
DynamicHtmlGen htmlGen = new DynamicHtmlGen();
CodegenParameter modified = htmlGen.fromParameter(parameter, new HashSet<>());
Assert.assertEquals(modified.description, description);
}
use of org.wso2.transport.http.netty.config.Parameter in project wso2-synapse by wso2.
the class VFSTransportListener method generateSecureVaultProperties.
/**
* Helper method to generate securevault properties from given transport configuration.
*
* @param inDescription
* @return properties
*/
private Properties generateSecureVaultProperties(TransportInDescription inDescription) {
Properties properties = new Properties();
SecretResolver secretResolver = getConfigurationContext().getAxisConfiguration().getSecretResolver();
for (Parameter parameter : inDescription.getParameters()) {
String propertyValue = parameter.getValue().toString();
OMElement paramElement = parameter.getParameterElement();
if (paramElement != null) {
OMAttribute attribute = paramElement.getAttribute(new QName(CryptoConstants.SECUREVAULT_NAMESPACE, CryptoConstants.SECUREVAULT_ALIAS_ATTRIBUTE));
if (attribute != null && attribute.getAttributeValue() != null && !attribute.getAttributeValue().isEmpty()) {
if (secretResolver == null) {
throw new SecureVaultException("Cannot resolve secret password because axis2 secret resolver " + "is null");
}
if (secretResolver.isTokenProtected(attribute.getAttributeValue())) {
propertyValue = secretResolver.resolve(attribute.getAttributeValue());
}
}
}
properties.setProperty(parameter.getName().toString(), propertyValue);
}
return properties;
}
use of org.wso2.transport.http.netty.config.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();
}
use of org.wso2.transport.http.netty.config.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;
}
use of org.wso2.transport.http.netty.config.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();
// }
// }
}
Aggregations