removed maven-portal-bom
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/uri-resolver-manager@129428 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3dfbc38af0
commit
cc96a64745
22
pom.xml
22
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>uri-resolver-manager</artifactId>
|
<artifactId>uri-resolver-manager</artifactId>
|
||||||
<version>1.1.1-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>uri-resolver-manager</name>
|
<name>uri-resolver-manager</name>
|
||||||
<description>The URI Resolver Manager</description>
|
<description>The URI Resolver Manager</description>
|
||||||
|
@ -30,19 +30,6 @@
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.distribution</groupId>
|
|
||||||
<artifactId>maven-portal-bom</artifactId>
|
|
||||||
<version>LATEST</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||||
|
@ -68,7 +55,7 @@
|
||||||
<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> -->
|
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- END FWS -->
|
<!-- END FWS -->
|
||||||
|
@ -119,16 +106,19 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<scope>compile</scope>
|
<version>1.2.16</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<version>1.6.4</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</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>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<settings>
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>it-repo</id>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>true</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>local.central</id>
|
|
||||||
<url>@localRepositoryUrl@</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>local.central</id>
|
|
||||||
<url>@localRepositoryUrl@</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
</settings>
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>org.gcube.portlets.user.it</groupId>
|
|
||||||
<artifactId>simple-it</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<description>A simple IT verifying the basic use case.</description>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>@project.groupId@</groupId>
|
|
||||||
<artifactId>@project.artifactId@</artifactId>
|
|
||||||
<version>@project.version@</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>touch</id>
|
|
||||||
<phase>validate</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>touch</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
|
@ -1,3 +0,0 @@
|
||||||
File touchFile = new File( basedir, "target/touch.txt" );
|
|
||||||
|
|
||||||
assert touchFile.isFile()
|
|
|
@ -30,13 +30,15 @@ import org.xml.sax.InputSource;
|
||||||
* May 4, 2015
|
* May 4, 2015
|
||||||
*/
|
*/
|
||||||
public class UriResolverMapReader {
|
public class UriResolverMapReader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static final String URIRESOLVERMAP_SECONDARY_TYPE = "UriResolverMap";
|
public static final String URIRESOLVERMAP_SECONDARY_TYPE = "UriResolverMap";
|
||||||
public static final String URI_RESOLVER_MAP_RESOURCE_NAME = "Uri-Resolver-Map";
|
public static final String URI_RESOLVER_MAP_RESOURCE_NAME = "Uri-Resolver-Map";
|
||||||
|
|
||||||
|
// private Logger logger = LoggerFactory.getLogger(UriResolverMapReader.class);
|
||||||
|
//TODO TEMP SOLUTION IN ORDER TO PRINT USING ALSO LOG4J INTO GEOEXPLORER PORTLET
|
||||||
private Logger logger = LoggerFactory.getLogger(UriResolverMapReader.class);
|
private Logger logger = LoggerFactory.getLogger(UriResolverMapReader.class);
|
||||||
private String secondaryType;
|
private String secondaryType;
|
||||||
private String scope;
|
private String scope;
|
||||||
|
@ -50,16 +52,16 @@ public class UriResolverMapReader {
|
||||||
* @param scope - the scope to be searched
|
* @param scope - the scope to be searched
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public UriResolverMapReader(String scope) throws Exception {
|
public UriResolverMapReader(String scope) throws Exception {
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
|
|
||||||
if(scope==null){
|
if(scope==null){
|
||||||
throw new Exception("Scope is null, set scope provider!");
|
throw new Exception("Scope is null, set scope provider!");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resourceName = URI_RESOLVER_MAP_RESOURCE_NAME;
|
this.resourceName = URI_RESOLVER_MAP_RESOURCE_NAME;
|
||||||
this.secondaryType = URIRESOLVERMAP_SECONDARY_TYPE;
|
this.secondaryType = URIRESOLVERMAP_SECONDARY_TYPE;
|
||||||
readProfileFromInfrastrucure();
|
readProfileFromInfrastrucure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,29 +75,38 @@ public class UriResolverMapReader {
|
||||||
private void readProfileFromInfrastrucure() throws Exception {
|
private void readProfileFromInfrastrucure() throws Exception {
|
||||||
|
|
||||||
String queryString = getGcubeGenericQueryString(secondaryType, resourceName);
|
String queryString = getGcubeGenericQueryString(secondaryType, resourceName);
|
||||||
|
|
||||||
logger.info("Trying to fetch applicationProfile profile from the infrastructure for " + secondaryType + " scope: " + scope);
|
logger.info("Trying to fetch applicationProfile profile from the infrastructure for " + secondaryType + " scope: " + scope);
|
||||||
logger.info(queryString);
|
logger.info(queryString);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
logger.info("Getting Infrastructure Name...: ");
|
||||||
String infra = ScopeUtil.getInfrastructureNameFromScope(this.scope);
|
String infra = ScopeUtil.getInfrastructureNameFromScope(this.scope);
|
||||||
|
logger.info("Infrastructure Name returned: "+infra);
|
||||||
|
|
||||||
ScopeProvider.instance.set(infra);
|
ScopeProvider.instance.set(infra);
|
||||||
logger.info("scope provider set instance: "+infra);
|
logger.info("scope provider set instance: "+infra);
|
||||||
|
|
||||||
Query q = new QueryBox(queryString);
|
Query q = new QueryBox(queryString);
|
||||||
|
logger.info("new query box works");
|
||||||
DiscoveryClient<String> client = client();
|
|
||||||
List<String> appUriResolverMap = client.submit(q);
|
|
||||||
|
|
||||||
if (appUriResolverMap == null || appUriResolverMap.size() == 0)
|
DiscoveryClient<String> client = client();
|
||||||
|
logger.info("submitting query is: "+queryString);
|
||||||
|
List<String> appUriResolverMap = client.submit(q);
|
||||||
|
logger.info("submit query works");
|
||||||
|
|
||||||
|
if (appUriResolverMap == null || appUriResolverMap.size() == 0){
|
||||||
|
logger.error("Your applicationProfile with secondaryType: "+secondaryType+" and name "+resourceName+" is not registered in the infrastructure, scope: "+ScopeProvider.instance.get());
|
||||||
throw new ApplicationProfileException("Your applicationProfile with secondaryType: "+secondaryType+" and name "+resourceName+" is not registered in the infrastructure");
|
throw new ApplicationProfileException("Your applicationProfile with secondaryType: "+secondaryType+" and name "+resourceName+" is not registered in the infrastructure");
|
||||||
else {
|
}else {
|
||||||
|
logger.info("Building new DocumentBuilder..");
|
||||||
String elem = appUriResolverMap.get(0);
|
String elem = appUriResolverMap.get(0);
|
||||||
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
Node node = docBuilder.parse(new InputSource(new StringReader(elem))).getDocumentElement();
|
Node node = docBuilder.parse(new InputSource(new StringReader(elem))).getDocumentElement();
|
||||||
|
logger.info("Building new XPathHelper..");
|
||||||
XPathHelper helper = new XPathHelper(node);
|
XPathHelper helper = new XPathHelper(node);
|
||||||
List<String> currValue = null;
|
List<String> currValue = null;
|
||||||
|
logger.info("Evaluating XPath..");
|
||||||
currValue = helper.evaluate("/Resource/Profile/Body/access_point/application_type/text()");
|
currValue = helper.evaluate("/Resource/Profile/Body/access_point/application_type/text()");
|
||||||
if (currValue != null && currValue.size() > 0) {
|
if (currValue != null && currValue.size() > 0) {
|
||||||
logger.info("Application Types are: "+currValue.size());
|
logger.info("Application Types are: "+currValue.size());
|
||||||
|
@ -120,10 +131,13 @@ public class UriResolverMapReader {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error while trying to fetch applicationProfile with secondaryType: "+secondaryType+" and name "+resourceName+" from the infrastructure", e);
|
logger.error("Error while trying to fetch applicationProfile with secondaryType: "+secondaryType+" and name "+resourceName+" from the infrastructure", e);
|
||||||
throw new ApplicationProfileException("Error while trying to fetch applicationProfile with secondaryType: "+secondaryType+" and name "+resourceName+" from the infrastructure");
|
throw new ApplicationProfileException("Error while trying to fetch applicationProfile with secondaryType: "+secondaryType+" and name "+resourceName+" from the infrastructure");
|
||||||
|
}finally{
|
||||||
|
|
||||||
|
ScopeProvider.instance.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the gcube generic query string.
|
* Gets the gcube generic query string.
|
||||||
*
|
*
|
||||||
|
@ -132,14 +146,14 @@ public class UriResolverMapReader {
|
||||||
* @return the gcube generic query string
|
* @return the gcube generic query string
|
||||||
*/
|
*/
|
||||||
public static String getGcubeGenericQueryString(String secondaryType, String name){
|
public static String getGcubeGenericQueryString(String secondaryType, String name){
|
||||||
|
|
||||||
return "for $profile in collection('/db/Profiles/GenericResource')//Resource " +
|
return "for $profile in collection('/db/Profiles/GenericResource')//Resource " +
|
||||||
"where $profile/Profile/SecondaryType/string() eq '"+secondaryType+"' and $profile/Profile/Name/string() " +
|
"where $profile/Profile/SecondaryType/string() eq '"+secondaryType+"' and $profile/Profile/Name/string() " +
|
||||||
" eq '" + name + "'" +
|
" eq '" + name + "'" +
|
||||||
"return $profile";
|
"return $profile";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the application types.
|
* Gets the application types.
|
||||||
*
|
*
|
||||||
|
@ -176,7 +190,7 @@ public class UriResolverMapReader {
|
||||||
public String getResourceName() {
|
public String getResourceName() {
|
||||||
return resourceName;
|
return resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
|
@ -194,8 +208,8 @@ public class UriResolverMapReader {
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * The main method.
|
// * The main method.
|
||||||
// *
|
// *
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.uriresolvermanager.util;
|
package org.gcube.portlets.user.uriresolvermanager.util;
|
||||||
|
|
||||||
|
@ -15,31 +15,31 @@ public class ScopeUtil {
|
||||||
|
|
||||||
private static final String SCOPE_SEPARATOR = "/";
|
private static final String SCOPE_SEPARATOR = "/";
|
||||||
public static final Logger logger = LoggerFactory.getLogger(ScopeUtil.class);
|
public static final Logger logger = LoggerFactory.getLogger(ScopeUtil.class);
|
||||||
|
|
||||||
|
|
||||||
public static String getInfrastructureNameFromScope(String scope) throws Exception{
|
public static String getInfrastructureNameFromScope(String scope) throws Exception{
|
||||||
|
|
||||||
if(scope==null || scope.isEmpty()){
|
if(scope==null || scope.isEmpty()){
|
||||||
throw new Exception("Scope is null or empty");
|
throw new Exception("Scope is null or empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!scope.startsWith(SCOPE_SEPARATOR)){
|
if(!scope.startsWith(SCOPE_SEPARATOR)){
|
||||||
logger.warn("Input scope: "+scope+" not have / is a really scope?");
|
logger.warn("Input scope: "+scope+" has not / is a really scope?");
|
||||||
scope = SCOPE_SEPARATOR+scope;
|
scope = SCOPE_SEPARATOR+scope;
|
||||||
logger.warn("Tentative as scope: "+scope);
|
logger.warn("Tentative as scope: "+scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] splitScope = scope.split(SCOPE_SEPARATOR);
|
String[] splitScope = scope.split(SCOPE_SEPARATOR);
|
||||||
|
|
||||||
String rootScope = SCOPE_SEPARATOR + splitScope[1];
|
String rootScope = SCOPE_SEPARATOR + splitScope[1];
|
||||||
|
|
||||||
if(rootScope.length()<2){
|
if(rootScope.length()<2){
|
||||||
throw new Exception("Infrastructure name not found in "+scope);
|
throw new Exception("Infrastructure name not found in "+scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace("scope is "+ scope +" infra: "+rootScope);
|
logger.trace("scope is "+ scope +" infra: "+rootScope);
|
||||||
|
|
||||||
return rootScope;
|
return rootScope;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapExcept
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,12 +17,12 @@ import org.junit.Test;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class UriResolverManagerTest {
|
public class UriResolverManagerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUriResolverManger(){
|
public void testUriResolverManger(){
|
||||||
UriResolverManager manager;
|
UriResolverManager manager;
|
||||||
try {
|
try {
|
||||||
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab");
|
||||||
manager = new UriResolverManager();
|
manager = new UriResolverManager();
|
||||||
System.out.println(manager.getCapabilities());
|
System.out.println(manager.getCapabilities());
|
||||||
System.out.println(manager.getApplicationTypes());
|
System.out.println(manager.getApplicationTypes());
|
||||||
|
@ -33,12 +33,12 @@ public class UriResolverManagerTest {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void testGIS() {
|
public void testGIS() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
||||||
UriResolverManager resolver = new UriResolverManager("GIS");
|
UriResolverManager resolver = new UriResolverManager("GIS");
|
||||||
|
@ -55,17 +55,17 @@ public class UriResolverManagerTest {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testSMP() {
|
public void testSMP() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
||||||
UriResolverManager resolver = new UriResolverManager("SMP");
|
UriResolverManager resolver = new UriResolverManager("SMP");
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("smp-uri","smp://Wikipedia_logo_silver.png?5ezvFfBOLqaqBlwCEtAvz4ch5BUu1ag3yftpCvV gayz9bAtSsnO1/sX6pemTKbDe0qbchLexXeWgGcJlskYE8td9QSDXSZj5VSl9kdN9SN0/LRYaWUZuP4Q1J7lEiwkU4GKPsiD6PDRVcT4QAqTEy5hSIbr6o4Y");
|
params.put("smp-uri","smp://Wikipedia_logo_silver.png?5ezvFfBOLqaqBlwCEtAvz4ch5BUu1ag3yftpCvV gayz9bAtSsnO1/sX6pemTKbDe0qbchLexXeWgGcJlskYE8td9QSDXSZj5VSl9kdN9SN0/LRYaWUZuP4Q1J7lEiwkU4GKPsiD6PDRVcT4QAqTEy5hSIbr6o4Y");
|
||||||
params.put("fileName", "wikipediaLogo");
|
params.put("fileName", "wikipediaLogo");
|
||||||
params.put("contentType", "");
|
params.put("contentType", "");
|
||||||
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) {
|
||||||
|
@ -76,12 +76,12 @@ public class UriResolverManagerTest {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thread safe
|
* Thread safe
|
||||||
*/
|
*/
|
||||||
@Test
|
// @Test
|
||||||
public void testSMPID(){
|
public void testSMPID(){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -91,7 +91,7 @@ public class UriResolverManagerTest {
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("smp-id","553f9265e4b0567b75021fce");
|
params.put("smp-id","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) {
|
||||||
|
@ -102,14 +102,14 @@ public class UriResolverManagerTest {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thread safe
|
* Thread safe
|
||||||
*/
|
*/
|
||||||
// @Test
|
// @Test
|
||||||
public void test2(){
|
public void test2(){
|
||||||
|
|
||||||
|
|
||||||
//create thread to print counter value
|
//create thread to print counter value
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@ -117,17 +117,17 @@ public class UriResolverManagerTest {
|
||||||
public void run() {
|
public void run() {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
||||||
UriResolverManager resolver;
|
UriResolverManager resolver;
|
||||||
resolver = new UriResolverManager("GIS");
|
resolver = new UriResolverManager("GIS");
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("gis-UUID", "eb1a1b63-f324-47ee-9522-b8f5803e19ec");
|
params.put("gis-UUID", "eb1a1b63-f324-47ee-9522-b8f5803e19ec");
|
||||||
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
|
||||||
|
|
||||||
System.out.println("Thread "+Thread.currentThread().getId() +" reading counter is: " + resolver.countReaders());
|
System.out.println("Thread "+Thread.currentThread().getId() +" reading counter is: " + resolver.countReaders());
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
|
@ -141,11 +141,11 @@ public class UriResolverManagerTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
t.start();
|
t.start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500000);
|
Thread.sleep(500000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -153,7 +153,7 @@ public class UriResolverManagerTest {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue