Package org.olat.core.util.vfs

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


    VFSContainer root = cp.getRootDir();
    String filenName = file.getUploadFileName();
    // don't check on mimetypes - some browser use different mime types when sending files (OLAT-4547)
    if (filenName.toLowerCase().endsWith(".zip")) {
      // unzip and add files
      VFSLeaf archive = new LocalFileImpl(file.getUploadFile());
      String archiveName = file.getUploadFileName();
      String unzipDirName = archiveName.substring(0, archiveName.toLowerCase().indexOf(".zip"));
      unzipDirName = VFSManager.similarButNonExistingName(root, unzipDirName);
      VFSContainer unzipDir = root.createChildContainer(unzipDirName);
      ZipUtil.unzip(archive, unzipDir);
      // add items of unzipDir to tree
      pageToBeSelected = addItem(unzipDir, currentPage.getIdentifier(), true);
      CPManager.getInstance().writeToFile(cp);

    } else {
      // Single file
      VFSLeaf uploadedItem = new LocalFileImpl(file.getUploadFile());
      uploadedItem.rename(file.getUploadFileName());
      // rename to unique name in root folder
      renameToNonExistingDesignation(root, uploadedItem);
      // move item to root folder
      root.copyFrom(uploadedItem);
      pageToBeSelected = addItem(uploadedItem, currentPage.getIdentifier(), false);
View Full Code Here


   * @param unzippedDir
   * @param mani
   * @return
   */
  private String createMenuAndFrame(File unzippedDir, File mani) {
    LocalFileImpl vfsMani = new LocalFileImpl(mani);
    CPManifestTreeModel ctm = new CPManifestTreeModel(vfsMani);
    TreeNode root = ctm.getRootNode();
    this.rootTitle = root.getTitle();
    StringBuilder sb = new StringBuilder();
    sb.append(DOCTYPE);
View Full Code Here

      fireEvent(ureq, Event.CANCELLED_EVENT);
    } else if (source == file && event.wasTriggerdBy(FormEvent.ONCHANGE)) {
      // display the uploaded file
      if (file.isUploadSuccess()) {
        File newFile = file.getUploadFile();
        MediaResource newResource = new VFSMediaResource(new LocalFileImpl(newFile));
        setImage(newResource);
      }
    } else if (source == deleteImageLink && event.wasTriggerdBy(FormEvent.ONCLICK)) {
      unsetImage();
    }
View Full Code Here

        // Update the image
        String imageFilename = RepositoryEntryImageController.getImageFilename(entry);
        String repoImagePath = FolderConfig.getCanonicalRoot() + FolderConfig.getRepositoryHome() + "/" + imageFilename;
        File repoEntryImage = new File(repoImagePath);
        if (repoEntryImage.exists()) {
          VFSLeaf repoImage = new LocalFileImpl(repoEntryImage);
          getFeedMediaContainer(feed).copyFrom(repoImage);
          VFSLeaf newImage = (VFSLeaf) getFeedMediaContainer(feed).resolve(imageFilename);
          if (newImage != null) {
            feed.setImageName(imageFilename);
          }
View Full Code Here

      String saveFileName = getSaveFileName(file.getUploadFileName());

      File renamed = new File(uploadedFile.getParent() + "/" + saveFileName);
      uploadedFile.renameTo(renamed);
      VFSLeaf mediaFile = new LocalFileImpl(renamed);
      itemMediaContainer.copyFrom(mediaFile);

      // Update the enclosure
      Enclosure enclosure = new Enclosure();
      enclosure.setFileName(saveFileName);
View Full Code Here

      // Save the new image
      File uploadedFile = image.getUploadFile();
      String saveFileName = getSaveFileName(image.getUploadFileName());
      File renamed = new File(uploadedFile.getParent() + "/" + saveFileName);
      uploadedFile.renameTo(renamed);
      VFSLeaf imageLeaf = new LocalFileImpl(renamed);
      getFeedMediaContainer(feed).copyFrom(imageLeaf);
      feed.setImageName(saveFileName);
    }
  }
View Full Code Here

      iconPath = getImagePath("fo_sticky");     
    }   
    if (iconPath != null) {
      File file = new File(iconPath);
      if (file.exists()) {
        LocalFileImpl imgFile = new LocalFileImpl(file);
        container.copyFrom(imgFile);
        fileNameList.add(file.getName());
      } else {
        Tracing.logError("Could not find image for forum RTF formatter::" + iconPath, ForumFormatter.class);
      }
View Full Code Here

      VFSLeaf leaf = allLeafs.get(i);
      leafs.add(leaf);
      // add link to item
      // Add link to jump to course node
      if (leaf instanceof LocalFileImpl) {
        LocalFileImpl localFile = (LocalFileImpl) leaf;
        String relPath = localFile.getBasefile().getAbsolutePath().substring(rootFolder.getBasefile().getAbsolutePath().length());
        Link nodeLink = LinkFactory.createLink("nodeLink_" + (i+1), peekviewVC, this);
        nodeLink.setCustomDisplayText(leaf.getName());
        int lastDot = localFile.getName().lastIndexOf(".");
        String cssClass = "";
        if (lastDot > 0 ) {
          cssClass = "b_filetype_" + localFile.getName().substring(lastDot+1);
        }
        nodeLink.setCustomEnabledLinkCSS("b_with_small_icon_left b_filetype_file o_gotoNode " + cssClass);
        nodeLink.setUserObject(relPath);       
      } else {
        // hu? don't konw how to work with non-local impls
View Full Code Here

    VFSContainer scoDirectory = ScormDirectoryHelper.getScoDirectory(username, courseEnv, node);
    if(scoDirectory == null) return null;
   
    VFSItem reloadSettingsFile = scoDirectory.resolve(RELOAD_SETTINGS_FILE);
    if(reloadSettingsFile instanceof LocalFileImpl) {
      LocalFileImpl fileImpl = (LocalFileImpl)reloadSettingsFile;
      return new SequencerModel(fileImpl.getBasefile(), null);
    } else if (reloadSettingsFile != null) {
      throw new OLATRuntimeException(this.getClass(), "Programming error, SCORM results must be file based", null);
    }
    return null;
  }
View Full Code Here

    }
  }

 
  public void testIsFileSupported() {
    assertTrue("html must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.html"))));
    assertTrue("htm must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.htm"))));
    assertTrue("HTML must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.HTML"))));
    assertTrue("HTM must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.HTM"))));
    assertTrue("HTM must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.xhtml"))));
    assertTrue("HTM must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.XHTML"))));

    assertTrue("pdf must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.pdf"))));
    assertTrue("PDF must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.PDF"))));

    assertTrue("DOC must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.DOC"))));
    assertTrue("doc must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.doc"))));

    assertTrue("TXT must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.TXT"))));
    assertTrue("txt must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.txt"))));
    assertTrue("txt must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.readme"))));
    assertTrue("txt must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.README"))));
    assertTrue("txt must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.csv"))));
    assertTrue("txt must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.CSV"))));
    assertTrue("XML must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.XML"))));
    assertTrue("xml must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.xml"))));
  }
View Full Code Here

TOP

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

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.