/** processing method invoked from a Web environment */
  public void doHPTransaction(HttpServletRequest req, HttpServletResponse resp)
      throws BeanException {
    oHttpServletRequest = req;
    oHttpServletResponse = resp;

    if (tracing == true) {
      traceArgs[0] = this;
      traceArgs[1] = " CrownCounselIndexGetList_Access.doHPTransaction()";
      try {
        traceMethod.invoke(o, traceArgs);
      } catch (Exception x) {
      }
    }

    try {
      startHereCommon();
    } catch (BeanException e) {
      // remove the ejb instance if handle exists
      if (ejb != null) {
        try {
          ejb.remove();
        } catch (Exception x) {
        }
        ejb = null;
      }

      // go set error fields
      setupErrorFields(e);

      throw e; // rethrow the exception.
    }
  }
  /** processing method invoked from application */
  public void processRequest() throws BeanException {
    if (tracing == true) {
      traceArgs[0] = this;
      traceArgs[1] = " CrownCounselIndexGetList_Access.processRequest()";
      try {
        traceMethod.invoke(o, traceArgs);
      } catch (Exception x) {
      }
    }

    try {
      startHereCommon();
    } catch (BeanException e) {
      // remove the ejb instance if handle exists
      if (ejb != null) {
        try {
          ejb.remove();
        } catch (Exception x) {
        }
        ejb = null;
      }

      // go set error fields
      setupErrorFields(e);

      throw e;
    }
  }
