test of file existence performed over http only
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@132806 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
55311493ba
commit
81cd4aa4b3
|
@ -13,7 +13,9 @@ import org.slf4j.LoggerFactory;
|
|||
public class UtilMethods {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UtilMethods.class);
|
||||
|
||||
private final static String HTTPS = "https";
|
||||
private final static String HTTP = "http";
|
||||
|
||||
/**
|
||||
* Ckan username has _ instead of . (that is, costantino.perciante -> costantino_perciante)
|
||||
* @param owner
|
||||
|
@ -64,8 +66,10 @@ public class UtilMethods {
|
|||
return false;
|
||||
|
||||
try {
|
||||
// replace https
|
||||
String urlToTest = URLName.replace(HTTPS, HTTP);
|
||||
HttpURLConnection.setFollowRedirects(true);
|
||||
HttpURLConnection con = (HttpURLConnection) new URL(URLName).openConnection();
|
||||
HttpURLConnection con = (HttpURLConnection) new URL(urlToTest).openConnection();
|
||||
con.setRequestMethod("HEAD");
|
||||
logger.debug("Return code is " + con.getResponseCode());
|
||||
return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
|
||||
|
|
Loading…
Reference in New Issue