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:
Francesco Mangiacrapa 2016-06-24 13:26:58 +00:00
parent 3dfbc38af0
commit cc96a64745
7 changed files with 76 additions and 164 deletions

22
pom.xml
View File

@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>uri-resolver-manager</artifactId>
<version>1.1.1-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>uri-resolver-manager</name>
<description>The URI Resolver Manager</description>
@ -30,19 +30,6 @@
</developer>
</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>
<distroDirectory>${project.basedir}/distro</distroDirectory>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
@ -68,7 +55,7 @@
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<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>
</dependency>
<!-- END FWS -->
@ -119,16 +106,19 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>compile</scope>
<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>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
<scope>compile</scope>
</dependency>

View File

@ -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>

View File

@ -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>

View File

@ -1,3 +0,0 @@
File touchFile = new File( basedir, "target/touch.txt" );
assert touchFile.isFile()

View File

@ -30,13 +30,15 @@ import org.xml.sax.InputSource;
* May 4, 2015
*/
public class UriResolverMapReader {
/**
*
*
*/
public static final String URIRESOLVERMAP_SECONDARY_TYPE = "UriResolverMap";
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 String secondaryType;
private String scope;
@ -50,16 +52,16 @@ public class UriResolverMapReader {
* @param scope - the scope to be searched
* @throws Exception the exception
*/
public UriResolverMapReader(String scope) throws Exception {
public UriResolverMapReader(String scope) throws Exception {
this.scope = scope;
if(scope==null){
throw new Exception("Scope is null, set scope provider!");
}
this.resourceName = URI_RESOLVER_MAP_RESOURCE_NAME;
this.secondaryType = URIRESOLVERMAP_SECONDARY_TYPE;
readProfileFromInfrastrucure();
readProfileFromInfrastrucure();
}
@ -73,29 +75,38 @@ public class UriResolverMapReader {
private void readProfileFromInfrastrucure() throws Exception {
String queryString = getGcubeGenericQueryString(secondaryType, resourceName);
logger.info("Trying to fetch applicationProfile profile from the infrastructure for " + secondaryType + " scope: " + scope);
logger.info(queryString);
try {
logger.info("Getting Infrastructure Name...: ");
String infra = ScopeUtil.getInfrastructureNameFromScope(this.scope);
logger.info("Infrastructure Name returned: "+infra);
ScopeProvider.instance.set(infra);
logger.info("scope provider set instance: "+infra);
Query q = new QueryBox(queryString);
DiscoveryClient<String> client = client();
List<String> appUriResolverMap = client.submit(q);
logger.info("new query box works");
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");
else {
}else {
logger.info("Building new DocumentBuilder..");
String elem = appUriResolverMap.get(0);
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node node = docBuilder.parse(new InputSource(new StringReader(elem))).getDocumentElement();
logger.info("Building new XPathHelper..");
XPathHelper helper = new XPathHelper(node);
List<String> currValue = null;
logger.info("Evaluating XPath..");
currValue = helper.evaluate("/Resource/Profile/Body/access_point/application_type/text()");
if (currValue != null && currValue.size() > 0) {
logger.info("Application Types are: "+currValue.size());
@ -120,10 +131,13 @@ public class UriResolverMapReader {
} catch (Exception 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");
}finally{
ScopeProvider.instance.reset();
}
}
/**
* Gets the gcube generic query string.
*
@ -132,14 +146,14 @@ public class UriResolverMapReader {
* @return the gcube generic query string
*/
public static String getGcubeGenericQueryString(String secondaryType, String name){
return "for $profile in collection('/db/Profiles/GenericResource')//Resource " +
"where $profile/Profile/SecondaryType/string() eq '"+secondaryType+"' and $profile/Profile/Name/string() " +
" eq '" + name + "'" +
"return $profile";
}
/**
* Gets the application types.
*
@ -176,7 +190,7 @@ public class UriResolverMapReader {
public String getResourceName() {
return resourceName;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@ -194,8 +208,8 @@ public class UriResolverMapReader {
builder.append("]");
return builder.toString();
}
// /**
// * The main method.
// *

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package org.gcube.portlets.user.uriresolvermanager.util;
@ -15,31 +15,31 @@ public class ScopeUtil {
private static final String SCOPE_SEPARATOR = "/";
public static final Logger logger = LoggerFactory.getLogger(ScopeUtil.class);
public static String getInfrastructureNameFromScope(String scope) throws Exception{
if(scope==null || scope.isEmpty()){
throw new Exception("Scope is null or empty");
}
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;
logger.warn("Tentative as scope: "+scope);
}
String[] splitScope = scope.split(SCOPE_SEPARATOR);
String rootScope = SCOPE_SEPARATOR + splitScope[1];
if(rootScope.length()<2){
throw new Exception("Infrastructure name not found in "+scope);
}
logger.trace("scope is "+ scope +" infra: "+rootScope);
return rootScope;
}
}

View File

@ -8,7 +8,7 @@ import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapExcept
import org.junit.Test;
/**
*
*
*/
/**
@ -17,12 +17,12 @@ import org.junit.Test;
*
*/
public class UriResolverManagerTest {
@Test
public void testUriResolverManger(){
UriResolverManager manager;
try {
ScopeProvider.instance.set("/gcube/devsec/devVRE");
ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab");
manager = new UriResolverManager();
System.out.println(manager.getCapabilities());
System.out.println(manager.getApplicationTypes());
@ -33,12 +33,12 @@ public class UriResolverManagerTest {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
// @Test
public void testGIS() {
try {
ScopeProvider.instance.set("/gcube/devsec/devVRE");
UriResolverManager resolver = new UriResolverManager("GIS");
@ -55,17 +55,17 @@ public class UriResolverManagerTest {
e.printStackTrace();
}
}
// @Test
public void testSMP() {
try {
ScopeProvider.instance.set("/gcube/devsec/devVRE");
UriResolverManager resolver = new UriResolverManager("SMP");
Map<String, String> params = new HashMap<String, String>();
params.put("smp-uri","smp://Wikipedia_logo_silver.png?5ezvFfBOLqaqBlwCEtAvz4ch5BUu1ag3yftpCvV gayz9bAtSsnO1/sX6pemTKbDe0qbchLexXeWgGcJlskYE8td9QSDXSZj5VSl9kdN9SN0/LRYaWUZuP4Q1J7lEiwkU4GKPsiD6PDRVcT4QAqTEy5hSIbr6o4Y");
params.put("fileName", "wikipediaLogo");
params.put("contentType", "");
params.put("contentType", "");
String shortLink = resolver.getLink(params, true); //true, link is shorted otherwise none
System.out.println(shortLink);
} catch (UriResolverMapException e) {
@ -76,12 +76,12 @@ public class UriResolverManagerTest {
e.printStackTrace();
}
}
/**
* Thread safe
*/
@Test
// @Test
public void testSMPID(){
try {
@ -91,7 +91,7 @@ public class UriResolverManagerTest {
Map<String, String> params = new HashMap<String, String>();
params.put("smp-id","553f9265e4b0567b75021fce");
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
System.out.println(shortLink);
} catch (UriResolverMapException e) {
@ -102,14 +102,14 @@ public class UriResolverManagerTest {
e.printStackTrace();
}
}
/**
* Thread safe
*/
// @Test
public void test2(){
//create thread to print counter value
Thread t = new Thread(new Runnable() {
@ -117,17 +117,17 @@ public class UriResolverManagerTest {
public void run() {
while (true) {
try {
ScopeProvider.instance.set("/gcube/devsec/devVRE");
UriResolverManager resolver;
resolver = new UriResolverManager("GIS");
Map<String, String> params = new HashMap<String, String>();
params.put("gis-UUID", "eb1a1b63-f324-47ee-9522-b8f5803e19ec");
params.put("scope", "/gcube/devsec/devVRE");
String shortLink = resolver.getLink(params, true);
System.out.println(shortLink); //true, link is shorted otherwise none
System.out.println("Thread "+Thread.currentThread().getId() +" reading counter is: " + resolver.countReaders());
Thread.sleep(1000);
} catch (InterruptedException ex) {
@ -141,11 +141,11 @@ public class UriResolverManagerTest {
}
}
}
});
t.start();
try {
Thread.sleep(500000);
} catch (InterruptedException e) {
@ -153,7 +153,7 @@ public class UriResolverManagerTest {
e.printStackTrace();
}
}
}