use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class EtagHandlerPipe method configure.
@Override
public void configure() throws ConfigurationException {
super.configure();
String action = getAction();
if (action == null) {
throw new ConfigurationException(getLogPrefix(null) + "action must be set");
}
if (!actions.contains(action)) {
throw new ConfigurationException(getLogPrefix(null) + "illegal value for action [" + action + "], must be one of " + actions.toString());
}
boolean hasUriPatternParameter = false;
ParameterList parameterList = getParameterList();
for (int i = 0; i < parameterList.size(); i++) {
Parameter parameter = parameterList.getParameter(i);
if ("uriPattern".equalsIgnoreCase(parameter.getName()))
hasUriPatternParameter = true;
}
if (getUriPattern() == null && !hasUriPatternParameter) {
throw new ConfigurationException(getLogPrefix(null) + "no uriPattern found!");
}
cache = ApiCacheManager.getInstance();
}
use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class StreamPipeTest method createHttpRequestParameter.
private Parameter createHttpRequestParameter(MockMultipartHttpServletRequest request, IPipeLineSession session) {
session.put("httpRequest", request);
Parameter parameter = new Parameter();
parameter.setName("httpRequest");
parameter.setSessionKey("httpRequest");
return parameter;
}
use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class IfsaSimulatorJmsSender method configure.
public void configure() throws ConfigurationException {
if (!getMessageType().equalsIgnoreCase(RR_REQUEST) && !getMessageType().equalsIgnoreCase(RR_REPLY) && !getMessageType().equalsIgnoreCase(FF_REQUEST)) {
throw new ConfigurationException(getLogPrefix() + "illegal value for messageType [" + getMessageType() + "], must be '" + RR_REQUEST + "', '" + RR_REPLY + "'" + "' or '" + FF_REQUEST + "'");
}
Parameter p = new Parameter();
p.setName("ifsa");
p.setValue("_IFSA_HEADER_");
addParameter(p);
p = new Parameter();
p.setName("ifsa_api");
p.setValue("jms_wrapper");
addParameter(p);
p = new Parameter();
p.setName("ifsa_api_version");
p.setValue("22.30.020");
addParameter(p);
p = new Parameter();
p.setName("ifsa_auth_flag");
p.setValue("1");
addParameter(p);
p = new Parameter();
p.setName("ifsa_bif_id");
if (getMessageType().equalsIgnoreCase(RR_REQUEST)) {
String iad = AppConstants.getInstance().getProperty("IFSAApplicationID", "");
p.setPattern(iad + "#{ifsa_destination}#{uid}");
} else if (getMessageType().equalsIgnoreCase(RR_REPLY)) {
p.setSessionKey("ifsa_bif_id");
} else if (getMessageType().equalsIgnoreCase(FF_REQUEST)) {
String iad = AppConstants.getInstance().getProperty("IFSAApplicationID", "");
p.setPattern(iad + "#{ifsa_destination}#{uid}");
}
addParameter(p);
p = new Parameter();
p.setName("ifsa_bif_type");
if (getMessageType().equalsIgnoreCase(RR_REQUEST)) {
p.setValue("0");
} else if (getMessageType().equalsIgnoreCase(RR_REPLY)) {
p.setValue("0");
} else if (getMessageType().equalsIgnoreCase(FF_REQUEST)) {
p.setValue("2");
}
addParameter(p);
p = new Parameter();
p.setName("ifsa_bulk");
p.setValue("0");
addParameter(p);
p = new Parameter();
p.setName("ifsa_bulk_auth_flag");
p.setValue("0");
addParameter(p);
p = new Parameter();
p.setName("ifsa_cil_version");
p.setValue("22.30.009");
addParameter(p);
p = new Parameter();
p.setName("ifsa_comp_algo");
p.setDefaultValue("");
p.setSessionKey("null");
addParameter(p);
if (getMessageType().equalsIgnoreCase(RR_REQUEST)) {
// overruled in IBIS configuration
} else if (getMessageType().equalsIgnoreCase(RR_REPLY)) {
p = new Parameter();
p.setName("ifsa_destination");
p.setSessionKey("ifsa_source");
addParameter(p);
} else if (getMessageType().equalsIgnoreCase(FF_REQUEST)) {
// overruled in IBIS configuration
}
p = new Parameter();
p.setName("ifsa_expiry");
if (getMessageType().equalsIgnoreCase(RR_REQUEST)) {
p.setValue(AppConstants.getInstance().getProperty("timeOutIFSARR", ""));
} else if (getMessageType().equalsIgnoreCase(RR_REPLY)) {
p.setValue(AppConstants.getInstance().getProperty("timeOutIFSARR", ""));
} else if (getMessageType().equalsIgnoreCase(FF_REQUEST)) {
p.setValue("0");
}
addParameter(p);
p = new Parameter();
p.setName("ifsa_header_version");
p.setValue("02.02.000");
addParameter(p);
p = new Parameter();
p.setName("ifsa_hop_count");
p.setValue("000");
addParameter(p);
p = new Parameter();
p.setName("ifsa_node_id");
p.setValue(AppConstants.getInstance().getProperty("ifsa_node_id", ""));
addParameter(p);
p = new Parameter();
p.setName("ifsa_ori_area");
if (getMessageType().equalsIgnoreCase(RR_REQUEST)) {
p.setValue(AppConstants.getInstance().getProperty("ifsa_ori_area", ""));
} else if (getMessageType().equalsIgnoreCase(RR_REPLY)) {
p.setValue(AppConstants.getInstance().getProperty("ifsa_ori_area", ""));
} else if (getMessageType().equalsIgnoreCase(FF_REQUEST)) {
p.setDefaultValue("");
p.setSessionKey("null");
}
p.setMinLength(60);
addParameter(p);
p = new Parameter();
p.setName("ifsa_ori_format");
p.setDefaultValue("");
p.setSessionKey("null");
addParameter(p);
p = new Parameter();
p.setName("ifsa_ori_length");
p.setDefaultValue("");
p.setSessionKey("null");
addParameter(p);
p = new Parameter();
p.setName("ifsa_ori_rtq");
if (getMessageType().equalsIgnoreCase(RR_REQUEST)) {
p.setValue(AppConstants.getInstance().getProperty("ifsa_ori_rtq", ""));
} else if (getMessageType().equalsIgnoreCase(RR_REPLY)) {
p.setDefaultValue("");
p.setSessionKey("null");
} else if (getMessageType().equalsIgnoreCase(FF_REQUEST)) {
p.setDefaultValue("");
p.setSessionKey("null");
}
p.setMinLength(48);
addParameter(p);
p = new Parameter();
p.setName("ifsa_ori_rtqm");
if (getMessageType().equalsIgnoreCase(RR_REQUEST)) {
p.setValue(AppConstants.getInstance().getProperty("ifsa_ori_rtqm", ""));
} else if (getMessageType().equalsIgnoreCase(RR_REPLY)) {
p.setDefaultValue("");
p.setSessionKey("null");
} else if (getMessageType().equalsIgnoreCase(FF_REQUEST)) {
p.setDefaultValue("");
p.setSessionKey("null");
}
p.setMinLength(48);
addParameter(p);
p = new Parameter();
p.setName("ifsa_priority");
if (getMessageType().equalsIgnoreCase(RR_REQUEST)) {
p.setValue("3");
} else if (getMessageType().equalsIgnoreCase(RR_REPLY)) {
p.setValue("3");
} else if (getMessageType().equalsIgnoreCase(FF_REQUEST)) {
p.setValue("2");
}
addParameter(p);
p = new Parameter();
p.setName("ifsa_source");
if (getMessageType().equalsIgnoreCase(RR_REQUEST)) {
p.setValue(AppConstants.getInstance().getProperty("IFSAApplicationID", ""));
} else if (getMessageType().equalsIgnoreCase(RR_REPLY)) {
String iad = AppConstants.getInstance().getProperty("IFSAApplicationID", "");
p.setPattern(iad + "#{ifsa_destination}");
} else if (getMessageType().equalsIgnoreCase(FF_REQUEST)) {
p.setValue(AppConstants.getInstance().getProperty("IFSAApplicationID", ""));
}
addParameter(p);
p = new Parameter();
p.setName("ifsa_unique_id");
p.setPattern("{uid}");
addParameter(p);
p = new Parameter();
p.setName("JMS_IBM_MsgType");
if (getMessageType().equalsIgnoreCase(RR_REQUEST)) {
p.setValue("1");
} else if (getMessageType().equalsIgnoreCase(RR_REPLY)) {
p.setValue("2");
} else if (getMessageType().equalsIgnoreCase(FF_REQUEST)) {
p.setValue("8");
}
p.setType(Parameter.TYPE_INTEGER);
addParameter(p);
if (getMessageType().equalsIgnoreCase(RR_REPLY) && getDestinationName() == null) {
if (paramList != null) {
paramList.configure();
}
} else {
super.configure();
}
}
use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class DirectWrapperPipe method doPipeWithTimeoutGuarded.
public String doPipeWithTimeoutGuarded(Object input, IPipeLineSession session) throws PipeRunException {
String result;
ParameterValueList pvl = null;
if (getParameterList() != null) {
ParameterResolutionContext prc = new ParameterResolutionContext((String) input, session);
try {
pvl = prc.getValues(getParameterList());
} catch (ParameterException e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception extracting parameters", e);
}
}
String destination = getParameterValue(pvl, DESTINATION);
String cmhVersion = getParameterValue(pvl, CMHVERSION);
String addOutputNamespace = getParameterValue(pvl, ADDOUTPUTNAMESPACE);
EsbSoapWrapperPipe eswPipe = new EsbSoapWrapperPipe();
if (addOutputNamespace != null) {
if ("on".equalsIgnoreCase(addOutputNamespace)) {
eswPipe.setAddOutputNamespace(true);
}
}
if (destination != null) {
Parameter p = new Parameter();
p.setName(DESTINATION);
p.setValue(destination);
eswPipe.addParameter(p);
}
if (cmhVersion != null) {
if (StringUtils.isNumeric(cmhVersion)) {
eswPipe.setCmhVersion(Integer.parseInt(cmhVersion));
}
}
PipeForward pf = new PipeForward();
pf.setName("success");
eswPipe.registerForward(pf);
try {
eswPipe.configure();
PipeRunResult prr = eswPipe.doPipe(input, session);
result = (String) prr.getResult();
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + "Exception on wrapping input", e);
}
return result;
}
use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class TestTool method createParametersMapFromParamProperties.
/**
* Create a Map for a specific property based on other properties that are
* the same except for a .param1.name, .param1.value or .param1.valuefile
* suffix. The property with the .name suffix specifies the key for the
* Map, the property with the value suffix specifies the value for the Map.
* A property with a the .valuefile suffix can be used as an alternative
* for a property with a .value suffix to specify the file to read the
* value for the Map from. More than one param can be specified by using
* param2, param3 etc.
*
* @param propertiesDirectory suffix for filenames specified by properties
* with a .valuefile suffix. Can be left empty.
* @param properties
* @param property
* @param writers
* @return
*/
private static Map createParametersMapFromParamProperties(Properties properties, String property, Map writers, boolean createParameterObjects, ParameterResolutionContext parameterResolutionContext) {
debugMessage("Search parameters for property '" + property + "'", writers);
Map result = new HashMap();
boolean processed = false;
int i = 1;
while (!processed) {
String name = properties.getProperty(property + ".param" + i + ".name");
if (name != null) {
Object value;
String type = properties.getProperty(property + ".param" + i + ".type");
if ("httpResponse".equals(type)) {
String outputFile;
String filename = properties.getProperty(property + ".param" + i + ".filename");
if (filename != null) {
outputFile = properties.getProperty(property + ".param" + i + ".filename.absolutepath");
} else {
outputFile = properties.getProperty(property + ".param" + i + ".outputfile");
}
HttpServletResponseMock httpServletResponseMock = new HttpServletResponseMock();
httpServletResponseMock.setOutputFile(outputFile);
value = httpServletResponseMock;
} else if ("httpRequest".equals(type)) {
value = properties.getProperty(property + ".param" + i + ".value");
if ("multipart".equals(value)) {
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
// following line is required to avoid
// "(FileUploadException) the request was rejected because
// no multipart boundary was found"
request.setContentType("multipart/mixed;boundary=gc0p4Jq0M2Yt08jU534c0p");
List<Part> parts = new ArrayList<Part>();
boolean partsProcessed = false;
int j = 1;
while (!partsProcessed) {
String filename = properties.getProperty(property + ".param" + i + ".part" + j + ".filename");
if (filename == null) {
partsProcessed = true;
} else {
String partFile = properties.getProperty(property + ".param" + i + ".part" + j + ".filename.absolutepath");
String partType = properties.getProperty(property + ".param" + i + ".part" + j + ".type");
String partName = properties.getProperty(property + ".param" + i + ".part" + j + ".name");
if ("file".equalsIgnoreCase(partType)) {
File file = new File(partFile);
try {
FilePart filePart = new FilePart("file" + j, (partName == null ? file.getName() : partName), file);
parts.add(filePart);
} catch (FileNotFoundException e) {
errorMessage("Could not read file '" + partFile + "': " + e.getMessage(), e, writers);
}
} else {
String string = readFile(partFile, writers);
StringPart stringPart = new StringPart((partName == null ? "string" + j : partName), string);
parts.add(stringPart);
}
j++;
}
}
Part[] allParts = new Part[parts.size()];
allParts = parts.toArray(allParts);
MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity(allParts, new PostMethod().getParams());
ByteArrayOutputStream requestContent = new ByteArrayOutputStream();
try {
multipartRequestEntity.writeRequest(requestContent);
} catch (IOException e) {
errorMessage("Could not create multipart: " + e.getMessage(), e, writers);
}
request.setContent(requestContent.toByteArray());
request.setContentType(multipartRequestEntity.getContentType());
value = request;
} else {
MockHttpServletRequest request = new MockHttpServletRequest();
value = request;
}
} else {
value = properties.getProperty(property + ".param" + i + ".value");
if (value == null) {
String filename = properties.getProperty(property + ".param" + i + ".valuefile.absolutepath");
if (filename != null) {
value = readFile(filename, writers);
} else {
String inputStreamFilename = properties.getProperty(property + ".param" + i + ".valuefileinputstream.absolutepath");
if (inputStreamFilename != null) {
try {
value = new FileInputStream(inputStreamFilename);
} catch (FileNotFoundException e) {
errorMessage("Could not read file '" + inputStreamFilename + "': " + e.getMessage(), e, writers);
}
}
}
}
}
if (value != null && value instanceof String) {
if ("node".equals(properties.getProperty(property + ".param" + i + ".type"))) {
try {
value = XmlUtils.buildNode((String) value, true);
} catch (DomBuilderException e) {
errorMessage("Could not build node for parameter '" + name + "' with value: " + value, e, writers);
}
} else if ("domdoc".equals(properties.getProperty(property + ".param" + i + ".type"))) {
try {
value = XmlUtils.buildDomDocument((String) value, true);
} catch (DomBuilderException e) {
errorMessage("Could not build node for parameter '" + name + "' with value: " + value, e, writers);
}
} else if ("list".equals(properties.getProperty(property + ".param" + i + ".type"))) {
List<String> parts = new ArrayList<String>(Arrays.asList(((String) value).split("\\s*(,\\s*)+")));
List list = new LinkedList<String>();
for (String part : parts) {
list.add(part);
}
value = list;
} else if ("map".equals(properties.getProperty(property + ".param" + i + ".type"))) {
List<String> parts = new ArrayList<String>(Arrays.asList(((String) value).split("\\s*(,\\s*)+")));
Map map = new LinkedHashMap<String, String>();
for (String part : parts) {
String[] splitted = part.split("\\s*(=\\s*)+", 2);
if (splitted.length == 2) {
map.put(splitted[0], splitted[1]);
} else {
map.put(splitted[0], "");
}
}
value = map;
}
}
if (createParameterObjects) {
String pattern = properties.getProperty(property + ".param" + i + ".pattern");
if (value == null && pattern == null) {
errorMessage("Property '" + property + ".param" + i + " doesn't have a value or pattern", writers);
} else {
try {
Parameter parameter = new Parameter();
parameter.setName(name);
if (value != null && !(value instanceof String)) {
parameter.setSessionKey(name);
parameterResolutionContext.getSession().put(name, value);
} else {
parameter.setValue((String) value);
parameter.setPattern(pattern);
}
parameter.configure();
result.put(name, parameter);
debugMessage("Add param with name '" + name + "', value '" + value + "' and pattern '" + pattern + "' for property '" + property + "'", writers);
} catch (ConfigurationException e) {
errorMessage("Parameter '" + name + "' could not be configured", writers);
}
}
} else {
if (value == null) {
errorMessage("Property '" + property + ".param" + i + ".value' or '" + property + ".param" + i + ".valuefile' or '" + property + ".param" + i + ".valuefileinputstream' not found while property '" + property + ".param" + i + ".name' exist", writers);
} else {
result.put(name, value);
debugMessage("Add param with name '" + name + "' and value '" + value + "' for property '" + property + "'", writers);
}
}
i++;
} else {
processed = true;
}
}
return result;
}
Aggregations