Search in sources :

Example 1 with FileDataByPath

use of org.sonarqube.ws.WsBatch.WsProjectResponse.FileDataByPath in project sonarqube by SonarSource.

the class DefaultProjectRepositoriesLoader method processStream.

private static ProjectRepositories processStream(InputStream is, String projectKey) {
    try {
        WsProjectResponse response = WsProjectResponse.parseFrom(is);
        Table<String, String, FileData> fileDataTable = HashBasedTable.create();
        Table<String, String, String> settings = HashBasedTable.create();
        Map<String, Settings> settingsByModule = response.getSettingsByModule();
        for (Map.Entry<String, Settings> e1 : settingsByModule.entrySet()) {
            for (Map.Entry<String, String> e2 : e1.getValue().getSettings().entrySet()) {
                settings.put(e1.getKey(), e2.getKey(), e2.getValue());
            }
        }
        Map<String, FileDataByPath> fileDataByModuleAndPath = response.getFileDataByModuleAndPath();
        for (Map.Entry<String, FileDataByPath> e1 : fileDataByModuleAndPath.entrySet()) {
            for (Map.Entry<String, WsBatch.WsProjectResponse.FileData> e2 : e1.getValue().getFileDataByPath().entrySet()) {
                FileData fd = new FileData(e2.getValue().getHash(), e2.getValue().getRevision());
                fileDataTable.put(e1.getKey(), e2.getKey(), fd);
            }
        }
        return new ProjectRepositories(settings, fileDataTable, new Date(response.getLastAnalysisDate()));
    } catch (IOException e) {
        throw new IllegalStateException("Couldn't load project repository for " + projectKey, e);
    } finally {
        IOUtils.closeQuietly(is);
    }
}
Also used : IOException(java.io.IOException) Date(java.util.Date) FileDataByPath(org.sonarqube.ws.WsBatch.WsProjectResponse.FileDataByPath) WsBatch(org.sonarqube.ws.WsBatch) WsProjectResponse(org.sonarqube.ws.WsBatch.WsProjectResponse) Map(java.util.Map) Settings(org.sonarqube.ws.WsBatch.WsProjectResponse.Settings)

Aggregations

IOException (java.io.IOException)1 Date (java.util.Date)1 Map (java.util.Map)1 WsBatch (org.sonarqube.ws.WsBatch)1 WsProjectResponse (org.sonarqube.ws.WsBatch.WsProjectResponse)1 FileDataByPath (org.sonarqube.ws.WsBatch.WsProjectResponse.FileDataByPath)1 Settings (org.sonarqube.ws.WsBatch.WsProjectResponse.Settings)1