git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/sdi-library@150793 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0c0a9586db
commit
9bee40aaaf
|
@ -14,7 +14,7 @@ import org.gcube.spatial.data.sdi.model.ServiceConstants;
|
||||||
import org.gcube.spatial.data.sdi.proxies.DefaultMetadata;
|
import org.gcube.spatial.data.sdi.proxies.DefaultMetadata;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
public class MetadataPlugin extends AbstractPlugin<WebTarget, Metadata>{
|
public class MetadataPlugin extends SDIAbstractPlugin<WebTarget, Metadata>{
|
||||||
|
|
||||||
public MetadataPlugin() {
|
public MetadataPlugin() {
|
||||||
super("sdi-service/gcube/service");
|
super("sdi-service/gcube/service");
|
||||||
|
|
|
@ -8,13 +8,13 @@ import org.gcube.common.clients.Plugin;
|
||||||
import org.gcube.spatial.data.sdi.interfaces.Metadata;
|
import org.gcube.spatial.data.sdi.interfaces.Metadata;
|
||||||
import org.gcube.spatial.data.sdi.model.ServiceConstants;
|
import org.gcube.spatial.data.sdi.model.ServiceConstants;
|
||||||
|
|
||||||
public abstract class AbstractPlugin<S, P> implements Plugin<S, P>{
|
public abstract class SDIAbstractPlugin<S, P> implements Plugin<S, P>{
|
||||||
|
|
||||||
|
|
||||||
private static final MetadataPlugin metadata_plugin=new MetadataPlugin();
|
private static final MetadataPlugin metadata_plugin=new MetadataPlugin();
|
||||||
|
|
||||||
|
|
||||||
public static ProxyBuilder<Metadata> manager() {
|
public static ProxyBuilder<Metadata> metadata() {
|
||||||
return new ProxyBuilderImpl<WebTarget,Metadata>(metadata_plugin);
|
return new ProxyBuilderImpl<WebTarget,Metadata>(metadata_plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public abstract class AbstractPlugin<S, P> implements Plugin<S, P>{
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|
||||||
public AbstractPlugin(String name) {
|
public SDIAbstractPlugin(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.gcube.spatial.data.sdi;
|
||||||
|
|
||||||
|
import org.gcube.spatial.data.sdi.interfaces.*;
|
||||||
|
import org.gcube.spatial.data.sdi.plugins.SDIAbstractPlugin;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class MetadataTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailableTemplatesTest(){
|
||||||
|
TokenSetter.set("/gcube/devsec/devVRE");
|
||||||
|
Metadata meta=SDIAbstractPlugin.metadata().build();
|
||||||
|
System.out.println(meta.getAvailableTemplates());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package org.gcube.spatial.data.sdi;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class TokenSetter {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static Properties props=new Properties();
|
||||||
|
|
||||||
|
static{
|
||||||
|
try {
|
||||||
|
props.load(TokenSetter.class.getResourceAsStream("/tokens.properties"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("YOU NEED TO SET TOKEN FILE IN CONFIGURATION");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void set(String scope){
|
||||||
|
try{
|
||||||
|
if(!props.containsKey(scope)) throw new RuntimeException("No token found for scope : "+scope);
|
||||||
|
SecurityTokenProvider.instance.set(props.getProperty(scope));
|
||||||
|
}catch(Throwable e){
|
||||||
|
log.warn("Unable to set token for scope "+scope,e);
|
||||||
|
}
|
||||||
|
ScopeProvider.instance.set(scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue