#22757 moved to SHUB 2.0.0-SNAPSHOT
This commit is contained in:
parent
51c40079f7
commit
d864d43d15
|
@ -4,6 +4,12 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v2-7.0-SNAPSHOT] - 2022-01-31
|
||||
|
||||
**New**
|
||||
|
||||
- [#22757] moved to storagehub-client-library 2.0.0[-SNAPSHOT]
|
||||
|
||||
## [v2-6-1] - 2022-01-17
|
||||
|
||||
**New features**
|
||||
|
|
12
pom.xml
12
pom.xml
|
@ -9,7 +9,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.data.transfer</groupId>
|
||||
<artifactId>uri-resolver</artifactId>
|
||||
<version>2.6.1</version>
|
||||
<version>2.7.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<description>The URI Resolver is an HTTP URI resolver implemented as an REST service which gives access trough HTTP to different gcube Resolvers and gCube Applications.</description>
|
||||
|
||||
|
@ -123,7 +123,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -200,6 +200,12 @@
|
|||
<!-- <version>3.20-geoapi-3.0</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.geotoolkit</groupId>
|
||||
<artifactId>geotk-xml-base</artifactId>
|
||||
<version>3.20-geoapi-3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
|
@ -298,4 +304,4 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
package org.gcube.datatransfer.test;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.common.encryption.StringEncrypter;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datatransfer.resolver.services.exceptions.NotFoundException;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
|
||||
/**
|
||||
* The Class ServiceEndpointReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jan 27, 2022
|
||||
*/
|
||||
public class ServiceEndpointReader {
|
||||
|
||||
private static final String RESOURCE_NAME = "DEV Geoserver";
|
||||
private static final String CATEGORY_NAME = "Gis";
|
||||
private static final String SCOPE = "/gcube/devsec/devVRE";
|
||||
|
||||
public static Logger LOG = Logger.getLogger(ServiceEndpointReader.class);
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
readServiceEndpoint(SCOPE);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Read service endpoint.
|
||||
*
|
||||
* @param req the req
|
||||
* @param scope the scope
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void readServiceEndpoint(String scope) throws Exception{
|
||||
|
||||
String callerScope = null;
|
||||
try{
|
||||
callerScope = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(scope);
|
||||
LOG.info("Searching SE "+RESOURCE_NAME +" configurations in the scope: "+ScopeProvider.instance.get());
|
||||
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
query.addCondition("$resource/Profile/Name/text() eq '"+ RESOURCE_NAME +"'");
|
||||
query.addCondition("$resource/Profile/Category/text() eq '"+ CATEGORY_NAME +"'");
|
||||
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
List<ServiceEndpoint> toReturn = client.submit(query);
|
||||
|
||||
LOG.info("The query returned "+toReturn.size()+ " ServiceEndpoint/s");
|
||||
|
||||
if(toReturn.size()==0){
|
||||
String errorMessage = String.format("Missing the RR with Name '%s' and Category '%s' in the scope '%s'. Please contact the support.",RESOURCE_NAME,CATEGORY_NAME,ScopeProvider.instance.get());
|
||||
LOG.error(errorMessage);
|
||||
throw new Exception(errorMessage);
|
||||
|
||||
}
|
||||
|
||||
String accessPointUsername = null;
|
||||
String accessPointPwd = null;
|
||||
|
||||
ServiceEndpoint se = toReturn.get(0);
|
||||
Collection<AccessPoint> theAccessPoints = se.profile().accessPoints().asCollection();
|
||||
for (AccessPoint accessPoint : theAccessPoints) {
|
||||
accessPointUsername = accessPoint.username();
|
||||
System.out.println("AccessPoint username: "+accessPointPwd);
|
||||
accessPointPwd = accessPoint.password();
|
||||
if(accessPointUsername!=null && accessPointPwd!=null) {
|
||||
LOG.info("returning the access point with name: "+accessPoint.name());
|
||||
if (accessPointPwd != null) {
|
||||
accessPointPwd = StringEncrypter.getEncrypter().decrypt(accessPointPwd);
|
||||
LOG.info("Decrypted pwd registered into Access Point '" + accessPoint.name() + "' is: "
|
||||
+ accessPointPwd.substring(0,accessPointPwd.length()/2)+"...");
|
||||
|
||||
System.out.println("AccessPoint pwd is: "+accessPointPwd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}catch(Exception e){
|
||||
|
||||
if(e instanceof NotFoundException)
|
||||
throw e;
|
||||
|
||||
String errorMessage = "Error occurred on reading the "+RESOURCE_NAME+" SE registered in the scope: "+ScopeProvider.instance.get();
|
||||
LOG.error(errorMessage, e);
|
||||
throw new Exception(errorMessage);
|
||||
|
||||
}finally{
|
||||
if(callerScope!=null){
|
||||
LOG.info("Setting to the callerScope scope: "+callerScope);
|
||||
ScopeProvider.instance.set(callerScope);
|
||||
}else{
|
||||
LOG.info("Reset scope");
|
||||
ScopeProvider.instance.reset();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue