use of nl.nn.adapterframework.webcontrol.IniDynaActionForm in project iaf by ibissource.
the class SlotIdRecord method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
IniDynaActionForm showIbisstoreSummaryForm = (IniDynaActionForm) form;
// Initialize action
initAction(request);
if (ibisManager == null)
return (mapping.findForward("noIbisContext"));
String jmsRealm = (String) showIbisstoreSummaryForm.get("jmsRealm");
String cookieName = AppConstants.getInstance().getString(SHOWIBISSTORECOOKIE, SHOWIBISSTORECOOKIE);
if (StringUtils.isEmpty(jmsRealm)) {
// get jmsRealm value from cookie
Cookie[] cookies = request.getCookies();
if (null != cookies) {
for (int i = 0; i < cookies.length; i++) {
Cookie aCookie = cookies[i];
if (aCookie.getName().equals(cookieName)) {
jmsRealm = aCookie.getValue();
log.debug("jmsRealm from cookie [" + jmsRealm + "]");
}
}
}
}
for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) iAdapter;
for (Iterator receiverIt = adapter.getReceiverIterator(); receiverIt.hasNext(); ) {
ReceiverBase receiver = (ReceiverBase) receiverIt.next();
ITransactionalStorage errorStorage = receiver.getErrorStorage();
if (errorStorage != null) {
String slotId = errorStorage.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
String type = errorStorage.getType();
slotmap.put(type + "/" + slotId, sir);
}
}
ITransactionalStorage messageLog = receiver.getMessageLog();
if (messageLog != null) {
String slotId = messageLog.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
String type = messageLog.getType();
slotmap.put(type + "/" + slotId, sir);
}
}
}
PipeLine pipeline = adapter.getPipeLine();
if (pipeline != null) {
for (int i = 0; i < pipeline.getPipeLineSize(); i++) {
IPipe pipe = pipeline.getPipe(i);
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
ITransactionalStorage messageLog = msp.getMessageLog();
if (messageLog != null) {
String slotId = messageLog.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), null, msp.getName());
String type = messageLog.getType();
slotmap.put(type + "/" + slotId, sir);
slotmap.put(slotId, sir);
}
}
}
}
}
}
List jmsRealms = JmsRealmFactory.getInstance().getRegisteredRealmNamesAsList();
if (jmsRealms.size() == 0) {
jmsRealms.add("no realms defined");
} else {
if (StringUtils.isEmpty(jmsRealm)) {
jmsRealm = (String) jmsRealms.get(0);
}
}
showIbisstoreSummaryForm.set("jmsRealms", jmsRealms);
if (StringUtils.isNotEmpty(jmsRealm)) {
String result = "<none/>";
try {
IbisstoreSummaryQuerySender qs;
qs = (IbisstoreSummaryQuerySender) ibisManager.getIbisContext().createBeanAutowireByName(IbisstoreSummaryQuerySender.class);
qs.setSlotmap(slotmap);
try {
qs.setName("QuerySender");
qs.setJmsRealm(jmsRealm);
qs.setQueryType("select");
qs.setBlobSmartGet(true);
qs.configure(true);
qs.open();
result = qs.sendMessage("dummy", qs.getDbmsSupport().getIbisStoreSummaryQuery());
} catch (Throwable t) {
error("error occured on executing jdbc query", t);
} finally {
qs.close();
}
} catch (Exception e) {
error("error occured on creating or closing connection", e);
}
if (log.isDebugEnabled())
log.debug("result [" + result + "]");
request.setAttribute("result", result);
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
return (mapping.findForward("success"));
}
// Successfull: store cookie
String cookieValue = jmsRealm;
Cookie cookie = new Cookie(cookieName, cookieValue);
cookie.setMaxAge(Integer.MAX_VALUE);
log.debug("Store cookie for " + request.getServletPath() + " cookieName[" + cookieName + "] " + " cookieValue[" + cookieValue + "]");
try {
response.addCookie(cookie);
} catch (Throwable t) {
log.warn("unable to add cookie to request. cookie value [" + cookie.getValue() + "]", t);
}
log.debug("forward to success");
return (mapping.findForward("success"));
}
use of nl.nn.adapterframework.webcontrol.IniDynaActionForm in project iaf by ibissource.
the class BrowseJdbcTableExecute method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Initialize action
initAction(request);
// -------------------------------
if (isCancelled(request)) {
log.debug("browseJdbcTable was cancelled");
removeFormBean(mapping, request);
return (mapping.findForward("cancel"));
}
// Retrieve form content
// ---------------------
IniDynaActionForm browseJdbcTableForm = (IniDynaActionForm) form;
String form_jmsRealm = (String) browseJdbcTableForm.get("jmsRealm");
String form_tableName = (String) browseJdbcTableForm.get("tableName");
String form_where = (String) browseJdbcTableForm.get("where");
boolean form_numberOfRowsOnly = false;
String form_order = (String) browseJdbcTableForm.get("order");
if (browseJdbcTableForm.get("numberOfRowsOnly") != null)
form_numberOfRowsOnly = ((Boolean) browseJdbcTableForm.get("numberOfRowsOnly")).booleanValue();
int form_rownumMin = ((Integer) browseJdbcTableForm.get("rownumMin")).intValue();
int form_rownumMax = ((Integer) browseJdbcTableForm.get("rownumMax")).intValue();
if (!form_numberOfRowsOnly) {
if (form_rownumMin < 0) {
form_rownumMin = 0;
}
if (form_rownumMax < 0) {
form_rownumMax = 0;
}
if (form_rownumMin == 0 && form_rownumMax == 0) {
form_rownumMin = 1;
form_rownumMax = 100;
}
if (errors.isEmpty()) {
if (form_rownumMax < form_rownumMin) {
error("errors.generic", "Rownum max must be greater than or equal to Rownum min", null);
}
}
if (errors.isEmpty()) {
if (form_rownumMax - form_rownumMin >= 100) {
error("errors.generic", "Difference between Rownum max and Rownum min must be less than hundred", null);
}
}
if (!readAllowed(permissionRules, request, form_tableName)) {
error("errors.generic", "Access to table (" + form_tableName + ") not allowed", null);
}
}
if (errors.isEmpty()) {
DirectQuerySender qs;
String result = "";
String query = null;
try {
qs = (DirectQuerySender) ibisManager.getIbisContext().createBeanAutowireByName(DirectQuerySender.class);
try {
qs.setName("QuerySender");
qs.setJmsRealm(form_jmsRealm);
// if (form_numberOfRowsOnly || qs.getDatabaseType() == DbmsSupportFactory.DBMS_ORACLE) {
qs.setQueryType("select");
qs.setBlobSmartGet(true);
qs.setIncludeFieldDefinition(true);
qs.configure(true);
qs.open();
ResultSet rs = qs.getConnection().getMetaData().getColumns(null, null, form_tableName, null);
if (!rs.isBeforeFirst()) {
rs = qs.getConnection().getMetaData().getColumns(null, null, form_tableName.toUpperCase(), null);
}
String fielddefinition = "<fielddefinition>";
while (rs.next()) {
String field = "<field name=\"" + rs.getString(4) + "\" type=\"" + DB2XMLWriter.getFieldType(rs.getInt(5)) + "\" size=\"" + rs.getInt(7) + "\"/>";
fielddefinition = fielddefinition + field;
}
fielddefinition = fielddefinition + "</fielddefinition>";
String browseJdbcTableExecuteREQ = "<browseJdbcTableExecuteREQ>" + "<dbmsName>" + qs.getDbmsSupport().getDbmsName() + "</dbmsName>" + "<tableName>" + form_tableName + "</tableName>" + "<where>" + XmlUtils.encodeChars(form_where) + "</where>" + "<numberOfRowsOnly>" + form_numberOfRowsOnly + "</numberOfRowsOnly>" + "<order>" + form_order + "</order>" + "<rownumMin>" + form_rownumMin + "</rownumMin>" + "<rownumMax>" + form_rownumMax + "</rownumMax>" + fielddefinition + "<maxColumnSize>1000</maxColumnSize>" + "</browseJdbcTableExecuteREQ>";
URL url = ClassUtils.getResourceURL(this, DB2XML_XSLT);
if (url != null) {
Transformer t = XmlUtils.createTransformer(url);
query = XmlUtils.transformXml(t, browseJdbcTableExecuteREQ);
}
result = qs.sendMessage("dummy", query);
// } else {
// error("errors.generic","This function only supports oracle databases",null);
// }
} catch (Throwable t) {
error("errors.generic", "error occured on executing jdbc query [" + query + "]", t);
} finally {
qs.close();
}
} catch (Exception e) {
error("errors.generic", "error occured on creating or closing connection", e);
}
String resultEnvelope = "<resultEnvelope>" + "<request " + "tableName=\"" + form_tableName + "\">" + XmlUtils.encodeChars(query) + "</request>" + result + "</resultEnvelope>";
request.setAttribute("DB2Xml", resultEnvelope);
}
// Report any errors we have discovered back to the original form
if (!errors.isEmpty()) {
StoreFormData(browseJdbcTableForm);
saveErrors(request, errors);
return (new ActionForward(mapping.getInput()));
}
// Successfull: store cookie
String cookieValue = "";
cookieValue += "jmsRealm=\"" + form_jmsRealm + "\"";
// separator
cookieValue += " ";
cookieValue += "tableName=\"" + form_tableName + "\"";
// separator
cookieValue += " ";
cookieValue += "where=\"" + form_where + "\"";
// separator
cookieValue += " ";
cookieValue += "order=\"" + form_order + "\"";
// separator
cookieValue += " ";
cookieValue += "numberOfRowsOnly=\"" + form_numberOfRowsOnly + "\"";
// separator
cookieValue += " ";
cookieValue += "rownumMin=\"" + form_rownumMin + "\"";
// separator
cookieValue += " ";
cookieValue += "rownumMax=\"" + form_rownumMax + "\"";
Cookie sendJdbcBrowseCookie = new Cookie(AppConstants.getInstance().getProperty("WEB_JDBCBROWSECOOKIE_NAME"), cookieValue);
sendJdbcBrowseCookie.setMaxAge(Integer.MAX_VALUE);
log.debug("Store cookie for " + request.getServletPath() + " cookieName[" + AppConstants.getInstance().getProperty("WEB_JDBCBROWSECOOKIE_NAME") + "] " + " cookieValue[" + new StringTagger(cookieValue).toString() + "]");
try {
response.addCookie(sendJdbcBrowseCookie);
} catch (Throwable e) {
log.warn("unable to add cookie to request. cookie value [" + sendJdbcBrowseCookie.getValue() + "]");
}
// Forward control to the specified success URI
log.debug("forward to success");
return (mapping.findForward("success"));
}
use of nl.nn.adapterframework.webcontrol.IniDynaActionForm in project iaf by ibissource.
the class BrowseQueueExecute method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Initialize action
initAction(request);
// -------------------------------
if (isCancelled(request)) {
log.debug("browseQueue was cancelled");
removeFormBean(mapping, request);
return (mapping.findForward("cancel"));
}
// Retrieve form content
// ---------------------
IniDynaActionForm browseQueueForm = (IniDynaActionForm) form;
String form_jmsRealm = (String) browseQueueForm.get("jmsRealm");
String form_destinationName = (String) browseQueueForm.get("destinationName");
String form_destinationType = (String) browseQueueForm.get("destinationType");
boolean form_numberOfMessagesOnly = false;
boolean form_showPayload = false;
if (browseQueueForm.get("numberOfMessagesOnly") != null)
form_numberOfMessagesOnly = ((Boolean) browseQueueForm.get("numberOfMessagesOnly")).booleanValue();
if (browseQueueForm.get("showPayload") != null)
form_showPayload = ((Boolean) browseQueueForm.get("showPayload")).booleanValue();
// initiate MessageSender
JmsMessageBrowser jmsBrowser = new JmsMessageBrowser();
jmsBrowser.setName("BrowseQueueAction");
jmsBrowser.setJmsRealm(form_jmsRealm);
jmsBrowser.setDestinationName(form_destinationName);
jmsBrowser.setDestinationType(form_destinationType);
IMessageBrowser browser = jmsBrowser;
IMessageBrowsingIterator it = null;
try {
it = browser.getIterator();
List messages = new ArrayList();
while (it.hasNext()) {
messages.add(it.next());
}
log.debug("Browser returned " + messages.size() + " messages");
browseQueueForm.set("numberOfMessages", Integer.toString(messages.size()));
if (!form_numberOfMessagesOnly) {
/*
try {
for (int i = 0; i < messages.size(); i++) {
Message msg = (Message) messages.get(i);
if (msg instanceof TextMessage) {
TextMessage tm = (TextMessage) msg;
if (log.isDebugEnabled())
log.debug("Found message " + tm.getText());
}
}
} catch (JMSException je) {
log.error(je);
errors.add(
"",
new ActionError(
"errors.generic",
"error occured browsing messages:" + je.getMessage()));
}
*/
browseQueueForm.set("messages", messages);
} else
browseQueueForm.set("messages", new ArrayList());
} catch (ListenerException e) {
error("Error occured browsing messages", e);
} finally {
try {
if (it != null) {
it.close();
}
} catch (ListenerException e1) {
log.error(e1);
}
}
// Report any errors we have discovered back to the original form
if (!errors.isEmpty()) {
StoreFormData(browseQueueForm);
saveErrors(request, errors);
return (new ActionForward(mapping.getInput()));
}
// Successfull: store cookie
String cookieValue = "";
cookieValue += "jmsRealm=\"" + form_jmsRealm + "\"";
// separator
cookieValue += " ";
cookieValue += "destinationName=\"" + form_destinationName + "\"";
// separator
cookieValue += " ";
cookieValue += "destinationType=\"" + form_destinationType + "\"";
// separator
cookieValue += " ";
cookieValue += "showPayload=\"" + form_showPayload + "\"";
log.debug("*** value : " + AppConstants.getInstance().getString("WEB_QBROWSECOOKIE_NAME", "WEB_QBROWSECOOKIE"));
Cookie sendJmsCookie = new Cookie(AppConstants.getInstance().getString("WEB_QBROWSECOOKIE_NAME", "WEB_QBROWSECOOKIE"), cookieValue);
sendJmsCookie.setMaxAge(Integer.MAX_VALUE);
log.debug("Store cookie for " + request.getServletPath() + " cookieName[" + sendJmsCookie.getName() + "] " + " cookieValue[" + new StringTagger(cookieValue).toString() + "]");
try {
response.addCookie(sendJmsCookie);
} catch (Throwable e) {
log.warn("unable to add cookie to request. cookie value [" + sendJmsCookie.getValue() + "]");
}
// Forward control to the specified success URI
log.debug("forward to success");
return (mapping.findForward("success"));
}
use of nl.nn.adapterframework.webcontrol.IniDynaActionForm in project iaf by ibissource.
the class ExecuteJdbcQuery method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Initialize action
initAction(request);
IniDynaActionForm executeJdbcQueryForm = (IniDynaActionForm) form;
Cookie[] cookies = request.getCookies();
if (null != cookies) {
for (int i = 0; i < cookies.length; i++) {
Cookie aCookie = cookies[i];
if (aCookie.getName().equals(AppConstants.getInstance().getString("WEB_EXECJDBCCOOKIE_NAME", "WEB_EXECJDBCCOOKIE"))) {
StringTagger cs = new StringTagger(aCookie.getValue());
log.debug("restoring values from cookie: " + cs.toString());
try {
executeJdbcQueryForm.set("jmsRealm", cs.Value("jmsRealm"));
executeJdbcQueryForm.set("queryType", cs.Value("queryType"));
executeJdbcQueryForm.set("resultType", cs.Value("resultType"));
executeJdbcQueryForm.set("query", cs.Value("query"));
} catch (Exception e) {
log.warn("could not restore Cookie value's", e);
}
}
}
}
List jmsRealms = JmsRealmFactory.getInstance().getRegisteredRealmNamesAsList();
if (jmsRealms.size() == 0)
jmsRealms.add("no realms defined");
executeJdbcQueryForm.set("jmsRealms", jmsRealms);
List queryTypes = new ArrayList();
queryTypes.add("select");
queryTypes.add("other");
executeJdbcQueryForm.set("queryTypes", queryTypes);
List resultTypes = new ArrayList();
resultTypes.add("csv");
resultTypes.add("xml");
executeJdbcQueryForm.set("resultTypes", resultTypes);
// Forward control to the specified success URI
log.debug("forward to success");
return (mapping.findForward("success"));
}
use of nl.nn.adapterframework.webcontrol.IniDynaActionForm in project iaf by ibissource.
the class BrowseJdbcTable method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Initialize action
initAction(request);
if (form == null) {
log.debug(" Creating new browseJdbcTableForm bean under key " + mapping.getAttribute());
IniDynaActionForm browseJdbcTableForm = new IniDynaActionForm();
if ("request".equals(mapping.getScope())) {
request.setAttribute(mapping.getAttribute(), form);
} else {
session.setAttribute(mapping.getAttribute(), form);
}
}
IniDynaActionForm browseJdbcTableForm = (IniDynaActionForm) form;
Cookie[] cookies = request.getCookies();
if (null != cookies) {
for (int i = 0; i < cookies.length; i++) {
Cookie aCookie = cookies[i];
if (aCookie.getName().equals(AppConstants.getInstance().getProperty("WEB_JDBCBROWSECOOKIE_NAME"))) {
StringTagger cs = new StringTagger(aCookie.getValue());
log.debug("restoring values from cookie: " + cs.toString());
try {
browseJdbcTableForm.set("jmsRealm", cs.Value("jmsRealm"));
browseJdbcTableForm.set("tableName", cs.Value("tableName"));
browseJdbcTableForm.set("where", cs.Value("where"));
browseJdbcTableForm.set("order", cs.Value("order"));
browseJdbcTableForm.set("numberOfRowsOnly", new Boolean(cs.Value("numberOfRowsOnly")));
browseJdbcTableForm.set("rownumMin", new Integer(cs.Value("rownumMin")));
browseJdbcTableForm.set("rownumMax", new Integer(cs.Value("rownumMax")));
} catch (Exception e) {
log.warn("could not restore Cookie value's", e);
}
}
}
}
List jmsRealms = JmsRealmFactory.getInstance().getRegisteredRealmNamesAsList();
if (jmsRealms.size() == 0)
jmsRealms.add("no realms defined");
browseJdbcTableForm.set("jmsRealms", jmsRealms);
// Forward control to the specified success URI
log.debug("forward to success");
return (mapping.findForward("success"));
}
Aggregations