hostName = new URL(url).getHost();
} catch (MalformedURLException cause) {
throw new ScannerException(
- String.format("Incorrect URL: %s", url), cause
+ "scanner.incorrect.url", cause, url
);
}
ScannerType type = ScannerType.byHost(hostName);
if (type == null) {
throw new ScannerException(
- String.format("Host %s is not among the known for the scanner", hostName)
+ "scanner.host.unknown", hostName
);
}
return scanner(type).scanUrl(url);
package org.hedgecode.chess.scanner;
+import java.util.ResourceBundle;
+
/**
* ScannerException
*
*/
public class ScannerException extends Exception {
- public ScannerException(String message) {
- super(message);
- }
+ private static final ResourceBundle LOCALE_BUNDLE =
+ ResourceBundle.getBundle(ScannerConstants.LOCALE_BUNDLE_FILE);
- public ScannerException(Throwable cause) {
- super(cause);
+ public ScannerException(String key, Object... args) {
+ super(
+ String.format(
+ LOCALE_BUNDLE.getString(key), args
+ )
+ );
}
- public ScannerException(String message, Throwable cause) {
- super(message, cause);
+ public ScannerException(String key, Throwable cause, Object... args) {
+ super(
+ String.format(
+ LOCALE_BUNDLE.getString(key), args
+ ),
+ cause
+ );
}
}
);
} catch (IOException cause) {
throw new ScannerException(
- String.format("Failed to get settings from resource file: %s", jsonFileName), cause
+ "scanner.failed.settings", cause, jsonFileName
);
}
return settings;
}
} catch (IOException cause) {
throw new ScannerException(
- String.format("Error occurred for requesting URL: %s", url), cause
+ "scanner.request.error", cause, url
);
}
return sb.toString();
}
} catch (IOException cause) {
throw new ScannerException(
- String.format("Error occurred for requesting URL: %s", url), cause
+ "scanner.request.error", cause, url
);
}
return matcher.result();
package org.hedgecode.chess.scanner.portal;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import org.hedgecode.chess.scanner.Initiable;
import org.hedgecode.chess.scanner.ScannerException;
import org.hedgecode.chess.scanner.Settings;
import org.hedgecode.chess.scanner.entity.PGNGame;
import org.hedgecode.chess.scanner.entity.PGNTournament;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
+
/**
* Chess24Scanner
*
@Override
public PGNTournament scanTournament(String tournamentId) throws ScannerException {
throw new ScannerException(
- "The scanner functional of portal chess24.com is under development!"
+ "scanner.portal.under.development", DOMAIN_CHESS24
);
}
@Override
public PGNTournament findTournament(String tournamentName) throws ScannerException {
throw new ScannerException(
- "The scanner functional of portal chess24.com is under development!"
+ "scanner.portal.under.development", DOMAIN_CHESS24
);
}
@Override
public PGNGame scanGame(String gameId, String tournamentId) throws ScannerException {
throw new ScannerException(
- "The scanner functional of portal chess24.com is under development!"
+ "scanner.portal.under.development", DOMAIN_CHESS24
);
}
@Override
public PGNGame scanUrl(String gameUrl) throws ScannerException {
throw new ScannerException(
- "The scanner functional of portal chess24.com is under development!"
+ "scanner.portal.under.development", DOMAIN_CHESS24
);
}
import org.hedgecode.chess.scanner.entity.PGNGame;
import org.hedgecode.chess.scanner.entity.PGNTournament;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
+
/**
* Chess2700Scanner
*
@Override
public PGNTournament scanTournament(String tournamentId) throws ScannerException {
throw new ScannerException(
- "2700Chess does not support searching for a tournament by ID!"
+ "scanner.portal.search.unavailable.tournament.id", DOMAIN_2700CHESS
);
}
@Override
public PGNTournament findTournament(String tournamentName) throws ScannerException {
throw new ScannerException(
- "2700Chess does not support searching for a tournament by name!"
+ "scanner.portal.search.unavailable.tournament.name", DOMAIN_2700CHESS
);
}
);
if (pgn == null) {
throw new ScannerException(
- String.format("Failed to get PGN for requesting URL: %s", gameUrl)
+ "scanner.failed.request.url", gameUrl
);
}
pgn = StringUtils.formatCrlf(pgn);
if (!StringUtils.isPgn(pgn)) {
throw new ScannerException(
- String.format("Incorrect PGN for requesting URL: %s", gameUrl)
+ "scanner.incorrect.pgn.url", gameUrl
);
}
return new PGNGame(
import org.hedgecode.chess.scanner.format.chessbomb.GameFormat;
import org.hedgecode.chess.scanner.format.chessbomb.TournamentFormat;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
+
/**
* ChessBombScanner
*
@Override
public PGNGame scanGame(String gameId) throws ScannerException {
throw new ScannerException(
- "ChessBomb does not support searching game without a tournament name!"
+ "scanner.portal.search.without.tournament.name", DOMAIN_CHESSBOMB
);
}
);
if (encodeString == null) {
throw new ScannerException(
- String.format("Failed to decode source data for requesting URL: %s", url)
+ "scanner.failed.decode.url", url
);
}
return new String(
import org.hedgecode.chess.scanner.entity.PGNGame;
import org.hedgecode.chess.scanner.entity.PGNTournament;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
+
/**
* ChessComScanner
*
@Override
public PGNTournament scanTournament(String tournamentId) throws ScannerException {
throw new ScannerException(
- "The scanner functional of portal chess.com is under development!"
+ "scanner.portal.under.development", DOMAIN_CHESSCOM
);
}
@Override
public PGNTournament findTournament(String tournamentName) throws ScannerException {
throw new ScannerException(
- "The scanner functional of portal chess.com is under development!"
+ "scanner.portal.under.development", DOMAIN_CHESSCOM
);
}
@Override
public PGNGame scanGame(String gameId, String tournamentId) throws ScannerException {
throw new ScannerException(
- "The scanner functional of portal chess.com is under development!"
+ "scanner.portal.under.development", DOMAIN_CHESSCOM
);
}
@Override
public PGNGame scanUrl(String gameUrl) throws ScannerException {
throw new ScannerException(
- "The scanner functional of portal chess.com is under development!"
+ "scanner.portal.under.development", DOMAIN_CHESSCOM
);
}
);
if (!StringUtils.isPgn(pgn)) {
throw new ScannerException(
- String.format("Failed to get PGN for requesting game ID: %s", gameId)
+ "scanner.failed.request.game", gameId
);
}
return new PGNGame(
);
if (pgn == null || !StringUtils.isPgn(pgn)) {
throw new ScannerException(
- String.format("Failed to get PGN for requesting URL: %s", gameUrl)
+ "scanner.failed.request.url", gameUrl
);
}
return new PGNGame(
import org.hedgecode.chess.scanner.format.lichess.Format;
import org.hedgecode.chess.scanner.format.lichess.GameFormat;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
import static org.hedgecode.chess.scanner.format.PGNConstants.*;
/**
@Override
public PGNTournament findTournament(String tournamentName) throws ScannerException {
throw new ScannerException(
- "Lichess does not support searching for a tournament by name!"
+ "scanner.portal.search.unavailable,name", DOMAIN_LICHESS
);
}
);
if (!StringUtils.isPgn(pgn)) {
throw new ScannerException(
- String.format("Failed to get PGN for requesting game ID: %s", gameId)
+ "scanner.failed.request.game", gameId
);
}
return new PGNGame(
);
if (pgn == null) {
throw new ScannerException(
- String.format("Failed to get source data for requesting URL: %s", gameUrl)
+ "scanner.failed.source.data", gameUrl
);
}
GameFormat gameFormat = Format.formatGame(pgn);
pgn = StringEscapeUtils.unescapeHtml4(pgn);
if (!StringUtils.isPgn(pgn)) {
throw new ScannerException(
- String.format("Failed to get PGN for requesting URL: %s", gameUrl)
+ "scanner.failed.request.url", gameUrl
);
}
return new PGNGame(
--- /dev/null
+# Copyright (c) 2019-2020. Developed by Hedgecode.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Default localized string information
+# Localized for Locale en_US
+
+scanner.incorrect.url=Incorrect URL: %s
+scanner.incorrect.pgn.url=Incorrect PGN for requesting URL: %s
+scanner.host.unknown=Host %s is not among the known for the scanner
+scanner.request.error=Error occurred for requesting URL: %s
+scanner.failed.settings=Failed to get settings from resource file: %s
+scanner.failed.request.game=Failed to get PGN for requesting game ID: %s
+scanner.failed.request.url=Failed to get PGN for requesting URL: %s
+scanner.failed.source.data=Failed to get source data for requesting URL: %s
+scanner.failed.decode.url=Failed to decode source data for requesting URL: %s
+scanner.portal.under.development=The scanner functional of portal %s is under development
+scanner.portal.search.unavailable.tournament.id=%s does not support searching for a tournament by ID
+scanner.portal.search.unavailable.tournament.name=%s does not support searching for a tournament by name
+scanner.portal.search.without.tournament.name=%s does not support searching game without a tournament name
--- /dev/null
+# Copyright (c) 2019-2020. Developed by Hedgecode.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Localized for Locale ru_RU
+
+scanner.incorrect.url=\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 URL: %s
+scanner.incorrect.pgn.url=\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 PGN \u043F\u043E \u0437\u0430\u043F\u0440\u043E\u0441\u0443 URL: %s
+scanner.host.unknown=\u0425\u043E\u0441\u0442 %s \u043D\u0435 \u0432\u0445\u043E\u0434\u0438\u0442 \u0432 \u0447\u0438\u0441\u043B\u043E \u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0445 \u0441\u043A\u0430\u043D\u0435\u0440\u0443
+scanner.request.error=\u041F\u0440\u043E\u0438\u0437\u043E\u0448\u043B\u0430 \u043E\u0448\u0438\u0431\u043A\u0430 \u043F\u043E \u0437\u0430\u043F\u0440\u043E\u0441\u0443 URL: %s
+scanner.failed.settings=\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u0438\u0437 \u0444\u0430\u0439\u043B\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043E\u0432: %s
+scanner.failed.request.game=\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C PGN \u043F\u043E \u0437\u0430\u043F\u0440\u043E\u0441\u0443 ID \u043F\u0430\u0440\u0442\u0438\u0438: %s
+scanner.failed.request.url=\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C PGN \u043F\u043E \u0437\u0430\u043F\u0440\u043E\u0441\u0443 URL: %s
+scanner.failed.source.data=\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435 \u043F\u043E \u0437\u0430\u043F\u0440\u043E\u0441\u0443 URL: %s
+scanner.failed.decode.url=\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0434\u0435\u043A\u043E\u0434\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435 \u043F\u043E \u0437\u0430\u043F\u0440\u043E\u0441\u0443 URL: %s
+scanner.portal.under.development=\u0424\u0443\u043D\u043A\u0446\u0438\u043E\u043D\u0430\u043B \u0441\u043A\u0430\u043D\u0435\u0440\u0430 \u043F\u043E\u0440\u0442\u0430\u043B\u0430 %s \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u0441\u044F \u0432 \u0441\u0442\u0430\u0434\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043E\u0442\u043A\u0438
+scanner.portal.search.unavailable.tournament.id=%s \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043F\u043E\u0438\u0441\u043A \u0442\u0443\u0440\u043D\u0438\u0440\u0430 \u043F\u043E ID
+scanner.portal.search.unavailable.tournament.name=%s \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043F\u043E\u0438\u0441\u043A \u0442\u0443\u0440\u043D\u0438\u0440\u0430 \u043F\u043E \u0438\u043C\u0435\u043D\u0438
+scanner.portal.search.without.tournament.name=%s \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043F\u043E\u0438\u0441\u043A \u0438\u0433\u0440\u044B \u0431\u0435\u0437 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u044F \u0442\u0443\u0440\u043D\u0438\u0440\u0430