Search in sources :

Example 31 with ActionForward

use of org.apache.struts.action.ActionForward in project cu-kfs by CU-CommunityApps.

the class CuPreEncumbranceAction method execute.

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ActionForward actionForward = super.execute(mapping, form, request, response);
    setTabStates(form);
    return actionForward;
}
Also used : ActionForward(org.apache.struts.action.ActionForward)

Example 32 with ActionForward

use of org.apache.struts.action.ActionForward in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherAction method save.

@Override
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ActionForward actionForward = super.save(mapping, form, request, response);
    openRecurringDetailsTab(form);
    return actionForward;
}
Also used : ActionForward(org.apache.struts.action.ActionForward)

Example 33 with ActionForward

use of org.apache.struts.action.ActionForward in project iaf by ibissource.

the class ExecuteJdbcQueryExecute method executeSub.

public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    // Initialize action
    initAction(request);
    DynaActionForm executeJdbcQueryExecuteForm = (DynaActionForm) form;
    String form_jmsRealm = (String) executeJdbcQueryExecuteForm.get("jmsRealm");
    String form_queryType = (String) executeJdbcQueryExecuteForm.get("queryType");
    String form_resultType = (String) executeJdbcQueryExecuteForm.get("resultType");
    String form_query = (String) executeJdbcQueryExecuteForm.get("query");
    DirectQuerySender qs;
    String result = "";
    try {
        qs = (DirectQuerySender) ibisManager.getIbisContext().createBeanAutowireByName(DirectQuerySender.class);
        try {
            qs.setName("QuerySender");
            qs.setJmsRealm(form_jmsRealm);
            qs.setQueryType(form_queryType);
            qs.setBlobSmartGet(true);
            qs.configure(true);
            qs.open();
            result = qs.sendMessage("dummy", form_query);
            if ("csv".equalsIgnoreCase(form_resultType)) {
                URL url = ClassUtils.getResourceURL(this, DB2XML_XSLT);
                if (url != null) {
                    Transformer t = XmlUtils.createTransformer(url);
                    result = XmlUtils.transformXml(t, result);
                }
            }
        } 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);
    }
    StoreFormData(form_query, result, executeJdbcQueryExecuteForm);
    if (!errors.isEmpty()) {
        saveErrors(request, errors);
        return (new ActionForward(mapping.getInput()));
    }
    // Successfull: store cookie
    String cookieValue = "";
    cookieValue += "jmsRealm=\"" + form_jmsRealm + "\"";
    // separator
    cookieValue += " ";
    cookieValue += "queryType=\"" + form_queryType + "\"";
    // separator
    cookieValue += " ";
    cookieValue += "resultType=\"" + form_resultType + "\"";
    // separator
    cookieValue += " ";
    // TODO: fix workaround to avoid http error 500 on WAS (line separators in query cookie)
    String fq = Misc.replace(form_query, System.getProperty("line.separator"), " ");
    cookieValue += "query=\"" + fq + "\"";
    Cookie execJdbcCookie = new Cookie(AppConstants.getInstance().getProperty("WEB_EXECJDBCCOOKIE_NAME"), cookieValue);
    execJdbcCookie.setMaxAge(Integer.MAX_VALUE);
    log.debug("Store cookie for " + request.getServletPath() + " cookieName[" + AppConstants.getInstance().getProperty("WEB_EXECJDBCCOOKIE_NAME") + "] " + " cookieValue[" + new StringTagger(cookieValue).toString() + "]");
    try {
        response.addCookie(execJdbcCookie);
    } catch (Throwable e) {
        log.warn("unable to add cookie to request. cookie value [" + execJdbcCookie.getValue() + "]");
    }
    log.debug("forward to success");
    return (mapping.findForward("success"));
}
Also used : Cookie(javax.servlet.http.Cookie) DynaActionForm(org.apache.struts.action.DynaActionForm) Transformer(javax.xml.transform.Transformer) DirectQuerySender(nl.nn.adapterframework.jdbc.DirectQuerySender) StringTagger(nl.nn.adapterframework.util.StringTagger) URL(java.net.URL) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) ActionForward(org.apache.struts.action.ActionForward)

Example 34 with ActionForward

use of org.apache.struts.action.ActionForward in project iaf by ibissource.