Exemple #3
0
  private void callMethodForMultiPart(HttpServletRequest req, HttpServletResponse resp)
      throws Exception {
    String pinfo = req.getPathInfo();
    int pos = pinfo.indexOf('.');
    String cname = pinfo.substring(1, pos).replace('/', '.');
    String mname = pinfo.substring(pos + 1);

    MultiPartMap map = new MultiPartMap();
    FileItemIterator ite = new FileUpload().getItemIterator(req);
    while (ite.hasNext()) {
      FileItemStream item = ite.next();
      if (item.isFormField()) {
        map.put(item.getFieldName(), IOUtil.streamToString(item.openStream(), "UTF-8"));
      } else {
        FileItem val =
            new FileItem(
                item.getFileName(), item.getContentType(), IOUtil.streamToBytes(item.openStream()));
        map.put(item.getFieldName(), val);
      }
    }

    Class clazz = Class.forName(cname);
    Class[] types = new Class[] {MultiPartMap.class};
    Method method = clazz.getMethod(mname, types);
    if (method == null) {
      throw new RuntimeException("Not found method " + mname + "(Map)");
    }

    Object result = method.invoke(null, map);

    resp.setContentType(MIME_HTML + ";charset=utf-8");
    resp.getWriter().write(result.toString());
  }
  public java.lang.String getHPubXMLProperties(java.lang.String value) {
    if (tracing == true) {
      traceArgs[0] = this;
      traceArgs[1] = "CrownCounselIndexGetList_Access.getHPubXMLProperties(String)";
      try {
        traceMethod.invoke(o, traceArgs);
      } catch (Exception x) {
      }
    }

    inputProps.setHPubStyleSheet(value);

    try {
      startHereCommon();
    } catch (BeanException e) {
      // remove the ejb instance if handle exists
      if (ejb != null) {
        try {
          ejb.remove();
        } catch (Exception x) {
        }
        ejb = null;
      }

      // go set error fields
      setupErrorFields(e);
    }
    if (outputProps != null) return outputProps.getHPubXMLData();
    else return null;
  }
  // The default constructor
  public CrownCounselIndexGetList_Access() {
    String traceProp = null;
    if ((traceProp = System.getProperty(HOSTPUBLISHER_ACCESSBEAN_TRACE)) != null) {
      try {
        Class c = Class.forName(HOSTPUBLISHER_ACCESSTRACE_OBJECT);
        Method m = c.getMethod("getInstance", null);
        o = m.invoke(null, null);
        Class parmTypes[] = {String.class};
        m = c.getMethod("initTrace", parmTypes);
        Object initTraceArgs[] = {traceProp};
        BitSet tracingBS = (BitSet) m.invoke(o, initTraceArgs);
        Class parmTypes2[] = {Object.class, String.class};
        traceMethod = c.getMethod("trace", parmTypes2);
        tracing = tracingBS.get(HOSTPUBLISHER_ACCESSBEAN_TRACING);
        Class parmTypes3[] = {String.class, HttpSession.class};
        auditMethod = c.getMethod("audit", parmTypes3);
        auditing = tracingBS.get(HOSTPUBLISHER_ACCESSBEAN_AUDITING);
      } catch (Exception e) {
        // no tracing will be done
        System.err.println(
            (new Date(System.currentTimeMillis())).toString()
                + " hostpublisher.accessbean.trace="
                + traceProp
                + ", Exception="
                + e.toString());
      }
    }

    if (tracing == true) {
      traceArgs[0] = this;
      traceArgs[1] = " CrownCounselIndexGetList_Access()";
      try {
        traceMethod.invoke(o, traceArgs);
      } catch (Exception x) {
        System.err.println(
            (new Date(System.currentTimeMillis())).toString()
                + " traceMethod.invoke(null, traceArgs)"
                + ", Exception="
                + x.toString());
      }
    }
    inputProps = new CrownCounselIndexGetList_Properties();
    return;
  }
 /** event driven processing methods */
 public void hPubStartPerformed(HPubStartEvent evt) {
   if (tracing == true) {
     traceArgs[0] = this;
     traceArgs[1] = "CrownCounselIndexGetList_Access.hPubStartPerformed()";
     try {
       traceMethod.invoke(o, traceArgs);
     } catch (Exception x) {
     }
   }
   Thread newThread = new Thread(this);
   newThread.start();
 }
 /** event driven processing methods */
 public void hPubStartPerformed(HPubStartEvent evt) {
   if (tracing == true) {
     traceArgs[0] = this;
     traceArgs[1] = "OffenceCountTextPostData_Access.hPubStartPerformed()";
     try {
       traceMethod.invoke(o, traceArgs);
     } catch (Exception x) {
     }
   }
   Thread newThread = new Thread(this);
   newThread.start();
 }
 /** event driven processing methods */
 public void hPubStartPerformed(HPubStartEvent evt) {
   if (tracing == true) {
     traceArgs[0] = this;
     traceArgs[1] = "EnforcementAgencyIndexSearch_Access.hPubStartPerformed()";
     try {
       traceMethod.invoke(o, traceArgs);
     } catch (Exception x) {
     }
   }
   Thread newThread = new Thread(this);
   newThread.start();
 }
 /** event driven processing methods */
 public void hPubStartPerformed(HPubStartEvent evt) {
   if (tracing == true) {
     traceArgs[0] = this;
     traceArgs[1] = "CaseCashReceiptsGetOffenderDetails_Access.hPubStartPerformed()";
     try {
       traceMethod.invoke(o, traceArgs);
     } catch (Exception x) {
     }
   }
   Thread newThread = new Thread(this);
   newThread.start();
 }
 /** event driven processing methods */
 public void hPubStartPerformed(HPubStartEvent evt) {
   if (tracing == true) {
     traceArgs[0] = this;
     traceArgs[1] = "WitnessInformationIndexClear_Access.hPubStartPerformed()";
     try {
       traceMethod.invoke(o, traceArgs);
     } catch (Exception x) {
     }
   }
   Thread newThread = new Thread(this);
   newThread.start();
 }
