Exemple #1
0
 private void deploy() {
   List startList = new ArrayList();
   Iterator iter = dirMap.entrySet().iterator();
   try {
     while (iter.hasNext() && !shutdown) {
       Map.Entry entry = (Map.Entry) iter.next();
       File f = (File) entry.getKey();
       QEntry qentry = (QEntry) entry.getValue();
       long deployed = qentry.getDeployed();
       if (deployed == 0) {
         if (deploy(f)) {
           if (qentry.isQBean()) startList.add(qentry.getInstance());
           qentry.setDeployed(f.lastModified());
         } else {
           // deploy failed, clean up.
           iter.remove();
         }
       } else if (deployed != f.lastModified()) {
         undeploy(f);
         iter.remove();
         loader.forceNewClassLoaderOnNextScan();
       }
     }
     iter = startList.iterator();
     while (iter.hasNext()) {
       start((ObjectInstance) iter.next());
     }
   } catch (Exception e) {
     log.error("deploy", e);
   }
 }
Exemple #2
0
 public synchronized boolean reload(boolean force) {
   long now = System.currentTimeMillis();
   if (force == false && now < last_check + 3000) return false;
   last_check = now;
   File file = getPropertyFile();
   if (file.lastModified() == last_load_time) {
     return false;
   }
   last_load_time = file.lastModified();
   Properties temp = new Properties();
   if (file.canRead()) {
     FileInputStream in = null;
     try {
       in = new FileInputStream(file);
       temp.load(in);
     } catch (Exception e) {
       e.printStackTrace();
     } finally {
       FileUtil.close(in);
     }
   }
   property = ConfigValueUtil.replaceSysProp(temp);
   apply();
   ConfObserver.run();
   return true;
 }
Exemple #3
0
  /**
   * Checks to see if the list of outputFiles all exist, and have last-modified timestamps which are
   * later than the last-modified timestamp of all the grammar files involved in build the output
   * (imports must be checked). If these conditions hold, the method returns false, otherwise, it
   * returns true.
   *
   * @param grammarFileName The grammar file we are checking
   */
  public boolean buildRequired(String grammarFileName) throws IOException, ANTLRException {
    BuildDependencyGenerator bd = new BuildDependencyGenerator(this, grammarFileName);

    List<File> outputFiles = bd.getGeneratedFileList();
    List<File> inputFiles = bd.getDependenciesFileList();
    // Note that input directory must be set to use buildRequired
    File grammarFile;
    if (haveInputDir) {
      grammarFile = new File(inputDirectory, grammarFileName);
    } else {
      grammarFile = new File(grammarFileName);
    }
    long grammarLastModified = grammarFile.lastModified();
    for (File outputFile : outputFiles) {
      if (!outputFile.exists() || grammarLastModified > outputFile.lastModified()) {
        // One of the output files does not exist or is out of date, so we must build it
        return true;
      }
      // Check all of the imported grammars and see if any of these are younger
      // than any of the output files.
      if (inputFiles != null) {
        for (File inputFile : inputFiles) {

          if (inputFile.lastModified() > outputFile.lastModified()) {
            // One of the imported grammar files has been updated so we must build
            return true;
          }
        }
      }
    }
    if (isVerbose()) {
      System.out.println("Grammar " + grammarFile + " is up to date - build skipped");
    }
    return false;
  }
  protected void unpackComponents() throws IOException, FileNotFoundException {
    File applicationPackage = new File(getApplication().getPackageResourcePath());
    File componentsDir = new File(sGREDir, "components");
    if (componentsDir.lastModified() == applicationPackage.lastModified()) return;

    componentsDir.mkdir();
    componentsDir.setLastModified(applicationPackage.lastModified());

    GeckoAppShell.killAnyZombies();

    ZipFile zip = new ZipFile(applicationPackage);

    byte[] buf = new byte[32768];
    try {
      if (unpackFile(zip, buf, null, "removed-files")) removeFiles();
    } catch (Exception ex) {
      // This file may not be there, so just log any errors and move on
      Log.w(LOG_FILE_NAME, "error removing files", ex);
    }

    // copy any .xpi file into an extensions/ directory
    Enumeration<? extends ZipEntry> zipEntries = zip.entries();
    while (zipEntries.hasMoreElements()) {
      ZipEntry entry = zipEntries.nextElement();
      if (entry.getName().startsWith("extensions/") && entry.getName().endsWith(".xpi")) {
        Log.i("GeckoAppJava", "installing extension : " + entry.getName());
        unpackFile(zip, buf, entry, entry.getName());
      }
    }
  }
Exemple #5
0
 public int compare(Object o1, Object o2) {
   File f1 = (File) o1;
   File f2 = (File) o2;
   if (f1.isDirectory()) {
     if (f2.isDirectory()) {
       switch (mode) {
           // Filename or Type
         case 1:
         case 4:
           return sign
               * f1.getAbsolutePath()
                   .toUpperCase()
                   .compareTo(f2.getAbsolutePath().toUpperCase());
           // Filesize
         case 2:
           return sign * (new Long(f1.length()).compareTo(new Long(f2.length())));
           // Date
         case 3:
           return sign * (new Long(f1.lastModified()).compareTo(new Long(f2.lastModified())));
         default:
           return 1;
       }
     } else return -1;
   } else if (f2.isDirectory()) return 1;
   else {
     switch (mode) {
       case 1:
         return sign
             * f1.getAbsolutePath().toUpperCase().compareTo(f2.getAbsolutePath().toUpperCase());
       case 2:
         return sign * (new Long(f1.length()).compareTo(new Long(f2.length())));
       case 3:
         return sign * (new Long(f1.lastModified()).compareTo(new Long(f2.lastModified())));
       case 4:
         { // Sort by extension
           int tempIndexf1 = f1.getAbsolutePath().lastIndexOf('.');
           int tempIndexf2 = f2.getAbsolutePath().lastIndexOf('.');
           if ((tempIndexf1 == -1) && (tempIndexf2 == -1)) { // Neither have an extension
             return sign
                 * f1.getAbsolutePath()
                     .toUpperCase()
                     .compareTo(f2.getAbsolutePath().toUpperCase());
           }
           // f1 has no extension
           else if (tempIndexf1 == -1) return -sign;
           // f2 has no extension
           else if (tempIndexf2 == -1) return sign;
           // Both have an extension
           else {
             String tempEndf1 = f1.getAbsolutePath().toUpperCase().substring(tempIndexf1);
             String tempEndf2 = f2.getAbsolutePath().toUpperCase().substring(tempIndexf2);
             return sign * tempEndf1.compareTo(tempEndf2);
           }
         }
       default:
         return 1;
     }
   }
 }
Exemple #6
0
  public String _fmodified(String args[]) throws Exception {
    verifyCommand(args, _fmodifiedHelp, null, 2, Integer.MAX_VALUE);

    long time = 0;
    Collection<String> names = new ArrayList<String>();
    for (int i = 1; i < args.length; i++) {
      Processor.split(args[i], names);
    }
    for (String name : names) {
      File f = new File(name);
      if (f.exists() && f.lastModified() > time) time = f.lastModified();
    }
    return "" + time;
  }
      public WFile readFile(String strPath) {
        File objFile = new File(strPath);
        HashMap hmConts = new HashMap();
        setHM(strPath, hmConts);

        return new WFile(objFile.lastModified(), hmConts);
      }
  private boolean unpackFile(ZipFile zip, byte[] buf, ZipEntry fileEntry, String name)
      throws IOException, FileNotFoundException {
    if (fileEntry == null) fileEntry = zip.getEntry(name);
    if (fileEntry == null)
      throw new FileNotFoundException("Can't find " + name + " in " + zip.getName());

    File outFile = new File(sGREDir, name);
    if (outFile.lastModified() == fileEntry.getTime() && outFile.length() == fileEntry.getSize())
      return false;

    File dir = outFile.getParentFile();
    if (!dir.exists()) dir.mkdirs();

    InputStream fileStream;
    fileStream = zip.getInputStream(fileEntry);

    OutputStream outStream = new FileOutputStream(outFile);

    while (fileStream.available() > 0) {
      int read = fileStream.read(buf, 0, buf.length);
      outStream.write(buf, 0, read);
    }

    fileStream.close();
    outStream.close();
    outFile.setLastModified(fileEntry.getTime());
    return true;
  }
