/** * @param file */ public void addFile(File file) { if (PrivilegedFileHelper.exists(file)) { files.offer(file); } }
/** * {@inheritDoc} */ public void stop() { String tmpDirName = properties.get(WS_RS_TMP_DIR); File tmpDir = new File(tmpDirName); if (!PrivilegedFileHelper.exists(tmpDir)) { return; } File[] files = PrivilegedFileHelper.listFiles(tmpDir); for (File file : files) { if (PrivilegedFileHelper.exists(file)) { PrivilegedFileHelper.delete(file); } } }
/** * {@inheritDoc} */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { orderNumber = in.readInt(); // read canonical file path int size = in.readInt(); if (size > 0) { byte[] buf = new byte[size]; in.readFully(buf); File f = new File(new String(buf, "UTF-8")); // validate if exists if (PrivilegedFileHelper.exists(f)) { file = f; } else { file = null; } } else { // should not occurs but since we have a way to recover, it should not be // an issue file = null; } }
/** * Startup initialization. */ public void init() { // Directory for temporary files File tmpDir; String tmpDirName = properties.get(WS_RS_TMP_DIR); if (tmpDirName == null) { tmpDir = new File(PrivilegedSystemHelper.getProperty("java.io.tmpdir") + File.separator + "ws_jaxrs"); properties.put(WS_RS_TMP_DIR, tmpDir.getPath()); } else { tmpDir = new File(tmpDirName); } if (!PrivilegedFileHelper.exists(tmpDir)) { PrivilegedFileHelper.mkdirs(tmpDir); } }
/** * InitialContextBinder constructor. * * @param initialContextInitializer * initial context initializer * @param initParams * initialization parameters * @throws FileNotFoundException * @throws XMLStreamException * @throws NamingException */ InitialContextBinder(InitialContextInitializer initialContextInitializer, String bindingsStorePath) throws FileNotFoundException, XMLStreamException, NamingException { this.initialContextInitializer = initialContextInitializer; this.bindings = new ConcurrentHashMap<String, Reference>(); this.bindingsStorePath = bindingsStorePath; if (PrivilegedFileHelper.exists(new File(bindingsStorePath))) { Map<String, Reference> importedRefs = readBindings(); for (Entry<String, Reference> entry : importedRefs.entrySet()) { bindInternally(entry.getKey(), entry.getValue()); } } }
/** * Remove buffer. * * @throws IOException * if file cannot be removed. */ public void remove() throws IOException { if ((fileBuffer != null) && PrivilegedFileHelper.exists(fileBuffer)) { if (!PrivilegedFileHelper.delete(fileBuffer)) { throw new IOException("Cannot remove file " + PrivilegedFileHelper.getAbsolutePath(fileBuffer) + " Close all streams."); } } }
if (PrivilegedFileHelper.exists(storage))
File f = new File(path); if (PrivilegedFileHelper.exists(f))
while ((file = files.poll()) != null) if (PrivilegedFileHelper.exists(file))
if (PrivilegedFileHelper.exists(contentFile))
if (!PrivilegedFileHelper.exists(contentFile))
if (!PrivilegedFileHelper.exists(indexFile.getParentFile()))
/** * Delete current spool file. * * @throws IOException * if error */ private void removeSpoolFile() throws IOException { if (spoolFile != null) { if (spoolFile instanceof SpoolFile) { (spoolFile).release(this); } if (PrivilegedFileHelper.exists(spoolFile)) { if (!PrivilegedFileHelper.delete(spoolFile)) { spoolConfig.fileCleaner.addFile(spoolFile); if (LOG.isDebugEnabled()) { LOG.debug("Could not remove file. Add to fileCleaner " + PrivilegedFileHelper.getAbsolutePath(spoolFile)); } } } } }
if (!PrivilegedFileHelper.exists(backupFile))
if (!PrivilegedFileHelper.exists(this.containerConfig.spoolConfig.tempDirectory))