use of org.jenkinsci.remoting.RoleChecker 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);
}
use of org.jenkinsci.remoting.RoleChecker in project jenkin-qtest-plugin by QASymphony.
the class StoreResultServiceImpl method store.
@Override
public Boolean store(Job job, final SubmittedResult result) throws StoreResultException {
FilePath resultFolder = getResultFolder(job);
try {
resultFolder.mkdirs();
} catch (Exception e) {
throw new StoreResultException(String.format("Cannot make result folder:%s, %s", resultFolder.getName(), e.getMessage()));
}
FilePath resultFile = getResultFile(resultFolder, result.getBuildNumber() / BREAK_FILE_BY);
try {
resultFile.act(new FilePath.FileCallable<String>() {
@Override
public String invoke(File file, VirtualChannel virtualChannel) throws IOException, InterruptedException {
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter(file.getPath(), true));
writer.write(JsonUtils.toJson(result));
writer.newLine();
return null;
} finally {
if (null != writer)
writer.close();
}
}
@Override
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
}
});
} catch (Exception e) {
throw new StoreResultException("Cannot store result to file:" + e.getMessage());
}
return true;
}
Aggregations