use of org.springframework.roo.file.monitor.event.FileDetails in project spring-roo by spring-projects.
the class PollingFileMonitorService method remove.
public boolean remove(final MonitoringRequest request) {
synchronized (lock) {
Validate.notNull(request, "MonitoringRequest required");
// Advise of the cessation to monitoring
if (priorExecution.containsKey(request)) {
final List<FileEvent> eventsToPublish = new ArrayList<FileEvent>();
final Map<File, Long> priorFiles = priorExecution.get(request);
for (final Entry<File, Long> entry : priorFiles.entrySet()) {
final File thisFile = entry.getKey();
final Long lastModified = entry.getValue();
eventsToPublish.add(new FileEvent(new FileDetails(thisFile, lastModified), FileOperation.MONITORING_FINISH, null));
}
publish(eventsToPublish);
}
priorExecution.remove(request);
return requests.remove(request);
}
}
use of org.springframework.roo.file.monitor.event.FileDetails in project spring-roo by spring-projects.
the class ApplicationConfigServiceImpl method getApplicationProfiles.
@Override
public List<String> getApplicationProfiles(String moduleName) {
List<String> profiles = new ArrayList<String>();
final String applicationConfigFilename = StringUtils.removeEnd(getSpringConfigLocation(moduleName), DEFAULT_APPLICATION_CONFIG_FILE_EXTENSION);
// Find application config files
for (final FileDetails applicationConfig : fileManager.findMatchingAntPath(applicationConfigFilename + "*" + DEFAULT_APPLICATION_CONFIG_FILE_EXTENSION)) {
final String applicationConfigPath = applicationConfig.getCanonicalPath();
if (!fileManager.exists(applicationConfigPath)) {
continue;
}
// Extract profile
String profile = StringUtils.substringBetween(applicationConfigPath, applicationConfigFilename, ".properties");
profiles.add(StringUtils.removeStart(profile, "-"));
}
return profiles;
}
use of org.springframework.roo.file.monitor.event.FileDetails 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());
}
use of org.springframework.roo.file.monitor.event.FileDetails in project spring-roo by spring-projects.
the class AbstractPathResolvingStrategy method getRelativeSegment.
public String getRelativeSegment(final String identifier) {
final PhysicalPath parent = getApplicablePhysicalPath(identifier);
if (parent == null) {
return null;
}
final FileDetails parentFile = new FileDetails(parent.getLocation(), null);
return parentFile.getRelativeSegment(identifier);
}
use of org.springframework.roo.file.monitor.event.FileDetails in project spring-roo by spring-projects.
the class MavenPathResolvingStrategy method getApplicablePhysicalPath.
/**
* Locates the first {@link PhysicalPath} which can be construed as a parent
* of the presented identifier.
*
* @param identifier to locate the parent of (required)
* @return the first matching parent, or null if not found
*/
@Override
protected PhysicalPath getApplicablePhysicalPath(final String identifier) {
Validate.notNull(identifier, "Identifier required");
PhysicalPath physicalPath = null;
int longest = 0;
for (final Pom pom : pomManagementService.getPoms()) {
if (removeTrailingSeparator(identifier).startsWith(removeTrailingSeparator(pom.getRoot())) && removeTrailingSeparator(pom.getRoot()).length() > longest) {
longest = removeTrailingSeparator(pom.getRoot()).length();
int nextLongest = 0;
for (final PhysicalPath thisPhysicalPath : pom.getPhysicalPaths()) {
String possibleParent = new FileDetails(thisPhysicalPath.getLocation(), null).getCanonicalPath();
if (!possibleParent.endsWith(File.separator)) {
possibleParent = possibleParent.concat(File.separator);
}
if (removeTrailingSeparator(identifier).startsWith(possibleParent) && possibleParent.length() > nextLongest) {
nextLongest = possibleParent.length();
physicalPath = thisPhysicalPath;
}
}
}
}
return physicalPath;
}
Aggregations