[LIB-13] Functional for working with strings moved to StringUtils
[chesshog-scanner.git] / src / main / java / org / hedgecode / chess / scanner / portal / ChessGamesScanner.java
index 247660a..56fc032 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import org.hedgecode.chess.scanner.Scanner;
 import org.hedgecode.chess.scanner.ScannerException;
+import org.hedgecode.chess.scanner.StringUtils;
 import org.hedgecode.chess.scanner.entity.PGNGame;
 import org.hedgecode.chess.scanner.entity.PGNTournament;
 
@@ -75,7 +76,7 @@ public class ChessGamesScanner extends AbstractSettingsScanner implements Scanne
         String pgn = request(
                 assignUrl(gameId)
         );
-        if (!isPgnFormat(pgn)) {
+        if (!StringUtils.isPgn(pgn)) {
             throw new ScannerException(
                     String.format("Failed to get PGN for requesting game ID: %s", gameId)
             );
@@ -92,13 +93,12 @@ public class ChessGamesScanner extends AbstractSettingsScanner implements Scanne
 
     @Override
     public PGNGame scanUrl(String gameUrl) throws ScannerException {
-        String pgn = regex(
-                request(
-                        gameUrl
-                ),
+        String gamePage = request(gameUrl);
+        String pgn = StringUtils.match(
+                gamePage,
                 getSettings().getGameUrlRegex()
         );
-        if (pgn == null || !isPgnFormat(pgn)) {
+        if (pgn == null || !StringUtils.isPgn(pgn)) {
             throw new ScannerException(
                     String.format("Failed to get PGN for requesting URL: %s", gameUrl)
             );