コード例 #1
0
ファイル: SystemUtil.java プロジェクト: adamcameron/Lucee4
  public static String parsePlaceHolder(String path, ServletContext sc) {
    ResourceProvider frp = ResourcesImpl.getFileResourceProvider();

    if (path == null) return null;
    if (path.indexOf('{') != -1) {
      if (StringUtil.startsWith(path, '{')) {

        // Web Root
        if (path.startsWith("{web-root")) {
          if (path.startsWith("}", 9))
            path =
                frp.getResource(ReqRspUtil.getRootPath(sc))
                    .getRealResource(path.substring(10))
                    .toString();
          else if (path.startsWith("-dir}", 9))
            path =
                frp.getResource(ReqRspUtil.getRootPath(sc))
                    .getRealResource(path.substring(14))
                    .toString();
          else if (path.startsWith("-directory}", 9))
            path =
                frp.getResource(ReqRspUtil.getRootPath(sc))
                    .getRealResource(path.substring(20))
                    .toString();

        } else path = SystemUtil.parsePlaceHolder(path);
      }

      if ((path.indexOf("{web-context-hash}")) != -1) {
        String id = hash(sc);
        path = StringUtil.replace(path, "{web-context-hash}", id, false);
      }
    }
    return path;
  }