use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class JmsSender method configure.
/**
* Configures the sender
*/
@Override
public void configure() throws ConfigurationException {
if (StringUtils.isNotEmpty(getSoapAction()) && (paramList == null || paramList.findParameter("SoapAction") == null)) {
Parameter p = new Parameter();
p.setName("SoapAction");
p.setValue(getSoapAction());
addParameter(p);
}
if (paramList != null) {
paramList.configure();
}
super.configure();
if (isSoap()) {
// ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
// String msg = getLogPrefix()+"the use of attribute soap=true has been deprecated. Please change to SoapWrapperPipe";
// configWarnings.add(log, msg);
soapWrapper = SoapWrapper.getInstance();
}
}
use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class ExecuteJdbcProperties method doPost.
private String doPost(IPipeLineSession session) throws PipeRunException {
String action = (String) session.get("action");
String name = (String) session.get("name");
String value = (String) session.get("value");
FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
String form_jmsRealm = (String) session.get("jmsRealm");
if (StringUtils.isEmpty(name)) {
throw new PipeRunException(this, getLogPrefix(session) + "Name should not be empty");
}
String result = null;
String remoteUser = (String) session.get("principal");
if ("insert".equalsIgnoreCase(action)) {
try {
qs.setName("QuerySender");
qs.setJmsRealm(form_jmsRealm);
qs.setQueryType("insert");
if (StringUtils.isEmpty(remoteUser)) {
qs.setQuery("INSERT INTO IBISPROP (NAME, VALUE, LASTMODDATE) VALUES (?, ?, CURRENT_TIMESTAMP)");
} else {
qs.setQuery("INSERT INTO IBISPROP (NAME, VALUE, LASTMODDATE, LASTMODBY) VALUES (?, ?, CURRENT_TIMESTAMP, ?)");
}
Parameter param = new Parameter();
param.setName("name");
param.setValue(name);
qs.addParameter(param);
param = new Parameter();
param.setName("value");
param.setValue(value);
qs.addParameter(param);
if (StringUtils.isNotEmpty(remoteUser)) {
param = new Parameter();
param.setName("lastmodby");
param.setValue(remoteUser);
qs.addParameter(param);
}
qs.configure();
qs.open();
ParameterResolutionContext prc = new ParameterResolutionContext("", session);
result = qs.sendMessage("", "", prc);
} catch (Throwable t) {
throw new PipeRunException(this, getLogPrefix(session) + "Error occured on executing jdbc insert query", t);
} finally {
qs.close();
}
} else if ("update".equalsIgnoreCase(action)) {
try {
qs.setName("QuerySender");
qs.setJmsRealm(form_jmsRealm);
qs.setQueryType("update");
qs.setQuery("UPDATE IBISPROP SET VALUE=?, LASTMODDATE=CURRENT_TIMESTAMP, LASTMODBY=? WHERE NAME=?");
Parameter param = new Parameter();
param.setName("value");
param.setValue(value);
qs.addParameter(param);
param = new Parameter();
param.setName("lastmodby");
if (StringUtils.isNotEmpty(remoteUser)) {
param.setValue(remoteUser);
}
qs.addParameter(param);
param = new Parameter();
param.setName("name");
param.setValue(name);
qs.addParameter(param);
qs.configure();
qs.open();
ParameterResolutionContext prc = new ParameterResolutionContext("", session);
result = qs.sendMessage("", "", prc);
} catch (Throwable t) {
throw new PipeRunException(this, getLogPrefix(session) + "Error occured on executing jdbc update query", t);
} finally {
qs.close();
}
} else if ("delete".equalsIgnoreCase(action)) {
try {
qs.setName("QuerySender");
qs.setJmsRealm(form_jmsRealm);
qs.setQueryType("delete");
qs.setQuery("DELETE IBISPROP WHERE NAME=?");
Parameter param = new Parameter();
param.setName("name");
param.setValue(name);
qs.addParameter(param);
qs.configure();
qs.open();
ParameterResolutionContext prc = new ParameterResolutionContext("", session);
result = qs.sendMessage("", "", prc);
} catch (Throwable t) {
throw new PipeRunException(this, getLogPrefix(session) + "Error occured on executing jdbc delete query", t);
} finally {
qs.close();
}
} else {
throw new PipeRunException(this, getLogPrefix(session) + "Unknown action [" + action + "]");
}
session.put("result", result);
return "<dummy/>";
}
use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class ShowConfig method doGet.
private String doGet(IPipeLineSession session) throws PipeRunException {
String parm_name = (String) session.get("name");
if (StringUtils.isEmpty(parm_name)) {
return retrieveAllConfigs(session);
} else {
session.put("contentType", "application/octet-stream");
String parm_jmsRealm = (String) session.get("jmsRealm");
if (StringUtils.isEmpty(parm_jmsRealm)) {
parm_jmsRealm = JmsRealmFactory.getInstance().getFirstDatasourceJmsRealm();
if (parm_jmsRealm == null) {
throw new PipeRunException(this, getLogPrefix(session) + "No datasource jmsRealm available");
}
}
FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
String queryResult;
try {
qs.setName("QuerySender");
qs.setJmsRealm(parm_jmsRealm);
qs.setQueryType("select");
qs.setQuery("SELECT CONFIG FROM IBISCONFIG WHERE NAME = ? ORDER BY NAME");
Parameter param = new Parameter();
param.setName("name");
param.setSessionKey("name");
qs.addParameter(param);
qs.setScalar(true);
qs.setScalarExtended(true);
qs.setBlobsCompressed(false);
qs.setStreamResultToServlet(true);
qs.configure();
qs.open();
ParameterResolutionContext prc = new ParameterResolutionContext("dummy", session);
queryResult = qs.sendMessage("dummy", "dummy", prc);
} catch (Throwable t) {
throw new PipeRunException(this, getLogPrefix(session) + "Error occured on executing jdbc query", t);
} finally {
qs.close();
}
if (queryResult.length() == 0) {
// means result is found and streamed
} else {
throw new PipeRunException(this, getLogPrefix(session) + "Could not retrieve configuration for name [" + parm_name + "]");
}
return queryResult;
}
}
use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class ConfigData method processJarFile.
private String processJarFile(IPipeLineSession session, String name, String version, String fileName, String fileNameSessionKey) throws PipeRunException {
String formJmsRealm = (String) session.get("jmsRealm");
String activeConfig = (String) session.get(ACTIVE_CONFIG);
String autoReload = (String) session.get(AUTO_RELOAD);
String result = selectConfigQuery(session, name);
if ("on".equals(activeConfig)) {
activeConfigQuery(session, name, formJmsRealm, result);
}
if (Integer.parseInt(result) > 0) {
deleteConfigQuery(session, name, formJmsRealm, version);
}
String remoteUser = (String) session.get("principal");
FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
try {
qs.setName("QuerySender");
qs.setJmsRealm(formJmsRealm);
qs.setQueryType("insert");
if (StringUtils.isEmpty(remoteUser)) {
qs.setQuery("INSERT INTO IBISCONFIG (NAME, VERSION, FILENAME, CONFIG, CRE_TYDST, ACTIVECONFIG, AUTORELOAD) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, ?, ?)");
} else {
qs.setQuery("INSERT INTO IBISCONFIG (NAME, VERSION, FILENAME, CONFIG, CRE_TYDST, RUSER, ACTIVECONFIG, AUTORELOAD) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, ?, ?, ?)");
}
Parameter param = new Parameter();
param.setName("name");
param.setValue(name);
qs.addParameter(param);
param = new Parameter();
param.setName("version");
param.setValue(version);
qs.addParameter(param);
param = new Parameter();
param.setName("fileName");
param.setValue(fileName);
qs.addParameter(param);
param = new Parameter();
param.setName("config");
param.setSessionKey(fileNameSessionKey);
param.setType(Parameter.TYPE_INPUTSTREAM);
qs.addParameter(param);
if (StringUtils.isNotEmpty(remoteUser)) {
param = new Parameter();
param.setName("ruser");
param.setValue(remoteUser);
qs.addParameter(param);
}
setActiveConfig(activeConfig, qs);
setAutoReload(autoReload, qs);
qs.configure();
qs.open();
ParameterResolutionContext prc = new ParameterResolutionContext(DUMMY, session);
result = qs.sendMessage(DUMMY, DUMMY, prc);
} catch (Exception t) {
throw new PipeRunException(this, getLogPrefix(session) + "Error occured on executing jdbc query", t);
} finally {
qs.close();
}
return result;
}
use of nl.nn.adapterframework.parameters.Parameter in project iaf by ibissource.
the class ConfigData method deleteConfigQuery.
private String deleteConfigQuery(IPipeLineSession session, String name, String formJmsRealm, String version) throws PipeRunException {
FixedQuerySender qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
String result = "";
try {
qs.setName("QuerySender");
qs.setJmsRealm(formJmsRealm);
qs.setQuery("DELETE FROM IBISCONFIG WHERE NAME = ? AND VERSION = ?");
Parameter param = new Parameter();
param.setName("name");
param.setValue(name);
qs.addParameter(param);
param = new Parameter();
param.setName("version");
param.setValue(version);
qs.addParameter(param);
qs.setScalar(true);
qs.configure();
qs.open();
ParameterResolutionContext prc = new ParameterResolutionContext(DUMMY, session);
result = qs.sendMessage(DUMMY, DUMMY, prc);
} catch (Exception t) {
throw new PipeRunException(this, getLogPrefix(session) + "Error occured on executing jdbc query", t);
} finally {
qs.close();
}
return result;
}
Aggregations