Beispiel #1
0
  /**
   * Copies a source file to a destination file, optionally preserving the source's last
   * modification time. We already have an input stream to read the source file, but we know nothing
   * about the destination file yet. Note that this method <em>never</em> closes the given input
   * stream!
   *
   * @throws FileNotFoundException If either the source or the destination cannot get accessed.
   * @throws InputIOException If copying the data fails because of an IOException in the source.
   * @throws IOException If copying the data fails because of an IOException in the destination.
   */
  private static void cp0(
      final boolean preserve, final java.io.File src, final InputStream in, final java.io.File dst)
      throws IOException {
    try {
      if (dst instanceof File) {
        final File dstFile = (File) dst;
        dstFile.ensureNotVirtualRoot("cannot write");
        final String dstEntryName = dstFile.getEnclEntryName();
        if (dstEntryName != null) {
          cp0(preserve, src, in, dstFile.getEnclArchive().getArchiveController(), dstEntryName);
          return;
        }
      }
    } catch (RfsEntryFalsePositiveException dstIsNotArchive) {
    }

    // Treat the destination like a regular file.
    final OutputStream out = new java.io.FileOutputStream(dst);
    try {
      Streams.cat(in, out);
    } finally {
      out.close();
    }
    if (preserve && !dst.setLastModified(src.lastModified()))
      throw new IOException(dst.getPath() + " (cannot preserve last modification time)");
  }
Beispiel #2
0
 public static long getLastWriteTime(String filename) {
   try {
     java.io.File f = new java.io.File(filename);
     return f.lastModified();
   } catch (Exception ex) {
     return -1;
   }
 }
 /**
  * 删除指定的 Web 应用程序目录下所上传的文件
  *
  * @param application JSP/Servlet 的 ServletContext
  * @param filePath 相对文件路径
  */
 public static void deleteFile(ServletContext application, String filePath) {
   if (!isEmpty(filePath)) {
     String physicalFilePath = application.getRealPath(filePath);
     if (!isEmpty(physicalFilePath)) {
       java.io.File file = new java.io.File(physicalFilePath);
       file.delete();
     }
   }
 }
Beispiel #4
0
 /**
  * Returns the canonical form of the given file or the normalized absolute form if resolving the
  * prior fails.
  *
  * @return The canonical or absolute path of this file as a <code>java.io.File</code> instance.
  * @throws NullPointerException If <code>file</code> is <code>null</code>.
  */
 public static java.io.File getCanOrAbsFile(java.io.File file) {
   try {
     return file.getCanonicalFile();
   } catch (IOException ex) {
     final java.io.File parent = file.getParentFile();
     return normalize(
         parent != null
             ? new java.io.File(getCanOrAbsFile(parent), file.getName())
             : file.getAbsoluteFile());
   }
 }
  /**
   * 检查指定的 Web 应用程序目录下的文件是否存在.
   *
   * @param application JSP/Servlet 的 ServletContext
   * @param filePath 相对文件路径
   * @return boolean - 文件是否存在
   */
  public static boolean checkFileExists(ServletContext application, String filePath) {
    if (!isEmpty(filePath)) {
      String physicalFilePath = application.getRealPath(filePath);
      if (!isEmpty(physicalFilePath)) {
        java.io.File file = new java.io.File(physicalFilePath);
        return file.exists();
      }
    }

    return false;
  }
Beispiel #6
0
 private boolean CheckValidDir(String path) {
   java.io.File dir = new java.io.File(path);
   if (dir == null) {
     return false;
   }
   if (dir.isFile()) {
     return false;
   }
   if (!dir.exists()) {
     return false;
   }
   return true;
 }
 public java.net.URL getCodeBase() {
   if (codeBase == null) {
     try {
       java.io.File file = new java.io.File("");
       codeBase =
           new java.net.URL(
               "file",
               "", // no host
               file.getAbsolutePath().toString());
     } catch (java.net.MalformedURLException e) {
     }
   }
   return codeBase;
 }
Beispiel #8
0
 /**
  * Removes the entire directory tree represented by the parameter, regardless whether it's a file
  * or directory, whether the directory is empty or not or whether the file or directory is
  * actually an archive file, an entry in an archive file or not enclosed in an archive file at
  * all.
  *
  * <p>The name of this method is inspired by the Unix command line utility <code>rm</code> with
  * the <code>-r</code> option to operate recursively.
  *
  * <p>This file system operation is <em>not</em> atomic.
  *
  * @return Whether or not the entire directory tree was successfully removed.
  */
 public static boolean rm_r(final java.io.File file) {
   boolean ok = true;
   if (file.isDirectory()) {
     // Note that listing the directory this way will cause a recursive
     // deletion if the directory is actually an archive file.
     // Although this does not provide best performance (the archive
     // file could simply be removed like an ordinary file), it ensures
     // that the state cached by the ArchiveController is not bypassed
     // and hence prevents a potential bug.
     java.io.File[] members = file.listFiles();
     for (int i = members.length; --i >= 0; ) ok &= rm_r(members[i]);
   }
   return ok && file.delete();
 }
  /**
   * 在指定的 Web 应用程序目录下以指定路径创建目录.
   *
   * @param application JSP/Servlet 的 ServletContext
   * @param filePath 相对文件路径
   */
  public static boolean createDir(ServletContext application, String filePath) {
    if (!isEmpty(filePath)) {
      String physicalFilePath = application.getRealPath(filePath);
      if (!isEmpty(physicalFilePath)) {
        try {
          //  创建目录
          java.io.File dir = new java.io.File(application.getRealPath(filePath));
          return dir.mkdirs();
        } catch (Exception e) {
          System.err.println(" Unable to create directory  " + filePath);
        }
      }
    }

    return false;
  }
Beispiel #10
0
 /**
  * Removes any <code>&quot;.&quot;</code> and <code>&quot;..&quot;</code> directories from the
  * path wherever possible.
  *
  * @param file The file instance which's path is to be normalized.
  * @return <code>file</code> if it was already in normalized form. Otherwise, an object which's
  *     runtime class is guaranteed to be <code>java.io.File</code>.
  */
 public static java.io.File normalize(final java.io.File file) {
   final String path = file.getPath();
   final String newPath = Paths.normalize(path, File.separatorChar);
   return newPath != path // mind contract of Paths.normalize!
       ? new java.io.File(newPath)
       : file;
 }
Beispiel #11
0
 public static java.awt.Image loadImageFromFile(String path) {
   java.io.File file = new java.io.File(path);
   if (file.exists()) {
     java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
     java.awt.Image img = tk.createImage(path);
     try {
       java.awt.MediaTracker mt = new java.awt.MediaTracker(new javax.swing.JPanel());
       mt.addImage(img, 0);
       mt.waitForID(0);
     } catch (Exception ex) {
       return null;
     }
     return img;
   }
   return null;
 }
Beispiel #12
0
  /**
   * 在指定的 Web 应用程序目录下以指定路径创建文件
   *
   * @param application JSP/Servlet 的 ServletContext
   * @param filePath 相对文件路径
   */
  public static boolean createFile(ServletContext application, String filePath) {
    if (!isEmpty(filePath)) {
      String physicalFilePath = application.getRealPath(filePath);
      if (!isEmpty(physicalFilePath)) {
        java.io.File file = new java.io.File(physicalFilePath);

        try {
          //  创建文件
          return file.createNewFile();
        } catch (IOException e) {
          System.err.println(" Unable to create file  " + filePath);
        }
      }
    }

    return false;
  }
Beispiel #13
0
  public static String getShortFileName(String filename) {
    if (filename.length() > 50) {
      java.io.File f = new java.io.File(filename);
      if (nvl(f.getParentFile(), "").length() > 10) {
        String dir = f.getParentFile().getPath() + java.io.File.separatorChar;

        String shortDir = dir.substring(0, dir.indexOf(java.io.File.separatorChar) + 1);
        dir = dir.substring(dir.indexOf(java.io.File.separatorChar) + 1);
        if (dir.indexOf(java.io.File.separatorChar) > 0) {
          shortDir += dir.substring(0, dir.indexOf(java.io.File.separatorChar) + 1);
        }
        return shortDir + "..." + java.io.File.separatorChar + f.getName();
      }
    }

    return filename;
  }
Beispiel #14
0
 private static boolean mv0(
     final java.io.File src, final java.io.File dst, final ArchiveDetector detector) {
   boolean ok = true;
   if (src.isDirectory()) {
     final long srcLastModified = src.lastModified();
     final boolean srcIsArchived = src instanceof File && ((File) src).getInnerArchive() != null;
     final boolean dstIsArchived = dst instanceof File && ((File) dst).getInnerArchive() != null;
     final boolean srcIsGhost = srcIsArchived && srcLastModified <= 0;
     if (!srcIsGhost || !dstIsArchived || !File.isLenient()) dst.mkdir();
     final String[] members = src.list();
     if (!srcIsArchived && dstIsArchived) {
       // Create sorted entries if writing a new archive file.
       // This is courtesy only, so natural order is sufficient.
       Arrays.sort(members);
     }
     for (int i = 0, l = members.length; i < l; i++) {
       final String member = members[i];
       ok &= mv0(detector.createFile(src, member), detector.createFile(dst, member), detector);
     }
     if (!srcIsGhost) ok &= dst.setLastModified(srcLastModified);
   } else if (src.isFile()) { // !isDirectory()
     try {
       cp(true, src, dst);
     } catch (IOException ex) {
       ok = false;
     }
   } else {
     ok = false; // don't move special files!
   }
   return ok && src.delete(); // only unlink if ok!
 }
Beispiel #15
0
 public static void removePageFile(HTMLPage htmlPage, Identifier identifier, boolean EDIT_MODE) {
   String folderPath =
       (!EDIT_MODE) ? "live" + java.io.File.separator : "working" + java.io.File.separator;
   String velocityRootPath = Config.getStringProperty("VELOCITY_ROOT");
   if (velocityRootPath.startsWith("/WEB-INF")) {
     velocityRootPath = com.liferay.util.FileUtil.getRealPath(velocityRootPath);
   }
   String filePath =
       folderPath
           + identifier.getInode()
           + "."
           + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION");
   velocityRootPath += java.io.File.separator;
   java.io.File f = new java.io.File(velocityRootPath + filePath);
   f.delete();
   DotResourceCache vc = CacheLocator.getVeloctyResourceCache();
   vc.remove(ResourceManager.RESOURCE_TEMPLATE + filePath);
   CacheLocator.getHTMLPageCache().remove((HTMLPage) htmlPage);
 }
  public static List<ScmChange> getChanges(Project project, String path) {
    Session session = ((HibernateStorage) Manager.getStorageInstance()).getHibernateSession();

    String prefix = "";
    java.io.File searchDir = Manager.getStorageInstance().getWorkingDirectory(project);
    while (project.getParent() != null) {
      prefix = searchDir.getName() + java.io.File.separatorChar + prefix;
      project = project.getParent();
      searchDir = searchDir.getParentFile();
    }

    Query q =
        session.createQuery(
            "from ScmChange c where c.set.id.project = :project and name = :path order by c.set.date desc");
    q.setEntity("project", project);
    q.setString("path", prefix + path);

    return q.list();
  }
  public void unpack(String artifact, File destination) {
    File archiveFile = getAsFile(artifact);

    if (archiveFile == null || !archiveFile.exists()) return;
    if (archiveFile.isDirectory()) {
      try {
        Files.walkFileTree(archiveFile.toPath(), new CopyDirVisitor(archiveFile, destination));
      } catch (Exception e) {
        OutputBouble.reportError(e);
      }

    } else if (archiveFile.getName().endsWith("jar")) {
      destination.mkdirs();
      try {
        java.util.jar.JarFile jar = new java.util.jar.JarFile(archiveFile);
        java.util.Enumeration jarEnum = jar.entries();
        while (jarEnum.hasMoreElements()) {
          java.util.jar.JarEntry file = (java.util.jar.JarEntry) jarEnum.nextElement();
          java.io.File f = new java.io.File(destination + java.io.File.separator + file.getName());
          if (file.isDirectory()) { // if its a directory, create it
            f.mkdir();
            continue;
          }
          java.io.InputStream is = jar.getInputStream(file); // get the input stream
          java.io.FileOutputStream fos = new java.io.FileOutputStream(f);
          while (is.available() > 0) { // write contents of 'is' to 'fos'
            fos.write(is.read());
          }
          fos.close();
          is.close();
        }
        jar.close();
      } catch (Exception e) {

      }
    }
  }
