// Path: helpers/src/main/java/be/fedict/dcat/helpers/Fetcher.java
// public class Fetcher {
//     private final static Logger logger = LoggerFactory.getLogger(Fetcher.class);
//     private int delay = 1000;
//     
//     /**
//      * Sleep (between HTTP requests)
//      */
//     public void sleep() {
//         try {
//             Thread.sleep(getDelay());
//         } catch (InterruptedException ex) {
//         }
//     }
// 
//     
//     /**
//      * Get delay between HTTP requests
//      * 
//      * @return 
//      */
//     public int getDelay() {
//         return delay;
//     }
//     /**
//      * Set delay between HTTP requests (500 ms or higher)
//      * 
//      * @param delay milliseconds
//      */
//     public void setDelay(int delay) {
// 		if (delay >= 500) {
// 			this.delay = delay;
// 			logger.info("Setting delay to {} ms", delay);
// 		} else {
// 			logger.warn("Delay of {} ms is too low", delay);
// 		}
//     }
// 
// 
//     /**
//      * Make HTTP GET request, assuming UTF8 response
//      * 
//      * @param url
//      * @return String containing raw page or empty string
//      * @throws IOException 
//      */
// 	public String makeRequest(URL url) throws IOException {
// 		return makeRequest(url, StandardCharsets.UTF_8);
// 	}
//     
//     /**
//      * Make HTTP GET request, assuming a specific charset used in the response
//      *
//      * @param url
// 	 * @param charset response charset
//      * @return String containing raw page or empty string
//      * @throws IOException 
//      */
//     public String makeRequest(URL url, Charset charset) throws IOException {
//         logger.info("Get request for page {}", url);
//         Request request = Request.Get(url.toString());
// 		// some servers return 503 if no accept header is present
// 		request.addHeader(HttpHeaders.ACCEPT, "*/*");
// 		request.connectTimeout(240 * 1000);
// 		request.socketTimeout(240 * 1000);
//         HttpResponse res = request.execute().returnResponse();
//         // Return empty if the HTTP returns something faulty
//         int status = res.getStatusLine().getStatusCode();
//         if (status != 200) {
//             logger.warn("HTTP code {} getting page {}", status, url);
//             return "";
//         }
// 
//         return EntityUtils.toString(res.getEntity(), charset);
//     }
//     
//     /**
//      * Make HTTP HEAD request
//      * 
//      * @param url
//      * @return
//      * @throws IOException 
//      */
//     public int makeHeadRequest(URL url) throws IOException {
//         logger.info("Head request for {}", url);
//         Request request = Request.Head(url.toString());
//         
//         return request.execute().returnResponse()
//                                 .getStatusLine().getStatusCode();
//     }
// }


import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.fedict.dcat.helpers.Fetcher;
import java.io.BufferedReader;
import java.io.BufferedWriter;

/*
 * Copyright (c) 2016, FPS BOSA DG DT
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice, this
 *   list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

package be.fedict.dcat.tools;






/**
 * Simple link checker.
 * 
 * @author Bart Hanssens <bart.hanssens@fedict.be>
 */
public class LinkChecker {
    private final static Logger logger = LoggerFactory.getLogger(LinkChecker.class);
    
    private final static String PROP_PREFIX = "be.fedict.dcat.tools.linkchecker";
    
    private final static Properties prop = new Properties();

// Path: helpers/src/main/java/be/fedict/dcat/helpers/Fetcher.java
// public class Fetcher {
//     private final static Logger logger = LoggerFactory.getLogger(Fetcher.class);
//     private int delay = 1000;
//     
//     /**
//      * Sleep (between HTTP requests)
//      */
//     public void sleep() {
//         try {
//             Thread.sleep(getDelay());
//         } catch (InterruptedException ex) {
//         }
//     }
// 
//     
//     /**
//      * Get delay between HTTP requests
//      * 
//      * @return 
//      */
//     public int getDelay() {
//         return delay;
//     }
//     /**
//      * Set delay between HTTP requests (500 ms or higher)
//      * 
//      * @param delay milliseconds
//      */
//     public void setDelay(int delay) {
// 		if (delay >= 500) {
// 			this.delay = delay;
// 			logger.info("Setting delay to {} ms", delay);
// 		} else {
// 			logger.warn("Delay of {} ms is too low", delay);
// 		}
//     }
// 
// 
//     /**
//      * Make HTTP GET request, assuming UTF8 response
//      * 
//      * @param url
//      * @return String containing raw page or empty string
//      * @throws IOException 
//      */
// 	public String makeRequest(URL url) throws IOException {
// 		return makeRequest(url, StandardCharsets.UTF_8);
// 	}
//     
//     /**
//      * Make HTTP GET request, assuming a specific charset used in the response
//      *
//      * @param url
// 	 * @param charset response charset
//      * @return String containing raw page or empty string
//      * @throws IOException 
//      */
//     public String makeRequest(URL url, Charset charset) throws IOException {
//         logger.info("Get request for page {}", url);
//         Request request = Request.Get(url.toString());
// 		// some servers return 503 if no accept header is present
// 		request.addHeader(HttpHeaders.ACCEPT, "*/*");
// 		request.connectTimeout(240 * 1000);
// 		request.socketTimeout(240 * 1000);
//         HttpResponse res = request.execute().returnResponse();
//         // Return empty if the HTTP returns something faulty
//         int status = res.getStatusLine().getStatusCode();
//         if (status != 200) {
//             logger.warn("HTTP code {} getting page {}", status, url);
//             return "";
//         }
// 
//         return EntityUtils.toString(res.getEntity(), charset);
//     }
//     
//     /**
//      * Make HTTP HEAD request
//      * 
//      * @param url
//      * @return
//      * @throws IOException 
//      */
//     public int makeHeadRequest(URL url) throws IOException {
//         logger.info("Head request for {}", url);
//         Request request = Request.Head(url.toString());
//         
//         return request.execute().returnResponse()
//                                 .getStatusLine().getStatusCode();
//     }
// }


// Path: tools/src/main/java/be/fedict/dcat/tools/LinkChecker.java
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.fedict.dcat.helpers.Fetcher;
import java.io.BufferedReader;
import java.io.BufferedWriter;

/*
 * Copyright (c) 2016, FPS BOSA DG DT
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice, this
 *   list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

package be.fedict.dcat.tools;






/**
 * Simple link checker.
 * 
 * @author Bart Hanssens <bart.hanssens@fedict.be>
 */
public class LinkChecker {
    private final static Logger logger = LoggerFactory.getLogger(LinkChecker.class);
    
    private final static String PROP_PREFIX = "be.fedict.dcat.tools.linkchecker";
    
    private final static Properties prop = new Properties();

    private final static Fetcher fetcher = new Fetcher();
