X-Git-Url: https://git.hedgecode.org/?p=chesshog-scanner.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fhedgecode%2Fchess%2Fscanner%2Fportal%2FAbstractRequestScanner.java;fp=src%2Fmain%2Fjava%2Forg%2Fhedgecode%2Fchess%2Fscanner%2Fportal%2FAbstractRequestScanner.java;h=e179d2c284f169dcc4afd653d45b4bec35c4909f;hp=039084844a982591d9c4fcfad68981b019488603;hb=df574e5ec8ae08c1c50adbe30b597cd86e6ab3fa;hpb=25ccd0fd5d5a640bc2dac646f2d760b5d64b989b diff --git a/src/main/java/org/hedgecode/chess/scanner/portal/AbstractRequestScanner.java b/src/main/java/org/hedgecode/chess/scanner/portal/AbstractRequestScanner.java index 0390848..e179d2c 100644 --- a/src/main/java/org/hedgecode/chess/scanner/portal/AbstractRequestScanner.java +++ b/src/main/java/org/hedgecode/chess/scanner/portal/AbstractRequestScanner.java @@ -27,14 +27,14 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import org.hedgecode.chess.scanner.ChessHogScannerException; import org.hedgecode.chess.scanner.Scanner; +import org.hedgecode.chess.scanner.ScannerException; import org.hedgecode.chess.scanner.regex.RegexMatcher; import org.hedgecode.chess.scanner.regex.RegexResult; import org.hedgecode.chess.scanner.regex.RegexType; import org.hedgecode.chess.scanner.regex.RegexTypeMatcher; -import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*; +import static org.hedgecode.chess.scanner.ScannerConstants.*; /** * AbstractRequestScanner @@ -43,11 +43,11 @@ import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*; */ public abstract class AbstractRequestScanner implements Scanner { - protected String request(String url) throws ChessHogScannerException { + protected String request(String url) throws ScannerException { return request(url, true); } - protected String request(String url, boolean withCrlf) throws ChessHogScannerException { + protected String request(String url, boolean withCrlf) throws ScannerException { HttpGet request = new HttpGet(url); CloseableHttpResponse response = null; StringBuilder sb = new StringBuilder(); @@ -67,7 +67,7 @@ public abstract class AbstractRequestScanner implements Scanner { } } } catch (IOException cause) { - throw new ChessHogScannerException( + throw new ScannerException( String.format("Error occurred for requesting URL: %s", url), cause ); } finally { @@ -80,30 +80,30 @@ public abstract class AbstractRequestScanner implements Scanner { return sb.toString(); } - protected List split(String url, String splitMatch) throws ChessHogScannerException { + protected List split(String url, String splitMatch) throws ScannerException { RegexResult result = splitRequest(url, splitMatch); return result.resultList(); } - protected Map splitMap(String url, String splitMatch) throws ChessHogScannerException { + protected Map splitMap(String url, String splitMatch) throws ScannerException { RegexResult result = splitRequest(url, splitMatch); return result.resultMap(); } - protected RegexResult splitRequest(String url, String splitMatch) throws ChessHogScannerException { + protected RegexResult splitRequest(String url, String splitMatch) throws ScannerException { RegexMatcher matcher = new RegexTypeMatcher( RegexType.SPLIT, splitMatch ); return matchRequest(url, matcher, false); } - protected String match(String url, String match) throws ChessHogScannerException { + protected String match(String url, String match) throws ScannerException { List result = match(url, match, true); return result.isEmpty() ? null : result.get(0); } protected List match(String url, String match, boolean isFirst) - throws ChessHogScannerException + throws ScannerException { RegexMatcher matcher = new RegexTypeMatcher( RegexType.FIND, match @@ -117,7 +117,7 @@ public abstract class AbstractRequestScanner implements Scanner { } protected Map matchMap(String url, String match, boolean isFirst) - throws ChessHogScannerException + throws ScannerException { RegexMatcher matcher = new RegexTypeMatcher( RegexType.FIND, match @@ -131,14 +131,14 @@ public abstract class AbstractRequestScanner implements Scanner { } protected String match(String url, String startMatch, String endMatch) - throws ChessHogScannerException + throws ScannerException { List result = match(url, startMatch, endMatch, true); return result.isEmpty() ? null : result.get(0); } protected List match(String url, String startMatch, String endMatch, boolean isFirst) - throws ChessHogScannerException + throws ScannerException { RegexMatcher matcher = new RegexTypeMatcher( startMatch, endMatch @@ -152,7 +152,7 @@ public abstract class AbstractRequestScanner implements Scanner { } protected Map matchMap(String url, String startMatch, String endMatch, boolean isFirst) - throws ChessHogScannerException + throws ScannerException { RegexMatcher matcher = new RegexTypeMatcher( startMatch, endMatch @@ -166,7 +166,7 @@ public abstract class AbstractRequestScanner implements Scanner { } protected RegexResult matchRequest(String url, RegexMatcher matcher, boolean isFirst) - throws ChessHogScannerException + throws ScannerException { HttpGet request = new HttpGet(url); CloseableHttpResponse response = null; @@ -187,7 +187,7 @@ public abstract class AbstractRequestScanner implements Scanner { } } } catch (IOException cause) { - throw new ChessHogScannerException( + throw new ScannerException( String.format("Error occurred for requesting URL: %s", url), cause ); } finally {