2 * Copyright (c) 2019-2020. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.chess.scanner.portal;
19 import org.hedgecode.chess.scanner.Scanner;
20 import org.hedgecode.chess.scanner.ScannerException;
21 import org.hedgecode.chess.scanner.StringUtils;
22 import org.hedgecode.chess.scanner.entity.PGNGame;
23 import org.hedgecode.chess.scanner.entity.PGNTournament;
25 import static org.hedgecode.chess.scanner.ScannerConstants.*;
30 * @author Dmitry Samoshin aka gotty
32 public class Chess2700Scanner extends AbstractSettingsScanner implements Scanner {
34 private static final String SETTINGS_FILENAME = "2700chess.settings";
37 protected String getResourceName() {
38 return SETTINGS_FILENAME;
42 public PGNTournament scanTournament(String tournamentId) throws ScannerException {
43 throw new ScannerException(
44 "scanner.portal.search.unavailable.tournament.id", DOMAIN_2700CHESS
49 public PGNTournament findTournament(String tournamentName) throws ScannerException {
50 throw new ScannerException(
51 "scanner.portal.search.unavailable.tournament.name", DOMAIN_2700CHESS
56 public PGNGame scanGame(String gameId) throws ScannerException {
63 public PGNGame scanGame(String gameId, String tournamentId) throws ScannerException {
64 return scanGame(gameId);
68 public PGNGame scanUrl(String gameUrl) throws ScannerException {
71 getSettings().getGameUrlRegex()
74 throw new ScannerException(
75 "scanner.failed.request.url", gameUrl
78 pgn = StringUtils.formatCrlf(pgn);
79 if (!StringUtils.isPgn(pgn)) {
80 throw new ScannerException(
81 "scanner.incorrect.pgn.url", gameUrl