Beispiel #18
0
 /** Unchecked parameters version. */
 private static void cp_r0(
     final boolean preserve,
     final java.io.File src,
     final java.io.File dst,
     final ArchiveDetector srcDetector,
     final ArchiveDetector dstDetector)
     throws IOException {
   if (src.isDirectory()) {
     final long srcLastModified = src.lastModified();
     final boolean srcIsArchived = src instanceof File && ((File) src).getInnerArchive() != null;
     final boolean dstIsArchived = dst instanceof File && ((File) dst).getInnerArchive() != null;
     final boolean srcIsGhost = srcIsArchived && srcLastModified <= 0;
     if (!srcIsGhost || !dstIsArchived || !File.isLenient())
       if (!dst.mkdir() && !dst.isDirectory())
         throw new IOException("destination is not a directory");
     final String[] members = src.list();
     if (!srcIsArchived && dstIsArchived) {
       // Create sorted entries if writing a new archive.
       // This is a courtesy only, so natural order is sufficient.
       Arrays.sort(members);
     }
     for (int i = 0, l = members.length; i < l; i++) {
       final String member = members[i];
       cp_r0(
           preserve,
           srcDetector.createFile(src, member),
           dstDetector.createFile(dst, member),
           srcDetector,
           dstDetector);
     }
     if (preserve && !srcIsGhost)
       if (!dst.setLastModified(srcLastModified))
         throw new IOException("cannot set last modification time");
   } else if (src.isFile() && (!dst.exists() || dst.isFile())) {
     cp0(preserve, src, dst);
   } else {
     throw new IOException("cannot copy non-existent or special files");
   }
 }
  /**
   * Creates an authorized Credential object.
   *
   * @return an authorized Credential object.
   * @throws IOException
   */
  public static Credential authorize() throws IOException {
    // Load client secrets.
    InputStream in = CalendarPush.class.getResourceAsStream("/client_secret.json");
    GoogleClientSecrets clientSecrets =
        GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));

    // Build flow and trigger user authorization request.
    GoogleAuthorizationCodeFlow flow =
        new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
            .setDataStoreFactory(DATA_STORE_FACTORY)
            .setAccessType("offline")
            .build();
    Credential credential =
        new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
    System.out.println("Credentials saved to " + DATA_STORE_DIR.getAbsolutePath());
    return credential;
  }
Beispiel #20
0
 void open(java.lang.String name) {
   final java.lang.String textString;
   if (name == null || name.length() == 0) {
     return;
   }
   java.io.File file = new java.io.File(name);
   if (!file.exists()) {
     java.lang.String message =
         MessageFormat.format(
             resources.getString("Err_file_no_exist"), new java.lang.String[] {file.getName()});
     displayError(message);
     return;
   }
   try {
     java.io.FileInputStream stream = new java.io.FileInputStream(file.getPath());
     try {
       java.io.Reader in = new java.io.BufferedReader(new java.io.InputStreamReader(stream));
       char[] readBuffer = new char[2048];
       java.lang.StringBuffer buffer = new java.lang.StringBuffer((int) file.length());
       int n;
       while ((n = in.read(readBuffer)) > 0) {
         buffer.append(readBuffer, 0, (-n));
       }
       textString = buffer.toString();
       stream.close();
     } catch (java.io.IOException e) {
       java.lang.String message =
           MessageFormat.format(
               resources.getString("Err_file_io"), new java.lang.String[] {file.getName()});
       displayError(message);
       return;
     }
   } catch (java.io.FileNotFoundException e) {
     java.lang.String message =
         MessageFormat.format(
             resources.getString("Err_not_found"), new java.lang.String[] {file.getName()});
     displayError(message);
     return;
   }
   org.eclipse.swt.widgets.Display display = text.getDisplay();
   display.asyncExec(
       new java.lang.Runnable() {
         public void run() {
           text.setText(textString);
         }
       });
   lineStyler.parseBlockComments(textString);
 }
