forked from gCubeSystem/registry-publisher
Compare commits
2 Commits
rest-colle
...
master
Author | SHA1 | Date |
---|---|---|
Roberto Cirillo | 69ca8d374d | |
Roberto Cirillo | 8c5b74c444 |
15
.classpath
15
.classpath
|
@ -6,16 +6,19 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
@ -25,12 +28,6 @@
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/ic-client"/>
|
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/common-scope-maps"/>
|
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
org.eclipse.jdt.core.compiler.release=disabled
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.resources</groupId>
|
<groupId>org.gcube.resources</groupId>
|
||||||
<artifactId>registry-publisher</artifactId>
|
<artifactId>registry-publisher</artifactId>
|
||||||
<version>1.3.1-SNAPSHOT</version>
|
<version>1.3.0</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,6 @@ public class RegistryPublisherImpl implements RegistryPublisher {
|
||||||
log.debug("id generated: "+id);
|
log.debug("id generated: "+id);
|
||||||
ResourceMediator.setId(resource, id);
|
ResourceMediator.setId(resource, id);
|
||||||
}
|
}
|
||||||
HashSet<String> vosScopes = updateResourceScopes(resource);
|
|
||||||
// add the new scopes
|
// add the new scopes
|
||||||
for(String scope: scopes){
|
for(String scope: scopes){
|
||||||
log.debug("[VOCREATE] new scope added {}",scope);
|
log.debug("[VOCREATE] new scope added {}",scope);
|
||||||
|
@ -101,6 +100,7 @@ public class RegistryPublisherImpl implements RegistryPublisher {
|
||||||
log.error("the resource is not valid", e);
|
log.error("the resource is not valid", e);
|
||||||
throw new IllegalArgumentException("the resource is not valid ", e.getCause());
|
throw new IllegalArgumentException("the resource is not valid ", e.getCause());
|
||||||
}
|
}
|
||||||
|
HashSet<String> vosScopes = updateResourceScopes(resource);
|
||||||
try{
|
try{
|
||||||
if(currentScope != null){
|
if(currentScope != null){
|
||||||
// checking the current scope: if the operation fails in the current VO it will give an exception, if it fails in another VO no exception will be given
|
// checking the current scope: if the operation fails in the current VO it will give an exception, if it fails in another VO no exception will be given
|
||||||
|
@ -446,6 +446,9 @@ public class RegistryPublisherImpl implements RegistryPublisher {
|
||||||
|
|
||||||
private <T extends Resource> HashSet<String> updateResourceScopes(T resource) {
|
private <T extends Resource> HashSet<String> updateResourceScopes(T resource) {
|
||||||
HashSet<String> vosScopes = Utils.getInternalVOScopes(resource);
|
HashSet<String> vosScopes = Utils.getInternalVOScopes(resource);
|
||||||
|
// if the resource type is a RunningInstance or a HostingNode the check on the most recent resource is bypassed
|
||||||
|
if((resource.type().toString().equalsIgnoreCase("RunningInstance")) || (resource.type().toString().equalsIgnoreCase("GHN")))
|
||||||
|
return vosScopes;
|
||||||
//extract the scopes from the more recent resource found at vo level
|
//extract the scopes from the more recent resource found at vo level
|
||||||
List <String> latestScopesFound= Utils.setLatestInternalScopes(resource, vosScopes);
|
List <String> latestScopesFound= Utils.setLatestInternalScopes(resource, vosScopes);
|
||||||
log.debug("latest scope found are "+latestScopesFound);
|
log.debug("latest scope found are "+latestScopesFound);
|
||||||
|
|
|
@ -1,118 +0,0 @@
|
||||||
package org.gcube.informationsystem.publisher.stubs.registry;
|
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.faults.CreateException;
|
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.faults.InvalidResourceException;
|
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.faults.RemoveException;
|
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.faults.ResourceDoesNotExistException;
|
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.faults.ResourceNotAcceptedException;
|
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.faults.UpdateException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class CollectorStubs implements RegistryStub {
|
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(CollectorStubs.class);
|
|
||||||
|
|
||||||
public static final String TOKEN_HEADER_ENTRY = "gcube-token";
|
|
||||||
public static final String SCOPE_HEADER_ENTRY = "gcube-scope";
|
|
||||||
|
|
||||||
private String endopoint;
|
|
||||||
|
|
||||||
public CollectorStubs(String endopoint) {
|
|
||||||
super();
|
|
||||||
this.endopoint = endopoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void create(String profile, String type)
|
|
||||||
throws InvalidResourceException, ResourceNotAcceptedException, CreateException {
|
|
||||||
StringBuilder callUrl = new StringBuilder(endopoint).append("/").append(type);
|
|
||||||
try {
|
|
||||||
URL url = new URL(callUrl.toString());
|
|
||||||
HttpURLConnection connection = makeRequest(url, "POST");
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
connection.setRequestProperty("Content-type", "text/xml");
|
|
||||||
|
|
||||||
try(OutputStream os = new BufferedOutputStream(connection.getOutputStream())){
|
|
||||||
os.write(profile.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connection.getResponseCode()!=200) throw new Exception("error creating resource "+connection.getResponseCode());
|
|
||||||
}catch (Exception e) {
|
|
||||||
log.error("error on create",e);
|
|
||||||
throw new RemoveException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(String id, String type, String profile)
|
|
||||||
throws InvalidResourceException, ResourceNotAcceptedException, UpdateException {
|
|
||||||
StringBuilder callUrl = new StringBuilder(endopoint).append("/").append(type).append("/").append(id);
|
|
||||||
try {
|
|
||||||
URL url = new URL(callUrl.toString());
|
|
||||||
HttpURLConnection connection = makeRequest(url, "PUT");
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
connection.setRequestProperty("Content-type", "text/xml");
|
|
||||||
|
|
||||||
try(OutputStream os = new BufferedOutputStream(connection.getOutputStream())){
|
|
||||||
os.write(profile.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connection.getResponseCode()!=200) throw new Exception("error updating resource "+connection.getResponseCode());
|
|
||||||
}catch (Exception e) {
|
|
||||||
log.error("error on remove",e);
|
|
||||||
throw new RemoveException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(String id, String type) throws ResourceDoesNotExistException, RemoveException {
|
|
||||||
StringBuilder callUrl = new StringBuilder(endopoint).append("/").append(type).append("/").append(id);
|
|
||||||
try {
|
|
||||||
URL url = new URL(callUrl.toString());
|
|
||||||
HttpURLConnection connection = makeRequest(url, "DELETE");
|
|
||||||
connection.setDoInput(true);
|
|
||||||
if (connection.getResponseCode()!=200){
|
|
||||||
log.info("response code is not 200");
|
|
||||||
throw new Exception("error removing resource with id "+id);
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
log.error("error on remove",e);
|
|
||||||
throw new RemoveException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private HttpURLConnection makeRequest(URL url, String method) throws Exception{
|
|
||||||
HttpURLConnection connection;
|
|
||||||
if (url.toString().startsWith("https://"))
|
|
||||||
connection = (HttpsURLConnection)url.openConnection();
|
|
||||||
else connection = (HttpURLConnection)url.openConnection();
|
|
||||||
|
|
||||||
if (SecurityTokenProvider.instance.get()!=null)
|
|
||||||
connection.setRequestProperty(TOKEN_HEADER_ENTRY,SecurityTokenProvider.instance.get());
|
|
||||||
else if (ScopeProvider.instance.get()!=null)
|
|
||||||
connection.setRequestProperty(SCOPE_HEADER_ENTRY,ScopeProvider.instance.get());
|
|
||||||
else throw new RuntimeException("Collector requires authorization (via token or scope)");
|
|
||||||
|
|
||||||
connection.setRequestMethod(method);
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,15 +2,11 @@ package org.gcube.informationsystem.publisher.stubs.registry;
|
||||||
|
|
||||||
import static org.gcube.informationsystem.publisher.stubs.registry.RegistryConstants.*;
|
import static org.gcube.informationsystem.publisher.stubs.registry.RegistryConstants.*;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
|
||||||
|
|
||||||
import javax.jws.WebMethod;
|
import javax.jws.WebMethod;
|
||||||
import javax.jws.WebParam;
|
import javax.jws.WebParam;
|
||||||
import javax.jws.WebResult;
|
import javax.jws.WebResult;
|
||||||
import javax.jws.WebService;
|
import javax.jws.WebService;
|
||||||
|
|
||||||
import org.gcube.common.resources.gcore.Resource;
|
|
||||||
import org.gcube.common.resources.gcore.Resources;
|
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.faults.CreateException;
|
import org.gcube.informationsystem.publisher.stubs.registry.faults.CreateException;
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.faults.InvalidResourceException;
|
import org.gcube.informationsystem.publisher.stubs.registry.faults.InvalidResourceException;
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.faults.RemoveException;
|
import org.gcube.informationsystem.publisher.stubs.registry.faults.RemoveException;
|
||||||
|
@ -39,7 +35,6 @@ public interface RegistryStub {
|
||||||
@WebResult()
|
@WebResult()
|
||||||
void create(@WebParam(name="profile") String profile, @WebParam(name="type") String type ) throws InvalidResourceException,
|
void create(@WebParam(name="profile") String profile, @WebParam(name="type") String type ) throws InvalidResourceException,
|
||||||
ResourceNotAcceptedException, CreateException;
|
ResourceNotAcceptedException, CreateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param id the id of the resource to update
|
* @param id the id of the resource to update
|
||||||
|
@ -53,8 +48,7 @@ public interface RegistryStub {
|
||||||
@WebMethod(operationName="update")
|
@WebMethod(operationName="update")
|
||||||
@WebResult()
|
@WebResult()
|
||||||
void update(@WebParam(name="uniqueID") String id, @WebParam(name="type") String type, @WebParam(name="xmlProfile") String profile ) throws InvalidResourceException,
|
void update(@WebParam(name="uniqueID") String id, @WebParam(name="type") String type, @WebParam(name="xmlProfile") String profile ) throws InvalidResourceException,
|
||||||
ResourceNotAcceptedException, UpdateException;
|
ResourceNotAcceptedException, UpdateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param id the id of the resource to remove
|
* @param id the id of the resource to remove
|
||||||
|
@ -66,6 +60,7 @@ public interface RegistryStub {
|
||||||
@WebMethod(operationName="remove")
|
@WebMethod(operationName="remove")
|
||||||
@WebResult()
|
@WebResult()
|
||||||
void remove(@WebParam(name="uniqueID") String id, @WebParam(name="type") String type) throws ResourceDoesNotExistException,
|
void remove(@WebParam(name="uniqueID") String id, @WebParam(name="type") String type) throws ResourceDoesNotExistException,
|
||||||
RemoveException;
|
RemoveException;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.common.scope.api.ServiceMap;
|
|
||||||
import org.gcube.informationsystem.publisher.cache.RegistryCache;
|
import org.gcube.informationsystem.publisher.cache.RegistryCache;
|
||||||
import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException;
|
import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException;
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.CollectorStubs;
|
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.RegistryConstants;
|
import org.gcube.informationsystem.publisher.stubs.registry.RegistryConstants;
|
||||||
import org.gcube.informationsystem.publisher.stubs.registry.RegistryStub;
|
import org.gcube.informationsystem.publisher.stubs.registry.RegistryStub;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
|
@ -23,17 +21,16 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class RegistryStubs {
|
public class RegistryStubs {
|
||||||
|
|
||||||
private RegistryCache cache = new RegistryCache(10);
|
private RegistryCache cache = new RegistryCache(10);
|
||||||
private List<URI> endpoints;
|
private List<URI> endpoints;
|
||||||
private static final Logger log = LoggerFactory.getLogger(RegistryStubs.class);
|
private static final Logger log = LoggerFactory.getLogger(RegistryStubs.class);
|
||||||
|
|
||||||
private static final String XMLSTOREACCESS_SERVICE ="XMLStoreService";
|
|
||||||
|
|
||||||
|
|
||||||
public List<URI> getEndPoints(){
|
public List<URI> getEndPoints(){
|
||||||
String scope=ScopeProvider.instance.get();
|
String scope=ScopeProvider.instance.get();
|
||||||
// able/disable cache
|
// able/disable cache
|
||||||
endpoints=(List<URI>)cache.get(scope);
|
endpoints=(List<URI>)cache.get(scope);
|
||||||
if(endpoints==null){
|
if(endpoints==null){
|
||||||
SimpleQuery query = queryFor(GCoreEndpoint.class);
|
SimpleQuery query = queryFor(GCoreEndpoint.class);
|
||||||
|
@ -43,36 +40,30 @@ public class RegistryStubs {
|
||||||
public URI parse(String result) throws Exception {
|
public URI parse(String result) throws Exception {
|
||||||
return new URI(result.replaceAll("\n", ""));
|
return new URI(result.replaceAll("\n", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
DiscoveryClient<URI> client = new DelegateClient<URI>(uriParser, new ICClient());
|
DiscoveryClient<URI> client = new DelegateClient<URI>(uriParser, new ICClient());
|
||||||
query.addCondition("$resource/Profile/ServiceClass/text() eq '"+RegistryConstants.service_class+"'")
|
query.addCondition("$resource/Profile/ServiceClass/text() eq '"+RegistryConstants.service_class+"'")
|
||||||
.addCondition("$resource/Profile/ServiceName/text() eq '"+RegistryConstants.service_name+"'")
|
.addCondition("$resource/Profile/ServiceName/text() eq '"+RegistryConstants.service_name+"'")
|
||||||
.setResult("$resource/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint[string(@EntryName) eq '"+RegistryConstants.service_entrypoint+"']/string()");
|
.setResult("$resource/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint[string(@EntryName) eq '"+RegistryConstants.service_entrypoint+"']/string()");
|
||||||
endpoints = client.submit(query);
|
endpoints = client.submit(query);
|
||||||
if (endpoints.size()==0){
|
if (endpoints.size()==0){
|
||||||
throw new IllegalArgumentException("No registry endpoint founded");
|
throw new IllegalArgumentException("No registry endpoint founded");
|
||||||
}
|
}
|
||||||
// able/disable cache
|
// able/disable cache
|
||||||
cache.put(scope, endpoints);
|
cache.put(scope, endpoints);
|
||||||
}
|
}
|
||||||
return endpoints;
|
return endpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RegistryStub getStubs() throws RegistryNotFoundException{
|
public RegistryStub getStubs() throws RegistryNotFoundException{
|
||||||
ServiceMap serviceMap = ServiceMap.instance;
|
URI endpoint=null;
|
||||||
if (serviceMap!=null && serviceMap.version().equals("2.0.0")) {
|
//use another method to cache epr
|
||||||
String endpoint = serviceMap.endpoint(XMLSTOREACCESS_SERVICE);
|
endpoint = getEndPoints().get(0);
|
||||||
return new CollectorStubs(endpoint);
|
log.debug("get stubs from endpoint: "+ endpoint);
|
||||||
} else {
|
return stubFor(RegistryConstants.registry).at(endpoint);
|
||||||
//use another method to cache epr
|
|
||||||
URI endpoint = getEndPoints().get(0);
|
|
||||||
log.debug("get stubs from endpoint: "+ endpoint);
|
|
||||||
return stubFor(RegistryConstants.registry).at(endpoint);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegistryStub getStubs(URI endpoint) throws RegistryNotFoundException{
|
public RegistryStub getStubs(URI endpoint) throws RegistryNotFoundException{
|
||||||
log.debug("get stubs from endpoint: "+ endpoint);
|
log.debug("get stubs from endpoint: "+ endpoint);
|
||||||
return stubFor(RegistryConstants.registry).at(endpoint);
|
return stubFor(RegistryConstants.registry).at(endpoint);
|
||||||
|
|
|
@ -154,6 +154,7 @@ public class Utils {
|
||||||
|
|
||||||
private static <T extends Resource> List<String> extractInternalScopes(T resource, String latestVO) {
|
private static <T extends Resource> List<String> extractInternalScopes(T resource, String latestVO) {
|
||||||
T extractedResource=null;
|
T extractedResource=null;
|
||||||
|
log.debug("checking resource "+resource.id()+" type: "+resource.type());
|
||||||
if(resource.type().toString().equalsIgnoreCase("RuntimeResource")){
|
if(resource.type().toString().equalsIgnoreCase("RuntimeResource")){
|
||||||
extractedResource= (T)getServiceEndpointByID(resource.id(), latestVO);
|
extractedResource= (T)getServiceEndpointByID(resource.id(), latestVO);
|
||||||
}else if(resource.type().toString().equalsIgnoreCase("GenericResource")){
|
}else if(resource.type().toString().equalsIgnoreCase("GenericResource")){
|
||||||
|
|
|
@ -2,8 +2,6 @@ package org.gcube.informationsystem.publisher;
|
||||||
|
|
||||||
import static org.gcube.common.resources.gcore.Resources.print;
|
import static org.gcube.common.resources.gcore.Resources.print;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
||||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||||
import org.gcube.common.resources.gcore.Resource;
|
import org.gcube.common.resources.gcore.Resource;
|
||||||
import org.gcube.common.resources.gcore.Resource.Type;
|
import org.gcube.common.resources.gcore.Resource.Type;
|
||||||
|
@ -16,39 +14,38 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class GCoreEndpointPublisherTests {
|
public class GCoreEndpointPublisherTests {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(RegistryPublisherTests.class);
|
private static final Logger log = LoggerFactory.getLogger(RegistryPublisherTests.class);
|
||||||
static GCoreEndpoint running;
|
static GCoreEndpoint running;
|
||||||
static RegistryPublisher rp;
|
static RegistryPublisher rp;
|
||||||
static Resource r;
|
static Resource r;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void init(){
|
public static void init(){
|
||||||
// ScopeProvider.instance.set("/d4science.research-infrastructures.eu/EUBrazilOpenBio");
|
// ScopeProvider.instance.set("/d4science.research-infrastructures.eu/EUBrazilOpenBio");
|
||||||
ScopeProvider.instance.set("/gcube/devNext");
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
SecurityTokenProvider.instance.set("52b59669-ccde-46d2-a4da-108b9e941f7c-98187548");
|
running = Resources.unmarshal(GCoreEndpoint.class, PublisherTest.class.getClassLoader().getResourceAsStream("gCoreEndpoint.xml"));
|
||||||
rp=RegistryPublisherFactory.create();
|
rp=RegistryPublisherFactory.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void printTest(){
|
public void printTest(){
|
||||||
//print(running);
|
print(running);
|
||||||
//resource-specific tests
|
//resource-specific tests
|
||||||
assertEquals(Type.GCOREENDPOINT,running.type());
|
assertEquals(Type.GCOREENDPOINT,running.type());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void registerCreate(){
|
public void registerCreate(){
|
||||||
|
r=rp.create(running);
|
||||||
for (int i = 0; i<10; i++) {
|
System.out.println("new resource created: ");
|
||||||
running = Resources.unmarshal(GCoreEndpoint.class, PublisherTest.class.getClassLoader().getResourceAsStream("gCoreEndpoint.xml"));
|
if(r!=null)
|
||||||
r=rp.create(running);
|
print(r);
|
||||||
System.out.println("new resource created: "+r.id());
|
assertEquals(running,r);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*@AfterClass
|
@AfterClass
|
||||||
public static void forceDeleteResource(){
|
public static void forceDeleteResource(){
|
||||||
try {
|
try {
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
|
@ -62,8 +59,8 @@ public class GCoreEndpointPublisherTests {
|
||||||
advancedPublisher.forceRemove(r);
|
advancedPublisher.forceRemove(r);
|
||||||
ScopeProvider.instance.set(currentScope);
|
ScopeProvider.instance.set(currentScope);
|
||||||
|
|
||||||
|
|
||||||
}*/
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<Resource version="0.4.x">
|
<Resource version="0.4.x">
|
||||||
<ID></ID>
|
<ID>5d244ab0-9d79-11e3-af18-dd5904b11dd6</ID>
|
||||||
<Type>RunningInstance</Type>
|
<Type>RunningInstance</Type>
|
||||||
<Scopes>
|
<Scopes>
|
||||||
</Scopes>
|
</Scopes>
|
||||||
|
|
Loading…
Reference in New Issue