Exemple #9
0
 public boolean isOlderThan(String dir, String name, String extension, long time)
     throws java.io.IOException {
   String filename = getFilename(dir, name, extension);
   File f = new File(filename);
   // System.out.println("filename="+filename+" lm="+f.lastModified());
   return f.lastModified() < time;
 }
  /** Return the modify-time of the underlying properties file. */
  public long lastModified() {
    if ((file == null) || !file.exists()) {
      return lastadd;
    }

    return Math.max(file.lastModified(), lastadd);
  }
Exemple #11
0
  private void copy(File workspaceDir, InputStream in, Pattern glob, boolean overwrite)
      throws Exception {

    Jar jar = new Jar("dot", in);
    try {
      for (Entry<String, Resource> e : jar.getResources().entrySet()) {

        String path = e.getKey();
        bnd.trace("path %s", path);

        if (glob != null && !glob.matcher(path).matches()) continue;

        Resource r = e.getValue();
        File dest = Processor.getFile(workspaceDir, path);
        if (overwrite
            || !dest.isFile()
            || dest.lastModified() < r.lastModified()
            || r.lastModified() <= 0) {

          bnd.trace("copy %s to %s", path, dest);

          File dp = dest.getParentFile();
          if (!dp.exists() && !dp.mkdirs()) {
            throw new IOException("Could not create directory " + dp);
          }

          IO.copy(r.openInputStream(), dest);
        }
      }
    } finally {
      jar.close();
    }
  }
  /** Private method to read file if it has been changed since the last time we did */
  private void checkFile() {
    if ((file != null) && (file.lastModified() > lastread)) {
      reload();
    }

    lastcheck = System.currentTimeMillis();
  }
  // Servlets that support HTTP GET requests and can quickly determine their last modification time
  // should
  // override this method. This makes browser and proxy caches work more effectively, reducing the
  // load on
  // server and network resources.
  protected long getLastModified(HttpServletRequest req) {
    String query = req.getQueryString();
    if (query != null) return -1;

    String path = req.getPathInfo();
    if (path == null) return -1;

    if (path.endsWith(".asc")) path = path.substring(0, path.length() - 4);
    else if (path.endsWith(".ascii")) path = path.substring(0, path.length() - 6);
    else if (path.endsWith(".das")) path = path.substring(0, path.length() - 4);
    else if (path.endsWith(".dds")) path = path.substring(0, path.length() - 4);
    else if (path.endsWith(".ddx")) path = path.substring(0, path.length() - 4);
    else if (path.endsWith(".dods")) path = path.substring(0, path.length() - 5);
    else if (path.endsWith(".html")) path = path.substring(0, path.length() - 5);
    else if (path.endsWith(".info")) path = path.substring(0, path.length() - 5);
    else if (path.endsWith(".opendap")) path = path.substring(0, path.length() - 5);
    else return -1;

    // if (null != DatasetHandler.findResourceControl( path)) return -1; // LOOK weird Firefox
    // beahviour?

    File file = DataRootHandler.getInstance().getCrawlableDatasetAsFile(path);
    if ((file != null) && file.exists()) return file.lastModified();

    return -1;
  }
