示例#1
0
  public static void testBumpIncludeFile() throws Exception {
    File tmp = new File("tmp-ws");
    if (tmp.exists()) IO.deleteWithException(tmp);
    tmp.mkdir();
    assertTrue(tmp.isDirectory());

    try {
      IO.copy(new File("test/ws"), tmp);
      Workspace ws = Workspace.getWorkspace(tmp);
      Project project = ws.getProject("bump-included");
      project.setTrace(true);
      Version old = new Version(project.getProperty("Bundle-Version"));
      assertEquals(new Version(1, 0, 0), old);
      project.bump("=+0");

      Processor processor = new Processor();
      processor.setProperties(project.getFile("include.txt"));

      Version newv = new Version(processor.getProperty("Bundle-Version"));
      System.err.println("New version " + newv);
      assertEquals(1, newv.getMajor());
      assertEquals(1, newv.getMinor());
      assertEquals(0, newv.getMicro());
    } finally {
      IO.deleteWithException(tmp);
    }
  }
示例#2
0
文件: Installer.java 项目: suever/CTP
 private void fixConfigSchema() {
   File configFile;
   File ctpDir = new File(directory, "CTP");
   if (ctpDir.exists()) configFile = new File(ctpDir, "config.xml");
   else configFile = new File(directory, "config.xml");
   if (configFile.exists()) {
     try {
       Document doc = getDocument(configFile);
       Element root = doc.getDocumentElement();
       Element server = getFirstNamedChild(root, "Server");
       moveAttributes(server, sslAttrs, "SSL");
       moveAttributes(server, proxyAttrs, "ProxyServer");
       moveAttributes(server, ldapAttrs, "LDAP");
       if (programName.equals("ISN")) fixRSNAROOT(server);
       if (isMIRC(root)) fixFileServiceAnonymizerID(root);
       setFileText(configFile, toString(doc));
     } catch (Exception ex) {
       cp.appendln(Color.red, "\nUnable to convert the config file schema.");
       cp.appendln(Color.black, "");
     }
   } else {
     cp.appendln(Color.red, "\nUnable to find the config file to check the schema.");
     cp.appendln(Color.black, "");
   }
 }
 void put(final URI uri, ArtifactData data) throws Exception {
   reporter.trace("put %s %s", uri, data);
   File tmp = createTempFile(repoDir, "mtp", ".whatever");
   tmp.deleteOnExit();
   try {
     copy(uri.toURL(), tmp);
     byte[] sha = SHA1.digest(tmp).digest();
     reporter.trace("SHA %s %s", uri, Hex.toHexString(sha));
     ArtifactData existing = get(sha);
     if (existing != null) {
       reporter.trace("existing");
       xcopy(existing, data);
       return;
     }
     File meta = new File(repoDir, Hex.toHexString(sha) + ".json");
     File file = new File(repoDir, Hex.toHexString(sha));
     rename(tmp, file);
     reporter.trace("file %s", file);
     data.file = file.getAbsolutePath();
     data.sha = sha;
     data.busy = false;
     CommandData cmddata = parseCommandData(data);
     if (cmddata.bsn != null) {
       data.name = cmddata.bsn + "-" + cmddata.version;
     } else data.name = Strings.display(cmddata.title, cmddata.bsn, cmddata.name, uri);
     codec.enc().to(meta).put(data);
     reporter.trace("TD = " + data);
   } finally {
     tmp.delete();
     reporter.trace("puted %s %s", uri, data);
   }
 }
  /**
   * Load classes from given file. File could be either directory or JAR file.
   *
   * @param clsLdr Class loader to load files.
   * @param file Either directory or JAR file which contains classes or references to them.
   * @return Set of found and loaded classes or empty set if file does not exist.
   * @throws GridSpiException Thrown if given JAR file references to none existed class or
   *     IOException occurred during processing.
   */
  static Set<Class<? extends GridTask<?, ?>>> getClasses(ClassLoader clsLdr, File file)
      throws GridSpiException {
    Set<Class<? extends GridTask<?, ?>>> rsrcs = new HashSet<Class<? extends GridTask<?, ?>>>();

    if (file.exists() == false) {
      return rsrcs;
    }

    GridUriDeploymentFileResourceLoader fileRsrcLdr =
        new GridUriDeploymentFileResourceLoader(clsLdr, file);

    if (file.isDirectory()) {
      findResourcesInDirectory(fileRsrcLdr, file, rsrcs);
    } else {
      try {
        for (JarEntry entry : U.asIterable(new JarFile(file.getAbsolutePath()).entries())) {
          Class<? extends GridTask<?, ?>> rsrc = fileRsrcLdr.createResource(entry.getName(), false);

          if (rsrc != null) {
            rsrcs.add(rsrc);
          }
        }
      } catch (IOException e) {
        throw new GridSpiException(
            "Failed to discover classes in file: " + file.getAbsolutePath(), e);
      }
    }

    return rsrcs;
  }
