Added gcube-bom
Removed slf4j-log4j git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/uri-resolver-manager@146952 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5cb51f91ba
commit
d176690d36
29
pom.xml
29
pom.xml
|
@ -48,6 +48,18 @@
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.distribution</groupId>
|
||||||
|
<artifactId>gcube-bom</artifactId>
|
||||||
|
<version>LATEST</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
@ -55,7 +67,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.resources.discovery</groupId>
|
<groupId>org.gcube.resources.discovery</groupId>
|
||||||
<artifactId>ic-client</artifactId>
|
<artifactId>ic-client</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- END FWS -->
|
<!-- END FWS -->
|
||||||
|
@ -77,7 +88,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.core</groupId>
|
<groupId>org.gcube.core</groupId>
|
||||||
<artifactId>common-encryption</artifactId>
|
<artifactId>common-encryption</artifactId>
|
||||||
<version>[1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -103,23 +113,10 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- LOGGER -->
|
<!-- LOGGER -->
|
||||||
<dependency>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
<version>1.2.16</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
|
||||||
<version>1.6.4</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>1.6.4</version>
|
<scope>provided</scope>
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JUNIT -->
|
<!-- JUNIT -->
|
||||||
|
|
|
@ -7,7 +7,8 @@ import java.net.SocketTimeoutException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,41 +19,41 @@ import org.apache.log4j.Logger;
|
||||||
public class HttpRequestUtil {
|
public class HttpRequestUtil {
|
||||||
|
|
||||||
private static final int CONNECTION_TIMEOUT = 1000;
|
private static final int CONNECTION_TIMEOUT = 1000;
|
||||||
public static Logger logger = Logger.getLogger(HttpRequestUtil.class);
|
public static final Logger logger = LoggerFactory.getLogger(HttpRequestUtil.class);
|
||||||
|
|
||||||
public static boolean urlExists(String urlConn) throws Exception {
|
public static boolean urlExists(String urlConn) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
if(urlConn==null || urlConn.isEmpty())
|
if(urlConn==null || urlConn.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
URL url;
|
URL url;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
url = new URL(urlConn);
|
url = new URL(urlConn);
|
||||||
|
|
||||||
URLConnection connection = url.openConnection();
|
URLConnection connection = url.openConnection();
|
||||||
connection.setConnectTimeout(CONNECTION_TIMEOUT);
|
connection.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||||
connection.setReadTimeout(CONNECTION_TIMEOUT+CONNECTION_TIMEOUT);
|
connection.setReadTimeout(CONNECTION_TIMEOUT+CONNECTION_TIMEOUT);
|
||||||
|
|
||||||
logger.trace("open connection on: " + url);
|
logger.trace("open connection on: " + url);
|
||||||
|
|
||||||
// Cast to a HttpURLConnection
|
// Cast to a HttpURLConnection
|
||||||
if (connection instanceof HttpURLConnection) {
|
if (connection instanceof HttpURLConnection) {
|
||||||
HttpURLConnection httpConnection = (HttpURLConnection) connection;
|
HttpURLConnection httpConnection = (HttpURLConnection) connection;
|
||||||
|
|
||||||
httpConnection.setRequestMethod("GET");
|
httpConnection.setRequestMethod("GET");
|
||||||
|
|
||||||
int code = httpConnection.getResponseCode();
|
int code = httpConnection.getResponseCode();
|
||||||
|
|
||||||
httpConnection.disconnect();
|
httpConnection.disconnect();
|
||||||
|
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
logger.trace("status code is "+code+" - on url connection: "+urlConn);
|
logger.trace("status code is "+code+" - on url connection: "+urlConn);
|
||||||
return true;
|
return true;
|
||||||
}else
|
}else
|
||||||
logger.warn("status code is "+code+" - on url connection: "+urlConn);
|
logger.warn("status code is "+code+" - on url connection: "+urlConn);
|
||||||
|
|
||||||
// logger.trace("result: "+result);
|
// logger.trace("result: "+result);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,9 +76,9 @@ public class HttpRequestUtil {
|
||||||
throw new Exception("Error Exception");
|
throw new Exception("Error Exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println(HttpRequestUtil.urlExists("http://geoserver2.d4science.research-infrastructures.eu/geoserver/wms"));
|
System.out.println(HttpRequestUtil.urlExists("http://geoserver2.d4science.research-infrastructures.eu/geoserver/wms"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
|
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
|
||||||
import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
|
import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
|
||||||
|
@ -24,11 +21,11 @@ public class UriResolverManagerMain {
|
||||||
System.out.println(resolver.getApplicationTypes());
|
System.out.println(resolver.getApplicationTypes());
|
||||||
// System.out.println(resolver.discoveryServiceParameters(resolver.getResolver("SMP-ID")));
|
// System.out.println(resolver.discoveryServiceParameters(resolver.getResolver("SMP-ID")));
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
// Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("gis-UUID", "5ac49f44-999f-4efe-a32b-af71da2b39ac");
|
// params.put("gis-UUID", "5ac49f44-999f-4efe-a32b-af71da2b39ac");
|
||||||
params.put("scope", "/gcube/devsec/devVRE");
|
// params.put("scope", "/gcube/devsec/devVRE");
|
||||||
String shortLink = resolver.getLink(params, true);
|
// String shortLink = resolver.getLink(params, true);
|
||||||
System.out.println(shortLink); //true, link is shorted otherwise none
|
// System.out.println(shortLink); //true, link is shorted otherwise none
|
||||||
} catch (UriResolverMapException e) {
|
} catch (UriResolverMapException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
|
|
@ -89,9 +89,9 @@ public class UriResolverManagerTest {
|
||||||
UriResolverManager resolver;
|
UriResolverManager resolver;
|
||||||
resolver = new UriResolverManager("SMP-ID");
|
resolver = new UriResolverManager("SMP-ID");
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("smp-id","553f9265e4b0567b75021fce");
|
params.put("geo-exp","553f9265e4b0567b75021fce");
|
||||||
params.put("fileName", "dog");
|
// params.put("fileName", "dog");
|
||||||
params.put("contentType", "image/jpg");
|
// params.put("contentType", "image/jpg");
|
||||||
String shortLink = resolver.getLink(params, true); //true, link is shorted otherwise none
|
String shortLink = resolver.getLink(params, true); //true, link is shorted otherwise none
|
||||||
System.out.println(shortLink);
|
System.out.println(shortLink);
|
||||||
} catch (UriResolverMapException e) {
|
} catch (UriResolverMapException e) {
|
||||||
|
|
Loading…
Reference in New Issue