the class SendJmsMessageExecute 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("sendJmsMessage was cancelled");
        removeFormBean(mapping, request);
        return (mapping.findForward("success"));
    }
    // Retrieve form content
    // ---------------------
    DynaActionForm sendJmsMessageForm = (DynaActionForm) form;
    String form_jmsRealm = (String) sendJmsMessageForm.get("jmsRealm");
    String form_destinationName = (String) sendJmsMessageForm.get("destinationName");
    String form_destinationType = (String) sendJmsMessageForm.get("destinationType");
    boolean form_persistent = false;
    if (null != sendJmsMessageForm.get("persistent")) {
        form_persistent = ((Boolean) sendJmsMessageForm.get("persistent")).booleanValue();
    }
    String form_message = (String) sendJmsMessageForm.get("message");
    FormFile form_file = (FormFile) sendJmsMessageForm.get("file");
    String form_replyToName = (String) sendJmsMessageForm.get("replyToName");
    // if upload is choosen, it prevails over the message
    if ((form_file != null) && (form_file.getFileSize() > 0)) {
        log.debug("Upload of file [" + form_file.getFileName() + "] ContentType[" + form_file.getContentType() + "]");
        if (FileUtils.extensionEqualsIgnoreCase(form_file.getFileName(), "zip")) {
            ZipInputStream archive = new ZipInputStream(new ByteArrayInputStream(form_file.getFileData()));
            for (ZipEntry entry = archive.getNextEntry(); entry != null; entry = archive.getNextEntry()) {
                String name = entry.getName();
                int size = (int) entry.getSize();
                if (size > 0) {
                    byte[] b = new byte[size];
                    int rb = 0;
                    int chunk = 0;
                    while (((int) size - rb) > 0) {
                        chunk = archive.read(b, rb, (int) size - rb);
                        if (chunk == -1) {
                            break;
                        }
                        rb += chunk;
                    }
                    String currentMessage = XmlUtils.readXml(b, 0, rb, request.getCharacterEncoding(), false);
                    // initiate MessageSender
                    JmsSender qms = new JmsSender();
                    qms.setName("SendJmsMessageAction");
                    qms.setJmsRealm(form_jmsRealm);
                    qms.setDestinationName(form_destinationName);
                    qms.setPersistent(form_persistent);
                    qms.setDestinationType(form_destinationType);
                    if ((form_replyToName != null) && (form_replyToName.length() > 0))
                        qms.setReplyToName(form_replyToName);
                    processMessage(qms, name + "_" + Misc.createSimpleUUID(), currentMessage);
                }
                archive.closeEntry();
            }
            archive.close();
            form_message = null;
        } else {
            form_message = XmlUtils.readXml(form_file.getFileData(), request.getCharacterEncoding(), false);
        }
    } else {
        form_message = new String(form_message.getBytes(), Misc.DEFAULT_INPUT_STREAM_ENCODING);
    }
    if (form_message != null && form_message.length() > 0) {
        // initiate MessageSender
        JmsSender qms = new JmsSender();
        qms.setName("SendJmsMessageAction");
        qms.setJmsRealm(form_jmsRealm);
        qms.setDestinationName(form_destinationName);
        qms.setPersistent(form_persistent);
        qms.setDestinationType(form_destinationType);
        if ((form_replyToName != null) && (form_replyToName.length() > 0))
            qms.setReplyToName(form_replyToName);
        processMessage(qms, "testmsg_" + Misc.createUUID(), form_message);
    }
    StoreFormData(sendJmsMessageForm);
    // Report any errors we have discovered back to the original form
    if (!errors.isEmpty()) {
        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 + "\"";
    Cookie sendJmsCookie = new Cookie(AppConstants.getInstance().getProperty("WEB_JMSCOOKIE_NAME"), cookieValue);
    sendJmsCookie.setMaxAge(Integer.MAX_VALUE);
    log.debug("Store cookie for " + request.getServletPath() + " cookieName[" + AppConstants.getInstance().getProperty("WEB_JMSCOOKIE_NAME") + "] " + " 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"));
}
Also used : Cookie(javax.servlet.http.Cookie) DynaActionForm(org.apache.struts.action.DynaActionForm) ZipEntry(java.util.zip.ZipEntry) StringTagger(nl.nn.adapterframework.util.StringTagger) ActionForward(org.apache.struts.action.ActionForward) FormFile(org.apache.struts.upload.FormFile) ZipInputStream(java.util.zip.ZipInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) JmsSender(nl.nn.adapterframework.jms.JmsSender)

Example 35 with ActionForward

use of org.apache.struts.action.ActionForward in project iaf by ibissource.

the class TestServiceExecute method executeSub.

public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    // Initialize action
    initAction(request);
    DynaActionForm serviceTestForm = (DynaActionForm) form;
    // List form_services = (List) serviceTestForm.get("services");
    String form_serviceName = (String) serviceTestForm.get("serviceName");
    String form_message = (String) serviceTestForm.get("message");
    String form_result = (String) serviceTestForm.get("message");
    FormFile form_file = (FormFile) serviceTestForm.get("file");
    // if no message and no formfile, send an error
    if ((form_message == null) || (form_message.length() == 0)) {
        if ((form_file == null) || (form_file.getFileSize() == 0)) {
            storeFormData(null, null, serviceTestForm);
            warn("Nothing to send or test");
        }
    }
    // Report any errors we have discovered back to the original form
    if (!errors.isEmpty()) {
        saveErrors(request, errors);
        storeFormData(null, null, serviceTestForm);
        return (new ActionForward(mapping.getInput()));
    }
    if ((form_serviceName == null) || (form_serviceName.length() == 0)) {
        warn("No service selected");
    }
    // Report any errors we have discovered back to the original form
    if (!errors.isEmpty()) {
        saveErrors(request, errors);
        storeFormData(null, form_message, serviceTestForm);
        return (new ActionForward(mapping.getInput()));
    }
    // Execute the request
    if (!(ServiceDispatcher.getInstance().isRegisteredServiceListener(form_serviceName)))
        warn("Servicer with specified name [" + form_serviceName + "] is not registered at the Dispatcher");
    // Report any errors we have discovered back to the original form
    if (!errors.isEmpty()) {
        saveErrors(request, errors);
        storeFormData(null, form_message, serviceTestForm);
        return (new ActionForward(mapping.getInput()));
    }
    // if upload is choosen, it prevails over the message
    if ((form_file != null) && (form_file.getFileSize() > 0)) {
        form_message = XmlUtils.readXml(form_file.getFileData(), request.getCharacterEncoding(), false);
        log.debug("Upload of file [" + form_file.getFileName() + "] ContentType[" + form_file.getContentType() + "]");
    } else {
        form_message = new String(form_message.getBytes(), Misc.DEFAULT_INPUT_STREAM_ENCODING);
    }
    form_result = "";
    // Execute the request
    try {
        Map context = new HashMap();
        form_result = ServiceDispatcher.getInstance().dispatchRequest(form_serviceName, null, form_message, context);
    } catch (Exception e) {
        warn("Service with specified name [" + form_serviceName + "] got error", e);
    }
    storeFormData(form_result, form_message, serviceTestForm);
    // Report any errors we have discovered back to the original form
    if (!errors.isEmpty()) {
        saveErrors(request, errors);
        return (new ActionForward(mapping.getInput()));
    }
    // Forward control to the specified success URI
    log.debug("forward to success");
    return (mapping.findForward("success"));
}
Also used : DynaActionForm(org.apache.struts.action.DynaActionForm) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) ActionForward(org.apache.struts.action.ActionForward) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) FormFile(org.apache.struts.upload.FormFile)

Aggregations

ActionForward (org.apache.struts.action.ActionForward)117 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)16 ActionMessages (org.apache.struts.action.ActionMessages)14 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)11 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)11 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)9 ActionMessage (org.apache.struts.action.ActionMessage)9 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)8 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)7 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)7 UserContext (org.mifos.security.util.UserContext)7 IOException (java.io.IOException)6 Date (java.util.Date)6 AuthorizationPersistence (cn.edu.zju.acm.onlinejudge.persistence.AuthorizationPersistence)5 ArrayList (java.util.ArrayList)5 Cookie (javax.servlet.http.Cookie)5 ActionMapping (org.apache.struts.action.ActionMapping)5 CloseSession (org.mifos.framework.util.helpers.CloseSession)5 Submission (cn.edu.zju.acm.onlinejudge.bean.Submission)4 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)4