Exemple #14
0
  static void optimize(final File f, final File d, final Remapper remapper) throws IOException {
    if (f.isDirectory()) {
      File[] files = f.listFiles();
      for (int i = 0; i < files.length; ++i) {
        optimize(files[i], d, remapper);
      }
    } else if (f.getName().endsWith(".class")) {
      ConstantPool cp = new ConstantPool();
      ClassReader cr = new ClassReader(new FileInputStream(f));
      // auto-boxing removal requires to recompute the maxs
      ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
      ClassConstantsCollector ccc = new ClassConstantsCollector(cw, cp);
      ClassOptimizer co = new ClassOptimizer(ccc, remapper);
      cr.accept(co, ClassReader.SKIP_DEBUG);

      Set<Constant> constants = new TreeSet<Constant>(new ConstantComparator());
      constants.addAll(cp.values());

      cr = new ClassReader(cw.toByteArray());
      cw = new ClassWriter(0);
      Iterator<Constant> i = constants.iterator();
      while (i.hasNext()) {
        Constant c = i.next();
        c.write(cw);
      }
      cr.accept(cw, ClassReader.SKIP_DEBUG);

      if (MAPPING.get(cr.getClassName() + "/remove") != null) {
        return;
      }
      String n = remapper.mapType(cr.getClassName());
      File g = new File(d, n + ".class");
      if (!g.exists() || g.lastModified() < f.lastModified()) {
        if (!g.getParentFile().exists() && !g.getParentFile().mkdirs()) {
          throw new IOException("Cannot create directory " + g.getParentFile());
        }
        OutputStream os = new FileOutputStream(g);
        try {
          os.write(cw.toByteArray());
        } finally {
          os.close();
        }
      }
    }
  }
 protected void addPathFile(final File pathComponent) throws IOException {
   if (!this.pathComponents.contains(pathComponent)) {
     this.pathComponents.addElement(pathComponent);
   }
   if (pathComponent.isDirectory()) {
     return;
   }
   final String absPathPlusTimeAndLength =
       pathComponent.getAbsolutePath()
           + pathComponent.lastModified()
           + "-"
           + pathComponent.length();
   String classpath = AntClassLoader.pathMap.get(absPathPlusTimeAndLength);
   if (classpath == null) {
     JarFile jarFile = null;
     try {
       jarFile = new JarFile(pathComponent);
       final Manifest manifest = jarFile.getManifest();
       if (manifest == null) {
         return;
       }
       classpath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
     } finally {
       if (jarFile != null) {
         jarFile.close();
       }
     }
     if (classpath == null) {
       classpath = "";
     }
     AntClassLoader.pathMap.put(absPathPlusTimeAndLength, classpath);
   }
   if (!"".equals(classpath)) {
     final URL baseURL = AntClassLoader.FILE_UTILS.getFileURL(pathComponent);
     final StringTokenizer st = new StringTokenizer(classpath);
     while (st.hasMoreTokens()) {
       final String classpathElement = st.nextToken();
       final URL libraryURL = new URL(baseURL, classpathElement);
       if (!libraryURL.getProtocol().equals("file")) {
         this.log(
             "Skipping jar library "
                 + classpathElement
                 + " since only relative URLs are supported by this"
                 + " loader",
             3);
       } else {
         final String decodedPath = Locator.decodeUri(libraryURL.getFile());
         final File libraryFile = new File(decodedPath);
         if (!libraryFile.exists() || this.isInPath(libraryFile)) {
           continue;
         }
         this.addPathFile(libraryFile);
       }
     }
   }
 }
 public static final boolean receive_file_exists(
     Client client, String filePath, long lastModified, long length) throws IOException {
   File existsFile = new File(client.getDirectory(), filePath);
   if (!existsFile.exists()) return false;
   if (existsFile.lastModified() != lastModified) return false;
   if (existsFile.length() != length) return false;
   File rootDir = getTempReceiveDir(client);
   IOUtils.appendLines(new File(rootDir, PATH_TO_MOVE), filePath);
   return true;
 }
