Package railo.commons.io.res

Examples of railo.commons.io.res.Resource


        body="<html><body><pre>"+HTMLEntities.escapeHTML(body)+"</pre></body></html>";
        pd4ml.render(body, os,null);
      }
      // image
      else if(mimetype==MIMETYPE_IMAGE) {
        Resource tmpDir= SystemUtil.getTempDirectory();
        Resource tmp = tmpDir.getRealResource(this+"-"+Math.random());
        IOUtil.copy(is, tmp,true);
        body="<html><body><img src=\"file://"+tmp+"\"></body></html>";
        try {
          pd4ml.render(body, os,null);
        }
        finally {
          tmp.delete();
       
      }
      // Application
      else if(mimetype==MIMETYPE_APPLICATION && "application/pdf".equals(strMimetype)) {
        IOUtil.copy(is, os,true,true);
View Full Code Here


        ResourceProvider fr = ResourcesImpl.getFileResourceProvider();
        if(pathes!=null) {
            String[] arr=ListUtil.toStringArrayEL(ListUtil.listToArray(pathes,File.pathSeparatorChar));
            for(int i=0;i<arr.length;i++) {   
                if(arr[i].toLowerCase().indexOf("windows\\system")!=-1) {
                    Resource file = fr.getResource(arr[i]);
                    if(file.exists() && file.isDirectory() && file.isWriteable()) return ResourceUtil.getCanonicalResourceEL(file);
                   
                }
            }
            for(int i=0;i<arr.length;i++) {   
                if(arr[i].toLowerCase().indexOf("windows")!=-1) {
                  Resource file = fr.getResource(arr[i]);
                    if(file.exists() && file.isDirectory() && file.isWriteable()) return ResourceUtil.getCanonicalResourceEL(file);
                   
                }
            }
            for(int i=0;i<arr.length;i++) {   
                if(arr[i].toLowerCase().indexOf("winnt")!=-1) {
                  Resource file = fr.getResource(arr[i]);
                    if(file.exists() && file.isDirectory() && file.isWriteable()) return ResourceUtil.getCanonicalResourceEL(file);
                   
                }
            }
            for(int i=0;i<arr.length;i++) {   
                if(arr[i].toLowerCase().indexOf("win")!=-1) {
                  Resource file = fr.getResource(arr[i]);
                    if(file.exists() && file.isDirectory() && file.isWriteable()) return ResourceUtil.getCanonicalResourceEL(file);
                   
                }
            }
            for(int i=0;i<arr.length;i++) {
              Resource file = fr.getResource(arr[i]);
                if(file.exists() && file.isDirectory() && file.isWriteable()) return ResourceUtil.getCanonicalResourceEL(file);
            }
        }
        return null;
    }
View Full Code Here

      String filename=CreateUniqueId.invoke();
      if(!StringUtil.isEmpty(extension,true)){
        if(extension.startsWith("."))filename+=extension;
        else filename+="."+extension;
      }
    Resource file = getTempDirectory().getRealResource(filename);
    if(touch)ResourceUtil.touch(file);
    return file;
  }
View Full Code Here

        ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
        // get all pathes
        URL[] urls=ucl.getURLs();
        for(int i=0;i<urls.length;i++) {
            Resource file=frp.getResource(urls[i].getPath());
            if(file.exists())
                pathes.add(ResourceUtil.getCanonicalResourceEL(file));
        }
       
    }
View Full Code Here

        String strPathes=System.getProperty("java.class.path");
        if(strPathes!=null) {
            Array arr=ListUtil.listToArrayRemoveEmpty(strPathes,pathSeperator);
            int len=arr.size();
            for(int i=1;i<=len;i++) {
                Resource file=frp.getResource(Caster.toString(arr.get(i,""),"").trim());
                if(file.exists())
                    pathes.add(ResourceUtil.getCanonicalResourceEL(file));
            }
        }
       
       
View Full Code Here

  public static String addPlaceHolder(Resource file,  Config config, String defaultValue) {
      //ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
     
        // temp
          Resource dir = config.getTempDirectory();
          String path = addPlaceHolder(dir,file,"{temp-directory}");
          if(!StringUtil.isEmpty(path)) return path;
             
        // Config
          dir = config.getConfigDir();
View Full Code Here

  }
 

  public static Resource[] download(Config config, String[] jars) throws IOException {
    List<Resource> list=new ArrayList<Resource>();
    Resource jar;
    lastCheck=-1;
    for(int i=0;i<jars.length;i++){
      jar=download(config, jars[i], WHEN_EXISTS_UPDATE);
      if(jar!=null) list.add(jar);
    }
View Full Code Here

    URL dataUrl=toURL(config,jarName);
       
    // destination file
    ClassLoader mainClassLoader = new TP().getClass().getClassLoader();
   
    Resource lib = config.getResource(CFMLEngineFactory.getClassLoaderRoot(mainClassLoader).getCanonicalPath());
     
    Resource jar=lib.getRealResource(jarName);
    SystemOut.printDate(out,"Check for jar at "+dataUrl);
        if(jar.exists()){
      if(whenExists==WHEN_EXISTS_RETURN_JAR) return jar;
      else if(whenExists==WHEN_EXISTS_RETURN_NULL) return null;
      else if(whenExists==WHEN_EXISTS_UPDATE) {
        // compare local and remote
        long localLen=jar.length();
        long remoteLengh=HTTPUtil.length(dataUrl);
        // only update when size change more than 10
        if(localLen==remoteLengh){
          SystemOut.printDate(out,"jar "+jar+" is up to date");
          return jar;
        }
        if(!jar.delete()) throw new IOException("cannot update jar ["+jar+"], jar is locked or write protected, stop the servlet engine and delete this jar manually.");
      }
      else throw new IOException("jar ["+jar+"] exists already");
    }
   
   
View Full Code Here

        }
       
       
        // create new file
        else if(res.length()>maxFileSize) {
            Resource parent = res.getParentResource();
            String name = res.getName();
            int lenMaxFileSize=(""+maxFiles).length();      
            for(int i=maxFiles;i>0;i--) {
             
                Resource to=parent.getRealResource(name+"."+StringUtil.addZeros(i, lenMaxFileSize)+".bak");
                Resource from=parent.getRealResource(name+"."+StringUtil.addZeros(i-1,lenMaxFileSize)+".bak");
                if(from.exists()) {
                    if(to.exists())to.delete();
                    from.renameTo(to);
                }
            }
            res.renameTo(parent.getRealResource(name+"."+StringUtil.addZeros(1,lenMaxFileSize)+".bak"));
            res=parent.getRealResource(name);//new File(parent,name);
            res.createNewFile();
View Full Code Here

      }
        return changed;
  }
 
  private static boolean exists(ConfigWeb config,String jarName) {
    Resource res = _toResource(config, jarName);
      if(res==null) return false;
      return res.exists();
    }
View Full Code Here

TOP

Related Classes of railo.commons.io.res.Resource

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.