Package railo.runtime

Examples of railo.runtime.Mapping


   
    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
        for(int i=0;i<this.mappings.length-1;i++) {
            mapping = this.mappings[i];
            if((!onlyTopLevel || mapping.isTopLevel()) && lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) {
              list.add(mapping.getPageSource(realPath.substring(mapping.getVirtual().length())));
            }
        }
       
        if(useDefaultMapping){
          list.add(this.mappings[this.mappings.length-1].getPageSource(realPath));
View Full Code Here


      if(ps==null) return null;
      return ps.getPhyscalFile();*/
    }

    public PageSource toPageSource(Mapping[] mappings, Resource res,PageSource defaultValue) {
        Mapping mapping;
        String path;
       
        // app-cfc mappings
        if(mappings!=null){
            for(int i=0;i<mappings.length;i++) {
                mapping = mappings[i];
               
            // Physical
               if(mapping.hasPhysical()) {
                 path=ResourceUtil.getPathToChild(res, mapping.getPhysical());
                   if(path!=null) {
                     return mapping.getPageSource(path);
                   }
               }
           // Archive
               if(mapping.hasArchive() && res.getResourceProvider() instanceof CompressResourceProvider) {
                 Resource archive = mapping.getArchive();
                 CompressResource cr = ((CompressResource) res);
                 if(archive.equals(cr.getCompressResource())) {
                   return mapping.getPageSource(cr.getCompressPath());
                 }
               }
            }
        }
       
        // config mappings
        for(int i=0;i<this.mappings.length;i++) {
            mapping = this.mappings[i];
             
         // Physical
            if(mapping.hasPhysical()) {
              path=ResourceUtil.getPathToChild(res, mapping.getPhysical());
                if(path!=null) {
                  return mapping.getPageSource(path);
                }
            }
        // Archive
            if(mapping.hasArchive() && res.getResourceProvider() instanceof CompressResourceProvider) {
            Resource archive = mapping.getArchive();
            CompressResource cr = ((CompressResource) res);
            if(archive.equals(cr.getCompressResource())) {
              return mapping.getPageSource(cr.getCompressPath());
            }
            }
        }
       
    // map resource to root mapping when same filesystem
        Mapping rootMapping = this.mappings[this.mappings.length-1];
        Resource root;
        if(rootMapping.hasPhysical() &&
            res.getResourceProvider().getScheme().equals((root=rootMapping.getPhysical()).getResourceProvider().getScheme())) {
         
          String realpath="";
          while(root!=null && !ResourceUtil.isChildOf(res, root)){
            root=root.getParentResource();
            realpath+="../";
          }
          String p2c=ResourceUtil.getPathToChild(res,root);
          if(StringUtil.startsWith(p2c, '/') || StringUtil.startsWith(p2c, '\\') )
            p2c=p2c.substring(1);
          realpath+=p2c;
         
          return rootMapping.getPageSource(realpath);
         
        }
        // MUST better impl than this
        if(this instanceof ConfigWebImpl) {
          Resource parent = res.getParentResource();
          if(parent!=null && !parent.equals(res)) {
            Mapping m = ((ConfigWebImpl)this).getApplicationMapping("/", parent.getAbsolutePath());
            return m.getPageSource(res.getName());
          }
        }
       
   
     // Archive
View Full Code Here

     * @param mappings The mappings to set.
     */
    protected void setMappings(Mapping[] mappings) {
        Arrays.sort(mappings,new Comparator(){
            public int compare(Object left, Object right) {
                Mapping r = ((Mapping)right);
              Mapping l = ((Mapping)left);
              int rtn=r.getVirtualLowerCaseWithSlash().length()-l.getVirtualLowerCaseWithSlash().length();
              if(rtn==0) return slashCount(r)-slashCount(l);
              return rtn;
            }

      private int slashCount(Mapping l) {
        String str=l.getVirtualLowerCaseWithSlash();
        int count=0,lastIndex=-1;
        while((lastIndex=str.indexOf('/', lastIndex))!=-1) {
          count++;
          lastIndex++;
        }
View Full Code Here

  public ORMConfiguration getORMConfig() {
    return ormConfig;
  }

  public Mapping createCustomTagAppMappings(String virtual, String physical) {
    Mapping m=customTagAppMappings.get(physical.toLowerCase());
   
    if(m==null){
      m=new MappingImpl(
        this,virtual,
        physical,
View Full Code Here

    // Server Mapping
    if (hasCS) {
      Mapping[] originals = ((ConfigServerImpl) configServer).getComponentMappings();
      Mapping[] clones = new Mapping[originals.length];
      LinkedHashMap map = new LinkedHashMap();
      Mapping m;
      for (int i = 0; i < clones.length; i++) {
        m = ((MappingImpl) originals[i]).cloneReadOnly(config);
        map.put(toKey(m), m);
        // clones[i]=((MappingImpl)m[i]).cloneReadOnly(config);
      }

      if (mappings != null) {
        for (int i = 0; i < mappings.length; i++) {
          m = mappings[i];
          map.put(toKey(m), m);
        }
      }
      if (originals.length > 0) {
        clones = new Mapping[map.size()];
        Iterator it = map.entrySet().iterator();
        Map.Entry entry;
        int index = 0;
        while (it.hasNext()) {
          entry = (Entry) it.next();
          clones[index++] = (Mapping) entry.getValue();
          // print.out("c:"+clones[index-1]);
        }
        hasSet = true;
        // print.err("set:"+clones.length);

        config.setComponentMappings(clones);
      }
    }

    if (!hasSet) {
      MappingImpl m = new MappingImpl(config, "/default", "{railo-web}/components/", null, ConfigImpl.INSPECT_UNDEFINED, true, false, false, true, false, true, null);
      config.setComponentMappings(new Mapping[] { m.cloneReadOnly(config) });
    }

  }
View Full Code Here

    ConfigWebImpl config = (ConfigWebImpl) pc.getConfig();
    String key=isweb?name.getString()+config.getId():name.getString();
      UDF udf=config.getFromFunctionCache(key);
    if(udf!=null) return udf;
   
    Mapping mapping=isweb?config.getFunctionMapping():config.getServerFunctionMapping();
      PageSourceImpl ps = (PageSourceImpl) mapping.getPageSource(filename);
      Page p = ps.loadPage(pc)
   
     
      // execute page
      Variables old = pc.variablesScope();
      pc.setVariablesScope(VAR);
      boolean wasSilent = pc.setSilent();
      try {
      p.call(pc);
      Object o= pc.variablesScope().get(name,null);
      if(o instanceof UDF) {
        udf= (UDF) o;
        config.putToFunctionCache(key, udf);
        return udf;
      }
      throw new ExpressionException("there is no Function defined with name ["+name+"] in template ["+mapping.getStrPhysical()+File.separator+filename+"]");
    }
      catch (Throwable t) {
      throw Caster.toPageException(t);
    }
    finally{
View Full Code Here

        else mappings=config.getMappings();
       
       
       
        for(int i=0;i<mappings.length;i++) {
            Mapping mapping = mappings[i];
            if(mapping.getVirtualLowerCaseWithSlash().equals(virtual)) {
              Map<String,String> errors = stoponerror?null:MapFactory.<String,String>getConcurrentMap();
                doCompileFile(mapping,mapping.getPhysical(),"",errors);
                if(errors!=null && errors.size()>0) {
                  StringBuilder sb=new StringBuilder();
                  Iterator<String> it = errors.keySet().iterator();
                  Object key;
                  while(it.hasNext()) {
View Full Code Here

      return getApplicationMapping(virtual, physical, null);
    }
   
    public Mapping getApplicationMapping(String virtual, String physical, String archive) {
      String key=virtual.toLowerCase()+physical.toLowerCase();
      Mapping m= applicationMappings.get(key);
      if(m==null){
        m=new MappingImpl(this,
          virtual,
          physical,
          archive,ConfigImpl.INSPECT_UNDEFINED,true,false,false,false,true,false,null
View Full Code Here

  }

  private void doCheckMappings(ConfigWeb config) {
        Mapping[] mappings = config.getMappings();
        for(int i=0;i<mappings.length;i++) {
            Mapping mapping = mappings[i];
            mapping.check();
        }
    }
View Full Code Here

TOP

Related Classes of railo.runtime.Mapping

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.