Package org.olat.core.gui.media

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


      else {
        // if an entry in a manifest points e.g. to a pdf file and the iframe
        // controller has not been initialized display it non-inline
        VFSItem currentItem = rootContainer.resolve(identifierRes);
        MediaResource mr;
        if (currentItem == null || !(currentItem instanceof VFSLeaf)) mr = new NotFoundMediaResource(identifierRes);
        else mr = new VFSMediaResource((VFSLeaf) currentItem);
        ureq.getDispatchResult().setResultingMediaResource(mr);
        // Prevent 'don't reload' warning
        cpTree.setDirty(false);
      }
View Full Code Here


        @SuppressWarnings("unused")
        public MediaResource handle(String relPath, HttpServletRequest request) {
          VFSItem vfsItem = courseFolder.resolve(relPath);
          MediaResource mr;
          if (vfsItem == null || !(vfsItem instanceof VFSLeaf)) mr = new NotFoundMediaResource(relPath);
          else mr = new VFSMediaResource((VFSLeaf) vfsItem);
          return mr;
        }
      };
      String uri = mapreg.register(cssUriMapper);
View Full Code Here

          }
 
          if (!ok) {
            // error
            meth.releaseConnection();
            return new NotFoundMediaResource(relPath);
          }
 
          // get or post successfully
          Header responseHeader = meth.getResponseHeader("Content-Type");
          if (responseHeader == null) {
            // error
            return new NotFoundMediaResource(relPath);
          }
          mr = new HttpRequestMediaResource(meth);
          return mr;
        }
      };
View Full Code Here

    // get a usersession-local mapper for the file storage (and tinymce's references to images and such)
    contentMapper = new Mapper() {
      public MediaResource handle(String relPath, HttpServletRequest request) {
        VFSItem vfsItem = documentBaseContainer.resolve(relPath);
        MediaResource mr;
        if (vfsItem == null || !(vfsItem instanceof VFSLeaf)) mr = new NotFoundMediaResource(relPath);
        else mr = new VFSMediaResource((VFSLeaf) vfsItem);
        return mr;
      }
    };
    // Register mapper for this user. This mapper is cleaned up in the
View Full Code Here

    String baseUrl = registerMapper(new Mapper() {
      public MediaResource handle(String relPath, HttpServletRequest request) {
        OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(ProjectBrokerManagerFactory.getProjectBrokerManager().getAttamchmentRelativeRootPath(project,courseEnv,cNode),null);
        VFSLeaf vfsfile = (VFSLeaf) rootFolder.resolve(relPath);
        if (vfsfile == null) {
          return new NotFoundMediaResource(relPath);
        } else {
          return new VFSMediaResource(vfsfile);
        }
      }
    });
View Full Code Here

        Tracing.logInfo("Catalog XML file requested by " + request.getRemoteAddr(), CatalogExportModuleDispatcher.class);
        ServletUtil.serveResource(request, response, new FileMediaResource(CatalogExportModuleDispatcher.getFile(), true));
      } catch (Exception e) {
        Tracing.logError("Error requesting catalog export file: ", e, CatalogExportModuleDispatcher.class);
        try {
          ServletUtil.serveResource(request, response, new NotFoundMediaResource(request.getRequestURI()));
        } catch (Exception e1) {
          // what now???
          Tracing.logError("What now ???", CatalogExportModuleDispatcher.class);
        }
      }
View Full Code Here

    String glossaryFolderString = FolderConfig.getCanonicalRoot() + FolderConfig.getRepositoryHome() + "/" + glossaryId + "/"
        + GlossaryMarkupItemController.INTERNAL_FOLDER_NAME;
    File glossaryFolderFile = new File(glossaryFolderString);
    if (!glossaryFolderFile.isDirectory()) {
      logWarn("GlossaryTerms delivery failed; path to glossaryFolder not existing: " + relPath, null);
      return new NotFoundMediaResource(relPath);
    }
    VFSContainer glossaryFolder = new LocalFolderImpl(glossaryFolderFile);
    if (!gIM.isFolderContainingGlossary(glossaryFolder)) {
      logWarn("GlossaryTerms delivery failed; glossaryFolder doesn't contain a valid Glossary: " + glossaryFolder, null);
      return new NotFoundMediaResource(relPath);
    }

    // Create a media resource
    StringMediaResource resource = new StringMediaResource() {
      @Override
View Full Code Here

    String glossaryFolderString = FolderConfig.getCanonicalRoot() + FolderConfig.getRepositoryHome() + "/" + glossaryId + "/"
        + GlossaryMarkupItemController.INTERNAL_FOLDER_NAME;
    File glossaryFolderFile = new File(glossaryFolderString);
    if (!glossaryFolderFile.isDirectory()) {
      logWarn("GlossaryDefinition delivery failed; path to glossaryFolder not existing: " + relPath, null);
      return new NotFoundMediaResource(relPath);
    }
    VFSContainer glossaryFolder = new LocalFolderImpl(glossaryFolderFile);
    if (!gIM.isFolderContainingGlossary(glossaryFolder)) {
      logWarn("GlossaryDefinition delivery failed; glossaryFolder doesn't contain a valid Glossary: " + glossaryFolder, null);
      return new NotFoundMediaResource(relPath);
    }

    // cut away ".html"
    String glossaryMainTerm = parts[2].substring(0, parts[2].length() - 5).replace("+", " ");

    // Create a media resource
    StringMediaResource resource = new StringMediaResource() {
      @Override
      public void prepare(HttpServletResponse hres) {
      // don't use normal string media headers which prevent caching,
      // use standard browser caching based on last modified timestamp
      }
    };
    resource.setLastModified(gIM.getGlossaryLastModifiedTime(glossaryFolder));
    resource.setContentType("text/html");

    ArrayList<GlossaryItem> glossItems = gIM.getGlossaryItemListByVFSItem(glossaryFolder);
    String description = "<dd><dt>" + glossaryMainTerm + "</dt>";
    // FIXME: have a way not to loop over all items, but get by Term
    boolean foundADescription = false;
    for (Iterator<GlossaryItem> iterator = glossItems.iterator(); iterator.hasNext();) {
      GlossaryItem glossaryItem = iterator.next();
      if (glossaryItem.getGlossTerm().toLowerCase().equals(glossaryMainTerm.toLowerCase())) {
        description += "<dl>" + glossaryItem.getGlossDef() + "</dl>";
        foundADescription = true;
        break;
      }
    }
    description += "</dd>";
    if (!foundADescription) return new NotFoundMediaResource(relPath);
   
    resource.setData(description);
    resource.setEncoding("utf-8");

    if (isLogDebugEnabled()) logDebug("loaded definition for " + glossaryMainTerm, null);
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.