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;
28 * @author Dmitry Samoshin aka gotty
30 public class Chess2700Scanner extends AbstractSettingsScanner implements Scanner {
32 private static final String SETTINGS_FILENAME = "2700chess.settings";
35 protected String getResourceName() {
36 return SETTINGS_FILENAME;
40 public PGNTournament scanTournament(String tournamentId) throws ScannerException {
41 throw new ScannerException(
42 "2700Chess does not support searching for a tournament by ID!"
47 public PGNTournament findTournament(String tournamentName) throws ScannerException {
48 throw new ScannerException(
49 "2700Chess does not support searching for a tournament by name!"
54 public PGNGame scanGame(String gameId) throws ScannerException {
61 public PGNGame scanGame(String gameId, String tournamentId) throws ScannerException {
62 return scanGame(gameId);
66 public PGNGame scanUrl(String gameUrl) throws ScannerException {
69 getSettings().getGameUrlRegex()
72 throw new ScannerException(
73 String.format("Failed to get PGN for requesting URL: %s", gameUrl)
76 pgn = StringUtils.formatCrlf(pgn);
77 if (!StringUtils.isPgn(pgn)) {
78 throw new ScannerException(
79 String.format("Incorrect PGN for requesting URL: %s", gameUrl)