Beispiel #21
0
  /** Unchecked parameters version. */
  private static void cp0(final boolean preserve, final java.io.File src, final java.io.File dst)
      throws IOException {
    assert src != null;
    assert dst != null;

    try {
      try {
        if (src instanceof File) {
          final File srcFile = (File) src;
          srcFile.ensureNotVirtualRoot("cannot read");
          final String srcEntryName = srcFile.getEnclEntryName();
          if (srcEntryName != null) {
            cp0(preserve, srcFile.getEnclArchive().getArchiveController(), srcEntryName, dst);
            return;
          }
        }
      } catch (RfsEntryFalsePositiveException srcIsNotArchive) {
      }

      // Treat the source like a regular file.
      final InputStream in = new java.io.FileInputStream(src);
      try {
        cp0(preserve, src, in, dst);
      } finally {
        try {
          in.close();
        } catch (IOException ex) {
          throw new InputIOException(ex);
        }
      }
    } catch (FileNotFoundException ex) {
      throw ex;
    } catch (ArchiveBusyException ex) {
      throw new FileBusyException(ex);
    } catch (ArchiveFileSystemException afse) {
      final FileNotFoundException fnfe = new FileNotFoundException(afse.toString());
      fnfe.initCause(afse);
      throw fnfe;
    } catch (IOException ex) {
      dst.delete();
      throw ex;
    }
  }
  //	----------------------------------------------------------------------------------------------------------------
  //      Method:     authorize
  //      Inputs:	    none
  //     Outputs:	    Credentials
  // Description:     Creates an authorized credential object, will throw IO exception
  //	----------------------------------------------------------------------------------------------------------------
  private static Credential authorize() throws IOException {
    // Load client secrets (from JSON file)
    InputStream in = Main.class.getResourceAsStream("/client_secret_ecen689project1.json");
    GoogleClientSecrets clientSecrets =
        GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));

    // Build flow and trigger user authorization request
    GoogleAuthorizationCodeFlow flow =
        new GoogleAuthorizationCodeFlow.Builder(
                HTTP_TRANSPORT,
                JSON_FACTORY,
                clientSecrets,
                Collections.singleton(FusiontablesScopes.FUSIONTABLES))
            .setDataStoreFactory(DATA_STORE_FACTORY)
            .build();

    // Authorize and get the credential
    Credential credential =
        new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
    System.out.println("Credentials saved to " + DATA_STORE_DIR.getAbsolutePath());
    return credential; // Return the credential
  }
  public synchronized void service(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpSession dbSession = request.getSession();
    JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    PageContext pageContext =
        _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
    ServletContext dbApplication = dbSession.getServletContext();

    try {
      // 实例化

      HttpSession session = request.getSession();
      ServletContext context = session.getServletContext();
      String path = context.getRealPath("/");
      counter count = new counter(dbApplication);
      SmartUpload mySmartUpload = new SmartUpload();
      mySmartUpload.setCharset("UTF-8");
      nseer_db_backup1 qcs_db = new nseer_db_backup1(dbApplication);

      if (qcs_db.conn((String) dbSession.getAttribute("unit_db_name"))) {

        mySmartUpload.initialize(pageContext);
        String file_type = getFileLength.getFileType((String) session.getAttribute("unit_db_name"));
        long d = getFileLength.getFileLength((String) session.getAttribute("unit_db_name"));
        mySmartUpload.setMaxFileSize(d);
        mySmartUpload.setAllowedFilesList(file_type);

        try {
          mySmartUpload.upload();
          String qcs_id = mySmartUpload.getRequest().getParameter("qcs_id");
          String config_id = mySmartUpload.getRequest().getParameter("config_id");

          String[] item = mySmartUpload.getRequest().getParameterValues("item");
          if (item != null) {
            String[] file_name = new String[mySmartUpload.getFiles().getCount()];
            String[] not_change = new String[mySmartUpload.getFiles().getCount()];
            java.util.Date now = new java.util.Date();
            SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
            String time = formatter.format(now);
            String standard_id = mySmartUpload.getRequest().getParameter("standard_id");
            String sqla =
                "select attachment1 from qcs_intrmanufacture where qcs_id='"
                    + qcs_id
                    + "' and (check_tag='5' or check_tag='9')";
            ResultSet rs = qcs_db.executeQuery(sqla);
            if (!rs.next()) {
              response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=1");
            } else {
              String[] attachment = mySmartUpload.getRequest().getParameterValues("attachment");
              String[] delete_file_name = new String[0];
              if (attachment != null) {
                delete_file_name = new String[attachment.length];
                for (int i = 0; i < attachment.length; i++) {
                  delete_file_name[i] = rs.getString(attachment[i]);
                }
              }
              for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
                com.jspsmart.upload.SmartFile file = mySmartUpload.getFiles().getFile(i);
                if (file.isMissing()) {
                  file_name[i] = "";
                  int q = i + 1;
                  String field_name = "attachment" + q;
                  if (!rs.getString(field_name).equals("")) not_change[i] = "yes";
                  continue;
                }
                int filenum =
                    count.read(
                        (String) dbSession.getAttribute("unit_db_name"), "qcsAttachmentcount");
                count.write(
                    (String) dbSession.getAttribute("unit_db_name"), "qcsAttachmentcount", filenum);
                file_name[i] = filenum + file.getFileName();
                file.saveAs(path + "qcs/file_attachments/" + filenum + file.getFileName());
              }
              String apply_id = mySmartUpload.getRequest().getParameter("apply_id");
              String product_id = mySmartUpload.getRequest().getParameter("product_id");
              String product_name = mySmartUpload.getRequest().getParameter("product_name");
              String qcs_amount = mySmartUpload.getRequest().getParameter("qcs_amount");
              String qcs_time = mySmartUpload.getRequest().getParameter("qcs_time");
              String quality_way = mySmartUpload.getRequest().getParameter("quality_way");
              String quality_solution = mySmartUpload.getRequest().getParameter("quality_solution");
              String sampling_standard =
                  mySmartUpload.getRequest().getParameter("sampling_standard");
              String sampling_amount = mySmartUpload.getRequest().getParameter("sampling_amount");
              String accept = mySmartUpload.getRequest().getParameter("accept");
              String reject = mySmartUpload.getRequest().getParameter("reject");
              String qualified = mySmartUpload.getRequest().getParameter("qualified");
              String unqualified = mySmartUpload.getRequest().getParameter("unqualified");
              String qcs_result = mySmartUpload.getRequest().getParameter("qcs_result");
              String checker = mySmartUpload.getRequest().getParameter("checker");
              String checker_id = mySmartUpload.getRequest().getParameter("checker_id");
              String check_time = mySmartUpload.getRequest().getParameter("check_time");
              String changer = mySmartUpload.getRequest().getParameter("changer");
              String changer_id = mySmartUpload.getRequest().getParameter("changer_id");
              String change_time = mySmartUpload.getRequest().getParameter("change_time");
              String bodyab =
                  new String(
                      mySmartUpload.getRequest().getParameter("remark").getBytes("UTF-8"), "UTF-8");
              String remark = exchange.toHtml(bodyab);

              sqla =
                  "update qcs_intrmanufacture set apply_id='"
                      + apply_id
                      + "',product_id='"
                      + product_id
                      + "',product_name='"
                      + product_name
                      + "',qcs_amount='"
                      + qcs_amount
                      + "',qcs_time='"
                      + qcs_time
                      + "',quality_way='"
                      + quality_way
                      + "',quality_solution='"
                      + quality_solution
                      + "',sampling_standard='"
                      + sampling_standard
                      + "',sampling_amount='"
                      + sampling_amount
                      + "',accept='"
                      + accept
                      + "',reject='"
                      + reject
                      + "',qualified='"
                      + qualified
                      + "',unqualified='"
                      + unqualified
                      + "',changer_id='"
                      + changer_id
                      + "',qcs_result='"
                      + qcs_result
                      + "',changer='"
                      + changer
                      + "',change_time='"
                      + change_time
                      + "',remark='"
                      + remark
                      + "',check_tag='5'";
              String sqlb = " where qcs_id='" + qcs_id + "'";
              if (attachment != null) {
                for (int i = 0; i < attachment.length; i++) {
                  sqla = sqla + "," + attachment[i] + "=''";
                  java.io.File file =
                      new java.io.File(path + "qcs/file_attachments/" + delete_file_name[i]);
                  file.delete();
                }
              }
              for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
                if (not_change[i] != null && not_change[i].equals("yes")) continue;
                int p = i + 1;
                sqla = sqla + ",attachment" + p + "='" + file_name[i] + "'";
              }
              String sql = sqla + sqlb;
              qcs_db.executeUpdate(sql);

              sql = "delete from qcs_intrmanufacture_details where qcs_id='" + qcs_id + "'";
              qcs_db.executeUpdate(sql);

              String[] default_basis =
                  mySmartUpload.getRequest().getParameterValues("default_basis");
              String[] ready_basis = mySmartUpload.getRequest().getParameterValues("ready_basis");
              String[] quality_method =
                  mySmartUpload.getRequest().getParameterValues("quality_method");
              String[] analyse_method =
                  mySmartUpload.getRequest().getParameterValues("analyse_method");
              String[] standard_value =
                  mySmartUpload.getRequest().getParameterValues("standard_value");
              String[] standard_max = mySmartUpload.getRequest().getParameterValues("standard_max");
              String[] standard_min = mySmartUpload.getRequest().getParameterValues("standard_min");
              String[] quality_value =
                  mySmartUpload.getRequest().getParameterValues("quality_value");
              String[] sampling_amount_d =
                  mySmartUpload.getRequest().getParameterValues("sampling_amount_d");
              String[] qualified_d = mySmartUpload.getRequest().getParameterValues("qualified_d");
              String[] unqualified_d =
                  mySmartUpload.getRequest().getParameterValues("unqualified_d");
              String[] quality_result =
                  mySmartUpload.getRequest().getParameterValues("quality_result");
              String[] unqualified_reason =
                  mySmartUpload.getRequest().getParameterValues("unqualified_reason");
              for (int i = 0; i < item.length; i++) {
                if (!item[i].equals("")) {
                  sql =
                      "insert into qcs_intrmanufacture_details(qcs_id,item,default_basis,ready_basis,quality_method,analyse_method,standard_value,standard_max,standard_min,quality_value,sampling_amount_d,qualified_d,unqualified_d,quality_result,unqualified_reason,details_number) values('"
                          + qcs_id
                          + "','"
                          + item[i]
                          + "','"
                          + default_basis[i]
                          + "','"
                          + ready_basis[i]
                          + "','"
                          + quality_method[i]
                          + "','"
                          + analyse_method[i]
                          + "','"
                          + standard_value[i]
                          + "','"
                          + standard_max[i]
                          + "','"
                          + standard_min[i]
                          + "','"
                          + quality_value[i]
                          + "','"
                          + sampling_amount_d[i]
                          + "','"
                          + qualified_d[i]
                          + "','"
                          + unqualified_d[i]
                          + "','"
                          + quality_result[i]
                          + "','"
                          + unqualified_reason[i]
                          + "','"
                          + i
                          + "')";
                  qcs_db.executeUpdate(sql);
                }
              }
              response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=0");
            }
            qcs_db.commit();
            qcs_db.close();
          } else {
            response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=7");
          }

        } catch (Exception ex) {
          response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=6");
        }

      } else {
        response.sendRedirect("error_conn.htm");
      }

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
  /**
   * Method for reading in data file, in a given format. Namely:
   *
   * <pre>
   * 881003,0.0000,14.1944,13.9444,14.0832,2200050,0
   * 881004,0.0000,14.1668,14.0556,14.1668,1490850,0
   * ...
   * 990108,35.8125,36.7500,35.5625,35.8125,4381200,0
   * 990111,35.8125,35.8750,34.8750,35.1250,3920800,0
   * 990112,34.8750,34.8750,34.0000,34.0625,3577500,0
   * </pre>
   *
   * <p>Where the fields represent, one believes, the following:
   *
   * <ol>
   *   <li>The date in 'YYMMDD' format
   *   <li>Open
   *   <li>High
   *   <li>Low
   *   <li>Last
   *   <li>Volume
   *   <li>Open Interest
   * </ol>
   *
   * One will probably make use of the closing price, but this can be redefined via the class
   * variable <code>DATUMFIELD</code>. Note that since the read in data are then used to compute the
   * return, this would be a good place to trap for zero values in the data, which will cause all
   * sorts of problems.
   *
   * @param dirName the directory in which to search for the data file.
   * @param filename the data filename itself.
   * @exception DemoException thrown if there was a problem with the data file.
   */
  private void readRatesFile(String dirName, String filename) throws DemoException {
    java.io.File ratesFile = new File(filename);
    java.io.BufferedReader in;
    try {
      InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(filename);

      //    if( ! ratesFile.canRead() ) {
      //      throw new DemoException("Cannot read the file "+ratesFile.toString());
      //    }

      in = new BufferedReader(new InputStreamReader(inputStream));
    } catch (Exception fnfex) {
      throw new DemoException(fnfex.toString());
    }
    //
    // Proceed to read all the lines of data into a Vector object.
    int iLine = 0, initNlines = 100, nLines = 0;

    String aLine;
    java.util.Vector allLines = new Vector(initNlines);
    try {
      while ((aLine = in.readLine()) != null) {
        iLine++;
        //
        // Note, I'm not entirely sure whether the object passed in is copied
        // by value, or just its reference.
        allLines.addElement(aLine);
      }
    } catch (IOException ioex) {
      throw new DemoException("Problem reading data from the file " + ioex.toString());
    }
    nLines = iLine;
    //
    // Now create an array to store the rates data.
    this.pathValue = new double[nLines];
    this.pathDate = new int[nLines];
    nAcceptedPathValue = 0;
    iLine = 0;
    for (java.util.Enumeration enum1 = allLines.elements(); enum1.hasMoreElements(); ) {
      aLine = (String) enum1.nextElement();
      String[] field = Utilities.splitString(",", aLine);
      int aDate = Integer.parseInt("19" + field[0]);
      //
      // static double Double.parseDouble() method is a feature of JDK1.2!
      double aPathValue = Double.valueOf(field[DATUMFIELD]).doubleValue();
      if ((aDate <= MINIMUMDATE) || (Math.abs(aPathValue) < EPSILON)) {
        dbgPrintln("Skipped erroneous data in " + filename + " indexed by date=" + field[0] + ".");
      } else {
        pathDate[iLine] = aDate;
        pathValue[iLine] = aPathValue;
        iLine++;
      }
    }
    //
    // Record the actual number of accepted data points.
    nAcceptedPathValue = iLine;
    //
    // Now to fill in the structures from the 'PathId' class.
    set_name(ratesFile.getName());
    set_startDate(pathDate[0]);
    set_endDate(pathDate[nAcceptedPathValue - 1]);
    set_dTime((double) (1.0 / 365.0));
  }
