imports changed due to updated ckan-library packages declaration. Social EndPoint is now switched to a GcoreEndpoint
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@141920 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
092cd2d4c2
commit
f14049cc36
|
@ -3,9 +3,6 @@
|
|||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<dependent-module archiveName="ckan-util-library-2.1.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="context-root" value="grsf-publisher-ws"/>
|
||||
<property name="java-output-path" value="/grsf-publisher-ws/target/classes"/>
|
||||
</wb-module>
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.data-catalogue.grsf-publisher-ws.1-0-1"
|
||||
date="2017-02-10">
|
||||
<Change>Minor fixes</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-catalogue.grsf-publisher-ws.1-0-0"
|
||||
date="2016-12-10">
|
||||
<Change>First Release</Change>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
|||
|
||||
<groupId>org.gcube.data-catalogue</groupId>
|
||||
<artifactId>grsf-publisher-ws</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>grsf-publisher-ws</name>
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import javax.validation.constraints.Size;
|
|||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.CustomField;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.models.ResourceBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.models.ResourceBean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.gcube.data_catalogue.grsf_publish_ws.json.input.TimeSeriesBean;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.models.ResourceBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.models.ResourceBean;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,9 +41,9 @@ import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.AssociationToGroupThread;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.ManageTimeSeriesThread;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.WritePostCatalogueManagerThread;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.models.ResourceBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.models.RolesCkanGroupOrOrg;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.models.ResourceBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.trentorise.opendata.jackan.model.CkanDataset;
|
||||
|
|
|
@ -41,9 +41,9 @@ import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.AssociationToGroupThread;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.ManageTimeSeriesThread;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.WritePostCatalogueManagerThread;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.models.ResourceBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.models.RolesCkanGroupOrOrg;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.models.ResourceBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.trentorise.opendata.jackan.model.CkanDataset;
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.client;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Retrieve the endpoint for the Social Networking service running on Smartgears.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class GcoreEndPointReaderSocial {
|
||||
|
||||
private String basePath = null;
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(GcoreEndPointReaderSocial.class);
|
||||
private static final String resource = "jersey-servlet";
|
||||
private static final String serviceName = "SocialNetworking";
|
||||
private static final String serviceClass = "Portal";
|
||||
|
||||
public GcoreEndPointReaderSocial(String context){
|
||||
|
||||
if(context == null || context.isEmpty())
|
||||
throw new IllegalArgumentException("A valid context is needed to discover the service");
|
||||
|
||||
|
||||
String oldContext = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(context);
|
||||
|
||||
try{
|
||||
|
||||
SimpleQuery query = queryFor(GCoreEndpoint.class);
|
||||
query.addCondition(String.format("$resource/Profile/ServiceClass/text() eq '%s'",serviceClass));
|
||||
query.addCondition("$resource/Profile/DeploymentData/Status/text() eq 'ready'");
|
||||
query.addCondition(String.format("$resource/Profile/ServiceName/text() eq '%s'",serviceName));
|
||||
query.setResult("$resource/Profile/AccessPoint/RunningInstanceInterfaces//Endpoint[@EntryName/string() eq \""+resource+"\"]/text()");
|
||||
|
||||
DiscoveryClient<String> client = client();
|
||||
List<String> endpoints = client.submit(query);
|
||||
if (endpoints == null || endpoints.isEmpty()) throw new Exception("Cannot retrieve the GCoreEndpoint serviceName: "+serviceName +", serviceClass: " +serviceClass +", in scope: "+context);
|
||||
|
||||
|
||||
this.basePath = endpoints.get(0);
|
||||
if(basePath==null)
|
||||
throw new Exception("Endpoint:"+resource+", is null for serviceName: "+serviceName +", serviceClass: " +serviceClass +", in scope: "+context);
|
||||
|
||||
logger.info("found entyname "+basePath+" for ckanResource: "+resource);
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to retrieve such service endpoint information!", e);
|
||||
}finally{
|
||||
if(oldContext != null && !oldContext.equals(context))
|
||||
ScopeProvider.instance.set(oldContext);
|
||||
}
|
||||
logger.info("Found base path " + basePath + " for the service");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base path of the social networking service
|
||||
* @return
|
||||
*/
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
}
|
|
@ -19,9 +19,9 @@ import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
|||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.cache.CacheImpl;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.cache.CacheInterface;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueFactory;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueImpl;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueImpl;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.safety.Whitelist;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -140,7 +140,7 @@ public abstract class HelperMethods {
|
|||
if((result = (String) userEmailCache.get(token)) != null){
|
||||
return result;
|
||||
}else{
|
||||
String baseUrl = new ServiceEndPointReaderSocial(context).getBasePath();
|
||||
String baseUrl = new GcoreEndPointReaderSocial(context).getBasePath();
|
||||
String url = baseUrl + "users/getUserEmail?gcube-token=" + token;
|
||||
logger.debug("Request url is " + url);
|
||||
result = executGETHttpRequest(url, 200);
|
||||
|
@ -163,7 +163,7 @@ public abstract class HelperMethods {
|
|||
if((result = (String) userFullnameCache.get(token)) != null){
|
||||
return result;
|
||||
}else{
|
||||
String baseUrl = new ServiceEndPointReaderSocial(context).getBasePath();
|
||||
String baseUrl = new GcoreEndPointReaderSocial(context).getBasePath();
|
||||
String url = baseUrl + "users/getUserFullname?gcube-token=" + token;
|
||||
logger.debug("Request url is " + url);
|
||||
result = executGETHttpRequest(url, 200);
|
||||
|
@ -356,7 +356,7 @@ public abstract class HelperMethods {
|
|||
String tokenUser = SecurityTokenProvider.instance.get();
|
||||
|
||||
logger.info("Current scope for writeProductPost is " + currentScope + " and token is " + tokenUser.substring(0, 10) + "***************");
|
||||
String basePath = new ServiceEndPointReaderSocial(currentScope).getBasePath();
|
||||
String basePath = new GcoreEndPointReaderSocial(currentScope).getBasePath();
|
||||
|
||||
if(basePath == null){
|
||||
|
||||
|
@ -429,6 +429,7 @@ public abstract class HelperMethods {
|
|||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, Object> getResponseEntityAsJSON(HttpResponse response){
|
||||
|
||||
Map<String, Object> toReturn = null;
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
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.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Retrieve the endpoint for the Social Networking service running on Smartgears.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class ServiceEndPointReaderSocial {
|
||||
|
||||
private String basePath = null;
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ServiceEndPointReaderSocial.class);
|
||||
private final static String RUNTIME_RESOURCE_NAME = "SocialNetworking";
|
||||
private final static String CATEGORY = "Portal";
|
||||
|
||||
public ServiceEndPointReaderSocial(String context){
|
||||
|
||||
if(context == null || context.isEmpty())
|
||||
throw new IllegalArgumentException("A valid context is needed to discover the service");
|
||||
|
||||
|
||||
String oldContext = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(context);
|
||||
|
||||
try{
|
||||
|
||||
List<ServiceEndpoint> resources = getConfigurationFromIS();
|
||||
if (resources.size() == 0){
|
||||
logger.error("There is no Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" and Category " + CATEGORY + " in this scope.");
|
||||
throw new Exception("There is no Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" and Category " + CATEGORY + " in this scope.");
|
||||
}
|
||||
else {
|
||||
|
||||
for (ServiceEndpoint res : resources) {
|
||||
|
||||
Iterator<AccessPoint> accessPointIterator = res.profile().accessPoints().iterator();
|
||||
|
||||
while (accessPointIterator.hasNext()) {
|
||||
ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator
|
||||
.next();
|
||||
|
||||
// get base path
|
||||
basePath = accessPoint.address();
|
||||
|
||||
// break
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
|
||||
logger.error("Unable to retrieve such service endpoint information!", e);
|
||||
|
||||
}finally{
|
||||
|
||||
if(oldContext != null && !oldContext.equals(context))
|
||||
ScopeProvider.instance.set(oldContext);
|
||||
|
||||
}
|
||||
|
||||
logger.info("Found base path " + basePath + " for the service");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve endpoints information from IS for DB
|
||||
* @return list of endpoints for ckan database
|
||||
* @throws Exception
|
||||
*/
|
||||
private List<ServiceEndpoint> getConfigurationFromIS() throws Exception{
|
||||
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_RESOURCE_NAME +"'");
|
||||
query.addCondition("$resource/Profile/Category/text() eq '"+ CATEGORY +"'");
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
List<ServiceEndpoint> toReturn = client.submit(query);
|
||||
return toReturn;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base path of the social networking service
|
||||
* @return
|
||||
*/
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@ import java.util.List;
|
|||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.models.RolesCkanGroupOrOrg;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.gcube.data_catalogue.grsf_publish_ws.utils.CSVHelpers;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.cache.CacheImpl;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.cache.CacheInterface;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.trentorise.opendata.jackan.model.CkanResourceBase;
|
||||
|
|
|
@ -40,8 +40,8 @@ import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Fishery_Type;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.AssociationToGroupThread;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueFactory;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
|
Loading…
Reference in New Issue