Exemple #17
0
  /**
   * return OutputStream of JasperReport object, this page could only be viewed from localhost for
   * security concern. parameter can be (id), or (table and type)
   *
   * @param id - report id, or
   * @param table - table name
   * @param type - reporttype "s","l","o", case insensitive
   * @param client(*) - client domain
   * @param version - version number, default to -1
   */
  public void process(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String clientName = request.getParameter("client");
    int objectId = ParamUtils.getIntAttributeOrParameter(request, "id", -1);
    if (objectId == -1) {
      // try using table and type
      objectId =
          getReportId(clientName, request.getParameter("table"), request.getParameter("type"));
    }
    if (objectId == -1) {
      logger.error("report not found, request is:" + Tools.toString(request));
      throw new NDSException("report not found");
    }
    int version = ParamUtils.getIntAttributeOrParameter(request, "version", -1);
    File reportXMLFile = new File(ReportTools.getReportFile(objectId, clientName));
    if (reportXMLFile.exists()) {
      // generate jasperreport if file not exists or not newer
      String reportName =
          reportXMLFile.getName().substring(0, reportXMLFile.getName().lastIndexOf("."));
      File reportJasperFile = new File(reportXMLFile.getParent(), reportName + ".jasper");
      if (!reportJasperFile.exists()
          || reportJasperFile.lastModified() < reportXMLFile.lastModified()) {
        JasperCompileManager.compileReportToFile(
            reportXMLFile.getAbsolutePath(), reportJasperFile.getAbsolutePath());
      }
      InputStream is = new FileInputStream(reportJasperFile);
      response.setContentType("application/octetstream;");
      response.setContentLength((int) reportJasperFile.length());

      // response.setHeader("Content-Disposition","inline;filename=\""+reportJasperFile.getName()+"\"");
      ServletOutputStream os = response.getOutputStream();

      byte[] b = new byte[8192];
      int bInt;
      while ((bInt = is.read(b, 0, b.length)) != -1) {
        os.write(b, 0, bInt);
      }
      is.close();
      os.flush();
      os.close();
    } else {
      throw new NDSException("Not found report template");
    }
  }
Exemple #18
0
 /**
  * Remove all files with date < cutoff.
  *
  * @param cutoff earliest date to allow
  * @param sbuff write results here, null is ok.
  */
 public static void cleanCache(Date cutoff, StringBuilder sbuff) {
   if (sbuff != null) sbuff.append("CleanCache files before ").append(cutoff).append("\n");
   File dir = new File(root);
   for (File file : dir.listFiles()) {
     Date lastMod = new Date(file.lastModified());
     if (lastMod.before(cutoff)) {
       file.delete();
       if (sbuff != null)
         sbuff.append(" delete ").append(file).append(" (").append(lastMod).append(")\n");
     }
   }
 }
Exemple #19
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"));
      }
    }
  }
Exemple #20
0
 /**
  * debug
  *
  * @param filename look for this file
  * @throws java.io.IOException if read error
  */
 static void make(String filename) throws IOException {
   File want = DiskCache.getCacheFile(filename);
   System.out.println("make=" + want.getPath() + "; exists = " + want.exists());
   if (!want.exists()) want.createNewFile();
   System.out.println(
       " canRead= "
           + want.canRead()
           + " canWrite = "
           + want.canWrite()
           + " lastMod = "
           + new Date(want.lastModified()));
   System.out.println(" original=" + filename);
 }
 /*.................................................................................................................*/
 public void processOutputFiles() {
   if (outputFileProcessor != null && outputFilePaths != null && lastModified != null) {
     String[] paths = outputFileProcessor.modifyOutputPaths(outputFilePaths);
     for (int i = 0; i < paths.length && i < lastModified.length; i++) {
       File file = new File(paths[i]);
       long lastMod = file.lastModified();
       if (!MesquiteLong.isCombinable(lastModified[i]) || lastMod > lastModified[i]) {
         outputFileProcessor.processOutputFile(paths, i);
         lastModified[i] = lastMod;
       }
     }
   }
 }
 public static void checkPluginPropertiesConsistency(Map map, File configDir) {
   File runtimeDir = new File(configDir, IPDEBuildConstants.BUNDLE_CORE_RUNTIME);
   if (runtimeDir.exists() && runtimeDir.isDirectory()) {
     long timestamp = runtimeDir.lastModified();
     Iterator iter = map.values().iterator();
     while (iter.hasNext()) {
       if (hasChanged((IMonitorModelBase) iter.next(), timestamp)) {
         CoreUtility.deleteContent(runtimeDir);
         break;
       }
     }
   }
 }
