import org.sonar.api.scan.filesystem.internal.DefaultInputFile;
import org.sonar.api.utils.PathUtils;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.TreeMap;
public class ResourceKeyMigration implements BatchComponent {
public void migrateIfNeeded(Project module, Iterable<InputFile> inputFiles) {
if (migrationNeeded) {
logger.info("Starting migration of resource keys");
- Map<String, InputFile> deprecatedFileKeyMapper = new TreeMap<String, InputFile>();
- Map<String, InputFile> deprecatedTestKeyMapper = new TreeMap<String, InputFile>();
- Map<String, String> deprecatedDirectoryKeyMapper = new TreeMap<String, String>();
+ Map<String, InputFile> deprecatedFileKeyMapper = new HashMap<String, InputFile>();
+ Map<String, InputFile> deprecatedTestKeyMapper = new HashMap<String, InputFile>();
+ Map<String, String> deprecatedDirectoryKeyMapper = new HashMap<String, String>();
for (InputFile inputFile : inputFiles) {
String deprecatedKey = inputFile.attribute(DefaultInputFile.ATTRIBUTE_COMPONENT_DEPRECATED_KEY);
if (deprecatedKey != null) {
.append(ResourceModel.class.getSimpleName())
.append(" where enabled = true ")
.append(" and rootId = :rootId ")
- .append(" and scope = '").append(Scopes.FILE).append("'");
+ .append(" and scope = '").append(Scopes.FILE).append("' order by key");
List<ResourceModel> resources = session.createQuery(hql.toString()).setParameter("rootId", moduleId).getResultList();
for (ResourceModel resourceModel : resources) {
String oldEffectiveKey = resourceModel.getKey();
import org.apache.commons.lang.StringUtils;
import org.sonar.api.BatchComponent;
import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.SonarIndex;
import org.sonar.api.config.Settings;
-import org.sonar.api.resources.File;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Languages;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
+import org.sonar.api.resources.*;
import org.sonar.api.scan.filesystem.FileQuery;
import org.sonar.api.scan.filesystem.InputFile;
import org.sonar.api.scan.filesystem.internal.DefaultInputFile;
* Index all files/directories of the module in SQ database and importing source code.
* @since 4.2
*/
-@InstantiationStrategy(InstantiationStrategy.PER_PROJECT)
public class ComponentIndexer implements BatchComponent {
private final Languages languages;