Beispiel #1
0
  public final String call() throws PageException {
    ThreadLocalPageContext.register(pc);
    pc.getRootOut().setAllowCompression(false); // make sure content is not compressed
    String str = null;
    try {
      _call(parent, pc);
    } finally {
      try {
        HttpServletResponseDummy rsp = (HttpServletResponseDummy) pc.getHttpServletResponse();

        String enc = ReqRspUtil.getCharacterEncoding(pc, rsp);
        // if(enc==null) enc="ISO-8859-1";

        pc.getOut().flush(); // make sure content is flushed

        ((ConfigImpl) pc.getConfig()).getFactory().releasePageContext(pc);
        str =
            IOUtil.toString(
                (new ByteArrayInputStream(baos.toByteArray())),
                enc); // TODO add support for none string content
      } catch (Throwable e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    return str;
  }
 /**
  * returns CongigWeb Implementtion
  *
  * @param realpath
  * @return ConfigWebImpl
  */
 protected ConfigWebImpl getConfigWebImpl(String realpath) {
   Iterator<String> it = initContextes.keySet().iterator();
   while (it.hasNext()) {
     ConfigWebImpl cw = ((CFMLFactoryImpl) initContextes.get(it.next())).getConfigWebImpl();
     if (ReqRspUtil.getRootPath(cw.getServletContext()).equals(realpath)) return cw;
   }
   return null;
 }
Beispiel #3
0
  @Override
  public void call(PageContext pc) throws PageException {
    try {
      pc.setSilent();
      InterfaceImpl interf = null;
      try {
        interf = newInstance(getPageSource().getComponentName(), false, new HashMap());
      } finally {
        pc.unsetSilent();
      }

      String qs = ReqRspUtil.getQueryString(pc.getHttpServletRequest());
      if (pc.getBasePageSource() == this.getPageSource() && pc.getConfig().debug())
        pc.getDebugger().setOutput(false);
      boolean isPost = pc.getHttpServletRequest().getMethod().equalsIgnoreCase("POST");

      // POST
      if (isPost) {
        // Soap
        if (ComponentPage.isSoap(pc))
          throw new ApplicationException(
              "can not instantiate interface ["
                  + this.getPageSource().getComponentName()
                  + "] as a component");
      }
      // GET
      else if (qs != null && qs.trim().equalsIgnoreCase("wsdl"))
        throw new ApplicationException(
            "can not instantiate interface ["
                + this.getPageSource().getComponentName()
                + "] as a component");

      // WDDX
      if (pc.urlFormScope().containsKey(KeyConstants._method))
        throw new ApplicationException(
            "can not instantiate interface ["
                + this.getPageSource().getComponentName()
                + "] as a component");

      // invoking via include
      if (pc.getTemplatePath().size() > 1) {
        throw new ApplicationException(
            "can not invoke interface [" + this.getPageSource().getComponentName() + "] as a page");
      }

      // DUMP
      // TODO component.setAccess(pc,Component.ACCESS_PUBLIC);
      String cdf = pc.getConfig().getComponentDumpTemplate();
      if (cdf != null && cdf.trim().length() > 0) {
        pc.variablesScope().set(KeyConstants._component, interf);
        pc.doInclude(cdf);
      } else
        pc.write(
            pc.getConfig()
                .getDefaultDumpWriter(DumpWriter.DEFAULT_RICH)
                .toString(pc, interf.toDumpData(pc, 9999, DumpUtil.toDumpProperties()), true));

    } catch (Throwable t) {
      throw Caster.toPageException(t); // Exception Handler.castAnd Stack(t, this, pc);
    }
  }