Exemple #23
0
 private long persist(File f, ObjectName name) {
   long deployed = f.lastModified();
   try {
     Element e = (Element) server.getAttribute(name, "Persist");
     if (e != null) {
       XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
       Document doc = new Document();
       e.detach();
       doc.setRootElement(e);
       File tmp = new File(f.getAbsolutePath() + ".tmp");
       FileWriter writer = new FileWriter(tmp);
       out.output(doc, writer);
       writer.close();
       f.delete();
       tmp.renameTo(f);
       deployed = f.lastModified();
     }
   } catch (Exception ex) {
     log.warn("persist", ex);
   }
   return deployed;
 }
 /**
  * Constructs an instance.
  *
  * @param pathname the name of a file
  */
 FileInfo(String pathname) {
   mPathname = pathname;
   File file = new File(pathname);
   // Cope with directory indexes for now
   // FIXME: [2003-05-09 bloch] is this the right place
   // for this?
   if (file.isDirectory()) {
     file = new File(pathname + File.separator + "library.lzx");
   }
   // Truncate to an seconds
   mLastMod = ((long) (file.lastModified() / 1000L)) * 1000L;
   mCanRead = file.canRead();
   // mLogger.debug("lm: " + mLastMod);
   mLength = file.length();
 }
Exemple #25
0
  public static void showCache(PrintStream pw) {
    pw.println("Cache files");
    pw.println("Size   LastModified       Filename");
    File dir = new File(root);
    for (File file : dir.listFiles()) {
      String org = null;
      org = EscapeStrings.urlDecode(file.getName());
      /*try {
        org = URLDecoder.decode(file.getName(), "UTF8");
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      }*/

      pw.println(" " + file.length() + " " + new Date(file.lastModified()) + " " + org);
    }
  }
  /**
   * Read block from file.
   *
   * @param file - File to read.
   * @param off - Marker position in file to start read from if {@code -1} read last blockSz bytes.
   * @param blockSz - Maximum number of chars to read.
   * @param lastModified - File last modification time.
   * @return Read file block.
   * @throws IOException In case of error.
   */
  public static VisorFileBlock readBlock(File file, long off, int blockSz, long lastModified)
      throws IOException {
    RandomAccessFile raf = null;

    try {
      long fSz = file.length();
      long fLastModified = file.lastModified();

      long pos = off >= 0 ? off : Math.max(fSz - blockSz, 0);

      // Try read more that file length.
      if (fLastModified == lastModified && fSz != 0 && pos >= fSz)
        throw new IOException(
            "Trying to read file block with wrong offset: " + pos + " while file size: " + fSz);

      if (fSz == 0)
        return new VisorFileBlock(file.getPath(), pos, fLastModified, 0, false, EMPTY_FILE_BUF);
      else {
        int toRead = Math.min(blockSz, (int) (fSz - pos));

        byte[] buf = new byte[toRead];

        raf = new RandomAccessFile(file, "r");

        raf.seek(pos);

        int cntRead = raf.read(buf, 0, toRead);

        if (cntRead != toRead)
          throw new IOException(
              "Count of requested and actually read bytes does not match [cntRead="
                  + cntRead
                  + ", toRead="
                  + toRead
                  + ']');

        boolean zipped = buf.length > 512;

        return new VisorFileBlock(
            file.getPath(), pos, fSz, fLastModified, zipped, zipped ? zipBytes(buf) : buf);
      }
    } finally {
      U.close(raf, null);
    }
  }
  // =====================================================
  // setEXIFpictureMetadaten()
  //
  // Aus dem Image-Original werden die EXIF-Daten f�r die
  // PM_PictureMetadatenX geholt und eingetragen
  // =====================================================
  public static void setEXIFpictureMetadaten(PM_Picture picture) {

    PM_PictureImageMetadaten imageMetadaten = picture.getImageMetadaten();

    // ----------------------------------------------------
    // FujiFilm Makernote:  SequenceNummer --> virtPicture
    // ----------------------------------------------------

    // -------------------------------------------------------
    // Date
    // ------------------------------------------------------

    String tagDatum = "Date/Time Original";
    String description = "";
    if (imageMetadaten.hasTag(tagDatum)) {
      description = imageMetadaten.getDescription(tagDatum);
    }

    // ----------------------------------------------------
    // Datum nicht vorhanden oder ung�ltig
    // ----------------------------------------------------
    Date myDate = null;
    if (description.length() == 0 || description.equals("0000:00:00 00:00:00")) {
      //			  System.out.println("......  Datum = " + description + " kann nicht konvertiert
      // werden");
      File f = picture.getFileOriginal();
      Date date = new Date(f.lastModified());
      picture.meta.setDateImport(date);
      picture.meta.setDateCurrent(new Date(date.getTime()));
      return;
    }

    // ----------------------------------------------------
    // g�ltiges Datum gefunden
    // ----------------------------------------------------
    DateFormat df = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
    try {
      myDate = df.parse(description);
    } catch (ParseException e) {
      //           System.out.println("ParseException fuer Datum = " + description);
      myDate = new Date(System.currentTimeMillis()); // default
    }
    picture.meta.setDateImport(myDate);
    picture.meta.setDateCurrent(new Date(myDate.getTime()));
  }
  private static void addFileToJar(
      @NotNull JarOutputStream jar,
      @NotNull File file,
      @NotNull File rootDirectory,
      boolean packRClasses)
      throws IOException {

    if (file.isDirectory()) {
      for (File child : file.listFiles()) {
        addFileToJar(jar, child, rootDirectory, packRClasses);
      }
    } else if (file.isFile()) {
      if (!FileUtil.getExtension(file.getName()).equals("class")) {
        return;
      }

      if (!packRClasses && R_PATTERN.matcher(file.getName()).matches()) {
        return;
      }

      final String rootPath = rootDirectory.getAbsolutePath();

      String path = file.getAbsolutePath();
      path = FileUtil.toSystemIndependentName(path.substring(rootPath.length()));
      if (path.charAt(0) == '/') {
        path = path.substring(1);
      }

      final JarEntry entry = new JarEntry(path);
      entry.setTime(file.lastModified());
      jar.putNextEntry(entry);

      BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
      try {
        final byte[] buffer = new byte[1024];
        int count;
        while ((count = bis.read(buffer)) != -1) {
          jar.write(buffer, 0, count);
        }
        jar.closeEntry();
      } finally {
        bis.close();
      }
    }
  }
  private boolean hasBaseChanged(URI installArea, File outputFolder) {
    String rememberedTimestamp;
    try {
      rememberedTimestamp =
          (String)
              loadProperties(
                      new File(
                          outputFolder, SimpleConfiguratorImpl.BASE_TIMESTAMP_FILE_BUNDLESINFO))
                  .get(SimpleConfiguratorImpl.KEY_BUNDLESINFO_TIMESTAMP);
    } catch (IOException e) {
      return false;
    }
    if (rememberedTimestamp == null) return false;

    File sharedBundlesInfo = new File(URIUtil.append(installArea, SHARED_BUNDLES_INFO));
    if (!sharedBundlesInfo.exists()) return true;
    return !String.valueOf(sharedBundlesInfo.lastModified()).equals(rememberedTimestamp);
  }
  /**
   * Decides if the given source is newer than a class.
   *
   * @param source the source we may want to compile
   * @param cls the former class
   * @return true if the source is newer, false else
   * @throws IOException if it is not possible to open an connection for the given source
   * @see #getTimeStamp(Class)
   */
  protected boolean isSourceNewer(URL source, Class cls) throws IOException {
    long lastMod;

    // Special handling for file:// protocol, as getLastModified() often reports
    // incorrect results (-1)
    if (isFile(source)) {
      // Coerce the file URL to a File
      // See ClassNodeResolver.isSourceNewer for another method that replaces '|' with ':'.
      // WTF: Why is this done and where is it documented?
      String path = source.getPath().replace('/', File.separatorChar).replace('|', ':');
      File file = new File(path);
      lastMod = file.lastModified();
    } else {
      URLConnection conn = source.openConnection();
      lastMod = conn.getLastModified();
      conn.getInputStream().close();
    }
    long classTime = getTimeStamp(cls);
    return classTime + config.getMinimumRecompilationInterval() < lastMod;
  }