示例#5
0
  private String getTitle(File f) {
    String result = "";
    if (!f.getName().endsWith(".html")) return "not HTML";
    else {
      try {
        BufferedReader reader = new BufferedReader(new FileReader(f));
        String ligne = reader.readLine();
        while (ligne != null && !ligne.contains("<TITLE>") && !ligne.contains("<title>")) {
          ligne = reader.readLine();
        }
        reader.close();
        if (ligne == null) return "No TITLE in page " + f.getName();
        else {
          String fin = "";
          String debut = "";
          if (ligne.contains("</TITLE>")) {
            debut = "<TITLE>";
            fin = "</TITLE>";
          } else if (ligne.contains("</title>")) {
            debut = "<title>";
            fin = "</title>";
          } else return "No title in page " + f.getName();

          int fin_index = ligne.lastIndexOf(fin);
          result = ligne.substring(ligne.indexOf(debut) + 7, fin_index);
          return result;
        }
      } catch (Exception e) {
        LOG.error("Error while reading file " + e);
        return "Error for file " + f.getName();
      }
    }
  }
示例#6
0
  public static void testBumpSubBuilders() throws Exception {
    File tmp = new File("tmp-ws");
    if (tmp.exists()) IO.deleteWithException(tmp);
    tmp.mkdir();
    assertTrue(tmp.isDirectory());

    try {
      IO.copy(new File("test/ws"), tmp);
      Workspace ws = Workspace.getWorkspace(tmp);
      Project project = ws.getProject("bump-sub");
      project.setTrace(true);

      assertNull(project.getProperty("Bundle-Version"));

      project.bump("=+0");

      assertNull(project.getProperty("Bundle-Version"));

      for (Builder b : project.getSubBuilders()) {
        assertEquals(new Version(1, 1, 0), new Version(b.getVersion()));
      }
    } finally {
      IO.deleteWithException(tmp);
    }
  }
示例#7
0
  /**
   * load from the specified jar filled with help files in the [language] directory in the jar
   *
   * @param file the jar file
   */
  private void loadFromJar(File file) {
    if (file.getName().toLowerCase().endsWith(".jar") && file.isFile()) {
      try {
        int counter = 0;
        JarInputStream jis;
        JarEntry je;
        counter = 0;
        jis = new JarInputStream(new BufferedInputStream(new FileInputStream(file)));
        je = jis.getNextJarEntry();

        while (je != null) {
          String mnemo = trimEntryName(je);
          if (je.getName().toLowerCase().matches(helproot + "/" + language + "/.*.htm")
              && !exists(mnemo)) {
            addToCache(jis, mnemo);
            counter++;
          }
          je = jis.getNextJarEntry();
        }
        jis.close();

        System.out.println(
            "+ " + String.valueOf(counter) + "\thelp text(s) from:\t" + file.getCanonicalPath());
      } catch (IOException ignored) {
      }
    }
  }
