Package org.olat.fileresource

Examples of org.olat.fileresource.FileResourceManager


   * @param res
   * @param ureq
   * @return the copy
   */
  public OLATResourceable createCopy(OLATResourceable res, UserRequest ureq) {
    FileResourceManager frm = FileResourceManager.getInstance();
    OLATResourceable copy = frm.createCopy(res, INTERNAL_FOLDER_NAME);
    return copy;
  }
View Full Code Here


   * @param ores
   * @param zipName
   */
  public void makeCPOfflineReadable(OLATResourceable ores, String zipName) {
    String repositoryHome = FolderConfig.getCanonicalRepositoryHome();
    FileResourceManager fm = FileResourceManager.getInstance();
    String relPath = fm.getUnzippedDirRel(ores);
    String resId = ores.getResourceableId().toString();

    File unzippedDir = new File(repositoryHome + "/" + relPath);
    File targetZip = new File(repositoryHome + "/" + resId + "/" + zipName);
    File cpOfflineMat = new File(WebappHelper.getContextRoot() + "/static/" + CPOFFLINEMENUMAT);
View Full Code Here

  /**
   * @see org.olat.modules.webFeed.managers.FeedManager#copy(org.olat.core.id.OLATResourceable)
   */
  @Override
  public OLATResourceable copy(OLATResourceable feed) {
    FileResourceManager manager = FileResourceManager.getInstance();
    return manager.createCopy(feed, getFeedKind(feed));
  }
View Full Code Here

  /**
   * @see org.olat.repository.handlers.RepositoryHandler#createCopy(org.olat.resource.OLATResourceable,
   *      org.olat.core.gui.UserRequest)
   */
  public OLATResourceable createCopy(OLATResourceable res, UserRequest ureq) {
    FileResourceManager frm = FileResourceManager.getInstance();
    VFSContainer wikiContainer = WikiManager.getInstance().getWikiContainer(res, WikiManager.WIKI_RESOURCE_FOLDER_NAME);
    if(wikiContainer==null) {
      //if the wiki container is null, let the WikiManager to create one
      WikiManager.getInstance().getOrLoadWiki(res);
    }
    OLATResourceable copy = frm.createCopy(res, WikiManager.WIKI_RESOURCE_FOLDER_NAME);
    VFSContainer rootContainer = frm.getFileResourceRootImpl(copy);
    //reset properties files to default values
    VFSContainer wikiCont = (VFSContainer)rootContainer.resolve(WikiManager.WIKI_RESOURCE_FOLDER_NAME);
    List leafs = wikiCont.getItems(new VFSItemSuffixFilter(new String[]{WikiManager.WIKI_PROPERTIES_SUFFIX}));
    for (Iterator iter = leafs.iterator(); iter.hasNext();) {
      VFSLeaf leaf = (VFSLeaf) iter.next();
      WikiPage page = Wiki.assignPropertiesToPage(leaf);
      //reset the copied pages to a the default values
      page.resetCopiedPage();
      WikiManager.getInstance().updateWikiPageProperties(copy, page);
    }
   
    //create folders
    VFSContainer newMediaCont = rootContainer.createChildContainer(WikiContainer.MEDIA_FOLDER_NAME);
    rootContainer.createChildContainer(WikiManager.VERSION_FOLDER_NAME);
    //copy media files to folders
    VFSContainer origRootContainer = frm.getFileResourceRootImpl(res);
    VFSContainer origMediaCont = (VFSContainer)origRootContainer.resolve(WikiContainer.MEDIA_FOLDER_NAME);
    List mediaFiles = origMediaCont.getItems();
    for (Iterator iter = mediaFiles.iterator(); iter.hasNext();) {
      VFSLeaf element = (VFSLeaf) iter.next();
      newMediaCont.copyFrom(element);
View Full Code Here

          fName = f.getName();
        } else {
          f = cfc.getUploadedFile();
          fName = cfc.getUploadedFileName();
        }
        FileResourceManager frm = FileResourceManager.getInstance();
        if (f!=null && !f.exists()) {
          // if f does not exist at this point then something went wrong with the upload
          // inform the user rather than issuing a log.error in FileUtils (OLAT-5383/OLAT-5384)
          getWindowControl().setError(translator.translate("Failed"));
          addCallback.failed(urequest);
          return;
        }
        try {       
          newFileResource = frm.addFileResource(f, fName);
        } catch (AddingResourceException e) {
          getWindowControl().setError(translator.translate(e.getErrorKey()));
          addCallback.failed(urequest);
          return;
        }
        if (newFileResource == null) {
          getWindowControl().setError(translator.translate("add.failed"));
          addCallback.failed(urequest);
          return;
        }

        if (limitTypes != null && limitTypes.size() > 0) { // check for type
          boolean validType = false;
          for (Iterator iter = limitTypes.iterator(); iter.hasNext();) {
            String limitType = (String) iter.next();
            if (newFileResource.getResourceableTypeName().equals(limitType)) validType = true;
          }
          if (!validType) { // rollback
            frm.deleteFileResource(newFileResource);
            getWindowControl().setError(translator.translate("add.wrongtype"));
            addCallback.failed(urequest);
            return;
          }
        }
View Full Code Here

  /**
   * Update the module configuration from the qti file: read min/max/cut values
   * @param res
   */
  public void updateModuleConfigFromQTIFile(OLATResource res) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedRoot = frm.unzipFileResource(res);
    //with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
    VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedRoot);
    VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
    if (vfsQTI==null){
      throw new AssertException("qti file did not exist even it should be guaranteed by repositor check-in "
View Full Code Here

  /**
   * Unzip package into temporary directory.
   * @return true if successfull, false otherwise
   */
  private boolean unzipPackage() {
    FileResourceManager frm = FileResourceManager.getInstance();
    File fPackageZIP = frm.getFileResource(fileResource);
    return ZipUtil.unzip(fPackageZIP, packageDir);
  }
View Full Code Here

 
  /**
   * @return True upon success, false otherwise.
   */
  public boolean savePackageToRepository() {
    FileResourceManager frm = FileResourceManager.getInstance();
    File tmpZipFile = new File(FolderConfig.getCanonicalTmpDir() + "/" + CodeHelper.getRAMUniqueID() + ".zip");
    // first save complete ZIP package to repository
    if (!savePackageTo(tmpZipFile)) return false;
    // move file from temp to repository root and rename
    File fRepositoryZip = frm.getFileResource(fileResource);
    if (!FileUtils.moveFileToDir(tmpZipFile, frm.getFileResourceRoot(fileResource))) {
      tmpZipFile.delete();
      return false;
    }
    fRepositoryZip.delete();
    new File(frm.getFileResourceRoot(fileResource), tmpZipFile.getName()).renameTo(fRepositoryZip);
    // delete old unzip content. If the repository entry gets called in the meantime,
    // the package will get unzipped again.
    tmpZipFile.delete();
    frm.deleteUnzipContent(fileResource);
    // to be prepared for the next start, unzip right now.
    return (frm.unzipFileResource(fileResource) != null);
  }
View Full Code Here

  public ImsRepositoryResolver(OLATResourceable fileResource) {
    init(fileResource);
  }

  private void init(OLATResourceable fileResource) {
    FileResourceManager frm = FileResourceManager.getInstance();
    fUnzippedDirRoot = frm.unzipFileResource(fileResource);
    sUnzippedDirRel = frm.getUnzippedDirRel(fileResource);
  }
View Full Code Here

TOP

Related Classes of org.olat.fileresource.FileResourceManager

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.