@Nonnull private static FileIOError _deleteUDO (@Nonnull final TemporaryUserDataObject aUDO) { LOGGER.info ("Deleting uploaded file " + aUDO); final FileIOError aError = FileOperationManager.INSTANCE.deleteFile (aUDO.getAsFile ()); if (aError.isFailure ()) LOGGER.error ("Failed to delete UDO " + aUDO.getPath () + ": " + aError.getErrorCode ()); return aError; }
@Nonnull public static File moveFile (@Nonnull final File aSrc, @Nonnull final File aDestFile, final boolean bOverwrite, final boolean bRename) throws IOException { File aRealDestFile = aDestFile; if (!bOverwrite && aRealDestFile.exists ()) { if (!bRename) throw new IOException ("File already exists: " + aRealDestFile); aRealDestFile = getUniqueFile (aRealDestFile.getAbsoluteFile ().getParentFile (), aRealDestFile.getName ()); } // Copy FileIOError aIOErr = s_aFOM.copyFile (aSrc, aRealDestFile); if (aIOErr.isFailure ()) throw new IOException ("Copy failed: " + aIOErr.toString ()); // Delete old aIOErr = s_aFOM.deleteFile (aSrc); if (aIOErr.isFailure ()) { s_aFOM.deleteFile (aRealDestFile); throw new IOException ("Move failed, unable to delete " + aSrc + ": " + aIOErr.toString ()); } return aRealDestFile; }
/** * This method may only be triggered with valid WAL filenames, as the passed * file is deleted! */ final void _deleteWALFileAfterProcessing (@Nonnull @Nonempty final String sWALFilename) { ValueEnforcer.notEmpty (sWALFilename, "WALFilename"); final File aWALFile = m_aIO.getFile (sWALFilename); if (FileOperationManager.INSTANCE.deleteFile (aWALFile).isFailure ()) { if (LOGGER.isErrorEnabled ()) LOGGER.error ("Failed to delete WAL file '" + aWALFile.getAbsolutePath () + "'"); } else { if (!isSilentMode ()) if (LOGGER.isInfoEnabled ()) LOGGER.info ("Deleted successfully imported WAL file '" + aWALFile.getAbsolutePath () + "'"); } }
/** * Deletes the underlying storage for a file item, including deleting any * associated temporary disk file. Although this storage will be deleted * automatically when the <code>FileItem</code> instance is garbage collected, * this method can be used to ensure that this is done at an earlier time, * thus preserving system resources. */ public void delete () { m_aCachedContent = null; final File aTempFile = getStoreLocation (); if (aTempFile != null) { final FileIOError aIOError = FileOperations.deleteFileIfExisting (aTempFile); if (aIOError.isFailure ()) if (LOGGER.isErrorEnabled ()) LOGGER.error ("Failed to delete temporary file " + aTempFile + " with error " + aIOError.toString ()); } }
/** * This method is called if recovery from the WAL file (partially) failed an * analysis might be needed. */ final void _maintainWALFileAfterProcessing (@Nonnull @Nonempty final String sWALFilename) { ValueEnforcer.notEmpty (sWALFilename, "WALFilename"); final File aWALFile = m_aIO.getFile (sWALFilename); final File aNewFile = new File (aWALFile.getParentFile (), aWALFile.getName () + "." + PDTFactory.getCurrentMillis () + ".bup"); if (FileOperationManager.INSTANCE.renameFile (aWALFile, aNewFile).isFailure ()) { if (LOGGER.isErrorEnabled ()) LOGGER.error ("Failed to rename WAL file '" + aWALFile.getAbsolutePath () + "' to '" + aNewFile.getAbsolutePath () + "'"); } else { if (LOGGER.isInfoEnabled ()) LOGGER.info ("Maintained WAL file '" + aWALFile.getAbsolutePath () + "' as '" + aNewFile.getAbsolutePath () + "' for debugging purposes"); } }
if (aError.isFailure ()) throw new DAOException ("The DAO of class " + getClass ().getName () +
if (aError.isFailure ()) throw new DAOException ("The DAO of class " + getClass ().getName () +
protected void store (@Nonnull final File aMsgFile, @Nonnull @WillClose final InputStream aIS) throws IOException { final String sTempDirname = attrs ().getAsString (ATTR_TEMPDIR); if (sTempDirname != null) { // write the data to a temporary directory first final File aTempDir = AS2IOHelper.getDirectoryFile (sTempDirname); final File aTempFile = AS2IOHelper.getUniqueFile (aTempDir, aMsgFile.getName ()); _writeStreamToFile (aIS, aTempFile); // copy the temp file over to the destination if (AS2IOHelper.getFileOperationManager ().renameFile (aTempFile, aMsgFile).isFailure ()) throw new IOException ("Rename from " + aTempFile.getAbsolutePath () + " to " + aMsgFile.getAbsolutePath () + " failed!"); } else { // Write directly to the destination file _writeStreamToFile (aIS, aMsgFile); } } }
public void deleteAllTemporaryFiles () { final ICommonsList <File> aTempFiles = m_aRWLock.writeLocked ( () -> { final ICommonsList <File> ret = m_aTempFiles.getClone (); m_aTempFiles.clear (); return ret; }); for (final File aTempFile : aTempFiles) { final FileIOError aIOError = FileOperations.deleteFileIfExisting (aTempFile); if (aIOError.isFailure ()) { if (LOGGER.isErrorEnabled ()) LOGGER.error ("Failed to delete temporary file " + aTempFile + " with error " + aIOError.toString ()); _addTempFile (aTempFile); } } } }
getSession ().getMessageProcessor ().handle (sResendAction, aMsg, aOptions); if (AS2IOHelper.getFileOperationManager ().deleteFile (aFile).isFailure ())
LOGGER.debug ("Deleting temporary file " + aFile.getAbsolutePath ()); final FileIOError aError = AS4IOHelper.getFileOperationManager ().deleteFileIfExisting (aFile); if (aError.isFailure ()) LOGGER.warn (" Failed to delete " + aFile.getAbsolutePath () + ": " + aError.toString ());
aMsg.attrs ().getAsString (CFileAttribute.MA_PENDING_FILENAME)); final FileIOError aIOErr = AS2IOHelper.getFileOperationManager ().copyFile (aFile, aPendingFile); if (aIOErr.isFailure ()) throw new OpenAS2Exception ("File was successfully sent but not copied to pending folder: " + aPendingFile +
if (aIOError.isFailure ()) throw new IllegalStateException ("Error on rename(existing-old)/rename(new-existing)/delete(old): " + aIOError);
if (FileOperations.createDirIfNotExisting (aSVRLFile.getParentFile ()).isFailure ()) log ("Failed to create parent directory of '" + aSVRLFile.getAbsolutePath () + "'!", Project.MSG_ERR);