diff --git a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/CompetitionUploadServlet.java b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/CompetitionUploadServlet.java
index 7bc4f023..3f73161a 100644
--- a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/CompetitionUploadServlet.java
+++ b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/CompetitionUploadServlet.java
@@ -18,8 +18,6 @@
import java.nio.charset.StandardCharsets;
import java.util.List;
-import static su.opencode.kefir.util.StringUtils.concat;
-
/**
* Copyright 2014 Dmitriy Popov.
* $HeadURL$
@@ -66,8 +64,10 @@ public void doAction() throws Exception {
}
catch (Exception e)
{
- logger.error( concat("Error while parsing zip file \"", entity.getZipFileName(), "\" into Competition model:"), e );
- throw new RuntimeException( concat("Error while parsing zip file \"", entity.getZipFileName(), "\" into Competition model:"), e);
+ String errorMessage = String.format("Error while parsing zip file \"%s\" into Competition model:", entity.getZipFileName());
+
+ logger.error(errorMessage, e );
+ throw new RuntimeException(errorMessage, e);
}
try
@@ -77,14 +77,17 @@ public void doAction() throws Exception {
}
catch (Exception e)
{
- logger.error(concat("Error while transforming Competition model to JSON:"), e);
- throw new RuntimeException( concat("Error while transforming Competition model to JSON:"), e);
+ String errorMessage = "Error while transforming Competition model to JSON:";
+
+ logger.error(errorMessage, e);
+ throw new RuntimeException(errorMessage, e);
}
CompetitionEntityService service = getService(CompetitionEntityService.class);
Long competitionId = service.createCompetitionEntity(entity);
- response.sendRedirect( concat(sb, "./competitionUploadSuccess.jsp?competitionId=", competitionId) );
+ String redirectLocation = String.format("./competitionUploadSuccess.jsp?competitionId=%d", competitionId);
+ response.sendRedirect(redirectLocation);
}
private CompetitionEntity processMultipartContent() throws FileUploadException, UnsupportedEncodingException {
diff --git a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/CompetitionZipFileDownloadServlet.java b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/CompetitionZipFileDownloadServlet.java
index f9cb89b9..363577fe 100644
--- a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/CompetitionZipFileDownloadServlet.java
+++ b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/CompetitionZipFileDownloadServlet.java
@@ -13,8 +13,6 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-import static su.opencode.kefir.util.StringUtils.concat;
-
/**
* Copyright 2014 LLC "Open Code"
* http://www.o-code.ru
@@ -33,14 +31,16 @@ protected Action getAction() {
public void doAction() throws Exception {
Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
if (competitionEntityId == null) {
- throw new ClientException(concat(sb, "\"", COMPETITION_ENTITY_ID_PARAM_NAME, "\" parameter is not set"));
+ String errorMessage = String.format("\"%s\" parameter is not set", COMPETITION_ENTITY_ID_PARAM_NAME);
+ throw new ClientException(errorMessage);
}
CompetitionEntityService service = getService(CompetitionEntityService.class);
CompetitionEntity entity = service.getCompetitionEntity(competitionEntityId);
if (entity == null) {
- throw new ClientException(concat(sb, "CompetitionEntity not found for id = ", competitionEntityId));
+ String errorMessage = String.format("CompetitionEntity not found for id = %d", competitionEntityId);
+ throw new ClientException(errorMessage);
}
String contentType = entity.getZipFileContentType();
diff --git a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/ZipFileParser.java b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/ZipFileParser.java
index dc30344f..c0b52179 100644
--- a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/ZipFileParser.java
+++ b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/entity/ZipFileParser.java
@@ -10,8 +10,6 @@
import java.util.UUID;
-import static su.opencode.kefir.util.StringUtils.concat;
-
/**
* Copyright 2014 Dmitriy Popov.
* $HeadURL$
@@ -28,26 +26,27 @@ private ZipFileParser() {
}
public static Competition parseZipFile(CompetitionEntity entity, String exportScriptVersion) {
- StringBuilder sb = new StringBuilder();
- String dirPath = getDirPath(sb);
+ String dirPath = getDirPath();
logger.info("Directory path to extract zip file: \"{}\"", dirPath);
FileUtils.createDirs(dirPath);
logger.info("Directory \"{}\" created successfully.", dirPath);
- String filePath = concat(sb, dirPath, FileUtils.FILE_SEPARATOR, entity.getZipFileName());
+ String filePath = dirPath + FileUtils.FILE_SEPARATOR + entity.getZipFileName();
logger.info("Zip file path: {}", filePath);
FileUtils.writeToFile(filePath, entity.getZipFileData());
logger.info("Zip file successfully written to path \"{}\".", filePath);
- String extractDirPath = concat(sb, dirPath, FileUtils.FILE_SEPARATOR, "extracted");
+ String extractDirPath = dirPath + FileUtils.FILE_SEPARATOR + "extracted";
ZipUtils.unzip(filePath, extractDirPath);
logger.info("Zip file \"{}\" successfully extracted to path \"{}\".", filePath, extractDirPath);
return VoidmainJsonParser.parseCompetition(entity.getName(), extractDirPath, exportScriptVersion);
}
- private static String getDirPath(StringBuilder sb) {
- return concat(sb, System.getProperty("jboss.server.home.dir"), FileUtils.FILE_SEPARATOR, ZIP_FILES_EXTRACT_DIR, FileUtils.FILE_SEPARATOR, "zip-", UUID.randomUUID());
+ private static String getDirPath() {
+ return System.getProperty("jboss.server.home.dir") +
+ FileUtils.FILE_SEPARATOR + ZIP_FILES_EXTRACT_DIR +
+ FileUtils.FILE_SEPARATOR + "zip-" + UUID.randomUUID();
}
}
diff --git a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/basic_info/CompetitionBasicInfoGetServlet.java b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/basic_info/CompetitionBasicInfoGetServlet.java
index 69afbad1..952723e7 100644
--- a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/basic_info/CompetitionBasicInfoGetServlet.java
+++ b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/basic_info/CompetitionBasicInfoGetServlet.java
@@ -7,8 +7,6 @@
import su.opencode.kefir.web.InitiableAction;
import su.opencode.kefir.web.JsonServlet;
-import static su.opencode.kefir.util.StringUtils.concat;
-
/**
* Copyright 2014 Dmitriy Popov.
* $HeadURL$
@@ -16,31 +14,31 @@
* $Revision$
* $Date:: $
*/
-public class CompetitionBasicInfoGetServlet extends JsonServlet
-{
- @Override
- protected Action getAction() {
- return new InitiableAction()
- {
- @Override
- public void doAction() throws Exception {
- Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
- if (competitionEntityId == null) {
- throw new ClientException( concat(sb, "\"", COMPETITION_ENTITY_ID_PARAM_NAME, "\" parameter is not set") );
- }
+public class CompetitionBasicInfoGetServlet extends JsonServlet {
+ @Override
+ protected Action getAction() {
+ return new InitiableAction() {
+ @Override
+ public void doAction() throws Exception {
+ Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
+ if (competitionEntityId == null) {
+ String errorMessage = String.format("\"%s\" parameter is not set", COMPETITION_ENTITY_ID_PARAM_NAME);
+ throw new ClientException(errorMessage);
+ }
- CompetitionEntityService service = getService(CompetitionEntityService.class);
- Competition competition = service.getCompetition(competitionEntityId);
+ CompetitionEntityService service = getService(CompetitionEntityService.class);
+ Competition competition = service.getCompetition(competitionEntityId);
- if (competition == null) {
- throw new ClientException( concat(sb, "Competition not found for competitionEntityId = ", competitionEntityId) );
- }
+ if (competition == null) {
+ String errorMessage = String.format("Competition not found for competitionEntityId = %d", competitionEntityId);
+ throw new ClientException(errorMessage);
+ }
- CompetitionBasicInfo basicInfo = new CompetitionBasicInfo(competition);
- writeSuccess(basicInfo);
- }
- };
- }
+ CompetitionBasicInfo basicInfo = new CompetitionBasicInfo(competition);
+ writeSuccess(basicInfo);
+ }
+ };
+ }
- public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
+ public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
}
diff --git a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/highchart/ErrorsCountChartValuesGetServlet.java b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/highchart/ErrorsCountChartValuesGetServlet.java
index e416655a..acdbb262 100644
--- a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/highchart/ErrorsCountChartValuesGetServlet.java
+++ b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/highchart/ErrorsCountChartValuesGetServlet.java
@@ -9,8 +9,6 @@
import su.opencode.kefir.web.InitiableAction;
import su.opencode.kefir.web.JsonServlet;
-import static su.opencode.kefir.util.StringUtils.concat;
-
/**
* Copyright 2014 Dmitriy Popov.
* $HeadURL$
@@ -18,29 +16,32 @@
* $Revision$
* $Date:: $
*/
-public class ErrorsCountChartValuesGetServlet extends JsonServlet
-{
- @Override
- protected Action getAction() {
- return new InitiableAction()
- {
- @Override
- public void doAction() throws Exception {
- Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
- if (competitionEntityId == null)
- throw new ClientException( concat(sb, "\"", COMPETITION_ENTITY_ID_PARAM_NAME, "\" parameter is not set") );
+public class ErrorsCountChartValuesGetServlet extends JsonServlet {
+
+ @Override
+ protected Action getAction() {
+ return new InitiableAction() {
+ @Override
+ public void doAction() throws Exception {
+ Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
+ if (competitionEntityId == null) {
+ String errorMessage = String.format("\"%s\" parameter is not set", COMPETITION_ENTITY_ID_PARAM_NAME);
+ throw new ClientException(errorMessage);
+ }
- CompetitionEntityService service = getService(CompetitionEntityService.class);
- Competition competition = service.getCompetition(competitionEntityId);
+ CompetitionEntityService service = getService(CompetitionEntityService.class);
+ Competition competition = service.getCompetition(competitionEntityId);
- if (competition == null)
- throw new ClientException( concat(sb, "Competition not found for competitionEntityId = ", competitionEntityId) );
+ if (competition == null) {
+ String errorMessage = String.format("Competition not found for competitionEntityId = %d", competitionEntityId);
+ throw new ClientException(errorMessage);
+ }
- HighChartValue highChartValue = ErrorsCountChartFiller.fillData(competition);
- writeSuccess(highChartValue);
- }
- };
- }
+ HighChartValue highChartValue = ErrorsCountChartFiller.fillData(competition);
+ writeSuccess(highChartValue);
+ }
+ };
+ }
- public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
+ public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
}
\ No newline at end of file
diff --git a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/highchart/SpeedChartValuesGetServlet.java b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/highchart/SpeedChartValuesGetServlet.java
index 1514c969..8fa0607e 100644
--- a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/highchart/SpeedChartValuesGetServlet.java
+++ b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/highchart/SpeedChartValuesGetServlet.java
@@ -9,8 +9,6 @@
import su.opencode.kefir.web.InitiableAction;
import su.opencode.kefir.web.JsonServlet;
-import static su.opencode.kefir.util.StringUtils.concat;
-
/**
* Copyright 2014 Dmitriy Popov.
* $HeadURL$
@@ -18,29 +16,32 @@
* $Revision$
* $Date:: $
*/
-public class SpeedChartValuesGetServlet extends JsonServlet
-{
- @Override
- protected Action getAction() {
- return new InitiableAction()
- {
- @Override
- public void doAction() throws Exception {
- Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
- if (competitionEntityId == null)
- throw new ClientException( concat(sb, "\"", COMPETITION_ENTITY_ID_PARAM_NAME, "\" parameter is not set") );
+public class SpeedChartValuesGetServlet extends JsonServlet {
+
+ @Override
+ protected Action getAction() {
+ return new InitiableAction() {
+ @Override
+ public void doAction() throws Exception {
+ Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
+ if (competitionEntityId == null) {
+ String errorMessage = String.format("\"%s\" parameter is not set", COMPETITION_ENTITY_ID_PARAM_NAME);
+ throw new ClientException(errorMessage);
+ }
- CompetitionEntityService service = getService(CompetitionEntityService.class);
- Competition competition = service.getCompetition(competitionEntityId);
+ CompetitionEntityService service = getService(CompetitionEntityService.class);
+ Competition competition = service.getCompetition(competitionEntityId);
- if (competition == null)
- throw new ClientException( concat(sb, "Competition not found for competitionEntityId = ", competitionEntityId) );
+ if (competition == null) {
+ String errorMessage = String.format("Competition not found for competitionEntityId = %d", competitionEntityId);
+ throw new ClientException(errorMessage);
+ }
- HighChartValue highChartValue = SpeedChartFiller.fillData(competition);
- writeSuccess(highChartValue);
- }
- };
- }
+ HighChartValue highChartValue = SpeedChartFiller.fillData(competition);
+ writeSuccess(highChartValue);
+ }
+ };
+ }
- public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
+ public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
}
\ No newline at end of file
diff --git a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/round/RoundInfoGetServlet.java b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/round/RoundInfoGetServlet.java
index 38d4782d..e189d897 100644
--- a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/round/RoundInfoGetServlet.java
+++ b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/model/round/RoundInfoGetServlet.java
@@ -8,8 +8,6 @@
import su.opencode.kefir.web.InitiableAction;
import su.opencode.kefir.web.JsonServlet;
-import static su.opencode.kefir.util.StringUtils.concat;
-
/**
* Copyright 2014 Dmitriy Popov.
* $HeadURL$
@@ -17,38 +15,45 @@
* $Revision$
* $Date:: $
*/
-public class RoundInfoGetServlet extends JsonServlet
-{
- @Override
- protected Action getAction() {
- return new InitiableAction()
- {
- @Override
- public void doAction() throws Exception {
- Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
- if (competitionEntityId == null)
- throw new ClientException( concat(sb, "\"", COMPETITION_ENTITY_ID_PARAM_NAME, "\" parameter is not set") );
-
- Integer roundNumber = getIntegerParam(ROUND_NUMBER_PARAM_NAME);
- if (roundNumber == null)
- throw new ClientException( concat(sb, "\"", ROUND_NUMBER_PARAM_NAME, "\" parameter is not set") );
-
- CompetitionEntityService service = getService(CompetitionEntityService.class);
- Competition competition = service.getCompetition(competitionEntityId);
-
- if (competition == null)
- throw new ClientException( concat(sb, "Competition not found for competitionEntityId = ", competitionEntityId) );
-
- Round round = competition.getRound(roundNumber);
- if (round == null)
- throw new ClientException( concat(sb, "Round with number ", roundNumber, " is not found for competitionEntityId = ", competitionEntityId) );
-
- RoundInfo roundInfo = new RoundInfo(competition, round);
- writeSuccess(roundInfo);
- }
- };
- }
-
- public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
- public static final String ROUND_NUMBER_PARAM_NAME = "roundNumber";
+public class RoundInfoGetServlet extends JsonServlet {
+
+ @Override
+ protected Action getAction() {
+ return new InitiableAction() {
+ @Override
+ public void doAction() throws Exception {
+ Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
+ if (competitionEntityId == null) {
+ String errorMessage = String.format("\"%s\" parameter is not set", COMPETITION_ENTITY_ID_PARAM_NAME);
+ throw new ClientException(errorMessage);
+ }
+
+ Integer roundNumber = getIntegerParam(ROUND_NUMBER_PARAM_NAME);
+ if (roundNumber == null) {
+ String errorMessage = String.format("\"%s\" parameter is not set", ROUND_NUMBER_PARAM_NAME);
+ throw new ClientException(errorMessage);
+ }
+
+ CompetitionEntityService service = getService(CompetitionEntityService.class);
+ Competition competition = service.getCompetition(competitionEntityId);
+
+ if (competition == null) {
+ String errorMessage = String.format("Competition not found for competitionEntityId = %d", competitionEntityId);
+ throw new ClientException(errorMessage);
+ }
+
+ Round round = competition.getRound(roundNumber);
+ if (round == null) {
+ String errorMessage = String.format("Round with number %d is not found for competitionEntityId = %d", roundNumber, competitionEntityId);
+ throw new ClientException(errorMessage);
+ }
+
+ RoundInfo roundInfo = new RoundInfo(competition, round);
+ writeSuccess(roundInfo);
+ }
+ };
+ }
+
+ public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
+ public static final String ROUND_NUMBER_PARAM_NAME = "roundNumber";
}
\ No newline at end of file
diff --git a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/processing/players_table/PlayerResultsTableXlsGetServlet.java b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/processing/players_table/PlayerResultsTableXlsGetServlet.java
index 84155a75..dabc3c0b 100644
--- a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/processing/players_table/PlayerResultsTableXlsGetServlet.java
+++ b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/processing/players_table/PlayerResultsTableXlsGetServlet.java
@@ -9,8 +9,6 @@
import su.opencode.kefir.web.InitiableAction;
import su.opencode.kefir.web.JsonServlet;
-import static su.opencode.kefir.util.StringUtils.concat;
-
/**
* Copyright 2014 Dmitriy Popov.
* $HeadURL$
@@ -18,35 +16,36 @@
* $Revision$
* $Date:: $
*/
-public class PlayerResultsTableXlsGetServlet extends JsonServlet
-{
- @Override
- protected Action getAction() {
- return new InitiableAction()
- {
- @Override
- public void doAction() throws Exception {
- Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
- if (competitionEntityId == null) {
- throw new ClientException( concat(sb, "\"", COMPETITION_ENTITY_ID_PARAM_NAME, "\" parameter is not set") );
- }
-
- CompetitionEntityService service = getService(CompetitionEntityService.class);
- Competition competition = service.getCompetition(competitionEntityId);
-
- if (competition == null) {
- throw new ClientException( concat(sb, "Competition not found for competitionEntityId = ", competitionEntityId) );
- }
-
- PlayersResultsTable table = new PlayersResultsTable();
- table.fillTable(competition);
-
- String fileName = concat(sb, "competition-", competitionEntityId, "-playerResultsTable.xlsx");
- XSSFWorkbook workbook = PlayerResultsTableToXlsConverter.toXssfWorkbook(table);
- writeToExcel(fileName, workbook);
- }
- };
- }
-
- public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
+public class PlayerResultsTableXlsGetServlet extends JsonServlet {
+
+ @Override
+ protected Action getAction() {
+ return new InitiableAction() {
+ @Override
+ public void doAction() throws Exception {
+ Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
+ if (competitionEntityId == null) {
+ String errorMessage = String.format("\"%s\" parameter is not set", COMPETITION_ENTITY_ID_PARAM_NAME);
+ throw new ClientException(errorMessage);
+ }
+
+ CompetitionEntityService service = getService(CompetitionEntityService.class);
+ Competition competition = service.getCompetition(competitionEntityId);
+
+ if (competition == null) {
+ String errorMessage = String.format("Competition not found for competitionEntityId = %d", competitionEntityId);
+ throw new ClientException(errorMessage);
+ }
+
+ PlayersResultsTable table = new PlayersResultsTable();
+ table.fillTable(competition);
+
+ String fileName = String.format("competition-%s-playerResultsTable.xlsx", competitionEntityId);
+ XSSFWorkbook workbook = PlayerResultsTableToXlsConverter.toXssfWorkbook(table);
+ writeToExcel(fileName, workbook);
+ }
+ };
+ }
+
+ public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
}
diff --git a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/processing/players_table/PlayersResultsTableDataGetServlet.java b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/processing/players_table/PlayersResultsTableDataGetServlet.java
index 25245d91..e3f27868 100644
--- a/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/processing/players_table/PlayersResultsTableDataGetServlet.java
+++ b/kgparserWeb/src/main/java/ru/klavogonki/kgparser/servlet/processing/players_table/PlayersResultsTableDataGetServlet.java
@@ -8,8 +8,6 @@
import su.opencode.kefir.web.InitiableAction;
import su.opencode.kefir.web.JsonServlet;
-import static su.opencode.kefir.util.StringUtils.concat;
-
/**
* Copyright 2014 LLC "Open Code"
* http://www.o-code.ru
@@ -18,33 +16,34 @@
* $Revision$
* $Date:: $
*/
-public class PlayersResultsTableDataGetServlet extends JsonServlet
-{
- @Override
- protected Action getAction() {
- return new InitiableAction()
- {
- @Override
- public void doAction() throws Exception {
- Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
- if (competitionEntityId == null) {
- throw new ClientException( concat(sb, "\"", COMPETITION_ENTITY_ID_PARAM_NAME, "\" parameter is not set") );
- }
-
- CompetitionEntityService service = getService(CompetitionEntityService.class);
- Competition competition = service.getCompetition(competitionEntityId);
-
- if (competition == null) {
- throw new ClientException( concat(sb, "Competition not found for competitionEntityId = ", competitionEntityId) );
- }
-
- PlayersResultsTable table = new PlayersResultsTable();
- table.fillTable(competition);
-
- writeSuccess(table);
- }
- };
- }
-
- public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
+public class PlayersResultsTableDataGetServlet extends JsonServlet {
+
+ @Override
+ protected Action getAction() {
+ return new InitiableAction() {
+ @Override
+ public void doAction() throws Exception {
+ Long competitionEntityId = getLongParam(COMPETITION_ENTITY_ID_PARAM_NAME);
+ if (competitionEntityId == null) {
+ String errorMessage = String.format("\"%s\" parameter is not set", COMPETITION_ENTITY_ID_PARAM_NAME);
+ throw new ClientException(errorMessage);
+ }
+
+ CompetitionEntityService service = getService(CompetitionEntityService.class);
+ Competition competition = service.getCompetition(competitionEntityId);
+
+ if (competition == null) {
+ String errorMessage = String.format("Competition not found for competitionEntityId = %d", competitionEntityId);
+ throw new ClientException(errorMessage);
+ }
+
+ PlayersResultsTable table = new PlayersResultsTable();
+ table.fillTable(competition);
+
+ writeSuccess(table);
+ }
+ };
+ }
+
+ public static final String COMPETITION_ENTITY_ID_PARAM_NAME = "competitionId";
}