Package play.vfs

Examples of play.vfs.VirtualFile


        }
    }

    public void serveStatic(HttpServletResponse servletResponse, HttpServletRequest servletRequest, RenderStatic renderStatic) throws IOException {

        VirtualFile file = Play.getVirtualFile(renderStatic.file);
        if (file == null || file.isDirectory() || !file.exists()) {
            serve404(servletRequest, servletResponse, new NotFound("The file " + renderStatic.file + " does not exist"));
        } else {
            servletResponse.setContentType(MimeTypes.getContentType(file.getName()));
            boolean raw = Play.pluginCollection.serveStatic(file, Request.current(), Response.current());
            if (raw) {
                copyResponse(Request.current(), Response.current(), servletRequest, servletResponse);
            } else {
                if (Play.mode == Play.Mode.DEV) {
                    servletResponse.setHeader("Cache-Control", "no-cache");
                    servletResponse.setHeader("Content-Length", String.valueOf(file.length()));
                    if (!servletRequest.getMethod().equals("HEAD")) {
                        copyStream(servletResponse, file.inputstream());
                    } else {
                        copyStream(servletResponse, new ByteArrayInputStream(new byte[0]));
                    }
                } else {
                    long last = file.lastModified();
                    String etag = "\"" + last + "-" + file.hashCode() + "\"";
                    if (!isModified(etag, last, servletRequest)) {
                        servletResponse.setHeader("Etag", etag);
                        servletResponse.setStatus(304);
                    } else {
                        servletResponse.setHeader("Last-Modified", Utils.getHttpDateFormatter().format(new Date(last)));
                        servletResponse.setHeader("Cache-Control", "max-age=" + Play.configuration.getProperty("http.cacheControl", "3600"));
                        servletResponse.setHeader("Etag", etag);
                        copyStream(servletResponse, file.inputstream());
                    }
                }
            }
        }
    }
View Full Code Here


    String fileContentString = null;

    try {

      VirtualFile vf = VirtualFile.fromRelativePath(filePath);
      File realFile = vf.getRealFile();
      fileContentString = FileUtils.readFileToString(realFile);

      models.utils.LogUtils.printLogNormal("Completed read file with file size: "
          + fileContentString.toString().length()
          / VarUtils.CONVERSION_1024 + " KB. Path: " + filePath
View Full Code Here

    List<String> fileNameList = new ArrayList<String>();

    try {

      VirtualFile virtualDir = VirtualFile.fromRelativePath(folderName);
      List<VirtualFile> virtualFileList = virtualDir.list();

      if (virtualFileList == null) {
         models.utils.LogUtils.printLogError
             ("virtualFileList is NULL! in getFileNamesInFolder()"
                + DateUtils.getNowDateTimeStrSdsm());
View Full Code Here

      dirNames = new ArrayList<String>();
    }

    try {

      VirtualFile virtualDir = VirtualFile.fromRelativePath(folderName);
      List<VirtualFile> virtualFileList = virtualDir.list();

      if (virtualFileList == null) {
         models.utils.LogUtils.printLogError
             ("virtualFileList is NULL! in getFileNamesInFolder()"
                + DateUtils.getNowDateTimeStrSdsm());
View Full Code Here

      return success;
    }

    try {

      VirtualFile virtualDir = VirtualFile.fromRelativePath(folderName);
      List<VirtualFile> virtualFileList = virtualDir.list();

      if (virtualFileList == null) {
         models.utils.LogUtils.printLogError
             ("virtualFileList is NULL! in getFileNamesInFolder()"
                + DateUtils.getNowDateTimeStrSdsm());
View Full Code Here

            Messages.defaults.putAll(IO.readUtf8Properties(is));
        } catch(Exception e) {
            Logger.warn("Defaults messsages file missing");
        }
        for(VirtualFile module : Play.modules.values()) {
            VirtualFile messages = module.child("conf/messages");
            if(messages != null && messages.exists()) {
                Messages.defaults.putAll(read(messages));
            }
        }
        VirtualFile appDM = Play.getVirtualFile("conf/messages");
        if(appDM != null && appDM.exists()) {
            Messages.defaults.putAll(read(appDM));
        }
        for (String locale : Play.langs) {
            Properties properties = new Properties();
            for(VirtualFile module : Play.modules.values()) {
                VirtualFile messages = module.child("conf/messages." + locale);
                if(messages != null && messages.exists()) {
                    properties.putAll(read(messages));
                }
            }
            VirtualFile appM = Play.getVirtualFile("conf/messages." + locale);
            if(appM != null && appM.exists()) {
                properties.putAll(read(appM));
            } else {
                Logger.warn("Messages file missing for locale %s", locale);
            }    
            Messages.locales.put(locale, properties);
View Full Code Here

    // Play.configuration.getProperty("agentmaster.nodegroup.conf.file.location");

    // in test
    try {

      VirtualFile vf = VirtualFile.fromRelativePath(filePath);
      File realFile = vf.getRealFile();

      boolean append = false;
      FileWriter fw = new FileWriter(realFile, append);
      fw.write(fileContent);
View Full Code Here

        Template template = null;
        for (VirtualFile vf : Play.templatesPath) {
            if (vf == null) {
                continue;
            }
            VirtualFile tf = vf.child(path);
            if (tf.exists()) {
                template = TemplateLoader.load(tf);
                break;
            }
        }
        /*
        if (template == null) {
        //When using the old 'key = (file.relativePath().hashCode() + "").replace("-", "M");',
        //the next line never return anything, since all values written to templates is using the
        //above key.
        //when using just file.relativePath() as key, the next line start returning stuff..
        //therefor I have commented it out.
        template = templates.get(path);
        }
         */
        //TODO: remove ?
        if (template == null) {
            VirtualFile tf = Play.getVirtualFile(path);
            if (tf != null && tf.exists()) {
                template = TemplateLoader.load(tf);
            } else {
                throw new TemplateNotFoundException(path);
            }
        }
View Full Code Here

        List<Template> res = new ArrayList<Template>();
        for (VirtualFile virtualFile : Play.templatesPath) {
            scan(res, virtualFile);
        }
        for (VirtualFile root : Play.roots) {
            VirtualFile vf = root.child("conf/routes");
            if (vf != null && vf.exists()) {
                Template template = load(vf);
                if (template != null) {
                    template.compile();
                }
            }
View Full Code Here

        if (fileName.contains("$")) {
            fileName = fileName.substring(0, fileName.indexOf("$"));
        }
        fileName = fileName.replace(".", "/") + ".java";
        for (VirtualFile path : Play.javaPath) {
            VirtualFile javaFile = path.child(fileName);
            if (javaFile.exists()) {
                return javaFile;
            }
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of play.vfs.VirtualFile

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.