示例#8
0
  /** initialization. load all files. */
  private void init() {
    URL home = getClass().getResource("..");
    File local;
    if (home != null) {
      System.out.println("looks like you are not starting from a jar-package");
      local = new File(home.getPath() + "/" + helproot + "/" + language + "/");
      System.out.println("local: " + local.getAbsolutePath());
      initFile(local);
      try {
        local =
            new File(
                new File(home.getPath()).getParentFile().getParentFile(),
                helproot + "/" + language);
        System.out.println("local: " + local.getAbsolutePath());
        initFile(local);
      } catch (Exception e) {
        System.out.println("but not loading from the developer workbench?!");
      }

    } else {
      System.out.println("looks like you are starting from a jar-package");
      local = CommandLoader.getLocation();
      initJar(local);
    }
    List<String> l = getLanguages();
    for (String aL : l) {
      System.out.println("language found: " + aL);
    }
  }
  private static void setupJurisdictionPolicies() throws Exception {
    String javaHomeDir = System.getProperty("java.home");
    String sep = File.separator;
    String pathToPolicyJar = javaHomeDir + sep + "lib" + sep + "security" + sep;

    File exportJar = new File(pathToPolicyJar, "US_export_policy.jar");
    File importJar = new File(pathToPolicyJar, "local_policy.jar");
    URL jceCipherURL = ClassLoader.getSystemResource("javax/crypto/Cipher.class");

    if ((jceCipherURL == null) || !exportJar.exists() || !importJar.exists()) {
      throw new SecurityException("Cannot locate policy or framework files!");
    }

    // Read jurisdiction policies.
    CryptoPermissions defaultExport = new CryptoPermissions();
    CryptoPermissions exemptExport = new CryptoPermissions();
    loadPolicies(exportJar, defaultExport, exemptExport);

    CryptoPermissions defaultImport = new CryptoPermissions();
    CryptoPermissions exemptImport = new CryptoPermissions();
    loadPolicies(importJar, defaultImport, exemptImport);

    // Merge the export and import policies for default applications.
    if (defaultExport.isEmpty() || defaultImport.isEmpty()) {
      throw new SecurityException("Missing mandatory jurisdiction " + "policy files");
    }
    defaultPolicy = defaultExport.getMinimum(defaultImport);

    // Merge the export and import policies for exempt applications.
    if (exemptExport.isEmpty()) {
      exemptPolicy = exemptImport.isEmpty() ? null : exemptImport;
    } else {
      exemptPolicy = exemptExport.getMinimum(exemptImport);
    }
  }
  /**
   * Recursively scans given directory and load all found files by loader.
   *
   * @param clsLdr Loader that could load class from given file.
   * @param dir Directory which should be scanned.
   * @param rsrcs Set which will be filled in.
   */
  @SuppressWarnings({"UnusedCatchParameter"})
  private static void findResourcesInDirectory(
      GridUriDeploymentFileResourceLoader clsLdr,
      File dir,
      Set<Class<? extends GridTask<?, ?>>> rsrcs) {
    assert dir.isDirectory() == true;

    for (File file : dir.listFiles()) {
      if (file.isDirectory()) {
        // Recurse down into directories.
        findResourcesInDirectory(clsLdr, file, rsrcs);
      } else {
        Class<? extends GridTask<?, ?>> rsrc = null;

        try {
          rsrc = clsLdr.createResource(file.getAbsolutePath(), true);
        } catch (GridSpiException e) {
          // Must never happen because we use 'ignoreUnknownRsrc=true'.
          assert false;
        }

        if (rsrc != null) {
          rsrcs.add(rsrc);
        }
      }
    }
  }
示例#11
0
  protected void generateJarFile(File jarFile, boolean standAlone, File dir) throws IOException {
    Verbose.log("Generating jar file ... " + jarFile);
    FileOutputStream out = new FileOutputStream(jarFile);
    InputStream manifestIo = getManifest();
    Manifest manifest = new Manifest(manifestIo);
    JarOutputStream jar = new JarOutputStream(out, manifest);

    int rootLen = dir.getAbsolutePath().length();

    int len = "java".length();
    for (File javaFile : javaFiles) {
      String fileName = javaFile.getPath();
      String classFile = fileName.substring(0, fileName.length() - len) + "class";
      String className = classFile.substring(rootLen + 1);
      addFileToJar(className, classFile, jar);

      String javaName = fileName.substring(rootLen + 1);
      addFileToJar(javaName, fileName, jar);
    }

    if (standAlone) {
      Verbose.log("Adding runtime classes to the jar");
      addRuntimeClasses(jar);
    }

    jar.close();
    out.close();
    Verbose.log("Generated jar file " + jarFile);
  }
示例#12
0
  public static void testBump() throws Exception {
    File tmp = new File("tmp-ws");
    if (tmp.exists()) IO.deleteWithException(tmp);
    tmp.mkdir();
    assertTrue(tmp.isDirectory());

    try {
      IO.copy(new File("test/ws"), tmp);
      Workspace ws = Workspace.getWorkspace(tmp);
      Project project = ws.getProject("p1");
      int size = project.getProperties().size();
      Version old = new Version(project.getProperty("Bundle-Version"));
      System.err.println("Old version " + old);
      project.bump("=+0");
      Version newv = new Version(project.getProperty("Bundle-Version"));
      System.err.println("New version " + newv);
      assertEquals(old.getMajor(), newv.getMajor());
      assertEquals(old.getMinor() + 1, newv.getMinor());
      assertEquals(0, newv.getMicro());
      assertEquals(size, project.getProperties().size());
      assertEquals("sometime", newv.getQualifier());
    } finally {
      IO.deleteWithException(tmp);
    }
  }