Beispiel #25
0
  public int doEndTag() throws JspException {
    try {
      HttpServletRequest request = (HttpServletRequest) (pageContext.getRequest());
      String file_ext = pageContext.getServletContext().getInitParameter("FileExtention");
      String dbfs_ext = pageContext.getServletContext().getInitParameter("DatabaseExtention");
      String db_name = pageContext.getServletContext().getInitParameter("DatabaseName");
      String db_query = pageContext.getServletContext().getInitParameter("DatabaseQuery");
      JspWriter out = pageContext.getOut();

      int KEEP_CACHE_TIME = 300;
      long current_time = System.currentTimeMillis();

      if (pagebody != null || pageurl != null || dbfsurl != null) {
        VariableTable vt = new VariableTable();
        vt.loadContent(FileCache.getFileContent(getPhysicalPath("/global" + file_ext)));
        vt.loadContent(FileCache.getFileContent(getPhysicalPath("default" + file_ext)));
        if (pageurl != null) vt.loadContent(FileCache.getFileContent(getPhysicalPath(pageurl)));
        if (dbfsurl != null) {
          VariableTable dbparam = new VariableTable();
          dbparam.add("path", java.sql.Types.VARCHAR);
          dbparam.setValue("path", dbfsurl);
          String pagebody = TextCache.getTextContent("source::" + dbfsurl);
          if (pagebody == null) {
            try {
              DBPooledConnection dbconn = DBLogicalManager.getPoolConnection(db_name);
              try {
                pagebody = DBOperation.getString(dbconn, db_query, dbparam);
                vt.loadContent(pagebody);
                TextCache.putContent(
                    System.currentTimeMillis(), "source::" + dbfsurl, pagebody, 20);
              } catch (java.sql.SQLException sqle) {
              }
              dbconn.close();
            } catch (java.lang.Exception sqle) {
            }
          } else {
            vt.loadContent(pagebody);
          }
        }
        if (pagebody != null) vt.loadContent(pagebody);
        getEnv(vt);
        vt.add("JSP.TAG", java.sql.Types.VARCHAR);
        vt.setValue("JSP.TAG", "YES");
        vt.add("REQUEST.URL", java.sql.Types.VARCHAR);
        vt.setValue("REQUEST.URL", request.getRequestURI());

        if (vt.exists("WEBCHART.KEEP_CACHE_TIME")) {
          KEEP_CACHE_TIME = vt.getInt("WEBCHART.KEEP_CACHE_TIME", 300);
          if (KEEP_CACHE_TIME < 5) KEEP_CACHE_TIME = 5;
        }
        java.io.File xsl_file = null;
        if (vt.getString("WEBCHART.XSLDOC") != null)
          xsl_file = new java.io.File(getPhysicalPath(vt.getString("WEBCHART.XSLDOC")));
        String cachekey = vt.parseString(vt.getString("WEBCHART.CACHE"));

        String cache_content = null;

        if (cachekey != null && !vt.exists("WEBCHART.FORCECACHE"))
          cache_content = TextCache.getTextContent(cachekey);

        if (cache_content == null) {
          java.io.StringWriter xmlbuf = new java.io.StringWriter();
          writeXMLHeader(xmlbuf, vt);
          xmlbuf.write("<root>\n");
          WebChart2.generateChart(xmlbuf, null, vt, file_ext);
          xmlbuf.write("</root>\n");

          java.io.StringWriter htmlbuf = new java.io.StringWriter();
          if (xsl_file != null && xsl_file.exists())
            BaseServlet.XML2HTML(
                htmlbuf,
                new java.io.StringReader(xmlbuf.toString()),
                new java.io.StringReader(FileCache.getFileContent(xsl_file)),
                FileCache.getFileContent(xsl_file));
          else
            BaseServlet.XML2HTML(
                htmlbuf,
                new java.io.StringReader(xmlbuf.toString()),
                new java.io.StringReader(StaticResource.getTextResource("defaultxsl")),
                StaticResource.getTextResource("defaultxsl"));
          cache_content = htmlbuf.toString();
          out.write(cache_content);
          if (cachekey != null)
            TextCache.putContent(current_time, cachekey, cache_content, KEEP_CACHE_TIME);
        } else {
          out.write(cache_content);
        }
      }
    } catch (IOException ioe) {
      throw new JspException("Error:    " + ioe.getMessage());
    }
    return EVAL_PAGE;
  }
