nikolas.laskaris 2016-07-20 13:42:04 +00:00
parent f31c272654
commit e6d9f3c3ee
3 changed files with 54 additions and 28 deletions

View File

@ -74,8 +74,8 @@
<dependency> <dependency>
<groupId>org.gcube.resources</groupId> <groupId>org.gcube.resources</groupId>
<artifactId>registry-publisher</artifactId> <artifactId>registry-publisher</artifactId>
<!-- <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> --> <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<version>[1.2.4-SNAPSHOT, 2.0.0-SNAPSHOT)</version> <!-- <version>[1.2.4-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
<!-- changed from version 1.1.0-SNAPSHOT. If this change introduces problems, please revert --> <!-- changed from version 1.1.0-SNAPSHOT. If this change introduces problems, please revert -->
</dependency> </dependency>

View File

@ -26,12 +26,12 @@ import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.application.framework.core.util.CacheEntryConstants; import org.gcube.application.framework.core.util.CacheEntryConstants;
import org.gcube.application.framework.core.util.QueryString; import org.gcube.application.framework.core.util.QueryString;
import org.gcube.application.framework.core.util.SessionConstants; import org.gcube.application.framework.core.util.SessionConstants;
import org.gcube.common.resources.gcore.Resources; //import org.gcube.common.resources.gcore.Resources;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.publisher.RegistryPublisher; import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory; //import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.informationsystem.publisher.ScopedPublisher; //import org.gcube.informationsystem.publisher.ScopedPublisher;
import org.gcube.informationsystem.publisher.stubs.registry.faults.PublisherException; //import org.gcube.informationsystem.publisher.stubs.registry.faults.PublisherException;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery; import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -43,8 +43,8 @@ import org.slf4j.LoggerFactory;
import static org.gcube.resources.discovery.icclient.ICFactory.*; import static org.gcube.resources.discovery.icclient.ICFactory.*;
import org.gcube.common.resources.gcore.Resource; //import org.gcube.common.resources.gcore.Resource;
import org.gcube.common.resources.gcore.ServiceInstance; //import org.gcube.common.resources.gcore.ServiceInstance;
/** /**
@ -62,7 +62,7 @@ public class GenericResource implements GenericResourceInfoI {
// protected static ISPublisher publisher = null; // protected static ISPublisher publisher = null;
// protected static ISClient client = null; // protected static ISClient client = null;
protected static ScopedPublisher scopedPublisher = null; // protected static ScopedPublisher scopedPublisher = null;
protected static RegistryPublisher publisher = null; protected static RegistryPublisher publisher = null;
protected static DiscoveryClient<org.gcube.common.resources.gcore.GenericResource> client = null; protected static DiscoveryClient<org.gcube.common.resources.gcore.GenericResource> client = null;
@ -82,7 +82,7 @@ public class GenericResource implements GenericResourceInfoI {
session = SessionManager.getInstance().getASLSession(extrenalSessionID, username); session = SessionManager.getInstance().getASLSession(extrenalSessionID, username);
try { try {
ScopeProvider.instance.set(session.getScope()); ScopeProvider.instance.set(session.getScope());
scopedPublisher = RegistryPublisherFactory.scopedPublisher(); // scopedPublisher = RegistryPublisherFactory.scopedPublisher();
publisher = RegistryPublisherFactory.create(); publisher = RegistryPublisherFactory.create();
} catch (Exception e) { } catch (Exception e) {
logger.error("Exception:", e); logger.error("Exception:", e);
@ -109,7 +109,7 @@ public class GenericResource implements GenericResourceInfoI {
this.session = session; this.session = session;
try { try {
ScopeProvider.instance.set(session.getScope()); ScopeProvider.instance.set(session.getScope());
scopedPublisher = RegistryPublisherFactory.scopedPublisher(); // scopedPublisher = RegistryPublisherFactory.scopedPublisher();
publisher = RegistryPublisherFactory.create(); publisher = RegistryPublisherFactory.create();
} catch (Exception e) { } catch (Exception e) {
logger.error("Exception:", e); logger.error("Exception:", e);
@ -316,8 +316,33 @@ public class GenericResource implements GenericResourceInfoI {
//maybe should change the visibility (into public) of addScope() within the Resource class of common-gcore-resources package in order to use it here. //maybe should change the visibility (into public) of addScope() within the Resource class of common-gcore-resources package in order to use it here.
List<String> scopes=new ArrayList<String>(); List<String> scopes=new ArrayList<String>();
scopes.add(session.getScope()); scopes.add(session.getScope());
org.gcube.common.resources.gcore.GenericResource res = scopedPublisher.create(gCubeRes, scopes);
logger.info("Created Generic Resource with id: "+res.id()+" on scope: "+scopes.toString());
// org.gcube.common.resources.gcore.GenericResource res = scopedPublisher.create(gCubeRes, scopes);
// logger.info("Created Generic Resource with id: "+res.id()+" on scope: "+scopes.toString());
// 1-oct-2013 -- adding generic resource to cache // 1-oct-2013 -- adding generic resource to cache
logger.info("Adding it also in cache..."); logger.info("Adding it also in cache...");

View File

@ -20,7 +20,7 @@ import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.publisher.RegistryPublisher; import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory; import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.informationsystem.publisher.ScopedPublisher; //import org.gcube.informationsystem.publisher.ScopedPublisher;
import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException; import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -32,8 +32,8 @@ public class RuntimeResource {
private static final Logger logger = LoggerFactory.getLogger(RuntimeResource.class); private static final Logger logger = LoggerFactory.getLogger(RuntimeResource.class);
protected static ScopedPublisher scopedPublisher = null; // protected static ScopedPublisher scopedPublisher = null;
// protected static RegistryPublisher registryPublisher = null; protected static RegistryPublisher registryPublisher = null;
protected static DiscoveryClient<ServiceEndpoint> client = null; protected static DiscoveryClient<ServiceEndpoint> client = null;
/** /**
@ -47,8 +47,9 @@ public class RuntimeResource {
session = SessionManager.getInstance().getASLSession(extrenalSessionID, username); session = SessionManager.getInstance().getASLSession(extrenalSessionID, username);
try { try {
ScopeProvider.instance.set(session.getScope()); ScopeProvider.instance.set(session.getScope());
scopedPublisher = RegistryPublisherFactory.scopedPublisher();
// registryPublisher = RegistryPublisherFactory.create(); // scopedPublisher = RegistryPublisherFactory.scopedPublisher();
registryPublisher = RegistryPublisherFactory.create();
} catch (Exception e) { } catch (Exception e) {
logger.error("Exception:", e); logger.error("Exception:", e);
} }
@ -70,8 +71,8 @@ public class RuntimeResource {
this.session = session; this.session = session;
try { try {
ScopeProvider.instance.set(session.getScope()); ScopeProvider.instance.set(session.getScope());
scopedPublisher = RegistryPublisherFactory.scopedPublisher(); // scopedPublisher = RegistryPublisherFactory.scopedPublisher();
// registryPublisher = RegistryPublisherFactory.create(); registryPublisher = RegistryPublisherFactory.create();
} catch (Exception e) { } catch (Exception e) {
logger.error("Exception:", e); logger.error("Exception:", e);
} }
@ -93,10 +94,10 @@ public class RuntimeResource {
* @throws RemoteException * @throws RemoteException
*/ */
public String createRuntimeResource(ServiceEndpoint runtimeResource) throws RegistryNotFoundException { public String createRuntimeResource(ServiceEndpoint runtimeResource) throws RegistryNotFoundException {
List<String> scopes = new ArrayList<String>(); // List<String> scopes = new ArrayList<String>();
scopes.add(session.getScope()); // scopes.add(session.getScope());
ServiceEndpoint se = scopedPublisher.create(runtimeResource, scopes); // ServiceEndpoint se = scopedPublisher.create(runtimeResource, scopes);
// ServiceEndpoint se = registryPublisher.create(runtimeResource); ServiceEndpoint se = registryPublisher.create(runtimeResource);
logger.debug("Created Runtime Resource with id: "+se.id()+" on scope: "+scopes.toString()); logger.debug("Created Runtime Resource with id: "+se.id()+" on scope: "+scopes.toString());
return se.id(); return se.id();
} }
@ -109,8 +110,8 @@ public class RuntimeResource {
*/ */
public String updateRuntimeResource(ServiceEndpoint runtimeResource) throws RemoteException { public String updateRuntimeResource(ServiceEndpoint runtimeResource) throws RemoteException {
try { try {
ServiceEndpoint se = scopedPublisher.update(runtimeResource); // ServiceEndpoint se = scopedPublisher.update(runtimeResource);
// ServiceEndpoint se = registryPublisher.update(runtimeResource); ServiceEndpoint se = registryPublisher.update(runtimeResource);
logger.debug("Updated Runtime Resource with id: "+runtimeResource.id()+"\tNew id : "+se.id()); logger.debug("Updated Runtime Resource with id: "+runtimeResource.id()+"\tNew id : "+se.id());
return se.id(); return se.id();
} catch (Exception e) { } catch (Exception e) {
@ -129,8 +130,8 @@ public class RuntimeResource {
try { try {
List<String> scopes=new ArrayList<String>(); List<String> scopes=new ArrayList<String>();
scopes.add(session.getScope()); scopes.add(session.getScope());
ServiceEndpoint se = scopedPublisher.remove(runtimeResource,scopes); // ServiceEndpoint se = scopedPublisher.remove(runtimeResource,scopes);
// ServiceEndpoint se = registryPublisher.remove(runtimeResource); ServiceEndpoint se = registryPublisher.remove(runtimeResource);
logger.debug("Deleted Runtime Resource with id: "+runtimeResource.id()); logger.debug("Deleted Runtime Resource with id: "+runtimeResource.id());
return se.id(); return se.id();
} catch (Exception e) { } catch (Exception e) {