Search in sources :

Example 1 with CreateDirectory

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

the class DefaultFileManager method createDirectory.

public FileDetails createDirectory(final String fileIdentifier) {
    if (fileMonitorService == null) {
        fileMonitorService = getFileMonitorService();
    }
    if (filenameResolver == null) {
        filenameResolver = getFileNameResolver();
    }
    if (undoManager == null) {
        undoManager = getUndoManager();
    }
    Validate.notNull(fileIdentifier, "File identifier required");
    Validate.notNull(fileMonitorService, "FileMonitorService required");
    Validate.notNull(filenameResolver, "FilenameResolver required");
    Validate.notNull(undoManager, "UndoManager required");
    final File actual = new File(fileIdentifier);
    Validate.isTrue(!actual.exists(), "File '%s' already exists", fileIdentifier);
    try {
        fileMonitorService.notifyCreated(actual.getCanonicalPath());
    } catch (final IOException ignored) {
    }
    new CreateDirectory(undoManager, filenameResolver, actual);
    return new FileDetails(actual, actual.lastModified());
}
Also used : FileDetails(org.springframework.roo.file.monitor.event.FileDetails) 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) CreateDirectory(org.springframework.roo.file.undo.CreateDirectory)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 FileDetails (org.springframework.roo.file.monitor.event.FileDetails)1 CreateDirectory (org.springframework.roo.file.undo.CreateDirectory)1 CreateFile (org.springframework.roo.file.undo.CreateFile)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