Package org.olat.core.gui.media

Examples of org.olat.core.gui.media.NotFoundMediaResource


      public MediaResource handle(String relPath,
          HttpServletRequest request) {
        VFSItem vfsItem = cssBaseContainer.resolve(relPath);
        MediaResource mr;
        if (vfsItem == null || !(vfsItem instanceof VFSLeaf))
          mr = new NotFoundMediaResource(relPath);
        else
          mr = new VFSMediaResource((VFSLeaf) vfsItem);
        return mr;
      }
    };
View Full Code Here


    if (pathInfo == null) {
      // huh? What's this, send not found, don't know what to do here
      if (isLogDebugEnabled()) {
        logDebug("PathInfo is null for static request URI::" + request.getRequestURI(), null);
      }
      ServletUtil.serveResource(request, response, new NotFoundMediaResource("error"));
      return;
    }
    // remove uri prefix and version from request if available
    String staticRelPath = null;
    if (pathInfo.indexOf(NOVERSION) != -1) {
      // no version provided - only remove mapper
      staticRelPath = pathInfo.substring(mapperPath.length() + 1 + NOVERSION.length(), pathInfo.length());
    }
    else {
      // version provided - remove it
      String version = Settings.getVersionId();
      staticRelPath = pathInfo.substring(mapperPath.length() + 1 + version.length(), pathInfo.length());
    }
   
    // remove any .. in the path
    String normalizedRelPath = normalizePath(staticRelPath);
    if (normalizedRelPath == null) {
      if (isLogDebugEnabled()) {
        logDebug("Path is null after noralizing for static request URI::" + request.getRequestURI(), null);
      }
      ServletUtil.serveResource(request, response, new NotFoundMediaResource("error"));
      return;
    }
    // create the file from the path
    String staticAbsPath = WebappHelper.getContextRoot() + STATIC_DIR_NAME + normalizedRelPath;
    File staticFile = new File(staticAbsPath);
    // only serve if file exists
    if (!staticFile.exists()) {
      if (isLogDebugEnabled()) {
        logDebug("File does not exist for URI::" + request.getRequestURI(), null);
      }
      // try fallback without version ID
      staticRelPath = pathInfo.substring(mapperPath.length() , pathInfo.length());
      normalizedRelPath = normalizePath(staticRelPath);
      staticAbsPath = WebappHelper.getContextRoot() + STATIC_DIR_NAME + normalizedRelPath;
      staticFile = new File(staticAbsPath);
      if (!staticFile.exists()) {
        ServletUtil.serveResource(request, response, new NotFoundMediaResource("error"));
        return;
      }
      // log as error, file exists but wrongly mapped
      logWarn("File exists but not mapped using version - use StaticMediaDispatch methods to create URL of static files! invalid URI::" + request.getRequestURI(), null);     
    }
View Full Code Here

            mr = new ClasspathMediaResource(Package.getPackage(bundleName), ContextHelpModule.CHELP_STATIC_DIR + fileName);           
          }
        }
        // If not even a fallback image is found, serve a not-found resource
        if (!mr.resourceExists()) {
          return new NotFoundMediaResource(relPath);
        }
        return mr;
      }
    };
    // we use user scope mappers because global mappers can only be instantiated once
View Full Code Here

  private Mapper createMapper(final VFSContainer rootContainer) {
    Mapper map = new Mapper() {
      public MediaResource handle(String relPath,HttpServletRequest request) {
        VFSItem currentItem = rootContainer.resolve(relPath);
        if (currentItem == null || (currentItem instanceof VFSContainer)) {
          return new NotFoundMediaResource(relPath);
        }
        return new VFSMediaResource((VFSLeaf)currentItem);
      }
    };
    return map;
View Full Code Here

        // Mapper is cleaned up automatically by basic controller
        String baseUrl = registerMapper(new Mapper() {
          public MediaResource handle(String relPath, HttpServletRequest request) {
            VFSLeaf vfsfile = (VFSLeaf) folderComponent.getRootContainer().resolve(relPath);
            if (vfsfile == null) {
              return new NotFoundMediaResource(relPath);
            } else {
              return new VFSMediaResource(vfsfile);
            }
          }
        });
View Full Code Here

    VFSLeaf vfsfile = (VFSLeaf)folderComponent.getRootContainer().resolve(path);
   
   
   
    if (vfsfile == null) {
      mr = new NotFoundMediaResource(path);
    } else {
      if (path.toLowerCase().endsWith(".html") || path.toLowerCase().endsWith(".htm")) {
        // setCurrentURI(path);
        // set the http content-type and the encoding
        // try to load in iso-8859-1
View Full Code Here

    MediaResource mr;
    VFSLeaf vfsLeaf = null;
    VFSItem vfsItem = null;
    //if directory gets renamed root becomes null
    if (rootDir == null) {
      return new NotFoundMediaResource("directory not found"+path);
    } else {
      vfsItem = rootDir.resolve(path);
    }
    //only files are allowed, but somehow it happened that folders showed up here
    if (vfsItem instanceof VFSLeaf) {
      vfsLeaf = (VFSLeaf) rootDir.resolve(path);
    } else {
      mr = new NotFoundMediaResource(path);
    }
    if (vfsLeaf == null) {
      mr = new NotFoundMediaResource(path);
    } else {
      // check if path ends with .html, .htm or .xhtml. We do this by searching for "htm"
      // and accept positions of this string at length-3 or length-4
      if (path.toLowerCase().lastIndexOf(FILE_SUFFIX_HTM) >= (path.length()-4)) {
        // set the http content-type and the encoding
View Full Code Here

      // -> ok, userrequest class asserts this.

      VFSItem sourceItem = rootContainer.resolve(moduleURI);
      // return 404 if the requested file does not exist
      if (sourceItem == null || (sourceItem instanceof VFSContainer)) {
        return new NotFoundMediaResource(moduleURI);
      }
      // we know the file exists.
     
      boolean checkRegular = true;
      // check for special case: render the follwing link in a new (server) window and all following clicks as well
View Full Code Here

    Mapper map = new Mapper() {
      public MediaResource handle(String relPath, HttpServletRequest request) {
        Tracing.logDebug("CPComponent Mapper relPath=" + relPath,HtmlStaticPageComponent.class);
        VFSItem currentItem = mapperRootContainer.resolve(relPath);
        if (currentItem == null || (currentItem instanceof VFSContainer)) {
          return new NotFoundMediaResource(relPath);
        }
        VFSMediaResource vmr = new VFSMediaResource((VFSLeaf)currentItem);
        String encoding = SimpleHtmlParser.extractHTMLCharset(((VFSLeaf)currentItem));
        Tracing.logDebug("CPComponent Mapper set encoding=" + encoding,HtmlStaticPageComponent.class);
        vmr.setEncoding(encoding);//
View Full Code Here

    Mapper contentMapper = new Mapper() {

      public MediaResource handle(String relPath, HttpServletRequest request) {
        VFSItem vfsItem = wikiContainer.resolve(relPath);
        MediaResource mr;
        if (vfsItem == null || !(vfsItem instanceof VFSLeaf)) mr = new NotFoundMediaResource(relPath);
        else mr = new VFSMediaResource((VFSLeaf) vfsItem);
        return mr;
      }
    };
    //datahandler.setImageURI(MapperRegistry.getInstanceFor(ureq.getUserSession()).register(contentMapper)+"/"+WikiContainer.MEDIA_FOLDER_NAME+"/");
View Full Code Here

TOP

Related Classes of org.olat.core.gui.media.NotFoundMediaResource

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.