// Path: src/main/java/cz/jiripinkas/jsitemapgenerator/exception/InvalidPriorityException.java
// public class InvalidPriorityException extends RuntimeException {
// 
//     public InvalidPriorityException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/cz/jiripinkas/jsitemapgenerator/exception/InvalidUrlException.java
// public class InvalidUrlException extends RuntimeException {
// 
//     public InvalidUrlException(Throwable cause) {
//         super(cause);
//     }
// 
// }
// 
// Path: src/main/java/cz/jiripinkas/jsitemapgenerator/exception/WebmasterToolsException.java
// public class WebmasterToolsException extends RuntimeException {
// 
//     public WebmasterToolsException(String message, Throwable ex) {
//         super(message, ex);
//     }
// 
//     public WebmasterToolsException(String message) {
//         super(message);
//     }
// 
//     public WebmasterToolsException(Throwable cause) {
//         super(cause);
//     }
// }


import cz.jiripinkas.jsitemapgenerator.exception.InvalidPriorityException;
import cz.jiripinkas.jsitemapgenerator.exception.InvalidUrlException;
import cz.jiripinkas.jsitemapgenerator.exception.WebmasterToolsException;
import java.io.*;
import java.lang.reflect.Method;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.zip.GZIPOutputStream;
                    try {
                        httpResponse = execute.invoke(ping.getHttpClientImplementation(), httpGet);
                        Method getEntity = Class.forName("org.apache.http.HttpResponse").getMethod("getEntity");
                        Object httpEntity = getEntity.invoke(httpResponse);
                        Method consume = Class.forName("org.apache.http.util.EntityUtils").getMethod("consume", Class.forName("org.apache.http.HttpEntity"));
                        consume.invoke(null, httpEntity);
                        Object getStatusLine = Class.forName("org.apache.http.HttpResponse").getMethod("getStatusLine").invoke(httpResponse);
                        int getStatusCode = (Integer) Class.forName("org.apache.http.StatusLine").getMethod("getStatusCode").invoke(getStatusLine);
                        if(getStatusCode != 200) {
                            responseIsNot200 = true;
                        }
                    } finally {
                        if(httpResponse != null) {
                            Class.forName("java.io.Closeable").getMethod("close").invoke(httpResponse);
                        }
                    }
                    // same code without reflection
//                    org.apache.http.impl.client.CloseableHttpClient closeableHttpClient = (org.apache.http.impl.client.CloseableHttpClient) ping.getHttpClientImplementation();
//                    org.apache.http.client.methods.HttpGet httpGet = new org.apache.http.client.methods.HttpGet(pingUrl);
//                    try (org.apache.http.client.methods.CloseableHttpResponse httpResponse = closeableHttpClient.execute(httpGet)) {
//                        org.apache.http.HttpEntity httpEntity = httpResponse.getEntity();
//                        org.apache.http.util.EntityUtils.consume(httpEntity);
//                        if(httpResponse.getStatusLine().getStatusCode() != 200) {
//                            responseIsNot200 = true;
//                        }
//                    }
                } else {
                    throw new UnsupportedOperationException("Unknown HttpClientType!");
                }
                if(responseIsNot200) {
// Path: src/main/java/cz/jiripinkas/jsitemapgenerator/exception/InvalidPriorityException.java
// public class InvalidPriorityException extends RuntimeException {
// 
//     public InvalidPriorityException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/cz/jiripinkas/jsitemapgenerator/exception/InvalidUrlException.java
// public class InvalidUrlException extends RuntimeException {
// 
//     public InvalidUrlException(Throwable cause) {
//         super(cause);
//     }
// 
// }
// 
// Path: src/main/java/cz/jiripinkas/jsitemapgenerator/exception/WebmasterToolsException.java
// public class WebmasterToolsException extends RuntimeException {
// 
//     public WebmasterToolsException(String message, Throwable ex) {
//         super(message, ex);
//     }
// 
//     public WebmasterToolsException(String message) {
//         super(message);
//     }
// 
//     public WebmasterToolsException(Throwable cause) {
//         super(cause);
//     }
// }


// Path: src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java
import cz.jiripinkas.jsitemapgenerator.exception.InvalidPriorityException;
import cz.jiripinkas.jsitemapgenerator.exception.InvalidUrlException;
import cz.jiripinkas.jsitemapgenerator.exception.WebmasterToolsException;
import java.io.*;
import java.lang.reflect.Method;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.zip.GZIPOutputStream;

                    try {
                        httpResponse = execute.invoke(ping.getHttpClientImplementation(), httpGet);
                        Method getEntity = Class.forName("org.apache.http.HttpResponse").getMethod("getEntity");
                        Object httpEntity = getEntity.invoke(httpResponse);
                        Method consume = Class.forName("org.apache.http.util.EntityUtils").getMethod("consume", Class.forName("org.apache.http.HttpEntity"));
                        consume.invoke(null, httpEntity);
                        Object getStatusLine = Class.forName("org.apache.http.HttpResponse").getMethod("getStatusLine").invoke(httpResponse);
                        int getStatusCode = (Integer) Class.forName("org.apache.http.StatusLine").getMethod("getStatusCode").invoke(getStatusLine);
                        if(getStatusCode != 200) {
                            responseIsNot200 = true;
                        }
                    } finally {
                        if(httpResponse != null) {
                            Class.forName("java.io.Closeable").getMethod("close").invoke(httpResponse);
                        }
                    }
                    // same code without reflection
//                    org.apache.http.impl.client.CloseableHttpClient closeableHttpClient = (org.apache.http.impl.client.CloseableHttpClient) ping.getHttpClientImplementation();
//                    org.apache.http.client.methods.HttpGet httpGet = new org.apache.http.client.methods.HttpGet(pingUrl);
//                    try (org.apache.http.client.methods.CloseableHttpResponse httpResponse = closeableHttpClient.execute(httpGet)) {
//                        org.apache.http.HttpEntity httpEntity = httpResponse.getEntity();
//                        org.apache.http.util.EntityUtils.consume(httpEntity);
//                        if(httpResponse.getStatusLine().getStatusCode() != 200) {
//                            responseIsNot200 = true;
//                        }
//                    }
                } else {
                    throw new UnsupportedOperationException("Unknown HttpClientType!");
                }
                if(responseIsNot200) {
                    throw new WebmasterToolsException(searchEngine.getPrettyName() + " could not be informed about new sitemap! Return code != 200");