Examples of VFSContainer


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

  public void event(UserRequest ureq, Controller source, Event event) {
    if (source == dialogCtr) {
      if (DialogBoxUIFactory.isYesEvent(event)) {       
        // do delete
        VFSContainer currentContainer = folderComponent.getCurrentContainer();
        List<String> files = fileSelection.getFiles();
        if (files.size() == 0) {
          // sometimes, browser sends empty form data...
          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();
View Full Code Here

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

    }
    //
    // Add path element
    if (showTargetPath) {     
      String path = "/ " + uploadVFSContainer.getName();
      VFSContainer container = uploadVFSContainer.getParentContainer();
      while (container != null) {
        path = "/ " + container.getName() + " " + path;
        container = container.getParentContainer();
      }
      pathEl = uifactory.addStaticTextElement("ul.target", path,fileUpload);
    }
   
    if (showMetadata) {
View Full Code Here

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

      }     
    }
    // update the destination path in the GUI
    if (showTargetPath) {     
      String path = "/ " + currentContainer.getName() + (uploadRelPath == null ? "" : " / " + uploadRelPath);
      VFSContainer container = currentContainer.getParentContainer();
      while (container != null) {
        path = "/ " + container.getName() + " " + path;
        container = container.getParentContainer();
      }
      pathEl.setValue(path);
    }
  }
View Full Code Here

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

   */
  public GlossaryDefinitionController(UserRequest ureq, WindowControl control, GlossaryItem glossaryItem, VFSContainer glossaryFolder) {
    super(ureq, control);
    this.glossaryItem = glossaryItem;
    String glossDef = glossaryItem.getGlossDef();
    VFSContainer tempMultimediaFolder = glossaryFolder.createChildContainer(MULTIMEDIA_SUBFOLDER);
    VFSContainer multimediaFolder;
    if (tempMultimediaFolder == null) {
      multimediaFolder = (VFSContainer) glossaryFolder.resolve(MULTIMEDIA_SUBFOLDER);
    } else {
      multimediaFolder = tempMultimediaFolder;
    }
View Full Code Here

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

    super(wControl);
  }

  public Controller execute(FolderComponent folderComponent, UserRequest ureq, WindowControl wControl, Translator translator) {

    VFSContainer inheritingContainer = VFSManager.findInheritingSecurityCallbackContainer(folderComponent.getCurrentContainer());
    if (inheritingContainer == null || inheritingContainer.getLocalSecurityCallback().getQuota() == null) {
      getWindowControl().setWarning(translator.translate("editQuota.nop"));
      return null;
    }
   
    currentSecCallback = inheritingContainer.getLocalSecurityCallback();
    // cleanup old controller first
    if (quotaEditController != null) quotaEditController.dispose();
    // create a edit controller
    quotaEditController = QuotaManager.getInstance().getQuotaEditorInstance(ureq, wControl, currentSecCallback.getQuota().getPath(), true);      quotaEditController.addControllerListener(this);
    if (quotaEditController != null) {
View Full Code Here

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

    doIndex(resourceContext, indexWriter, cpRoot);
  }
   
  protected void doIndex(SearchResourceContext resourceContext, OlatFullIndexer indexWriter, File cpRoot)
  throws IOException,InterruptedException  {
    VFSContainer container = new LocalFolderImpl(cpRoot);
    VFSLeaf fManifest = (VFSLeaf)container.resolve("imsmanifest.xml");
    if(fManifest != null) {
      Element rootElement =  IMSLoader.loadIMSDocument(fManifest).getRootElement();
      Document manfiestDoc = createManifestDocument(fManifest, rootElement, resourceContext);
      indexWriter.addDocument(manfiestDoc);
     
View Full Code Here

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

  private void createFolders(OLATResourceable ores) {
    long start = 0;
    if (log.isDebug()) {
      start = System.currentTimeMillis();
    }
    VFSContainer rootContainer = getWikiRootContainer(ores);
    VFSContainer unzippedDir = (VFSContainer) rootContainer.resolve(FileResourceManager.ZIPDIR);
    if (unzippedDir == null) { // check for _unzipped_ dir from imported wiki's
      if (rootContainer.createChildContainer(WIKI_RESOURCE_FOLDER_NAME) == null) throwError(ores);
      if (rootContainer.createChildContainer(WikiContainer.MEDIA_FOLDER_NAME) == null) throwError(ores);
      if (rootContainer.createChildContainer(VERSION_FOLDER_NAME) == null) throwError(ores);
    } else { // _unzipped_ dir found: move elements to wiki folder and delete
      // unzipped dir and zip files
      List files = unzippedDir.getItems();
      VFSContainer wikiCtn = rootContainer.createChildContainer(WIKI_RESOURCE_FOLDER_NAME);
      VFSContainer mediaCtn = rootContainer.createChildContainer(WikiContainer.MEDIA_FOLDER_NAME);
      if (rootContainer.createChildContainer(VERSION_FOLDER_NAME) == null) throwError(ores);
      if (wikiCtn == null) throwError(ores);
      // copy files to wiki and media folder
      for (Iterator iter = files.iterator(); iter.hasNext();) {
        VFSLeaf leaf = ((VFSLeaf) iter.next());
        if (leaf.getName().endsWith(WikiManager.WIKI_FILE_SUFFIX) || leaf.getName().endsWith(WikiManager.WIKI_PROPERTIES_SUFFIX)) {
          wikiCtn.copyFrom(leaf);
        } else {
          if (leaf.getName().contains(WikiManager.WIKI_FILE_SUFFIX+"-") || leaf.getName().contains(WikiManager.WIKI_PROPERTIES_SUFFIX+"-")) {
            leaf.delete(); // delete version history
          } else
          mediaCtn.copyFrom(leaf);
        }
      }
      unzippedDir.delete();
      List zipFiles = rootContainer.getItems(new VFSItemSuffixFilter(new String[] { "zip" }));
      // delete all zips
View Full Code Here

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

          log.debug("wiki not in cache. Loading wiki from filesystem. Ores: " + ores.getResourceableId());
          start = System.currentTimeMillis();
        }

        Wiki wiki = null;
        VFSContainer folder = getWikiContainer(ores, WIKI_RESOURCE_FOLDER_NAME);
        // wiki folder structure does not yet exists, but resource does. Create
        // wiki in group context
        if (folder == null) {
          // createWikiforExistingResource(ores);
          createFolders(ores);
          folder = getWikiContainer(ores, WIKI_RESOURCE_FOLDER_NAME);
        }
        // folders should be present, create the wiki
        wiki = new Wiki(getWikiRootContainer(ores));
        // filter for xyz.properties files
        List wikiLeaves = folder.getItems(new VFSItemSuffixFilter(new String[] { WikiManager.WIKI_PROPERTIES_SUFFIX }));
        for (Iterator iter = wikiLeaves.iterator(); iter.hasNext();) {
          VFSLeaf propertiesFile = (VFSLeaf) iter.next();
          WikiPage page = Wiki.assignPropertiesToPage(propertiesFile);
          if (page == null) {
            // broken pages get automatically cleaned from filesystem
            String contentFileToBeDeleted = (propertiesFile.getName().substring(0,
                propertiesFile.getName().length() - WikiManager.WIKI_PROPERTIES_SUFFIX.length()) + WikiManager.WIKI_FILE_SUFFIX);
            folder.resolve(contentFileToBeDeleted).delete();
            propertiesFile.delete();
            continue;
          }
          // index and menu page are loaded by default
          if (page.getPageName().equals(WikiPage.WIKI_INDEX_PAGE) || page.getPageName().equals(WikiPage.WIKI_MENU_PAGE)) {
            VFSLeaf leaf = (VFSLeaf) folder.resolve(page.getPageId() + "." + WikiManager.WIKI_FILE_SUFFIX);
            page.setContent(FileUtils.load(leaf.getInputStream(), "utf-8"));
          }

          // due to a bug we have to rename some pages that start with an non
          // ASCII lowercase letter
          String idOutOfFileName = propertiesFile.getName().substring(0, propertiesFile.getName().indexOf("."));
          if (!page.getPageId().equals(idOutOfFileName)) {
            // rename corrupt prop file
            propertiesFile.rename(page.getPageId() + "." + WikiManager.WIKI_PROPERTIES_SUFFIX);
            // load content and delete corrupt content file
            VFSLeaf contentFile = (VFSLeaf) folder.resolve(idOutOfFileName + "." + WikiManager.WIKI_FILE_SUFFIX);
            contentFile.rename(page.getPageId() + "." + WikiManager.WIKI_FILE_SUFFIX);
          }

          wiki.addPage(page);
        }
View Full Code Here

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

   * @param ores
   * @param page
   */
  protected void saveWikiPage(OLATResourceable ores, WikiPage page, boolean incrementVersion, Wiki wiki) {
    //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);
    if(leaf == null) throw new AssertException("Tried to save wiki page with id ("+page.getPageId()+") and Olatresource: "+ores.getResourceableId()+" but page already existed!");
    FileUtils.save(leaf.getOutputStream(false), page.getContent(), "utf-8");

    // store recent properties file
    leaf = wikiContentContainer.createChildLeaf(page.getPageId() + "." + WIKI_PROPERTIES_SUFFIX);
    if (leaf == null) throw new AssertException("could not create file for wiki page "+page.getPageId()+", ores: "+ores.getResourceableTypeName()+":"+ores.getResourceableId()+", wikicontainer:"+wikiContentContainer);
    if (incrementVersion) page.incrementVersion();
    // update modification time
    if (!page.getContent().equals("")) page.setModificationTime(System.currentTimeMillis());
    Properties p = getPageProperties(page);
View Full Code Here

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

   */
  protected void deleteWikiPage(OLATResourceable ores, WikiPage page) {
    String name = page.getPageName();
    // 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();) {
        VFSLeaf leaf = (VFSLeaf) iter.next();
        String filename = leaf.getName();
        if (filename.startsWith(page.getPageId())) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.