Package railo.runtime

Examples of railo.runtime.PageSource


      if(res.exists()) return res;
    return null;
  }
 
  public static PageSource getApplicationPageSourceRoot(PageContext pc, RefBoolean isCFC) {
    PageSource ps = ((PageContextImpl)pc).getPageSourceExisting("/"+Constants.APP_CFC);
    if(ps!=null) {
      isCFC.setValue(true);
        return ps;
    }
    ps = ((PageContextImpl)pc).getPageSourceExisting("/"+Constants.APP_CFM);
View Full Code Here


    return null;
  }
 

  public static PageSource getApplicationPageSourceCurr2Root(PageContext pc,PageSource requestedPage, RefBoolean isCFC) {
      PageSource res=requestedPage.getRealPage(Constants.APP_CFC);
      if(res.exists()) {
        isCFC.setValue(true);
        return res;
      }
      res=requestedPage.getRealPage(Constants.APP_CFM);
      if(res.exists()) return res;
     
      Array arr=railo.runtime.type.util.ListUtil.listToArrayRemoveEmpty(requestedPage.getFullRealpath(),"/");
    //Config config = pc.getConfig();
    String path;
    for(int i=arr.size()-1;i>0;i--) {
View Full Code Here

        sct.set(DO_STATUS_CODE, Caster.toBoolean(config.getErrorStatusCode()));
       
        // 500
        String template=config.getErrorTemplate(500);
        try {
            PageSource ps = ((PageContextImpl)pageContext).getPageSourceExisting(template);
            if(ps!=null) templates.set("500",ps.getDisplayPath());
            else templates.set("500","");
        } catch (PageException e) {
          templates.set("500","");
        }
        str.set("500",template);

        // 404
        template=config.getErrorTemplate(404);
        try {
            PageSource ps = ((PageContextImpl)pageContext).getPageSourceExisting(template);
            if(ps!=null) templates.set("404",ps.getDisplayPath());
            else templates.set("404","");
        } catch (PageException e) {
          templates.set("404","");
        }
        str.set("404",template);
View Full Code Here

    private void doGetComponent() throws PageException {
        Struct sct=new StructImpl();
        pageContext.setVariable(getString("admin",action,"returnVariable"),sct);
        // Base Component
        try {
            PageSource ps = ((PageContextImpl)pageContext).getPageSourceExisting(config.getBaseComponentTemplate());
            if(ps!=null) sct.set("baseComponentTemplate",ps.getDisplayPath());
            else sct.set("baseComponentTemplate","");
        } catch (PageException e) {
            sct.set("baseComponentTemplate","");
        }
        sct.set("strBaseComponentTemplate",config.getBaseComponentTemplate());
       
        // dump template
        try {
            PageSource ps = ((PageContextImpl)pageContext).getPageSourceExisting(config.getComponentDumpTemplate());
            if(ps!=null) sct.set("componentDumpTemplate",ps.getDisplayPath());
            else sct.set("componentDumpTemplate","");
        } catch (PageException e) {
            sct.set("componentDumpTemplate","");
        }
        sct.set("strComponentDumpTemplate",config.getComponentDumpTemplate());
View Full Code Here

   
    public PageSource getPageSourceExisting(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping, boolean onlyPhysicalExisting) {
        realPath=realPath.replace('\\','/');
        String lcRealPath = StringUtil.toLowerCase(realPath)+'/';
        Mapping mapping;
        PageSource ps;

        if(mappings!=null){
          for(int i=0;i<mappings.length;i++) {
              mapping = mappings[i];
              //print.err(lcRealPath+".startsWith"+(mapping.getStrPhysical()));
              if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
                ps= mapping.getPageSource(realPath.substring(mapping.getVirtual().length()));
                if(onlyPhysicalExisting) {
                  if(ps.physcalExists())return ps;
                }
                else if(ps.exists()) return ps;
              }
          }
        }
       
        /// special mappings
        if(useSpecialMappings && lcRealPath.startsWith("/mapping-",0)){
          String virtual="/mapping-tag";
          // tag mappings
          Mapping[] tagMappings=(this instanceof ConfigWebImpl)?new Mapping[]{((ConfigWebImpl)this).getServerTagMapping(),getTagMapping()}:new Mapping[]{getTagMapping()};
          if(lcRealPath.startsWith(virtual,0)){
            for(int i=0;i<tagMappings.length;i++) {
                mapping = tagMappings[i];
                //if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
                  ps = mapping.getPageSource(realPath.substring(virtual.length()));
                  if(onlyPhysicalExisting) {
                    if(ps.physcalExists())return ps;
                  }
                  else if(ps.exists()) return ps;
                //}
            }
          }
         
          // customtag mappings
          tagMappings=getCustomTagMappings();
          virtual="/mapping-customtag";
          if(lcRealPath.startsWith(virtual,0)){
            for(int i=0;i<tagMappings.length;i++) {
                mapping = tagMappings[i];
                //if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
                  ps = mapping.getPageSource(realPath.substring(virtual.length()));
                  if(onlyPhysicalExisting) {
                    if(ps.physcalExists())return ps;
                  }
                  else if(ps.exists()) return ps;
                //}
            }
          }
        }
       
        // component mappings (only used for gateway)
        if(pc!=null && ((PageContextImpl)pc).isGatewayContext()) {
          boolean isCFC=getCFCExtension().equalsIgnoreCase(ResourceUtil.getExtension(realPath, null));
            if(isCFC) {
            Mapping[] cmappings = getComponentMappings();
            for(int i=0;i<cmappings.length;i++) {
              ps = cmappings[i].getPageSource(realPath);
                if(onlyPhysicalExisting) {
                  if(ps.physcalExists())return ps;
                }
                else if(ps.exists()) return ps;
              }
          }
        }
       
        // config mappings
        for(int i=0;i<this.mappings.length-1;i++) {
            mapping = this.mappings[i];
            if((!onlyTopLevel || mapping.isTopLevel()) && lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
              ps= mapping.getPageSource(realPath.substring(mapping.getVirtual().length()));
              if(onlyPhysicalExisting) {
                if(ps.physcalExists())return ps;
              }
              else if(ps.exists()) return ps;
            }
        }
       
        if(useDefaultMapping){
          ps= this.mappings[this.mappings.length-1].getPageSource(realPath);
          if(onlyPhysicalExisting) {
            if(ps.physcalExists())return ps;
          }
          else if(ps.exists()) return ps;
        }
        return null;
    }
View Full Code Here

    public PageSource[] getPageSources(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping) {
        realPath=realPath.replace('\\','/');
        String lcRealPath = StringUtil.toLowerCase(realPath)+'/';
        Mapping mapping;

        PageSource ps;
        List<PageSource> list=new ArrayList<PageSource>();
     
        if(mappings!=null){
          for(int i=0;i<mappings.length;i++) {
              mapping = mappings[i];
              //print.err(lcRealPath+".startsWith"+(mapping.getStrPhysical()));
              if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
                list.add(mapping.getPageSource(realPath.substring(mapping.getVirtual().length())));
              }
          }
        }
       
        /// special mappings
        if(useSpecialMappings && lcRealPath.startsWith("/mapping-",0)){
          String virtual="/mapping-tag";
          // tag mappings
          Mapping[] tagMappings=(this instanceof ConfigWebImpl)?new Mapping[]{((ConfigWebImpl)this).getServerTagMapping(),getTagMapping()}:new Mapping[]{getTagMapping()};
          if(lcRealPath.startsWith(virtual,0)){
            for(int i=0;i<tagMappings.length;i++) {
                ps=tagMappings[i].getPageSource(realPath.substring(virtual.length()));
                if(ps.exists()) list.add(ps);
            }
          }
         
          // customtag mappings
          tagMappings=getCustomTagMappings();
          virtual="/mapping-customtag";
          if(lcRealPath.startsWith(virtual,0)){
            for(int i=0;i<tagMappings.length;i++) {
                ps=tagMappings[i].getPageSource(realPath.substring(virtual.length()));
                if(ps.exists()) list.add(ps);
            }
          }
        }
       
        // component mappings (only used for gateway)
        if(pc!=null && ((PageContextImpl)pc).isGatewayContext()) {
          boolean isCFC=getCFCExtension().equalsIgnoreCase(ResourceUtil.getExtension(realPath, null));
            if(isCFC) {
            Mapping[] cmappings = getComponentMappings();
            for(int i=0;i<cmappings.length;i++) {
              ps=cmappings[i].getPageSource(realPath);
              if(ps.exists()) list.add(ps);
              }
          }
        }
       
        // config mappings
View Full Code Here

 
  public Page getCachedPage(PageContext pc,String pathWithCFC) throws PageException {
    if(componentPathCache==null) return null;
   
    PageSource ps = componentPathCache.get(pathWithCFC.toLowerCase());
    if(ps==null) return null;
    return ((PageSourceImpl)ps).loadPage(pc,(Page)null);
  }
View Full Code Here

    Resource[] children = dir.listResources(FILTER);
   
    RestSettings settings = pc.getApplicationContext().getRestSettings();
    ArrayList<Source> sources = new ArrayList<Source>();
 
    PageSource ps;
    ComponentAccess cfc;
    Struct meta;
    String path;
    for(int i=0;i<children.length;i++){
      try{
View Full Code Here

      String cp = SystemUtil.addPlaceHolder(res, null);
      if(!StringUtil.isEmpty(cp))return cp;
    }
   
    //Config config=pc.getConfig();
    PageSource ps = pc.toPageSource(res,null);
    if(ps==null) return absPath;
   
    String realPath = ps.getRealpath();
    realPath=realPath.replace('\\', '/');
    if(StringUtil.endsWith(realPath,'/'))realPath=realPath.substring(0,realPath.length()-1);
   
    String mapping=ps.getMapping().getVirtual();
    mapping=mapping.replace('\\', '/');
    if(StringUtil.endsWith(mapping,'/'))mapping=mapping.substring(0,mapping.length()-1);
   
    return mapping+realPath;
  }
View Full Code Here

        Object parameters=null;
        try {
            cfc="/"+serviceName.replace('.','/')+".cfc";
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            pc=createPageContext(factory,cfc,"method="+serviceMethodName,baos,req);
            PageSource source = ((PageContextImpl)pc).getPageSourceExisting(cfc);

            if(caster==null)caster=((ConfigImpl)pc.getConfig()).getAMFCaster(configMap);
            parameters=caster.toCFMLObject(rawParams);
          if(source!=null) {
            print(pc,cfc+"?method="+serviceMethodName);
              // Map
              //print.err(parameters);
            if(parameters instanceof Map){
              //print.err("map");
                pc.getHttpServletRequest().setAttribute("argumentCollection", parameters);
              }
            // List
              else if(parameters instanceof List){
                //print.err("list");
                pc.getHttpServletRequest().setAttribute("argumentCollection", parameters);
              }
              else {
                ArrayList list = new ArrayList();
                list.add(parameters);
                pc.getHttpServletRequest().setAttribute("argumentCollection", list);
               
              }
             
                // Execute
                pc.execute(cfc,true);

                // write back response
                writeBackResponse(pc,rsp);
               
                // After
              return caster.toAMFObject(pc.variablesScope().get(AMF_FORWARD,null));
             
            }
        }
        finally {
            if(pc!=null)factory.releaseRailoPageContext(pc);
        }   
       
     // CFML Files
        String cfml;
        try {
            cfml="/"+(serviceName.replace('.','/')+'/'+serviceMethodName.replace('.','/'))+".cfm";
            pc=createPageContext(factory,cfml,"",null,req);
            PageSource source = ((PageContextImpl)pc).getPageSourceExisting(cfml);
           
            if(source!=null) {
              print(pc,cfml);
              // Before
                Struct params=new StructImpl();
View Full Code Here

TOP

Related Classes of railo.runtime.PageSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.