Beispiel #26
0
  /**
   * Returns <code>true</code> if the given file exists or can be created and at least one byte can
   * be successfully written to it - the file is restored to its previous state afterwards. This is
   * a much stronger test than {@link File#canWrite()}.
   *
   * <p>Please note that if the file is actually open for reading or other activities this method
   * may not be able to reset the last modification time of the file after testing, in which case
   * <code>false</code> is returned. This is known to apply to the Windows platform, but not on Unix
   * platforms.
   */
  public static boolean isWritableOrCreatable(final java.io.File file) {
    try {
      if (!file.exists()) {
        final boolean created = file.createNewFile();
        boolean ok = isWritableOrCreatable(file);
        if (created && !file.delete()) ok = false; // be conservative!
        return ok;
      } else if (file.canWrite()) {
        // Some operating and file system combinations make File.canWrite()
        // believe that the file is writable although it's not.
        // We are not that gullible, so let's test this...
        final long time = file.lastModified();
        if (!file.setLastModified(time + 1)) {
          // This may happen on Windows and normally means that
          // somebody else has opened this file
          // (regardless of read or write mode).
          // Be conservative: We don't allow writing to this file!
          return false;
        }

        boolean ok;
        try {
          // Open the file for reading and writing, requiring any
          // update to its contents to be written to the filesystem
          // synchronously.
          // As Dr. Simon White from Catalysoft, Cambridge, UK reported,
          // "rws" does NOT work on Mac OS X with Apple's Java 1.5
          // Release 1 (equivalent to Sun's Java 1.5.0_02), however
          // it DOES work with Apple's Java 1.5 Release 3.
          // He also confirmed that "rwd" works on Apple's
          // Java 1.5 Release 1, so we use this instead.
          // Thank you very much for spending the time to fix this
          // issue, Dr. White!
          final RandomAccessFile raf = new RandomAccessFile(file, "rwd");
          try {
            final boolean empty;
            int octet = raf.read();
            if (octet == -1) {
              octet = 0; // assume first byte is 0
              empty = true;
            } else {
              empty = false;
            }

            // Let's test if we can (over)write the first byte.
            raf.seek(0);
            raf.write((octet ^ -1) & 0xFF); // write complement
            try {
              // Rewrite original content and check success.
              raf.seek(0);
              raf.write(octet);
              raf.seek(0);
              final int check = raf.read();
              // This should always return true unless the storage
              // device is faulty.
              ok = octet == check;
            } finally {
              if (empty) raf.setLength(0);
            }
          } finally {
            raf.close();
          }
        } finally {
          if (!file.setLastModified(time)) {
            // This may happen on Windows and normally means that
            // somebody else has opened this file meanwhile
            // (regardless of read or write mode).
            // Be conservative: We don't allow (further) writing to
            // this file!
            ok = false;
          }
        }
        return ok;
      } else { // if (file.exists() && !file.canWrite()) {
        return false;
      }
    } catch (IOException ex) {
      return false; // don't allow writing if anything goes wrong!
    }
  }