示例#13
0
  private Service getService(File base) throws Exception {
    File dataFile = new File(base, "data");
    if (!dataFile.isFile()) return null;

    ServiceData data = getData(ServiceData.class, dataFile);
    return new Service(this, data);
  }
示例#14
0
  void test(String[] opts, String className) throws Exception {
    count++;
    System.err.println("Test " + count + " " + Arrays.asList(opts) + " " + className);
    Path testSrcDir = Paths.get(System.getProperty("test.src"));
    Path testClassesDir = Paths.get(System.getProperty("test.classes"));
    Path classes = Paths.get("classes." + count);
    classes.createDirectory();

    Context ctx = new Context();
    PathFileManager fm = new JavacPathFileManager(ctx, true, null);
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    List<String> options = new ArrayList<String>();
    options.addAll(Arrays.asList(opts));
    options.addAll(Arrays.asList("-verbose", "-XDverboseCompilePolicy", "-d", classes.toString()));
    Iterable<? extends JavaFileObject> compilationUnits =
        fm.getJavaFileObjects(testSrcDir.resolve(className + ".java"));
    StringWriter sw = new StringWriter();
    PrintWriter out = new PrintWriter(sw);
    JavaCompiler.CompilationTask t =
        compiler.getTask(out, fm, null, options, null, compilationUnits);
    boolean ok = t.call();
    System.err.println(sw.toString());
    if (!ok) {
      throw new Exception("compilation failed");
    }

    File expect = new File("classes." + count + "/" + className + ".class");
    if (!expect.exists()) throw new Exception("expected file not found: " + expect);
    long expectedSize = new File(testClassesDir.toString(), className + ".class").length();
    long actualSize = expect.length();
    if (expectedSize != actualSize)
      throw new Exception("wrong size found: " + actualSize + "; expected: " + expectedSize);
  }
示例#15
0
 /** Computes the crc32 of a File. This is necessary when the ZipOutputStream is in STORED mode. */
 private void crc32File(ZipEntry e, File f) throws IOException {
   CRC32OutputStream os = new CRC32OutputStream();
   copy(f, os);
   if (os.n != f.length()) {
     throw new JarException(formatMsg("error.incorrect.length", f.getPath()));
   }
   os.updateEntry(e);
 }
示例#16
0
 protected void compileTypes(File dir) throws ToolsException {
   Compiler compiler = new Compiler();
   List<String> fileNames = new ArrayList<String>();
   for (File f : javaFiles) {
     fileNames.add(f.getPath());
   }
   compiler.compile(fileNames.toArray(new String[fileNames.size()]), dir);
 }
示例#17
0
 /** Create a path value from a list of directories and jar files. */
 String createPath(File... files) {
   StringBuilder sb = new StringBuilder();
   for (File f : files) {
     if (sb.length() > 0) sb.append(File.pathSeparatorChar);
     sb.append(f.getPath());
   }
   return sb.toString();
 }
示例#18
0
 /**
  * Deletes the directory passed as parameters
  *
  * @param dir the directory to delete
  */
 public static void deleteDir(File dir) {
   File[] list = dir.listFiles();
   for (int i = 0; i < list.length; i++) {
     if (list[i].isDirectory()) deleteDir(list[i]);
     else list[i].delete();
   }
   dir.delete();
 }
示例#19
0
 private static void checkPackageInfoFiles(
     Project project, String packageName, boolean expectPackageInfo, boolean expectPackageInfoJava)
     throws Exception {
   File pkgInfo = IO.getFile(project.getSrc(), packageName + "/packageinfo");
   File pkgInfoJava = IO.getFile(project.getSrc(), packageName + "/package-info.java");
   assertEquals(expectPackageInfo, pkgInfo.exists());
   assertEquals(expectPackageInfoJava, pkgInfoJava.exists());
 }
