Examples of FileResource


Examples of org.jruby.util.FileResource

    }

    @JRubyMethod(name = "identical?", required = 2, module = true)
    public static IRubyObject identical_p(IRubyObject recv, IRubyObject filename1, IRubyObject filename2) {
        Ruby runtime = recv.getRuntime();
        FileResource file1 = fileResource(filename1);
        FileResource file2 = fileResource(filename2);

        if (Platform.IS_WINDOWS || !runtime.getPosix().isNative()) {
            // posix stat uses inodes to determine indentity, and windows has no inodes
            // (they are always zero), so we use canonical paths instead. (JRUBY-5726)
            // If we can't load a native POSIX, use this same logic. (JRUBY-6982)
            if (file1.exists() && file2.exists()) {
                try {
                    String canon1 = new File(file1.absolutePath()).getCanonicalPath();
                    String canon2 = new File(file2.absolutePath()).getCanonicalPath();
                    return runtime.newBoolean(canon1.equals(canon2));
                } catch (IOException canonicalizationError) {
                    return runtime.getFalse();
                }
            } else {
                return runtime.getFalse();
            }
        }

        FileStat stat1 = file1.stat();
        FileStat stat2 = file2.stat();

        return runtime.newBoolean(stat1 != null && stat2 != null && stat1.isIdentical(stat2));
    }
View Full Code Here

Examples of org.linkedin.util.io.resource.FileResource

   * @return the resource
   */
  @Override
  public InternalResource doBuildResource(String path)
  {
    return new FileResource(this, path, new File(_root, path));
  }
View Full Code Here

Examples of org.mortbay.resource.FileResource

  private static Resource toResource(File f) {
    if (f == null) {
      throw new NullPointerException("externalResourceDir may not be null");
    }
    try {
      return new FileResource(f.toURI().toURL());
    } catch (Exception e) {
      throw new IllegalArgumentException("Invalid externalResourceDirectory: " + f.getPath(), e);
    }
  }
View Full Code Here

