Package org.olat.core.util.vfs

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


      //this command don't overwrite existing folders
      return Collections.emptyList();
    }
   
    String sZipContainer = name.substring(0, name.length() - 4);
    VFSItem zipContainer = currentContainer.resolve(sZipContainer);
    if(zipContainer == null) {
      return Collections.emptyList();
    } else if (zipContainer instanceof VFSContainer) {
      return ZipUtil.checkLockedFileBeforeUnzip(vfsItem, (VFSContainer)zipContainer, identity, isAdmin);
    } else {
View Full Code Here


          getWindowControl().setError(translator.translate("failed"));
          status = FolderCommandStatus.STATUS_FAILED;
          fireEvent(ureq, FOLDERCOMMAND_FINISHED);
        }
        for (String file : files) {
          VFSItem item = currentContainer.resolve(file);
          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();
          } else {
            getWindowControl().setWarning(translator.translate("del.partial"));
          }
        }
       
View Full Code Here

     * Creates a zipFile by using ZipUtil and fires Event.DONE_EVENT if successful.
     *
     * @see org.olat.core.commons.modules.bc.commands.AbstractCreateItemForm#formOK(org.olat.core.gui.UserRequest)
     */
    protected void formOK(UserRequest ureq) {   
      VFSItem zipFile = currentContainer.createChildLeaf(getItemName());
      if (zipFile == null) {
        this.fireEvent(ureq, Event.FAILED_EVENT);
        return;       
      }
     
      List<VFSItem> vfsFiles = new ArrayList<VFSItem>();
      for (String fileName : selection.getFiles()) {
        VFSItem item = currentContainer.resolve(fileName);
        if (item != nullvfsFiles.add(item);
      }
      if (!ZipUtil.zip(vfsFiles, (VFSLeaf)zipFile)) {
        // cleanup zip file
        zipFile.delete();       
View Full Code Here

          isInputValid = false;
          return isInputValid;
        }
        //Note: use java.io.File and not VFS to create a leaf. File must not exist upon ZipUtil.zip()
        name = name + ".zip";
        VFSItem zipFile = currentContainer.resolve(name);
        if (zipFile != null) {         
          textElement.setErrorKey("zip.alreadyexists", new String[] {name});
          isInputValid = false;         
        } else {
          isInputValid = true;         
View Full Code Here

  /**
   * Internal helper to finish the upload and add metadata
   */
  private void finishSuccessfullUpload(String fileName, UserRequest ureq) {
    VFSItem item = currentContainer.resolve(fileName);
    if (item instanceof OlatRootFileImpl) {
      OlatRootFileImpl relPathItem = (OlatRootFileImpl) item;
      // create meta data
      MetaInfo meta = MetaInfoFactory.createMetaInfoFor(relPathItem);
      if (metaDataCtr != null) {
View Full Code Here

    if (uploadRelPath == null) {
      // reset to current base container
      this.uploadVFSContainer = this.currentContainer;
    } else {
      // try to resolve given rel path from current container
      VFSItem uploadDir = currentContainer.resolve(uploadRelPath);
      if (uploadDir != null) {
        // make sure this is really a container and not a file!
        if (uploadDir instanceof VFSContainer) {
          this.uploadVFSContainer = (VFSContainer) uploadDir;
        } else {
View Full Code Here

    //cluster_OK by guido
    VFSContainer versionsContainer = getWikiContainer(ores, VERSION_FOLDER_NAME);
    VFSContainer wikiContentContainer = getWikiContainer(ores, WIKI_RESOURCE_FOLDER_NAME);
    // rename existing content file to version x and copy it to the version
    // container
    VFSItem item = wikiContentContainer.resolve(page.getPageId() + "." + WIKI_FILE_SUFFIX);
    if (item != null && incrementVersion) {
      if (page.getVersion() > 0) {
        versionsContainer.copyFrom(item);
        VFSItem copiedItem = versionsContainer.resolve(page.getPageId() + "." + WIKI_FILE_SUFFIX);
        String fileName = page.getPageId() + "." + WIKI_FILE_SUFFIX + "-" + page.getVersion();
        copiedItem.rename(fileName);
      }
      item.delete();
    }
    // rename existing meta file to version x and copy it to the version
    // container
    item = wikiContentContainer.resolve(page.getPageId() + "." + WIKI_PROPERTIES_SUFFIX);
    if (item != null && incrementVersion) {
      // TODO renaming and coping does not work. Bug?? felix fragen
      if (page.getVersion() > 0) {
        versionsContainer.copyFrom(item);
        VFSItem copiedItem = versionsContainer.resolve(page.getPageId() + "." + WIKI_PROPERTIES_SUFFIX);
        String fileName = page.getPageId() + "." + WIKI_PROPERTIES_SUFFIX + "-" + page.getVersion();
        copiedItem.rename(fileName);
      }
      item.delete();
    }
    // store recent content file
    VFSLeaf leaf = wikiContentContainer.createChildLeaf(page.getPageId() + "." + WIKI_FILE_SUFFIX);
View Full Code Here

    // do not delete default pages
    if (name.equals(WikiPage.WIKI_INDEX_PAGE) || name.equals(WikiPage.WIKI_MENU_PAGE)) return;
    VFSContainer wikiContentContainer = getWikiContainer(ores, WIKI_RESOURCE_FOLDER_NAME);
    VFSContainer versionsContainer = getWikiContainer(ores, VERSION_FOLDER_NAME);
    //delete content and property file
    VFSItem item = wikiContentContainer.resolve(page.getPageId() + "." + WIKI_FILE_SUFFIX);
    if (item != null) item.delete();
    item = wikiContentContainer.resolve(page.getPageId() + "." + WIKI_PROPERTIES_SUFFIX);
    if (item != null) item.delete();
   
    //delete all version files of the page
    List leafs = versionsContainer.getItems(new VFSLeafFilter());
    if (leafs.size() > 0) {
      for (Iterator iter = leafs.iterator(); iter.hasNext();) {
View Full Code Here

   * @param node
   * @return
   */
  public static VFSContainer getScoDirectory(String username, CourseEnvironment courseEnv, ScormCourseNode node) {
    Long courseId = courseEnv.getCourseResourceableId();
    VFSItem userFolder = ScormDirectoryHelper.getScormRootFolder().resolve(username);
    if(userFolder != null) {
      VFSItem scoFolder = userFolder.resolve(courseId.toString() + "-" + node.getIdent());
      if(scoFolder instanceof VFSContainer) {
        return (VFSContainer)scoFolder;
      }
    }
    return null;
View Full Code Here

  public void setImageMapperUri(UserRequest ureq, final VFSContainer wikiContainer) {
    // get a usersession-local mapper for images in this wiki
    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;
      }
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.