Package java.io

Examples of java.io.File$TempFileLocker


    // look to see if WEKA_HOME has been defined as an environment
    // variable
    Environment env = Environment.getSystemWide();
    String wh = env.getVariableValue("WEKA_HOME");
    if (wh != null) {
      WEKA_HOME = new File(wh);
      PACKAGES_DIR = new File(wh + File.separator + "packages");
    } else {     
      env.addVariableSystemWide("WEKA_HOME", WEKA_HOME.toString());
    }
   
    boolean ok = true;
    if (!WEKA_HOME.exists()) {
      // create it for the user
      if (!WEKA_HOME.mkdir()) {
        System.err.println("Unable to create WEKA_HOME ("
            + WEKA_HOME.getAbsolutePath() + ")");
        ok = false;
      }
    }
   
    if (!PACKAGES_DIR.exists()) {
      // create the packages dir
      if (!PACKAGES_DIR.mkdir()) {
        System.err.println("Unable to create packages directory ("
            + PACKAGES_DIR.getAbsolutePath() + ")");
        ok = false;
      }
    }
   
    m_wekaHomeEstablished = ok;
    PACKAGE_MANAGER.setPackageHome(PACKAGES_DIR);
    try {
      String repURL = env.getVariableValue("weka.core.wekaPackageRepositoryURL");
      if (repURL == null || repURL.length() == 0) {
        // See if there is a URL named in $WEKA_HOME/props/PackageRepository.props
        File repPropsFile = new File(PROPERTIES_DIR.toString() + File.separator
            + "PackageRepository.props");
       
       
        if (repPropsFile.exists()) {
          Properties repProps = new Properties();
          repProps.load(new FileInputStream(repPropsFile));
          repURL = repProps.getProperty("weka.core.wekaPackageRepositoryURL");
        }
      }
     
      if (repURL == null || repURL.length() == 0) {
        repURL = "http://weka.sourceforge.net/packageMetaData";
      } else {
        System.err.println("weka.core.WekaPackageRepositoryURL = " + repURL);
      }
     
      REP_URL = new URL(repURL);
      PACKAGE_MANAGER.setPackageRepositoryURL(REP_URL);
    } catch (MalformedURLException ex) {
      ex.printStackTrace();
    } catch (IOException ex) {
      ex.printStackTrace();
    }
   
    PACKAGE_MANAGER.setBaseSystemName("weka");
    PACKAGE_MANAGER.setBaseSystemVersion(weka.core.Version.VERSION);
   
    // Now check the cache and establish it if necessary
    File cacheDir = new File(WEKA_HOME.toString() + File.separator
        + "repCache");
    try {
      String tempCacheString = "file://" + cacheDir.toString();
      // sanitize URI and fix slashes (for Windows)
      tempCacheString = tempCacheString.replace(" ", "%20");
      tempCacheString = tempCacheString.replace('\\', '/');
      if (tempCacheString.startsWith("file://") && !tempCacheString.startsWith("file:///")) {
        tempCacheString = tempCacheString.substring(7);
        tempCacheString = "file:///" + tempCacheString;
      }
      URI tempURI = new URI(tempCacheString);
//      System.err.println(" -- " + tempURI.toString());
      CACHE_URL = tempURI.toURL();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    if (!cacheDir.exists()) {
      if (!cacheDir.mkdir()) {
        System.err.println("Unable to create repository cache directory ("
            + cacheDir.getAbsolutePath() + ")");
        CACHE_URL = null;
      } else {
        // refreshCache();
        INITIAL_CACHE_BUILD_NEEDED = true;
      }
View Full Code Here


        doNotLoadIfFileMissing.toString().length() > 0) {

      StringTokenizer tok = new StringTokenizer(doNotLoadIfFileMissing.toString(), ",");
      while (tok.hasMoreTokens()) {
        String nextT = tok.nextToken().trim();
        File toCheck = new File(packageRootPath + nextT);
        if (!toCheck.exists()) {
          for (PrintStream p : progress) {
            p.println("[Weka] " + toLoad.getName() + " can't be loaded because "
                + toCheck.getPath() + " appears to be missing.");
          }
          result = false;
          break;
        }
      }
View Full Code Here

      ZipEntry ze;
      final byte[] buff = new byte[1024];
      while ((ze = zis.getNextEntry()) != null) {
//        System.out.println("Cache: inflating " + ze.getName());
        if (ze.isDirectory()) {
          new File(cacheDir, ze.getName()).mkdir();
          continue;
        }
        BufferedOutputStream bo =
          new BufferedOutputStream(new FileOutputStream(new File(cacheDir, ze.getName())));
        while (true) {
          int amountRead = zis.read(buff);
          if (amountRead == -1) {
            break;
          }
          // write the data here
          bo.write(buff, 0, amountRead);
        }
        bo.close();
      }
    } catch (Exception e) {
      e.printStackTrace();
     
      // OK, we have a problem with the repository cache - use
      // the repository itself instead and delete repCache
      CACHE_URL = null;
      try {
        DefaultPackageManager.deleteDir(new File(cacheDir), System.out);
      } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
     
View Full Code Here

      String resourceName) {
   
    String fullResourcePath = getPackageHome().toString()
      + File.separator + packageName + File.separator + resourceName;
   
    return new File(fullResourcePath).exists();
  }
View Full Code Here

            log.debug("StartupTask Deployment from file : " + fileName + " : Started");
        }

        try {
            Startup st = StartupFinder.getInstance().getStartup(artifactConfig, properties);
                st.setFileName((new File(fileName)).getName());
                if (log.isDebugEnabled()) {
                    log.debug("StartupTask named '" + st.getName()
                            + "' has been built from the file " + fileName);
                }
                st.init(getSynapseEnvironment());
View Full Code Here

            log.debug("StartupTask update from file : " + fileName + " has started");
        }

        try {
            Startup st = StartupFinder.getInstance().getStartup(artifactConfig, properties);
            st.setFileName((new File(fileName)).getName());

            if (log.isDebugEnabled()) {
                log.debug("StartupTask: " + st.getName() + " has been built from the file: " + fileName);
            }
            st.init(getSynapseEnvironment());
View Full Code Here

    PACKAGE_MANAGER.installPackages(toInstall, progress);
   
    for (Package p : toInstall) {     
     
      String packageName = p.getName();
      File packageDir = new File(PACKAGE_MANAGER.getPackageHome().toString() + File.separator
          + packageName);
     
      boolean loadIt = loadCheck(p, packageDir, progress);
     
      if (loadIt) {
View Full Code Here

        p.println(message);
      }
    }
   
    PACKAGE_MANAGER.installPackageFromRepository(packageName, version, progress);
    File packageDir = new File(PACKAGE_MANAGER.getPackageHome().toString() + File.separator
        + packageName);
   
    boolean loadIt = checkForMissingClasses(toLoad, progress);
    if (loadIt) {
      File packageRoot =
        new File(PACKAGE_MANAGER.getPackageHome() + File.separator
            + packageName);
      loadIt = checkForMissingFiles(toLoad, packageRoot, progress);
      if (loadIt) {
        loadPackageDirectory(packageDir, false);
      }
View Full Code Here

   
    PACKAGE_MANAGER.installPackageFromArchive(packageArchivePath, progress);
   
    boolean loadIt = checkForMissingClasses(toInstall, progress);
    if (loadIt) {
      File packageRoot =
        new File(PACKAGE_MANAGER.getPackageHome() + File.separator
            + toInstall.getName());
      loadIt = checkForMissingFiles(toInstall, packageRoot, progress);
      if (loadIt) {
        loadPackageDirectory(packageRoot, false);
      }
View Full Code Here

      }
    }
   
    boolean loadIt = checkForMissingClasses(installed, progress);
    if (loadIt) {
      File packageRoot =
        new File(PACKAGE_MANAGER.getPackageHome() + File.separator
            + installed.getName());
      loadIt = checkForMissingFiles(installed, packageRoot, progress);
      if (loadIt) {
        loadPackageDirectory(packageRoot, false);
      }
View Full Code Here

TOP

Related Classes of java.io.File$TempFileLocker

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.