Package org.olat.core.util.vfs

Examples of org.olat.core.util.vfs.VFSLeaf


    VFSContainer rootContainer = SPCourseNode.getNodeFolderContainer((SPCourseNode) courseNode, course.getCourseEnvironment());
    String chosenFile = (String) courseNode.getModuleConfiguration().get(SPEditController.CONFIG_KEY_FILE);
    // First: Index choosen HTML file
    if (log.isDebug()) log.debug("Index chosen file in SP. chosenFile=" + chosenFile);
     VFSLeaf leaf = (VFSLeaf)rootContainer.resolve(chosenFile);
    if (leaf != null) {
      String filePath = getPathFor(leaf);
      if (log.isDebug()) log.debug("Found chosen file in SP. filePath=" + filePath );
      doIndexVFSLeafByMySelf(courseNodeResourceContext, leaf, indexWriter, filePath);
      if (!indexOnlyChosenFile) {
View Full Code Here


              link = rootFilePath + "/" + link;
            }
          }
          VFSItem item = rootContainer.resolve(link);
          if ( (item != null) && (item instanceof VFSLeaf) ) {
            VFSLeaf subPageLeaf = (VFSLeaf)item;
            if (log.isDebug()) log.debug("subPageLeaf=" + subPageLeaf);
            String filePath = getPathFor(subPageLeaf);
            doIndexVFSLeafByMySelf(courseNodeResourceContext, subPageLeaf, indexWriter, filePath);
            alreadyIndexFileNames.add(subPageLeaf.getName());
            indexSubPages(courseNodeResourceContext,rootContainer,indexWriter,subPageLeaf,alreadyIndexFileNames,mySubPageLevel,rootFilePath);
          } else {
            if (log.isDebug()) log.debug("Could not found sub-page for link=" + link);
          }
        } else {
View Full Code Here

                      + "</body></html>"; // Text = 'Dies ist der Test Text'
    String text = "Test HTML Seite fuer JUnit Test Dies ist der Test\u00A0Text";
    // Create a test HTML File 
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(rootPath , null);
    OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(filePath, rootFolder);
    VFSLeaf leaf = (VFSLeaf)namedFolder.resolve(htmlFileName);
    if (leaf != null) {
      leaf.delete();
    }
    leaf = namedFolder.createChildLeaf(htmlFileName);
    BufferedOutputStream bos = new BufferedOutputStream(leaf.getOutputStream(false));
    FileUtils.save(bos,htmlText,"utf-8");
    try {
      bos.close();
     
      SearchResourceContext resourceContext = new SearchResourceContext();
      resourceContext.setBusinessControlFor(OresHelper.createOLATResourceableType("FileDocumentFactoryTest"));
      resourceContext.setFilePath(filePath + "/" + leaf.getName());
      Document htmlDocument = FileDocumentFactory.createDocument(resourceContext, leaf);
      // 1. Check content
      String content = htmlDocument.get(OlatDocument.CONTENT_FIELD_NAME);
      assertEquals("Wrong HTML content=" + content.trim() + " , must be =" + text.trim(), text.trim(), content.trim());
      // 2. Check resourceUrl
View Full Code Here

   */
  private void doFileDelivery(UserRequest ureq, String taskFile) {
    OlatRootFolderImpl forumContainer = new OlatRootFolderImpl(TACourseNode.getTaskFolderPathRelToFolderRoot(courseEnv, node), null);
    VFSItem item = forumContainer.resolve(taskFile);
    if (item instanceof VFSLeaf) {
      VFSLeaf leaf = (VFSLeaf)item;
      ureq.getDispatchResult().setResultingMediaResource(new VFSMediaResource(leaf));
    } else if (item==null) {
      Tracing.logWarn("Can not cast to VFSLeaf. item==null, taskFile=" + taskFile,null, TaskController.class);
    } else {
      Tracing.logWarn("Can not cast to VFSLeaf. item.class.name=" + item.getClass().getName() + ", taskFile="+taskFile,null, TaskController.class);
View Full Code Here

    if (repoRef != null) {
      OLATResourceable ores = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repoRef, true).getOlatResource();
     
      VFSContainer container = FeedManager.getInstance().getFeedContainer(ores);
      if (container != null) {
        VFSLeaf archive = FeedManager.getInstance().getFeedArchive(ores);
        destination.copyFrom(archive);
      }
      // FIXME:FG:6.3 Archive user comments as soon as implemented.     
    }
  }
View Full Code Here

  /**
   *
   */
  private void uploadFiles(FileElement attachmentFileElement) {
    VFSLeaf uploadedItem = new LocalFileImpl(attachmentFileElement.getUploadFile());
    ProjectBrokerManagerFactory.getProjectBrokerManager().saveAttachedFile(project, attachmentFileElement.getUploadFileName(), uploadedItem, courseEnv, courseNode );
  }
View Full Code Here

    // very old fancy code
    // Mapper is cleaned up automatically by basic controller
    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

  /**
   *
   */
  private void uploadFiles(FileElement attachmentFileElement) {
    VFSLeaf uploadedItem = new LocalFileImpl(attachmentFileElement.getUploadFile());
    ProjectBrokerManagerFactory.getProjectBrokerManager().saveAttachedFile(project, attachmentFileElement.getUploadFileName(), uploadedItem, courseEnv, courseNode );
  }
View Full Code Here

      // Project.getAttachmentFileName is the previous file-name, will not be deleted; student could have open detail-project page with previous attachemnt-link
      if (!item.getName().equals(project.getAttachmentFileName())) {
        item.delete();
      }
    }
    VFSLeaf newFile = (VFSLeaf)uploadVFSContainer.resolve(fileName);
    if (newFile == null) {
      newFile = uploadVFSContainer.createChildLeaf(fileName);
    }
    BufferedInputStream in = new BufferedInputStream(uploadedItem.getInputStream());
    BufferedOutputStream out = new BufferedOutputStream(newFile.getOutputStream(false));
    boolean success = false;
    if (in != null) {
      success = FileUtils.copy(in, out);         
    }
    FileUtils.closeSafely(in);
View Full Code Here

      if (event.equals(Event.DONE_EVENT)) {
        File fIn;
        File fDropbox = getDropBox(ureq.getIdentity());
        boolean success = false;
        if (fileChooserController.isFileFromFolder()) {
          VFSLeaf fileSelection = fileChooserController.getFileSelection();
          if (!(fileSelection instanceof LocalFileImpl))
            throw new AssertException("Only local files supported for dropboc so far.");
          fIn = ((LocalFileImpl)fileSelection).getBasefile();
          String fileName = fIn.getName();
          if (new File(fDropbox, fileName).exists()) {
View Full Code Here

TOP

Related Classes of org.olat.core.util.vfs.VFSLeaf

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.