}
FileSystemPathUtil.checkFormat(folderPath);
if (folderPath.equals(FileSystem.SEPARATOR)) {
throw new FileSystemException("cannot delete root");
}
String parentDir = FileSystemPathUtil.getParentDir(folderPath);
String name = FileSystemPathUtil.getName(folderPath);
int count = 0;
PreparedStatement stmt = deleteFolderStmt;
synchronized (stmt) {
try {
stmt.setString(1, parentDir);
stmt.setString(2, name);
stmt.setString(3, folderPath);
stmt.setString(4, folderPath + FileSystem.SEPARATOR + "%");
count = stmt.executeUpdate();
} catch (SQLException e) {
String msg = "failed to delete folder: " + folderPath;
log.error(msg, e);
throw new FileSystemException(msg, e);
} finally {
resetStatement(stmt);
}
}
if (count == 0) {
throw new FileSystemException("no such folder: " + folderPath);
}
}