Beispiel #27
0
 /** @see File#contains */
 public static boolean contains(java.io.File a, java.io.File b) {
   a = getCanOrAbsFile(a);
   b = getCanOrAbsFile(b);
   return contains(a.getPath(), b.getPath());
 }
  public static void processBrRequisitionFile(
      java.io.File filePortrait2Process,
      biz.systempartners.claims.ClaimsViewer claimsViewer,
      java.util.Vector invoiceVector,
      java.util.Vector filesVector) {

    biz.systempartners.claims.XMLClaimFile xmlClaimFile =
        new biz.systempartners.claims.XMLClaimFile();

    xmlClaimFile.processFile(filePortrait2Process);

    javax.swing.JTable tempInvoiceTable;

    java.util.Vector headerInvoiceVector = new java.util.Vector(1, 1);

    headerInvoiceVector.addElement("Invoice No.");

    //     claimsTable = new javax.swing.JTable(5,4);
    // claimsTable = claimsViewer.getInvoiceTable();
    claimsTable = xmlClaimFile.xmlClaim.getInvoiceTable();
    invoiceTable = claimsViewer.getInvoiceListTable();

    javax.swing.JPanel claimsViewerPanel = claimsViewer.getClaimsViewerPanel();

    javax.swing.JScrollPane jScrollPane11 = claimsViewer.getScrollPane();

    javax.swing.JScrollPane invoiceScrollPane = claimsViewer.getInvoiceListScrollPane();

    invoiceVector = claimsViewer.getInvoiceVector();

    java.util.Vector invoiceChildVector = new java.util.Vector(1, 1);
    javax.swing.JTextField patientNo = claimsViewer.getPatientNo();
    javax.swing.JTextField patientName = claimsViewer.getPatientName();
    javax.swing.JTextField schemeMemberNo = claimsViewer.getSchemeMemberNo();
    javax.swing.JTextField schemeName = claimsViewer.getSchemeName();
    javax.swing.JTextField schemePayer = claimsViewer.getSchemePayer();
    javax.swing.JTextField accountNo = claimsViewer.getAccountNo();
    javax.swing.JTextField invoiceNo = claimsViewer.getInvoiceNo();
    javax.swing.JTextField healthCareProvider = claimsViewer.getHealthCareProvider();

    jScrollPane11.setViewportView(claimsTable);
    if (claimsViewer.isShowing()) {
      claimsViewer.validate();
    } else {
      claimsViewer.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH);
      claimsViewer.setVisible(true);
    }

    claimsViewer.invalidate();

    // try {

    //     try {

    //   java.io.FileInputStream requisFileIOStream = new
    // java.io.FileInputStream(filePortrait2Process);

    //   java.io.ObjectInputStream requisObjInStream = new
    // java.io.ObjectInputStream(requisFileIOStream);

    //                javax.swing.table.JTableHeader claimsTableHeader =
    // (javax.swing.table.JTableHeader)requisObjInStream.readObject();

    //  requisTable = (javax.swing.JTable)requisObjInStream.readObject();

    //  String invoiceNoString = (java.lang.String)requisObjInStream.readObject();
    String invoiceNoString = xmlClaimFile.xmlClaim.getInvoiceNumber();
    invoiceNo.setText(invoiceNoString);

    //  patientNo.setText((java.lang.String)requisObjInStream.readObject());
    patientNo.setText(xmlClaimFile.xmlClaim.getPatientNumber());
    System.out.println(
        "PATIENT NUMBER : "
            + xmlClaimFile.xmlClaim.getPatientNumber()
            + "   "
            + xmlClaimFile.xmlClaim.getPatientName()
            + "  "
            + xmlClaimFile.xmlClaim.getSchemeName());
    // patientName.setText((java.lang.String)requisObjInStream.readObject());
    patientName.setText(xmlClaimFile.xmlClaim.getPatientName());
    //   schemeMemberNo.setText((java.lang.String)requisObjInStream.readObject());
    schemeMemberNo.setText(xmlClaimFile.xmlClaim.getSchemeMemberNumber());
    //   schemeName.setText((java.lang.String)requisObjInStream.readObject());
    schemeName.setText(xmlClaimFile.xmlClaim.getSchemeName());
    //  schemePayer.setText((java.lang.String)requisObjInStream.readObject());
    schemePayer.setText(xmlClaimFile.xmlClaim.getSchemePayer());
    //  accountNo.setText((java.lang.String)requisObjInStream.readObject());
    accountNo.setText(xmlClaimFile.xmlClaim.getAccountNumber());
    healthCareProvider.setText(xmlClaimFile.xmlClaim.getHealthCareProvider());

    tempInvoiceTable = new javax.swing.JTable(invoiceVector, headerInvoiceVector);
    invoiceChildVector.add(invoiceNoString);
    invoiceChildVector.add(filePortrait2Process.getPath());
    if (filesVector == null) {
      filesVector = new java.util.Vector(1, 1);
    }

    filesVector.add(filePortrait2Process.getAbsolutePath());
    claimsViewer.filesVector = filesVector;
    if (invoiceVector == null) {
      invoiceVector = new java.util.Vector(1, 1);
    }
    invoiceVector.add(invoiceChildVector);
    /*
    invoiceNo.setText(invoiceNoString);
    invoiceChildVector.add(invoiceNoString);
    invoiceChildVector.add(filePortrait2Process.getPath());
    filesVector.add(filePortrait2Process.getAbsolutePath());
    //                System.out.println("Child Cector Size ="+invoiceChildVector.size());
    //                System.out.println("File saved in child vector ="+filePortrait2Process.getPath());
    invoiceVector.add(invoiceChildVector);
    //                            for (int j = 0; j < invoiceChildVector.capacity(); j++) {
    //                System.out.println("Child entry ["+invoiceChildVector.elementAt(j)+"]");
    //            }
    patientNo.setText((java.lang.String)requisObjInStream.readObject());

    patientName.setText((java.lang.String)requisObjInStream.readObject());

    schemeMemberNo.setText((java.lang.String)requisObjInStream.readObject());

    schemeName.setText((java.lang.String)requisObjInStream.readObject());

    schemePayer.setText((java.lang.String)requisObjInStream.readObject());

    accountNo.setText((java.lang.String)requisObjInStream.readObject());
    */
    tempInvoiceTable = new javax.swing.JTable(invoiceVector, headerInvoiceVector);

    System.out.println("Starting to populate tables ...");
    /**
     * for (int i = 0; i < requisTable.getModel().getRowCount(); i++) {
     *
     * <p>for (int j = 0; j < requisTable.getModel().getColumnCount(); j++){
     *
     * <p>if (requisTable.getValueAt(i,0) != null) {
     *
     * <p>claimsTable.setValueAt(requisTable.getValueAt(i,j), i, j);
     *
     * <p>System.out.println(requisTable.getValueAt(i,j)); } } }
     */
    for (int i = 0; i < tempInvoiceTable.getModel().getRowCount(); i++) {

      for (int j = 0; j < tempInvoiceTable.getModel().getColumnCount(); j++) {

        if (tempInvoiceTable.getValueAt(i, 0) != null) {

          invoiceTable.setValueAt(tempInvoiceTable.getValueAt(i, j), i, j);
          System.out.println("Invoices : " + tempInvoiceTable.getValueAt(i, j));
          System.out.println(tempInvoiceTable.getValueAt(i, j));
        }
      }
    }

    //        claimsTable.setModel(requisTable.getModel());

    gridBagConstraints = new java.awt.GridBagConstraints();

    gridBagConstraints.gridx = 0;

    gridBagConstraints.gridy = 0;

    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;

    gridBagConstraints.weightx = 1.0;

    gridBagConstraints.weighty = 100.0;

    claimsViewerPanel.removeAll();

    claimsViewerPanel.add(jScrollPane11, gridBagConstraints);

    invoiceScrollPane.setViewportView(invoiceTable);

    jScrollPane11.setViewportView(claimsTable);

    claimsViewerPanel.validate();

    for (int i = 0; i < invoiceVector.size(); i++) {

      java.util.Vector childVector = (java.util.Vector) invoiceVector.elementAt(i);

      for (int j = 0; j < childVector.size(); j++) {

        //               System.out.println("Child entry at ---- !!! ["+j+"] is
        // ["+childVector.elementAt(j)+"]");

        File file2SelectedInvoice;

        file2SelectedInvoice = new java.io.File(childVector.elementAt(j).toString());

        System.out.println("Selected File ---- !!!!! [" + file2SelectedInvoice.getPath() + "]");
      }

      //           for (int j = 0; j < childVector.size(); j++) {

      //            if  (childVector.elementAt(0).toString().equalsIgnoreCase(invoiceNo)) {

      //           }
      //        }

    }

    //   } catch(java.lang.ClassNotFoundException cnfExec) {

    //       javax.swing.JOptionPane.showMessageDialog(new java.awt.Frame(), cnfExec.getMessage());

    //    }

    // } catch(java.io.IOException ioExec) {

    //    javax.swing.JOptionPane.showMessageDialog(new java.awt.Frame(), ioExec.getMessage());

    //  }
  }
