throws StorageException {
final File oldLayerPath = getLayerPath(oldLayerName);
final File newLayerPath = getLayerPath(newLayerName);
if (newLayerPath.exists()) {
throw new StorageException("Can't rename layer directory " + oldLayerPath + " to "
+ newLayerPath + ". Target directory already exists");
}
if (!oldLayerPath.exists()) {
this.listeners.sendLayerRenamed(oldLayerName, newLayerName);
return true;
}
if (!oldLayerPath.canWrite()) {
log.info(oldLayerPath + " is not writable");
return false;
}
boolean renamed = oldLayerPath.renameTo(newLayerPath);
if (renamed) {
this.listeners.sendLayerRenamed(oldLayerName, newLayerName);
} else {
throw new StorageException("Couldn't rename layer directory " + oldLayerPath + " to "
+ newLayerPath);
}
return renamed;
}