use of org.springframework.roo.file.undo.DeleteFile 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);
}
}
Aggregations