Beispiel #29
0
  /**
   * Copies a source file to a destination file, optionally preserving the source's last
   * modification time. We know that the source file appears to be an entry in an archive file, but
   * we know nothing about the destination file yet.
   *
   * <p>Note that this method synchronizes on the class object in order to prevent dead locks by two
   * threads copying archive entries to the other's source archive concurrently!
   *
   * @throws FalsePositiveException If the source or the destination is a false positive and the
   *     exception cannot get resolved within this method.
   * @throws InputIOException If copying the data fails because of an IOException in the source.
   * @throws IOException If copying the data fails because of an IOException in the destination.
   */
  private static void cp0(
      final boolean preserve,
      final ArchiveController srcController,
      final String srcEntryName,
      final java.io.File dst)
      throws IOException {
    // Do not assume anything about the lock status of the controller:
    // This method may be called from a subclass while a lock is acquired!
    // assert !srcController.readLock().isLocked();
    // assert !srcController.writeLock().isLocked();

    try {
      try {
        if (dst instanceof File) {
          final File dstFile = (File) dst;
          dstFile.ensureNotVirtualRoot("cannot write");
          final String dstEntryName = dstFile.getEnclEntryName();
          if (dstEntryName != null) {
            cp0(
                preserve,
                srcController,
                srcEntryName,
                dstFile.getEnclArchive().getArchiveController(),
                dstEntryName);
            return;
          }
        }
      } catch (RfsEntryFalsePositiveException isNotArchive) {
        // Both the source and/or the destination may be false positives,
        // so we need to use the exception's additional information to
        // find out which controller actually detected the false positive.
        if (isNotArchive.getController() == srcController)
          throw isNotArchive; // not my job - pass on!
      }

      final InputStream in;
      final long time;
      srcController.readLock().lock();
      try {
        in = srcController.createInputStream0(srcEntryName); // detects false positives!
        time = srcController.lastModified(srcEntryName);
      } finally {
        srcController.readLock().unlock();
      }

      // Treat the destination like a regular file.
      final OutputStream out;
      try {
        out = new java.io.FileOutputStream(dst);
      } catch (IOException ex) {
        try {
          in.close();
        } catch (IOException inFailure) {
          throw new InputIOException(inFailure);
        }
        throw ex;
      }

      cp(in, out);
      if (preserve && !dst.setLastModified(time))
        throw new IOException(dst.getPath() + " (cannot preserve last modification time)");
    } catch (ArchiveEntryFalsePositiveException ex) {
      assert srcController == ex.getController();
      // Reroute call to the source's enclosing archive controller.
      cp0(
          preserve,
          srcController.getEnclController(),
          srcController.enclEntryName(srcEntryName),
          dst);
    }
  }