Package org.olat.core.util.vfs

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


        cpContentCtr.setCurrentURI(identifierRes);
      }
      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
View Full Code Here


      cssUriMapper = new Mapper() {
        final VFSContainer courseFolder = course.getCourseFolderContainer();

        @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;
        }
View Full Code Here

        fileName = fileName.toLowerCase();
        if (!isAllowedFileSuffixes(fileName)) {         
          this.showError(NLS_ERROR_FILETYPE);
          if (cmdUpload.fileWasOverwritten().booleanValue()) return;
          // delete file
          VFSItem item = rootContainer.resolve(cmdUpload.getFileName());
            if (item != null && (item.canDelete() == VFSConstants.YES)) {
              if (item instanceof OlatRelPathImpl) {
                // delete all meta info
                MetaInfo meta = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)item);
                if (meta != null) meta.deleteAll();
              }
              // delete the item itself
              item.delete();
            }
          return;
        } else {
          if (fileName.endsWith("zip")) {
            // unzip zip file
View Full Code Here

    else if (source == editButton){ // edit the chosen file in the rich text editor
      if (chosenFile == null) {       
        showError(NLS_ERROR_CHOOSEFILEFIRST);
        return;
      }
      VFSItem vfsItem = rootContainer.resolve(chosenFile);
      if (vfsItem == null || !(vfsItem instanceof VFSLeaf)) {       
        showError(NLS_ERROR_FILEDOESNOTEXIST);
        return;
      }

      String editFile;
      VFSContainer editRoot;
      if (allowRelativeLinks.booleanValue()) {
        editRoot = rootContainer;
        editFile = chosenFile;
      } else {
        ContainerAndFile caf = VFSUtil.calculateSubRoot(rootContainer, chosenFile);
        editRoot = caf.getContainer();
        editFile = caf.getFileName();
      }
     
      removeAsListenerAndDispose(wysiwygCtr);
      wysiwygCtr = createWysiwygController(ureq, getWindowControl(), editRoot, editFile);     
      listenTo(wysiwygCtr);
      removeAsListenerAndDispose(cmcWysiwygCtr);
      cmcWysiwygCtr = new CloseableModalController(getWindowControl(), getTranslator().translate("close"), wysiwygCtr.getInitialComponent());
      listenTo(cmcWysiwygCtr);
      cmcWysiwygCtr.activate();
      updateVelocityVariables(chosenFile);
      fireEvent(ureq, FILE_CONTENT_CHANGED_EVENT);
    }
    // delete the chosen file
    else if (source == deleteButton){
      if (chosenFile == null) {       
        showError(NLS_ERROR_CHOOSEFILEFIRST);
        return;
      }
      VFSItem vfsItem = rootContainer.resolve(chosenFile);
      if (vfsItem == null || !(vfsItem instanceof LocalFileImpl)) {       
        showError(NLS_ERROR_FILEDOESNOTEXIST);
        return;
      }
      File file = ((LocalFileImpl)vfsItem).getBasefile();
View Full Code Here

      } else if (!fileName.endsWith(".html") && !fileName.endsWith(".htm")) {
        //add html extension if missing
        fileName = fileName + ".html";
      }
      if (fileName.charAt(0) != '/') fileName = '/' + fileName;
      VFSItem vfsItem = rootContainer.resolve(fileName);
      if (vfsItem != null) {
        textElement.setErrorKey("error.fileExists", new String[] {fileName});
        isInputValid = false;
      } else {
        newFileName = fileName;
View Full Code Here

 
  protected List<VFSItem> getMediaFileList() {
    List<VFSItem> allFiles = mediaContainer.getItems();
    List<VFSItem> mediaFilesOnly = new ArrayList<VFSItem>();
    for (Iterator<VFSItem> iter = allFiles.iterator(); iter.hasNext();) {
      VFSItem element = iter.next();
      if(!element.getName().endsWith(WikiMainController.METADATA_SUFFIX)) mediaFilesOnly.add(element);
    }
    return mediaFilesOnly;
  }
View Full Code Here

    List folders = rootContainer.getItems();
    VFSLeaf indexLeaf =(VFSLeaf)rootContainer.resolve("index.html");
    if(indexLeaf != null) indexLeaf.delete();
    List filesTozip = new ArrayList();
    for (Iterator iter = folders.iterator(); iter.hasNext();) {
      VFSItem item = (VFSItem)iter.next();
      if (item instanceof VFSContainer) {
        VFSContainer folder = (VFSContainer) item;
        List items = folder.getItems();
        String overviewPage = WikiToZipUtils.createIndexPageForExport(items);
        if(overviewPage != null){
View Full Code Here

      // catch upload event
      if (event instanceof FolderEvent && event.getCommand().equals(FolderEvent.UPLOAD_EVENT)) {
        FolderEvent folderEvent = (FolderEvent) event;
        // Get file from temp folder location
        uploadedFileName = folderEvent.getFilename();
        VFSItem file = uploadContainer.resolve(uploadedFileName);
        if (file != null) {
          // remove old files first from a previous upload
          if (uploadedFile != null && uploadedFile.exists()) uploadedFile.delete();
          // We knot it is a local file, cast is necessary to get file reference
          uploadedFile = ((LocalFileImpl)file).getBasefile();
View Full Code Here

    // user selected one attachment from the attachment list
    int pos = Integer.parseInt(cmd.substring(cmd.indexOf("_") + 1, cmd.lastIndexOf("_")));
    // velocity counter starts at 1
    List<VFSItem> attachments = new ArrayList<VFSItem>();
    attachments.addAll((Collection<VFSItem>) messageMap.get("attachments"));
    VFSItem vI = attachments.get(pos - 1);
    VFSLeaf vl = (VFSLeaf) vI;
    ureq.getDispatchResult().setResultingMediaResource(new VFSMediaResource(vl));
  }
View Full Code Here

    VFSContainer container = new OlatRootFolderImpl(FolderConfig.getUserHomes() + File.separator + ureq.getIdentity().getName() + "/private/archive", null);
    // append export timestamp to avoid overwriting previous export
    Date tmp = new Date(System.currentTimeMillis());
    java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH_mm_ss");
    String folder = "forum_" + forum.getKey().toString()+"_"+formatter.format(tmp);
    VFSItem vfsItem = container.resolve(folder);
    if (vfsItem == null || !(vfsItem instanceof VFSContainer)) {
      vfsItem = container.createChildContainer(folder);
    }
    container = (VFSContainer) vfsItem;
    return container;
View Full Code Here

TOP

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

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.