示例#20
0
 void updateLastModifiedTime(Set<ZipEntry> zes) throws IOException {
   for (ZipEntry ze : zes) {
     long lastModified = ze.getTime();
     if (lastModified != -1) {
       File f = new File(ze.getName().replace('/', File.separatorChar));
       f.setLastModified(lastModified);
     }
   }
 }
示例#21
0
 public static void testClasspath() throws Exception {
   File project = new File("").getAbsoluteFile();
   File workspace = project.getParentFile();
   Processor processor = new Processor();
   EclipseClasspath p = new EclipseClasspath(processor, workspace, project);
   System.err.println(p.getDependents());
   System.err.println(p.getClasspath());
   System.err.println(p.getSourcepath());
   System.err.println(p.getOutput());
 }
示例#22
0
 /** Write a file containing the given string. Parent directories are created as needed. */
 File writeFile(File f, String s) throws IOException {
   if (f.getParentFile() != null) f.getParentFile().mkdirs();
   FileWriter out = new FileWriter(f);
   try {
     out.write(s);
   } finally {
     out.close();
   }
   return f;
 }
示例#23
0
 public static void cleanUpUnpacked(File libDir) {
   if (libDir.exists() && libDir.listFiles(new ExtFilter(".gz")).length > 0) {
     for (File gz : libDir.listFiles(new ExtFilter(".gz"))) {
       try {
         gz.delete();
       } catch (Exception e) {
       }
     }
   }
 }
示例#24
0
 public static void removePreviousLibs(File libDir) {
   if (libDir.exists() && libDir.listFiles(new PrefixFilter("runwar")).length > 0) {
     for (File previous : libDir.listFiles(new PrefixFilter("runwar"))) {
       try {
         previous.delete();
       } catch (Exception e) {
         System.err.println("Could not delete previous lib: " + previous.getAbsolutePath());
       }
     }
   }
 }
示例#25
0
  /** Adds a new file entry to the ZIP output stream. */
  void addFile(ZipOutputStream zos, File file) throws IOException {
    String name = file.getPath();
    boolean isDir = file.isDirectory();
    if (isDir) {
      name = name.endsWith(File.separator) ? name : (name + File.separator);
    }
    name = entryName(name);

    if (name.equals("") || name.equals(".") || name.equals(zname)) {
      return;
    } else if ((name.equals(MANIFEST_DIR) || name.equals(MANIFEST_NAME)) && !Mflag) {
      if (vflag) {
        output(formatMsg("out.ignore.entry", name));
      }
      return;
    }

    long size = isDir ? 0 : file.length();

    if (vflag) {
      out.print(formatMsg("out.adding", name));
    }
    ZipEntry e = new ZipEntry(name);
    e.setTime(file.lastModified());
    if (size == 0) {
      e.setMethod(ZipEntry.STORED);
      e.setSize(0);
      e.setCrc(0);
    } else if (flag0) {
      crc32File(e, file);
    }
    zos.putNextEntry(e);
    if (!isDir) {
      copy(file, zos);
    }
    zos.closeEntry();
    /* report how much compression occurred. */
    if (vflag) {
      size = e.getSize();
      long csize = e.getCompressedSize();
      out.print(formatMsg2("out.size", String.valueOf(size), String.valueOf(csize)));
      if (e.getMethod() == ZipEntry.DEFLATED) {
        long ratio = 0;
        if (size != 0) {
          ratio = ((size - csize) * 100) / size;
        }
        output(formatMsg("out.deflated", String.valueOf(ratio)));
      } else {
        output(getMsg("out.stored"));
      }
    }
  }
示例#26
0
  public List<CommandData> getCommands(File commandDir) throws Exception {
    List<CommandData> result = new ArrayList<CommandData>();

    if (!commandDir.exists()) {
      return result;
    }

    for (File f : commandDir.listFiles()) {
      CommandData data = getData(CommandData.class, f);
      if (data != null) result.add(data);
    }
    return result;
  }
