use of com.qasymphony.ci.plugin.store.file.FileReader in project jenkin-qtest-plugin by QASymphony.
the class StoreResultServiceImpl method fetch.
@Override
public ReadSubmitLogResult fetch(ReadSubmitLogRequest request) throws StoreResultException {
FilePath resultPath = getResultFolder(request.getProject());
int numOrder = request.getCurrentBuildNumber() / BREAK_FILE_BY;
List<FileReader> readerList = getReaderList(resultPath, numOrder);
// get saved configuration
Configuration configuration = ConfigService.getPluginConfiguration(request.getProject());
String qTestUrl = configuration == null ? "" : configuration.getUrl();
Long projectId = configuration == null ? 0L : configuration.getProjectId();
int total = 0;
Map<Integer, SubmittedResult> resultMap = new HashMap<>();
for (FileReader reader : readerList) {
total += reader.size();
try {
resultMap.putAll(buildSubmittedResult(reader.readAll(), qTestUrl, projectId));
} catch (IOException e) {
throw new StoreResultException(e.getMessage(), e);
} finally {
try {
reader.close();
} catch (IOException e) {
throw new StoreResultException(e.getMessage(), e);
}
}
}
return new ReadSubmitLogResult().setTotal(total).setResults(resultMap);
}
use of com.qasymphony.ci.plugin.store.file.FileReader in project jenkin-qtest-plugin by QASymphony.
the class StoreResultServiceImpl method readResult.
private static Map<Integer, SubmittedResult> readResult(FilePath resultFile, String url, Long projectId) throws StoreResultException {
SortedMap<Integer, String> lines = null;
try {
lines = resultFile.act(new FilePath.FileCallable<SortedMap<Integer, String>>() {
@Override
public SortedMap<Integer, String> invoke(File file, VirtualChannel virtualChannel) throws IOException, InterruptedException {
FileReader fileReader = new FileReader(file);
SortedMap<Integer, String> lines;
try {
lines = fileReader.readAll();
} finally {
if (null != fileReader)
fileReader.close();
}
return lines;
}
@Override
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
}
});
} catch (Exception e) {
throw new StoreResultException(String.format("Cannot read from result file:%s, %s", resultFile.getName(), e.getMessage()));
}
return buildSubmittedResult(lines, url, projectId);
}
Aggregations