Exemple #11
0
  private void callMethodForParam(HttpServletRequest req, HttpServletResponse resp)
      throws Exception {
    String pinfo = req.getPathInfo();
    int pos = pinfo.indexOf('.');
    String cname = pinfo.substring(1, pos).replace('/', '.');
    String mname = pinfo.substring(pos + 1);

    int argc = 0;
    while (req.getParameter("a" + argc) != null) argc++;

    Class clazz = Class.forName(cname);
    Method method = null;
    Method[] methods = clazz.getMethods();
    for (int i = 0; i < methods.length; i++) {
      if (methods[i].getParameterTypes().length == argc && mname.equals(methods[i].getName())) {
        method = methods[i];
      }
    }
    if (method == null) {
      throw new RuntimeException("Not found method " + mname + "(" + argc + "args)");
    }

    Object[] args = new Object[argc];
    Class[] types = method.getParameterTypes();
    if (types != null) {
      for (int i = 0; i < types.length; i++) {
        args[i] = toArg(types[i], req.getParameter("a" + i));
      }
    }

    Object result = method.invoke(null, args);

    resp.setContentType(MIME_JSON);
    OutputStream out = resp.getOutputStream();
    out.write("{\"result\":".getBytes("UTF-8"));
    new JSONSerializer().serialize(result, out);
    out.write("}".getBytes("UTF-8"));
    out.flush();
  }
  public CrownCounselIndexGetList_Properties processWSRequest(
      CrownCounselIndexGetList_Properties props) throws BeanException {

    if (tracing == true) {
      traceArgs[0] = this;
      traceArgs[1] =
          "CrownCounselIndexGetList_Access.processWSRequest(CrownCounselIndexGetList_Properties)";
      try {
        traceMethod.invoke(o, traceArgs);
      } catch (Exception x) {
      }
    }
    fixNullInputsForSOAP(props);

    inputProps = props;
    setHPubAccessHandleString(inputProps.getHPubAccessHandle());

    try {
      startHereCommon();
    } catch (BeanException e) {
      // remove the ejb instance if handle exists
      if (ejb != null) {
        try {
          ejb.remove();
        } catch (Exception x) {
        }
        ejb = null;
      }

      // go set error fields
      setupErrorFields(e);

      throw e;
    }
    outputProps.setHPubAccessHandle(getHPubAccessHandleString());
    fixNullOutputsForSOAP(outputProps);
    return outputProps;
  }
 private void endHereCommon() throws BeanException {
   // save EJB object handle in property
   if (ejb != null) {
     try {
       hPubAccessHandle = ejb.getHandle();
     } catch (Exception e) {
       String errMsg =
           (new Date(System.currentTimeMillis())).toString()
               + " HPS5955 "
               + this.getClass().getName()
               + ": ejb.getHandle(), ejb="
               + ejb
               + ": "
               + e.getClass().getName()
               + ": "
               + e.getMessage();
       System.err.println(errMsg);
       if (tracing == true) {
         traceArgs[0] = this;
         traceArgs[1] = errMsg;
         try {
           traceMethod.invoke(o, traceArgs);
         } catch (Exception x) {
         }
       }
       throw new BeanException(errMsg);
     }
   }
   // save ejb accessHandle and hpubLinkKey in HttpSession
   if ((oHttpServletRequest != null) && (outputProps != null)) {
     // a new HPubEjb2HttpSessionBindingListener object containing the ejb access
     // handle and hPubLinkKey for the connection is bound to the session using
     // a prefix and the ending connection state of the IO just processed.
     // This hPubLinkKey uniquely identifies the connection associated with the
     // IO chain for that HP Runtime JVM.
     // The ejb access handle is contained within the HPubEjb2HttpSessionBindingListener
     // object so that an ejb remove can be issued in the case where a session
     // timeout or session invalidation occurs for an incomplete IO chain.
     HttpSession theWebsession = oHttpServletRequest.getSession(true);
     if (theWebsession != null) {
       synchronized (theWebsession) {
         try {
           String theKey = KEY_WEBCONN + outputProps.getHPubEndChainName();
           hPubLinkKey = outputProps.getHPubLinkKey();
           theWebsession.setAttribute(
               theKey, new HPubEJB2HttpSessionBindingListener(hPubAccessHandle, hPubLinkKey));
           if (tracing == true) {
             traceArgs[0] = this;
             traceArgs[1] =
                 "theWebsession.setAttribute("
                     + theKey
                     + ",new HPubEJB2HttpSessionBindingListener("
                     + hPubAccessHandle
                     + ", "
                     + hPubLinkKey
                     + "))";
             try {
               traceMethod.invoke(o, traceArgs);
             } catch (Exception x) {
             }
           }
           if (auditing == true) {
             auditArgs[0] =
                 "\n---\nIN:"
                     + this.getClass().getName()
                     + " "
                     + theKey
                     + " "
                     + hPubAccessHandle
                     + " "
                     + hPubLinkKey
                     + " "
                     + theWebsession.getId();
             auditArgs[1] = theWebsession;
             try {
               auditMethod.invoke(o, auditArgs);
             } catch (Exception x) {
             }
           }
         } catch (Exception e) {
           hPubLinkKey = null; // set to null to force following error logic
         }
       }
     }
     // if an error occurred throw an exception to cause ejb remove to be issued.
     if ((theWebsession == null) || (hPubLinkKey == null)) {
       String errMsg =
           (new Date(System.currentTimeMillis())).toString()
               + " HPS5956 "
               + this.getClass().getName()
               + ": HttpServletRequest.getSession(true), hPubLinkKey="
               + hPubLinkKey;
       System.err.println(errMsg);
       if (tracing == true) {
         traceArgs[0] = this;
         traceArgs[1] = errMsg;
         try {
           traceMethod.invoke(o, traceArgs);
         } catch (Exception x) {
         }
       }
       throw new BeanException(errMsg);
     }
   }
   // send Event to User indicating that the Query request is complete
   RequestCompleteEvent hPubEvent = new RequestCompleteEvent(this);
   fireHPubReqCompleteEvent(hPubEvent);
   return;
 }
  /** all processing methods end up here */
  private void startHereCommon() throws BeanException {
    // try to get the linkKey if already set in input properties
    try {
      hPubLinkKey = inputProps.getHPubLinkKey();
    } catch (Exception e) {
    }

    // if running in Web environment and either the ejb access handle or
    // the linkKey are null, try to get them from the HttpSession
    if (oHttpServletRequest != null) {
      HttpSession theWebsession = oHttpServletRequest.getSession(false);
      if (theWebsession != null) {
        synchronized (theWebsession) {
          try {
            if (tracing == true) {
              traceArgs[0] = this;
              traceArgs[1] = "HttpSession.getId()=" + theWebsession.getId();
              try {
                traceMethod.invoke(o, traceArgs);
              } catch (Exception x) {
              }
            }
            String theKey = KEY_WEBCONN + inputProps.getHPubStartChainName();
            // if linkKey or access handle is null try to get it from Websession
            HPubEJB2HttpSessionBindingListener sbl =
                (HPubEJB2HttpSessionBindingListener) theWebsession.getAttribute(theKey);
            if ((hPubLinkKey == null) && (sbl != null)) {
              hPubLinkKey = sbl.getLinkKey();
              if (tracing == true) {
                traceArgs[0] = this;
                traceArgs[1] = "HttpSession.getAttribute(hPubLinkKey)=" + hPubLinkKey;
                try {
                  traceMethod.invoke(o, traceArgs);
                } catch (Exception x) {
                }
              }
              inputProps.setHPubLinkKey(hPubLinkKey);
            }
            if ((hPubAccessHandle == null) && (sbl != null)) {
              hPubAccessHandle = sbl.getEjbHandle();
              if (tracing == true) {
                traceArgs[0] = this;
                traceArgs[1] = "HttpSession.getAttribute(hPubAccessHandle)=" + hPubAccessHandle;
                try {
                  traceMethod.invoke(o, traceArgs);
                } catch (Exception x) {
                }
              }
            }
            // set the ejb handle to null before removing the Session Binding
            // Listener object
            if (auditing == true) {
              if (sbl != null)
                auditArgs[0] =
                    "\n---\nOUT:"
                        + this.getClass().getName()
                        + " "
                        + theKey
                        + " "
                        + hPubAccessHandle
                        + " "
                        + hPubLinkKey
                        + " "
                        + theWebsession.getId();
              else // error - object not found in HttpSession
              auditArgs[0] =
                    "\n---\nERR:"
                        + this.getClass().getName()
                        + " "
                        + theKey
                        + " "
                        + theWebsession.getId();

              auditArgs[1] = theWebsession;
              try {
                auditMethod.invoke(o, auditArgs);
              } catch (Exception x) {
              }
            }
            if (sbl != null) sbl.setEjbHandle(null);
            theWebsession.removeAttribute(theKey);
          } catch (IllegalStateException e) {
          }
        }
      }
    }
    // if either of required properties are still null then the ejb cannot
    // be accessed - throw an exception.
    if ((hPubAccessHandle == null) || (hPubLinkKey == null)) {
      String errMsg =
          (new Date(System.currentTimeMillis())).toString()
              + " HPS5951 "
              + this.getClass().getName()
              + ": hPubAccessHandle==null || hPubLinkKey==null";
      System.err.println(errMsg);
      if (tracing == true) {
        traceArgs[0] = this;
        traceArgs[1] = errMsg;
        try {
          traceMethod.invoke(o, traceArgs);
        } catch (Exception x) {
        }
      }
      throw new BeanException(errMsg);
    } else {
      if (tracing == true) {
        traceArgs[0] = this;
        traceArgs[1] = "hPubAccessHandle=" + hPubAccessHandle + ",hPubLinkKey=" + hPubLinkKey;
        try {
          traceMethod.invoke(o, traceArgs);
        } catch (Exception x) {
        }
      }
    }

    // get the EJB object from the handle
    try {
      ejb =
          (com.ibm.HostPublisher.EJB.HPubEJB2)
              javax.rmi.PortableRemoteObject.narrow(
                  hPubAccessHandle.getEJBObject(), com.ibm.HostPublisher.EJB.HPubEJB2.class);
    } catch (Exception e) {
      String errMsg =
          (new Date(System.currentTimeMillis())).toString()
              + " HPS5952 "
              + this.getClass().getName()
              + ": getEJBObject(): "
              + e.getClass().getName()
              + ": "
              + e.getMessage();
      System.err.println(errMsg);
      if (tracing == true) {
        traceArgs[0] = this;
        traceArgs[1] = errMsg;
        try {
          traceMethod.invoke(o, traceArgs);
        } catch (Exception x) {
        }
      }
      throw new BeanException(errMsg);
    }
    // if ejb handle, go invoke the HPubEJB's main business method.
    if (ejb != null) {
      try {
        outputProps = (CrownCounselIndexGetList_Properties) ejb.processIO(inputProps);
        inputProps = outputProps;
        inputProps.setInitialCall(false);
      } catch (Exception e) {
        String errMsg =
            (new Date(System.currentTimeMillis())).toString()
                + " HPS5953 "
                + this.getClass().getName()
                + ": processIO("
                + inputProps.getClass().getName()
                + "): "
                + e.getClass().getName()
                + ": "
                + e.getMessage();
        System.err.println(errMsg);
        if (tracing == true) {
          traceArgs[0] = this;
          traceArgs[1] = errMsg;
          try {
            traceMethod.invoke(o, traceArgs);
          } catch (Exception x) {
          }
        }
        throw new BeanException(errMsg);
      }
    }
    endHereCommon();
    return;
  }
  /**
   * Processes the request coming to the servlet and grabs the attributes set by the servlet and
   * uses them to fire off pre-determined methods set in the setupActionMethods function of the
   * servlet.
   *
   * @param request the http request coming from the browser.
   * @param response the http response going to the browser.
   * @throws javax.servlet.ServletException
   * @throws java.io.IOException
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    if (!actionInitialized) {
      LogController.write(this, "This dispatcher servlet is not initialized properly!");
      return;
    }

    if (actionTag == null) {
      LogController.write(this, "There is no action attribute tag name!");
      return;
    }

    HttpSession httpSession = request.getSession();
    UserSession userSession = (UserSession) httpSession.getAttribute("user_session");

    if (userSession == null) {
      LogController.write(this, "User session is no longer available in this http session.");

      userSession = new UserSession();

      // We always want a user session though...
      httpSession.setAttribute("user_session", userSession);
    }

    String action = (String) request.getAttribute(actionTag);

    try {
      if (action == null) {
        // There is no action attribute specified, check parameters.
        String external_action = (String) request.getParameter(actionTag);

        if (external_action != null) {
          Method method = externalActions.get(external_action);

          if (method != null) {
            LogController.write(this, "Performing external action: " + external_action);
            method.invoke(this, new Object[] {userSession, request, response});
          } else {
            if (defaultExternalMethod != null) {
              LogController.write(this, "Performing default external action.");
              defaultExternalMethod.invoke(this, new Object[] {userSession, request, response});
            } else {
              LogController.write(this, "Unable to perform default external action.");
            }
          }
        } else {
          if (defaultExternalMethod != null) {
            LogController.write(this, "Performing default external action.");
            defaultExternalMethod.invoke(this, new Object[] {userSession, request, response});
          } else {
            LogController.write(this, "Unable to perform default external action.");
          }
        }
      } else {
        Method method = internalActions.get(action);

        if (method != null) {
          LogController.write(this, "Performing internal action: " + action);
          method.invoke(this, new Object[] {userSession, request, response});
        } else {
          if (defaultInternalMethod != null) {
            LogController.write(this, "Performing default internal action.");
            defaultInternalMethod.invoke(this, new Object[] {userSession, request, response});
          } else {
            LogController.write(this, "Unable to perform default internal action.");
          }
        }

        request.removeAttribute("application_action");
      }
    } catch (IllegalAccessException accessEx) {
      LogController.write(this, "Exception while processing request: " + accessEx.getMessage());
    } catch (InvocationTargetException invokeEx) {
      LogController.write(this, "Exception while processing request: " + invokeEx.toString());
      invokeEx.printStackTrace();
    } catch (Exception ex) {
      LogController.write(this, "Unknown exception: " + ex.toString());
    }
  }
Exemple #16
0
  private void printComponentTree(
      PrintWriter out, String errorId, FacesContext context, UIComponent comp, int depth) {
    for (int i = 0; i < depth; i++) out.print(' ');

    boolean isError = false;
    if (errorId != null && errorId.equals(comp.getClientId(context))) {
      isError = true;
      out.print("<span style='color:red'>");
    }

    out.print("&lt;" + comp.getClass().getSimpleName());
    if (comp.getId() != null) out.print(" id=\"" + comp.getId() + "\"");

    for (Method method : comp.getClass().getMethods()) {
      if (!method.getName().startsWith("get") && !method.getName().startsWith("is")) continue;
      else if (method.getParameterTypes().length != 0) continue;

      String name;

      if (method.getName().startsWith("get")) name = method.getName().substring(3);
      else if (method.getName().startsWith("is")) name = method.getName().substring(2);
      else continue;

      // XXX: getURL
      name = Character.toLowerCase(name.charAt(0)) + name.substring(1);

      ValueExpression expr = comp.getValueExpression(name);

      Class type = method.getReturnType();

      if (expr != null) {
        out.print(" " + name + "=\"" + expr.getExpressionString() + "\"");
      } else if (method.getDeclaringClass().equals(UIComponent.class)
          || method.getDeclaringClass().equals(UIComponentBase.class)) {
      } else if (name.equals("family")) {
      } else if (String.class.equals(type)) {
        try {
          Object value = method.invoke(comp);

          if (value != null) out.print(" " + name + "=\"" + value + "\"");
        } catch (Exception e) {
        }
      }
    }

    int facetCount = comp.getFacetCount();
    int childCount = comp.getChildCount();

    if (facetCount == 0 && childCount == 0) {
      out.print("/>");

      if (isError) out.print("</span>");

      out.println();
      return;
    }
    out.println(">");

    if (isError) out.print("</span>");

    for (int i = 0; i < childCount; i++) {
      printComponentTree(out, errorId, context, comp.getChildren().get(i), depth + 1);
    }

    for (int i = 0; i < depth; i++) out.print(' ');

    if (isError) out.print("<span style='color:red'>");

    out.println("&lt;/" + comp.getClass().getSimpleName() + ">");

    if (isError) out.print("</span>");
  }