示例#27
0
  /**
   * Copies a file or directory
   *
   * @param src the file or directory to copy
   * @param dest where copy
   * @throws IOException
   */
  public static void copyFile(File src, File dest) throws IOException {
    if (!src.exists()) throw new IOException("File not found '" + src.getAbsolutePath() + "'");
    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(src));

    byte[] read = new byte[4096];
    int len;
    while ((len = in.read(read)) > 0) out.write(read, 0, len);

    out.flush();
    out.close();
    in.close();
  }
  /**
   * Puts the uninstaller.
   *
   * @exception Exception Description of the Exception
   */
  private void putUninstaller() throws Exception {
    // Me make the .uninstaller directory
    String dest = translatePath("$INSTALL_PATH") + File.separator + "Uninstaller";
    String jar = dest + File.separator + "uninstaller.jar";
    File pathMaker = new File(dest);
    pathMaker.mkdirs();

    // We log the uninstaller deletion information
    UninstallData udata = UninstallData.getInstance();
    udata.setUninstallerJarFilename(jar);
    udata.setUninstallerPath(dest);

    // We open our final jar file
    FileOutputStream out = new FileOutputStream(jar);
    ZipOutputStream outJar = new ZipOutputStream(out);
    idata.uninstallOutJar = outJar;
    outJar.setLevel(9);
    udata.addFile(jar);

    // We copy the uninstaller
    InputStream in = getClass().getResourceAsStream("/res/IzPack.uninstaller");
    ZipInputStream inRes = new ZipInputStream(in);
    ZipEntry zentry = inRes.getNextEntry();
    while (zentry != null) {
      // Puts a new entry
      outJar.putNextEntry(new ZipEntry(zentry.getName()));

      // Byte to byte copy
      int unc = inRes.read();
      while (unc != -1) {
        outJar.write(unc);
        unc = inRes.read();
      }

      // Next one please
      inRes.closeEntry();
      outJar.closeEntry();
      zentry = inRes.getNextEntry();
    }
    inRes.close();

    // We put the langpack
    in = getClass().getResourceAsStream("/langpacks/" + idata.localeISO3 + ".xml");
    outJar.putNextEntry(new ZipEntry("langpack.xml"));
    int read = in.read();
    while (read != -1) {
      outJar.write(read);
      read = in.read();
    }
    outJar.closeEntry();
  }
示例#29
0
文件: Installer.java 项目: suever/CTP
 // Take a tree of files starting in a directory in a zip file
 // and copy them to a disk directory, recreating the tree.
 private int unpackZipFile(
     File inZipFile, String directory, String parent, boolean suppressFirstPathElement) {
   int count = 0;
   if (!inZipFile.exists()) return count;
   parent = parent.trim();
   if (!parent.endsWith(File.separator)) parent += File.separator;
   if (!directory.endsWith(File.separator)) directory += File.separator;
   File outFile = null;
   try {
     ZipFile zipFile = new ZipFile(inZipFile);
     Enumeration zipEntries = zipFile.entries();
     while (zipEntries.hasMoreElements()) {
       ZipEntry entry = (ZipEntry) zipEntries.nextElement();
       String name = entry.getName().replace('/', File.separatorChar);
       if (name.startsWith(directory)) {
         if (suppressFirstPathElement) name = name.substring(directory.length());
         outFile = new File(parent + name);
         // Create the directory, just in case
         if (name.indexOf(File.separatorChar) >= 0) {
           String p = name.substring(0, name.lastIndexOf(File.separatorChar) + 1);
           File dirFile = new File(parent + p);
           dirFile.mkdirs();
         }
         if (!entry.isDirectory()) {
           System.out.println("Installing " + outFile);
           // Copy the file
           BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outFile));
           BufferedInputStream in = new BufferedInputStream(zipFile.getInputStream(entry));
           int size = 1024;
           int n = 0;
           byte[] b = new byte[size];
           while ((n = in.read(b, 0, size)) != -1) out.write(b, 0, n);
           in.close();
           out.flush();
           out.close();
           // Count the file
           count++;
         }
       }
     }
     zipFile.close();
   } catch (Exception e) {
     System.err.println("...an error occured while installing " + outFile);
     e.printStackTrace();
     System.err.println("Error copying " + outFile.getName() + "\n" + e.getMessage());
     return -count;
   }
   System.out.println(count + " files were installed.");
   return count;
 }
示例#30
0
  public List<ServiceData> getServices(File serviceDir) throws Exception {
    List<ServiceData> result = new ArrayList<ServiceData>();

    if (!serviceDir.exists()) {
      return result;
    }

    for (File sdir : serviceDir.listFiles()) {
      File dataFile = new File(sdir, "data");
      ServiceData data = getData(ServiceData.class, dataFile);
      result.add(data);
    }
    return result;
  }