Search in sources :

Example 1 with DeleteDirectory

use of org.springframework.roo.file.undo.DeleteDirectory in project spring-roo by spring-projects.

the class DefaultFileManager method delete.

public void delete(final String fileIdentifier, final String reasonForDeletion) {
    if (fileMonitorService == null) {
        fileMonitorService = getFileMonitorService();
    }
    if (filenameResolver == null) {
        filenameResolver = getFileNameResolver();
    }
    if (undoManager == null) {
        undoManager = getUndoManager();
    }
    Validate.notNull(fileMonitorService, "FileMonitorService required");
    Validate.notNull(filenameResolver, "FilenameResolver required");
    Validate.notNull(undoManager, "UndoManager is required");
    if (StringUtils.isBlank(fileIdentifier)) {
        return;
    }
    final File actual = new File(fileIdentifier);
    Validate.isTrue(actual.exists(), "File '%s' does not exist", fileIdentifier);
    try {
        fileMonitorService.notifyDeleted(actual.getCanonicalPath());
    } catch (final IOException ignored) {
    }
    if (actual.isDirectory()) {
        new DeleteDirectory(undoManager, filenameResolver, actual, reasonForDeletion);
    } else {
        new DeleteFile(undoManager, filenameResolver, actual, reasonForDeletion);
    }
}
Also used : DeleteDirectory(org.springframework.roo.file.undo.DeleteDirectory) IOException(java.io.IOException) MutableFile(org.springframework.roo.process.manager.MutableFile) CreateFile(org.springframework.roo.file.undo.CreateFile) File(java.io.File) DeleteFile(org.springframework.roo.file.undo.DeleteFile) UpdateFile(org.springframework.roo.file.undo.UpdateFile) DeleteFile(org.springframework.roo.file.undo.DeleteFile)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 CreateFile (org.springframework.roo.file.undo.CreateFile)1 DeleteDirectory (org.springframework.roo.file.undo.DeleteDirectory)1 DeleteFile (org.springframework.roo.file.undo.DeleteFile)1 UpdateFile (org.springframework.roo.file.undo.UpdateFile)1 MutableFile (org.springframework.roo.process.manager.MutableFile)1