Examples of org.nutz.resource.impl.FileResource

      if (null == f || f.isDirectory()) {
        list.addAll(scan(path, regex));
      }
      // 普通磁盘文件
      else if (f.isFile()) {
        list.add(new FileResource(f));
      }
      // 存放在 jar 中的文件
      else if (isInJar(f)) {
        NutResource nutResource = makeJarNutResource(f);
        if (nutResource != null) {
View Full Code Here

Examples of org.olat.fileresource.types.FileResource

  /**
   * @return the new created resource
   */
  public FileResource createWiki() {
    FileResource resource = new WikiResource();
    createFolders(resource);
    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource ores = rm.createOLATResourceInstance(resource);
    rm.saveOLATResource(ores);
    return resource;
View Full Code Here

Examples of org.olat.fileresource.types.FileResource

  public FileResource addFileResource(File fResource, String newName, FileResource knownResource) throws AddingResourceException {

    // ZIPDIR is a reserved name... check
    if (fResource.getName().equals(ZIPDIR)) throw new AssertException("Trying to add FileResource with reserved name '" + ZIPDIR + "'.");

    FileResource tempFr = new FileResource();
    if (knownResource != null) tempFr = knownResource;

    // move file to its new place
    File fResourceFileroot = getFileResourceRoot(tempFr);
    if (!FileUtils.copyFileToDir(fResource, fResourceFileroot)) return null;

    if (!fResource.getName().equals(newName)) { // need to rename file to new
      // name
      File fNewName = new File(fResourceFileroot, newName);
      if (!new File(fResourceFileroot, fResource.getName()).renameTo(fNewName)) {
        FileUtils.deleteDirsAndFiles(fResourceFileroot, true, true);
        return null;
      }
      fResource = fNewName;
    }

    if (knownResource == null) {
      // save resourceableID
      Long resourceableId = tempFr.getResourceableId();
      // extract type
      try {
        if (DocFileResource.validate(fResource)) tempFr = new DocFileResource();
        else if (XlsFileResource.validate(fResource)) tempFr = new XlsFileResource();
        else if (PowerpointFileResource.validate(fResource)) tempFr = new PowerpointFileResource();
        else if (PdfFileResource.validate(fResource)) tempFr = new PdfFileResource();
        else if (ImageFileResource.validate(fResource)) tempFr = new ImageFileResource();
        else if (MovieFileResource.validate(fResource)) tempFr = new MovieFileResource();
        else if (SoundFileResource.validate(fResource)) tempFr = new SoundFileResource();
        else if (AnimationFileResource.validate(fResource)) tempFr = new AnimationFileResource();
        else if (SharedFolderFileResource.validate(fResource)) tempFr = new SharedFolderFileResource();
        // add a wiki copy
        else if (WikiResource.validate(fResource)) tempFr = new WikiResource();
        // add a podcast copy
        else if (PodcastFileResource.validate(fResource)) tempFr = new PodcastFileResource(fResourceFileroot, fResource);
        // add a blog copy
        else if (BlogFileResource.validate(fResource)) tempFr = new BlogFileResource(fResourceFileroot, fResource);
        // add a glossary copy
        else if (GlossaryResource.validate(fResource)) tempFr = new GlossaryResource();
        // the following types need unzippedDir
        else if (fResource.getName().toLowerCase().endsWith(".zip")) {
          File fUnzippedDir = unzipFileResource(tempFr);
          if (fUnzippedDir == null) {
            // in case of failure we forward the error message
            throw new AddingResourceException("resource.error.zip");
          }
          if (TestFileResource.validate(fUnzippedDir)) tempFr = new TestFileResource();
          else if (WikiResource.validate(fUnzippedDir)) tempFr = new WikiResource();
          else if (PodcastFileResource.validate(fUnzippedDir)) tempFr = new PodcastFileResource(fResourceFileroot, fUnzippedDir);
          else if (BlogFileResource.validate(fUnzippedDir)) tempFr = new BlogFileResource(fResourceFileroot, fUnzippedDir);
          else if (SurveyFileResource.validate(fUnzippedDir)) tempFr = new SurveyFileResource();
          // CP must be later entry... Test- and SurveyFileResource may contain
          // imsmanifest.xml as well
          else if (ImsCPFileResource.validate(fUnzippedDir)) tempFr = new ImsCPFileResource();
          // scorm and cp now can throw an exception which helps to show a
          // better error message in case
          // of a failure in adding a new resource
          else if (ScormCPFileResource.validate(fUnzippedDir)) tempFr = new ScormCPFileResource();
          // glossary resources are packaged within zip for import/export
          else if (GlossaryResource.validate(fUnzippedDir)) tempFr = new GlossaryResource();
          else {
            // just a generic ZIP file... we can delete the temporary unziped
            // dir...
            throw new AddingResourceException("doesn't matter what error key is declared");
          }
        }
      } catch (AddingResourceException exception) {
        // in case of failure we delete the resource and forward the error
        // message
        deleteFileResource(tempFr);
        throw exception;
      }

      tempFr.overrideResourceableId(resourceableId);
    }

    // add olat resource
    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource ores = rm.findOrPersistResourceable(tempFr);
View Full Code Here

Examples of org.olat.fileresource.types.FileResource

  /**
   * @param res
   * @return Get resourceable as file.
   */
  private File getFileResource(OLATResourceable res, String resourceFolderName) {
    FileResource fr = getAsGenericFileResource(res);
    File f = getFile(fr, resourceFolderName);
    if (f == null) // folder not existing or no file in it
    throw new OLATRuntimeException(FileResourceManager.class, "could not getFileResource for OLATResourceable " + res.getResourceableId()
        + ":" + res.getResourceableTypeName(), null);
    return f;
View Full Code Here

Examples of org.olat.fileresource.types.FileResource

  /**
   * @param res
   * @return File resource as downloadeable media resource.
   */
  public MediaResource getAsDownloadeableMediaResource(OLATResourceable res) {
    FileResource fr = getAsGenericFileResource(res);
    File f = getFile(fr);
    if (f == null) // folder not existing or no file in it
    throw new OLATRuntimeException(FileResourceManager.class, "could not get File for OLATResourceable " + res.getResourceableId() + ":"
        + res.getResourceableTypeName(), null);
    return new DownloadeableMediaResource(f);
View Full Code Here

Examples of org.olat.fileresource.types.FileResource

    Translator translator = Util.createPackageTranslator(this.getClass(), locale);
    return new FileDetailsForm("fileDetails", translator, res);
  }

  private FileResource getAsGenericFileResource(OLATResourceable res) {
    FileResource fr = new FileResource();
    fr.overrideResourceableId(res.getResourceableId());
    return fr;
  }
View Full Code Here

Examples of org.olat.fileresource.types.FileResource

          folderOfResource.createChildContainer(QTIEditorPackage.FOLDERNAMEFOR_CHANGELOG);
         
          //these are eiterh surveys or tests
          //try it as testresource then as survey, after this give up
          Long oresId = new Long(folderOfResource.getName());
          FileResource fr = new TestFileResource();
          fr.overrideResourceableId(oresId);
          myEntry = rm.lookupRepositoryEntry(fr,false);
          if(myEntry==null){
            //no qti test found, try the qti survey
            fr = new SurveyFileResource();
            fr.overrideResourceableId(oresId);
            myEntry = rm.lookupRepositoryEntry(fr,false);
          }
          //
          if(myEntry!=null){
            List identites = manager.getVisibleIdentitiesByPowerSearch(folderOfUser.getName(),null,false, null,null,null,null,null);
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.