minor refactoring

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@144750 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-03-08 15:35:56 +00:00
parent 8e9352aae5
commit 9bc07fb2e8
22 changed files with 385 additions and 458 deletions

View File

@ -18,11 +18,11 @@
<attribute name="org.eclipse.jst.component.nondependency" value=""/> <attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<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="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="owner.project.facets" value="java"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -1,8 +1,8 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
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.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.source=1.7

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<faceted-project> <faceted-project>
<installed facet="jst.utility" version="1.0"/> <installed facet="jst.utility" version="1.0"/>
<installed facet="java" version="1.8"/> <installed facet="java" version="1.7"/>
</faceted-project> </faceted-project>

View File

@ -1,4 +1,8 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.data-catalogue.ckan-util-library.2-2-1"
date="2017-04-01">
<Change>Some minor changes</Change>
</Changeset>
<Changeset component="org.gcube.data-catalogue.ckan-util-library.2-2-0" <Changeset component="org.gcube.data-catalogue.ckan-util-library.2-2-0"
date="2017-02-01"> date="2017-02-01">
<Change>Added method to delete/purge group</Change> <Change>Added method to delete/purge group</Change>

View File

@ -10,7 +10,7 @@
</parent> </parent>
<groupId>org.gcube.data-catalogue</groupId> <groupId>org.gcube.data-catalogue</groupId>
<artifactId>ckan-util-library</artifactId> <artifactId>ckan-util-library</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.2.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CKan utility library</name> <name>CKan utility library</name>

View File

@ -11,7 +11,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.resources.gcore.utils.XPathHelper; import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datacatalogue.ckanutillibrary.server.exceptions.ApplicationProfileNotFoundException; import org.gcube.datacatalogue.ckanutillibrary.shared.ex.ApplicationProfileNotFoundException;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query; import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox; import org.gcube.resources.discovery.client.queries.impl.QueryBox;
@ -24,14 +24,16 @@ import org.xml.sax.InputSource;
* This class has a method that tries to read the application profile whose structure contains * This class has a method that tries to read the application profile whose structure contains
* couples Scope/Current_Url to check where the the needed information needs to be discovered according to the current * couples Scope/Current_Url to check where the the needed information needs to be discovered according to the current
* portlet url. It means that the scope in which the ckan related information will be discovered could be different wrt the running one. * portlet url. It means that the scope in which the ckan related information will be discovered could be different wrt the running one.
* @author Costantino Perciante at ISTI-CNR * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
* (costantino.perciante@isti.cnr.it)
*/ */
public class ApplicationProfileScopePerUrlReader { public class ApplicationProfileScopePerUrlReader {
//logger
private static final Logger logger = LoggerFactory.getLogger(ApplicationProfileScopePerUrlReader.class); private static final Logger logger = LoggerFactory.getLogger(ApplicationProfileScopePerUrlReader.class);
private final static String APPLICATION_PROFILE_NAME = "DataCatalogueMapScopesUrls"; private final static String APPLICATION_PROFILE_NAME = "DataCatalogueMapScopesUrls";
private final static String QUERY = "for $profile in collection('/db/Profiles/GenericResource')//Resource " +
"where $profile/Profile/SecondaryType/string() eq 'ApplicationProfile' and $profile/Profile/Name/string() " +
" eq '" + APPLICATION_PROFILE_NAME + "'" +
"return $profile";
/** /**
* Get the scope in which discover for this url. If the Application Profile doesn't contain it, the current scope (taken * Get the scope in which discover for this url. If the Application Profile doesn't contain it, the current scope (taken
@ -41,17 +43,17 @@ public class ApplicationProfileScopePerUrlReader {
*/ */
public static String getScopePerUrl(String url){ public static String getScopePerUrl(String url){
logger.debug("Request scope for ckan portlet at url " + url); logger.info("Request scope for ckan portlet at url " + url);
String scope = ScopeProvider.instance.get(); String scope = ScopeProvider.instance.get();
String scopeToReturn = scope; String scopeToReturn = scope;
String rootScopeForInfrastructure = "/" + PortalContext.getConfiguration().getInfrastructureName(); String rootScopeForInfrastructure = "/" + PortalContext.getConfiguration().getInfrastructureName();
if(url == null || url.isEmpty()){ if(url == null || url.isEmpty()){
logger.debug("The url passed is null or empty! Returning current scope [" + scope + "]"); logger.info("The url passed is null or empty! Returning current scope [" + scope + "]");
return scope; return scope;
} }
// set this scope // set this scope
@ -60,10 +62,7 @@ public class ApplicationProfileScopePerUrlReader {
logger.debug("Trying to fetch applicationProfile profile from the infrastructure for " + APPLICATION_PROFILE_NAME + " scope: " + rootScopeForInfrastructure); logger.debug("Trying to fetch applicationProfile profile from the infrastructure for " + APPLICATION_PROFILE_NAME + " scope: " + rootScopeForInfrastructure);
try { try {
Query q = new QueryBox("for $profile in collection('/db/Profiles/GenericResource')//Resource " + Query q = new QueryBox(QUERY);
"where $profile/Profile/SecondaryType/string() eq 'ApplicationProfile' and $profile/Profile/Name/string() " +
" eq '" + APPLICATION_PROFILE_NAME + "'" +
"return $profile");
DiscoveryClient<String> client = client(); DiscoveryClient<String> client = client();
List<String> appProfile = client.submit(q); List<String> appProfile = client.submit(q);
@ -94,12 +93,10 @@ public class ApplicationProfileScopePerUrlReader {
else else
throw throw
new ApplicationProfileNotFoundException("Your applicationProfile EndPoint was not found in the profile, consider adding <EndPoint><Scope> element in <Body>"); new ApplicationProfileNotFoundException("Your applicationProfile EndPoint was not found in the profile, consider adding <EndPoint><Scope> element in <Body>");
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("Error while trying to fetch applicationProfile profile from the infrastructure", e); logger.error("Error while trying to fetch applicationProfile profile from the infrastructure", e);
}finally{ }finally{
// set back the scope
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
} }

View File

@ -5,10 +5,10 @@ import java.sql.SQLException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.gcube.datacatalogue.ckanutillibrary.server.models.CKanUserWrapper; import org.gcube.datacatalogue.ckanutillibrary.shared.CKanUserWrapper;
import org.gcube.datacatalogue.ckanutillibrary.server.models.CkanDatasetRelationship; import org.gcube.datacatalogue.ckanutillibrary.shared.CkanDatasetRelationship;
import org.gcube.datacatalogue.ckanutillibrary.server.models.DatasetRelationships; import org.gcube.datacatalogue.ckanutillibrary.shared.DatasetRelationships;
import org.gcube.datacatalogue.ckanutillibrary.server.models.ResourceBean; import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg; import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
@ -19,7 +19,7 @@ import eu.trentorise.opendata.jackan.model.CkanOrganization;
import eu.trentorise.opendata.jackan.model.CkanResource; import eu.trentorise.opendata.jackan.model.CkanResource;
/** /**
* This is the data-catalogue-library interface that shows the utility methods. * This is the data-catalogue-library interface.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public interface DataCatalogue { public interface DataCatalogue {
@ -103,7 +103,7 @@ public interface DataCatalogue {
* @return * @return
*/ */
List<String> getOrganizationsNames(); List<String> getOrganizationsNames();
/** /**
* Retrieve the organization with this name * Retrieve the organization with this name
*/ */
@ -150,10 +150,11 @@ public interface DataCatalogue {
* @param resources * @param resources
* @param setPublic (manage visibility: Admin role is needed) * @param setPublic (manage visibility: Admin role is needed)
* @return the id of the dataset on success, null otherwise * @return the id of the dataset on success, null otherwise
* @throws Exception
*/ */
String createCKanDataset(String apiKey, String title, String name, String organizationNameOrId, String author, String createCKanDataset(String apiKey, String title, String name, String organizationNameOrId, String author,
String authorMail, String maintainer, String maintainerMail, long version, String description, String licenseId, String authorMail, String maintainer, String maintainerMail, long version, String description, String licenseId,
List<String> tags, Map<String, String> customFields, List<ResourceBean> resources, boolean setPublic); List<String> tags, Map<String, String> customFields, List<ResourceBean> resources, boolean setPublic) throws Exception;
/** /**
* Create a dataset with those information. The method allows to have multiple values for the same custom field key. * Create a dataset with those information. The method allows to have multiple values for the same custom field key.
@ -175,10 +176,11 @@ public interface DataCatalogue {
* @param resources * @param resources
* @param setPublic (manage visibility: Admin role is needed) * @param setPublic (manage visibility: Admin role is needed)
* @return the id of the dataset on success, null otherwise * @return the id of the dataset on success, null otherwise
* @throws Exception
*/ */
String createCKanDatasetMultipleCustomFields(String apiKey, String title, String name, String organizationNameOrId, String author, String createCKanDatasetMultipleCustomFields(String apiKey, String title, String name, String organizationNameOrId, String author,
String authorMail, String maintainer, String maintainerMail, long version, String description, String licenseId, String authorMail, String maintainer, String maintainerMail, long version, String description, String licenseId,
List<String> tags, Map<String, List<String>> customFields, List<ResourceBean> resources, boolean setPublic); List<String> tags, Map<String, List<String>> customFields, List<ResourceBean> resources, boolean setPublic) throws Exception;
/** /**
* Given the id or the name of the dataset it returns its current url by contacting the uri resolver. * Given the id or the name of the dataset it returns its current url by contacting the uri resolver.
@ -188,7 +190,7 @@ public interface DataCatalogue {
* @return The url of the dataset on success, null otherwise * @return The url of the dataset on success, null otherwise
*/ */
String getUrlFromDatasetIdOrName(String datasetIdOrName); String getUrlFromDatasetIdOrName(String datasetIdOrName);
/** /**
* Given the id or the name of the dataset it returns its current url by contacting the uri resolver. * Given the id or the name of the dataset it returns its current url by contacting the uri resolver.
* If no uri resolver is available, an url that is not guaranteed to be long term valid will be generated. * If no uri resolver is available, an url that is not guaranteed to be long term valid will be generated.
@ -515,7 +517,7 @@ public interface DataCatalogue {
* @return * @return
*/ */
boolean deleteGroup(String groupName, boolean purge); boolean deleteGroup(String groupName, boolean purge);
/** /**
* The method returns the role the user has in the groups he/she belongs to (it uses the db, so it is much faster) * The method returns the role the user has in the groups he/she belongs to (it uses the db, so it is much faster)
* @param username * @param username
@ -523,7 +525,7 @@ public interface DataCatalogue {
* @return * @return
*/ */
Map<String, Map<CkanGroup, RolesCkanGroupOrOrg>>getUserRoleByGroup(String username, String apiKey); Map<String, Map<CkanGroup, RolesCkanGroupOrOrg>>getUserRoleByGroup(String username, String apiKey);
/** /**
* The method returns the role the user has in the organizations he/she belongs to (it uses the db, so it is much faster) * The method returns the role the user has in the organizations he/she belongs to (it uses the db, so it is much faster)
* @param username * @param username

View File

@ -10,38 +10,32 @@ import org.slf4j.LoggerFactory;
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public class DataCatalogueFactory { public class DataCatalogueFactory {
private static final Logger logger = LoggerFactory.getLogger(DataCatalogueFactory.class); private static final Logger logger = LoggerFactory.getLogger(DataCatalogueFactory.class);
private static final long MAX_LIFETIME = 1000 * 60 * 30; // 30 MINUTES private static final long MAX_LIFETIME = 1000 * 60 * 30; // 30 MINUTES
private static DataCatalogueFactory instance = new DataCatalogueFactory(); private static DataCatalogueFactory instance = new DataCatalogueFactory();
private static ConcurrentHashMap<String, CacheBean> cache; private static ConcurrentHashMap<String, CacheBean> cache;
/**
* Private constructor for the hashmap's object values
* @author Costantino Perciante at ISTI-CNR
* (costantino.perciante@isti.cnr.it)
*
*/
private class CacheBean{ private class CacheBean{
DataCatalogueImpl utils; DataCatalogueImpl utils;
long ttl; long ttl;
public CacheBean(long ttl, DataCatalogueImpl utils){ public CacheBean(long ttl, DataCatalogueImpl utils){
this.ttl = ttl; this.ttl = ttl;
this.utils = utils; this.utils = utils;
} }
} }
/** /**
* Private constructor * Private constructor
*/ */
private DataCatalogueFactory(){ private DataCatalogueFactory(){
logger.debug("Ckan factory object build"); logger.debug("Ckan factory object build");
cache = new ConcurrentHashMap<String, CacheBean>(); cache = new ConcurrentHashMap<String, CacheBean>();
} }
/** /**
* Get the factory instance * Get the factory instance
* @return * @return
@ -50,7 +44,7 @@ public class DataCatalogueFactory {
logger.debug("Factory requested"); logger.debug("Factory requested");
return instance; return instance;
} }
/** /**
* Retrieve the ckan utils information for the given scope * Retrieve the ckan utils information for the given scope
* @param scope * @param scope
@ -58,9 +52,10 @@ public class DataCatalogueFactory {
* @throws Exception * @throws Exception
*/ */
public DataCatalogueImpl getUtilsPerScope(String scope) throws Exception{ public DataCatalogueImpl getUtilsPerScope(String scope) throws Exception{
if(scope == null || scope.isEmpty()) if(scope == null || scope.isEmpty())
throw new IllegalArgumentException("Invalid scope given!"); throw new IllegalArgumentException("Invalid scope given!");
if(cache.containsKey(scope) && !expired(cache.get(scope))){ if(cache.containsKey(scope) && !expired(cache.get(scope))){
return cache.get(scope).utils; return cache.get(scope).utils;
} }

View File

@ -3,9 +3,7 @@ package org.gcube.datacatalogue.ckanutillibrary.server;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.InputStreamReader;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -30,14 +28,14 @@ import net.htmlparser.jericho.Renderer;
import net.htmlparser.jericho.Segment; import net.htmlparser.jericho.Segment;
import net.htmlparser.jericho.Source; import net.htmlparser.jericho.Source;
import org.gcube.datacatalogue.ckanutillibrary.server.models.CKanUserWrapper;
import org.gcube.datacatalogue.ckanutillibrary.server.models.CkanDatasetRelationship;
import org.gcube.datacatalogue.ckanutillibrary.server.models.DatasetRelationships;
import org.gcube.datacatalogue.ckanutillibrary.server.models.ResourceBean;
import org.gcube.datacatalogue.ckanutillibrary.server.models.State;
import org.gcube.datacatalogue.ckanutillibrary.server.utils.UtilMethods; import org.gcube.datacatalogue.ckanutillibrary.server.utils.UtilMethods;
import org.gcube.datacatalogue.ckanutillibrary.server.utils.url.EntityContext; import org.gcube.datacatalogue.ckanutillibrary.server.utils.url.EntityContext;
import org.gcube.datacatalogue.ckanutillibrary.shared.CKanUserWrapper;
import org.gcube.datacatalogue.ckanutillibrary.shared.CkanDatasetRelationship;
import org.gcube.datacatalogue.ckanutillibrary.shared.DatasetRelationships;
import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg; import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
import org.gcube.datacatalogue.ckanutillibrary.shared.State;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.JSONValue; import org.json.simple.JSONValue;
@ -72,6 +70,7 @@ import eu.trentorise.opendata.jackan.model.CkanUser;
* This is the Ckan Utils implementation class. * This is the Ckan Utils implementation class.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
@SuppressWarnings("unchecked")
public class DataCatalogueImpl implements DataCatalogue{ public class DataCatalogueImpl implements DataCatalogue{
private static final Logger logger = LoggerFactory.getLogger(DataCatalogueImpl.class); private static final Logger logger = LoggerFactory.getLogger(DataCatalogueImpl.class);
@ -88,6 +87,9 @@ public class DataCatalogueImpl implements DataCatalogue{
private boolean MANAGE_PRODUCT_BUTTON; private boolean MANAGE_PRODUCT_BUTTON;
private String CONTEXT; private String CONTEXT;
private final static String PATH_SET_PRIVATE_DATASET = "/api/3/action/bulk_update_private";
private final static String PATH_SET_PUBLIC_DATASET = "/api/3/action/bulk_update_public";
// ckan client // ckan client
private CkanClient client; private CkanClient client;
@ -95,7 +97,7 @@ public class DataCatalogueImpl implements DataCatalogue{
private ConcurrentHashMap<String, CKANTokenBean> apiKeysMap; private ConcurrentHashMap<String, CKANTokenBean> apiKeysMap;
// apikey bean expires after X minutes in the above map // apikey bean expires after X minutes in the above map
private static final int EXPIRE_KEY_TIME = 5 * 60 * 1000; private static final int EXPIRE_KEY_TIME = 60 * 60 * 1000;
private class CKANTokenBean{ private class CKANTokenBean{
private String apiKey; private String apiKey;
@ -158,6 +160,15 @@ public class DataCatalogueImpl implements DataCatalogue{
return URI_RESOLVER_URL; return URI_RESOLVER_URL;
} }
/**
* Check if the manage product is enabled
* @return
*/
@Override
public boolean isManageProductEnabled() {
return MANAGE_PRODUCT_BUTTON;
}
/** /**
* Retrieve connection from the pool * Retrieve connection from the pool
* @return a connection available within the pool * @return a connection available within the pool
@ -175,15 +186,6 @@ public class DataCatalogueImpl implements DataCatalogue{
} }
/**
* Check if the manage product is enabled
* @return
*/
@Override
public boolean isManageProductEnabled() {
return MANAGE_PRODUCT_BUTTON;
}
/** /**
* Tries to close a connection * Tries to close a connection
* @param connection * @param connection
@ -250,14 +252,16 @@ public class DataCatalogueImpl implements DataCatalogue{
}catch(Exception e){ }catch(Exception e){
logger.error("Unable to retrieve key for user " + ckanUsername, e); logger.error("Unable to retrieve key for user " + ckanUsername, e);
return null;
}finally{ }finally{
closeConnection(connection); closeConnection(connection);
} }
return null;
} }
@Override @Override
public CKanUserWrapper getUserFromApiKey(String apiKey) { public CKanUserWrapper getUserFromApiKey(String apiKey) {
logger.debug("Request user whose api key is = " + apiKey.substring(0, 3) + "*************"); logger.debug("Request user whose api key is = " + apiKey.substring(0, 3) + "*************");
// checks // checks
@ -550,7 +554,7 @@ public class DataCatalogueImpl implements DataCatalogue{
} }
/** /**
* Set dataset private * Set dataset private/public
* @param priv * @param priv
* @param organizationId (NOTE: The ID, not the name!) * @param organizationId (NOTE: The ID, not the name!)
* @param datasetId (NOTE: The ID, not the name!) * @param datasetId (NOTE: The ID, not the name!)
@ -568,52 +572,38 @@ public class DataCatalogueImpl implements DataCatalogue{
checkArgument(!datasetId.isEmpty()); checkArgument(!datasetId.isEmpty());
checkArgument(!organizationId.isEmpty()); checkArgument(!organizationId.isEmpty());
String pathSetPrivate = "/api/3/action/bulk_update_private"; JSONObject obj = new JSONObject();
String pathSetPublic = "/api/3/action/bulk_update_public"; obj.put("org_id", organizationId);
// Request parameters to be replaced JSONArray array = new JSONArray();
String parameter = "{" array.add(datasetId);
+ "\"org_id\":\"ORGANIZATION_ID\"," obj.put("datasets", array);
+ "\"datasets\":[\"DATASET_ID\"]"
+ "}";
// replace with right data try(CloseableHttpClient httpClient = HttpClientBuilder.create().build();) {
parameter = parameter.replace("ORGANIZATION_ID", organizationId); HttpPost request;
parameter = parameter.replace("DATASET_ID", datasetId);
if(priv){ if(priv)
try(CloseableHttpClient httpClient = HttpClientBuilder.create().build();) { request = new HttpPost(CKAN_CATALOGUE_URL + PATH_SET_PRIVATE_DATASET);
HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + pathSetPrivate); else
request.addHeader("Authorization", apiKey); request = new HttpPost(CKAN_CATALOGUE_URL + PATH_SET_PUBLIC_DATASET);
StringEntity params = new StringEntity(parameter);
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
logger.debug("[PRIVATE]Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase());
if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) logger.info("Excuting request for making dataset with id " + datasetId + " " + (priv? "private" : "public"));
return true;
}catch (Exception ex) { request.addHeader("Authorization", apiKey);
logger.error("Error while trying to set private the dataset ", ex); StringEntity params = new StringEntity(obj.toJSONString());
} request.setEntity(params);
}else HttpResponse response = httpClient.execute(request);
{
try(CloseableHttpClient httpClient = HttpClientBuilder.create().build();) {
HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + pathSetPublic);
StringEntity params = new StringEntity(parameter);
request.addHeader("Authorization", apiKey);
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
logger.debug("[PUBLIC]Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase());
if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) logger.info("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase());
return true;
}catch (Exception ex) { if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
logger.error("Error while trying to set public the dataset ", ex); return true;
}
}catch (Exception ex) {
logger.error("Error while trying to set private the dataset ", ex);
} }
return false; return false;
} }
@ -695,7 +685,7 @@ public class DataCatalogueImpl implements DataCatalogue{
String authorMail, String maintainer, String maintainerMail, String authorMail, String maintainer, String maintainerMail,
long version, String description, String licenseId, long version, String description, String licenseId,
List<String> tags, Map<String, String> customFields, List<String> tags, Map<String, String> customFields,
List<ResourceBean> resources, boolean setPublic) { List<ResourceBean> resources, boolean setPublic) throws Exception{
// delegate the private method // delegate the private method
return createCkanDatasetBody(apiKey, return createCkanDatasetBody(apiKey,
@ -712,7 +702,7 @@ public class DataCatalogueImpl implements DataCatalogue{
String authorMail, String maintainer, String maintainerMail, String authorMail, String maintainer, String maintainerMail,
long version, String description, String licenseId, long version, String description, String licenseId,
List<String> tags, Map<String, List<String>> customFieldsMultiple, List<String> tags, Map<String, List<String>> customFieldsMultiple,
List<ResourceBean> resources, boolean setPublic) { List<ResourceBean> resources, boolean setPublic) throws Exception{
// delegate the private method // delegate the private method
return createCkanDatasetBody(apiKey, return createCkanDatasetBody(apiKey,
@ -730,7 +720,7 @@ public class DataCatalogueImpl implements DataCatalogue{
long version, String description, String licenseId, long version, String description, String licenseId,
List<String> tags, Map<String, String> customFields, List<String> tags, Map<String, String> customFields,
Map<String, List<String>> customFieldsMultipleValues, Map<String, List<String>> customFieldsMultipleValues,
List<ResourceBean> resources, boolean setPublic){ List<ResourceBean> resources, boolean setPublic) throws Exception{
// checks (minimum) // checks (minimum)
checkNotNull(apiKey); checkNotNull(apiKey);
@ -743,18 +733,15 @@ public class DataCatalogueImpl implements DataCatalogue{
CheckedCkanClient client = new CheckedCkanClient(CKAN_CATALOGUE_URL, apiKey); CheckedCkanClient client = new CheckedCkanClient(CKAN_CATALOGUE_URL, apiKey);
// get client from apiKey
String ckanUsername = getUserFromApiKey(apiKey).getName(); String ckanUsername = getUserFromApiKey(apiKey).getName();
// create the base dataset and fill it
CkanDataset dataset = new CkanDataset(); CkanDataset dataset = new CkanDataset();
// get the name from the title
String nameToUse = name; String nameToUse = name;
if(nameToUse == null) if(nameToUse == null)
nameToUse = UtilMethods.fromProductTitleToName(title); nameToUse = UtilMethods.fromProductTitleToName(title);
logger.debug("Name of the dataset is going to be " + nameToUse + ". Title is going to be " + title); logger.debug("Name of the dataset is going to be " + nameToUse + ". Title is going to be " + title);
dataset.setName(nameToUse); dataset.setName(nameToUse);
dataset.setTitle(title); dataset.setTitle(title);
@ -773,67 +760,54 @@ public class DataCatalogueImpl implements DataCatalogue{
Renderer htmlRend = new Renderer(htmlSeg); Renderer htmlRend = new Renderer(htmlSeg);
dataset.setNotes(htmlRend.toString()); dataset.setNotes(htmlRend.toString());
logger.debug("Description (escaped is ) " + htmlRend.toString()); logger.debug("Description escaped " + htmlRend.toString());
} }
dataset.setLicenseId(licenseId); dataset.setLicenseId(licenseId);
// set the tags, if any // set the tags, if any
if(tags != null && !tags.isEmpty()){ if(tags != null && !tags.isEmpty()){
// convert to ckan tags
List<CkanTag> ckanTags = new ArrayList<CkanTag>(tags.size()); List<CkanTag> ckanTags = new ArrayList<CkanTag>(tags.size());
for (String stringTag : tags) { for (String stringTag : tags) {
ckanTags.add(new CkanTag(stringTag)); ckanTags.add(new CkanTag(stringTag));
} }
dataset.setTags(ckanTags); dataset.setTags(ckanTags);
} }
// set the custom fields, if any // set the custom fields, if any
List<CkanPair> extras = new ArrayList<CkanPair>();
if(customFields != null && !customFields.isEmpty()){ if(customFields != null && !customFields.isEmpty()){
// iterate and create
Iterator<Entry<String, String>> iterator = customFields.entrySet().iterator(); Iterator<Entry<String, String>> iterator = customFields.entrySet().iterator();
List<CkanPair> extras = new ArrayList<CkanPair>();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<String, String> entry = (Map.Entry<String, String>) iterator.next(); Map.Entry<String, String> entry = (Map.Entry<String, String>) iterator.next();
extras.add(new CkanPair(entry.getKey(), entry.getValue())); extras.add(new CkanPair(entry.getKey(), entry.getValue()));
} }
dataset.setExtras(extras);
}else if(customFieldsMultipleValues != null && !customFieldsMultipleValues.isEmpty()){ }else if(customFieldsMultipleValues != null && !customFieldsMultipleValues.isEmpty()){
// iterate and create
Iterator<Entry<String, List<String>>> iterator = customFieldsMultipleValues.entrySet().iterator(); Iterator<Entry<String, List<String>>> iterator = customFieldsMultipleValues.entrySet().iterator();
List<CkanPair> extras = new ArrayList<CkanPair>();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<String, List<String>> entry = (Map.Entry<String, List<String>>) iterator.next(); Map.Entry<String, List<String>> entry = (Map.Entry<String, List<String>>) iterator.next();
List<String> valuesForEntry = entry.getValue(); List<String> valuesForEntry = entry.getValue();
for (String value : valuesForEntry) { for (String value : valuesForEntry) {
extras.add(new CkanPair(entry.getKey(), value)); extras.add(new CkanPair(entry.getKey(), value));
} }
} }
// sort them
Collections.sort(extras, new Comparator<CkanPair>() {
@Override public int compare(CkanPair b1, CkanPair b2) {
return b1.getKey().compareTo(b2.getKey());
}
});
dataset.setExtras(extras);
} }
// sort them
Collections.sort(extras, new Comparator<CkanPair>() {
@Override public int compare(CkanPair b1, CkanPair b2) {
return b1.getKey().compareTo(b2.getKey());
}
});
dataset.setExtras(extras);
// check if we need to add the resources // check if we need to add the resources
if(resources != null && !resources.isEmpty()){ if(resources != null && !resources.isEmpty()){
@ -842,8 +816,6 @@ public class DataCatalogueImpl implements DataCatalogue{
try{ try{
List<CkanResource> resourcesCkan = new ArrayList<CkanResource>(); List<CkanResource> resourcesCkan = new ArrayList<CkanResource>();
for(ResourceBean resource: resources){ for(ResourceBean resource: resources){
CkanResource newResource = new CkanResource(); CkanResource newResource = new CkanResource();
@ -861,6 +833,7 @@ public class DataCatalogueImpl implements DataCatalogue{
}catch(Exception e){ }catch(Exception e){
logger.error("Unable to add those resources to the dataset", e); logger.error("Unable to add those resources to the dataset", e);
throw e;
} }
} }
@ -868,11 +841,9 @@ public class DataCatalogueImpl implements DataCatalogue{
// try to create // try to create
CkanDataset res = null; CkanDataset res = null;
try{ try{
res = client.createDataset(dataset); res = client.createDataset(dataset);
if(res != null){ if(res != null){
logger.debug("Dataset with name " + res.getName() + " has been created. Setting visibility"); logger.debug("Dataset with name " + res.getName() + " has been created. Setting visibility");
// set visibility // set visibility
@ -889,19 +860,15 @@ public class DataCatalogueImpl implements DataCatalogue{
boolean searchableSet = setSearchableField(res.getId(), true); boolean searchableSet = setSearchableField(res.getId(), true);
logger.info("Was searchable set to True? " + searchableSet); logger.info("Was searchable set to True? " + searchableSet);
} }
return res.getId(); return res.getId();
} }
}catch(Exception e){ }catch(Exception e){
// try to update
logger.error("Error while creating the dataset.", e); logger.error("Error while creating the dataset.", e);
throw e;
} }
return null; return null;
} }
@Override @Override
@ -972,7 +939,6 @@ public class DataCatalogueImpl implements DataCatalogue{
* @param entityName * @param entityName
* @return the url for the product * @return the url for the product
*/ */
@SuppressWarnings("unchecked")
private String getUrlForProduct(String context, EntityContext entityContext, String entityName, boolean unencrypted){ private String getUrlForProduct(String context, EntityContext entityContext, String entityName, boolean unencrypted){
String toReturn = null; String toReturn = null;
@ -1034,24 +1000,17 @@ public class DataCatalogueImpl implements DataCatalogue{
// we need to use the apis to make it // we need to use the apis to make it
String path = "/api/3/action/organization_member_create"; String path = "/api/3/action/organization_member_create";
// Request parameters to be replaced JSONObject obj = new JSONObject();
String parameter = "{" obj.put("id", organizationNameToCheck);
+ "\"id\":\"ORGANIZATION_ID_NAME\"," obj.put("username", ckanUsername);
+ "\"username\":\"USERNAME_ID_NAME\"," obj.put("role", RolesCkanGroupOrOrg.convertToCkanCapacity(correspondentRoleToCheck));
+ "\"role\":\"ROLE\""
+ "}";
// replace those values logger.debug("API request for organization membership is going to be " + obj.toJSONString());
parameter = parameter.replace("ORGANIZATION_ID_NAME", organizationNameToCheck);
parameter = parameter.replace("USERNAME_ID_NAME", ckanUsername);
parameter = parameter.replace("ROLE", RolesCkanGroupOrOrg.convertToCkanCapacity(correspondentRoleToCheck));
logger.debug("API request for organization membership is going to be " + parameter);
try(CloseableHttpClient httpClient = HttpClientBuilder.create().build();) { try(CloseableHttpClient httpClient = HttpClientBuilder.create().build();) {
HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + path); HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + path);
request.addHeader("Authorization", CKAN_TOKEN_SYS); // sys token request.addHeader("Authorization", CKAN_TOKEN_SYS); // sys token
StringEntity params = new StringEntity(parameter); StringEntity params = new StringEntity(obj.toJSONString());
request.setEntity(params); request.setEntity(params);
HttpResponse response = httpClient.execute(request); HttpResponse response = httpClient.execute(request);
logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase()); logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase());
@ -1124,24 +1083,17 @@ public class DataCatalogueImpl implements DataCatalogue{
// we need to use the apis to make it // we need to use the apis to make it
String path = "/api/3/action/group_member_create"; String path = "/api/3/action/group_member_create";
// Request parameters to be replaced JSONObject obj = new JSONObject();
String parameter = "{" obj.put("id", groupNameToCheck);
+ "\"id\":\"ORGANIZATION_ID_NAME\"," obj.put("username", ckanUsername);
+ "\"username\":\"USERNAME_ID_NAME\"," obj.put("role", RolesCkanGroupOrOrg.convertToCkanCapacity(correspondentRoleToCheck));
+ "\"role\":\"ROLE\""
+ "}";
// replace those values logger.debug("API request for organization membership is going to be " + obj.toJSONString());
parameter = parameter.replace("ORGANIZATION_ID_NAME", groupNameToCheck);
parameter = parameter.replace("USERNAME_ID_NAME", ckanUsername);
parameter = parameter.replace("ROLE", RolesCkanGroupOrOrg.convertToCkanCapacity(correspondentRoleToCheck));
logger.debug("API request for organization membership is going to be " + parameter);
try(CloseableHttpClient httpClient = HttpClientBuilder.create().build();) { try(CloseableHttpClient httpClient = HttpClientBuilder.create().build();) {
HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + path); HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + path);
request.addHeader("Authorization", CKAN_TOKEN_SYS); // sys token request.addHeader("Authorization", CKAN_TOKEN_SYS); // sys token
StringEntity params = new StringEntity(parameter); StringEntity params = new StringEntity(obj.toJSONString());
request.setEntity(params); request.setEntity(params);
HttpResponse response = httpClient.execute(request); HttpResponse response = httpClient.execute(request);
logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase()); logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase());
@ -1195,26 +1147,18 @@ public class DataCatalogueImpl implements DataCatalogue{
// we need to use the apis to make it // we need to use the apis to make it
String path = "/api/3/action/package_relationship_create"; String path = "/api/3/action/package_relationship_create";
// Request parameters to be replaced JSONObject obj = new JSONObject();
String parameter = "{" obj.put("subject", datasetIdSubject);
+ "\"subject\":\"SUBJECT\"," obj.put("object", datasetIdObject);
+ "\"object\":\"OBJECT\"," obj.put("type", relation.toString());
+ "\"type\":\"RELATIONSHIP\","
+ "\"comment\" : \"COMMENT\""
+ "}";
// replace those values
parameter = parameter.replace("SUBJECT", datasetIdSubject);
parameter = parameter.replace("OBJECT", datasetIdObject);
parameter = parameter.replace("RELATIONSHIP", relation.toString());
if(relationComment != null && !relationComment.isEmpty()) if(relationComment != null && !relationComment.isEmpty())
parameter = parameter.replace("COMMENT", relationComment); obj.put("comment", relationComment);
logger.debug("API request for relationship create is going to be " + parameter); logger.debug("API request for relationship create is going to be " + obj.toJSONString());
HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + path); HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + path);
request.addHeader("Authorization", apiKey); request.addHeader("Authorization", apiKey);
StringEntity params = new StringEntity(parameter); StringEntity params = new StringEntity(obj.toJSONString());
request.setEntity(params); request.setEntity(params);
HttpResponse response = httpClient.execute(request); HttpResponse response = httpClient.execute(request);
logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase()); logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase());
@ -1246,23 +1190,16 @@ public class DataCatalogueImpl implements DataCatalogue{
// we need to use the apis to make it // we need to use the apis to make it
String path = "/api/3/action/package_relationship_delete"; String path = "/api/3/action/package_relationship_delete";
// Request parameters to be replaced JSONObject obj = new JSONObject();
String parameter = "{" obj.put("subject", datasetIdSubject);
+ "\"subject\":\"SUBJECT\"," obj.put("object", datasetIdObject);
+ "\"object\":\"OBJECT\"," obj.put("type", relation.toString());
+ "\"type\":\"RELATIONSHIP\""
+ "}";
// replace those values logger.debug("API request for delete relationship is going to be " + obj.toJSONString());
parameter = parameter.replace("SUBJECT", datasetIdSubject);
parameter = parameter.replace("OBJECT", datasetIdObject);
parameter = parameter.replace("RELATIONSHIP", relation.toString());
logger.debug("API request for delete relationship is going to be " + parameter);
HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + path); HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + path);
request.addHeader("Authorization", apiKey); request.addHeader("Authorization", apiKey);
StringEntity params = new StringEntity(parameter); StringEntity params = new StringEntity(obj.toJSONString());
request.setEntity(params); request.setEntity(params);
HttpResponse response = httpClient.execute(request); HttpResponse response = httpClient.execute(request);
logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase()); logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase());
@ -1275,7 +1212,6 @@ public class DataCatalogueImpl implements DataCatalogue{
return false; return false;
} }
@SuppressWarnings("unchecked")
@Override @Override
public List<CkanDatasetRelationship> getRelationshipDatasets( public List<CkanDatasetRelationship> getRelationshipDatasets(
String datasetIdSubject, String datasetIdObject, String apiKey) { String datasetIdSubject, String datasetIdObject, String apiKey) {
@ -1293,47 +1229,25 @@ public class DataCatalogueImpl implements DataCatalogue{
// we need to use the apis to make it // we need to use the apis to make it
String path = "/api/3/action/package_relationships_list"; String path = "/api/3/action/package_relationships_list";
String parameter; JSONObject obj = new JSONObject();
obj.put("id", datasetIdSubject);
// Request parameters to be replaced // Request parameters to be replaced
if(datasetIdObject == null || datasetIdObject.isEmpty())
parameter = "{"
+ "\"id\":\"SUBJECT\""
+ "}";
else
parameter = "{"
+ "\"id\":\"SUBJECT\","
+ "\"id2\":\"OBJECT\""
+ "}";
// replace those values
parameter = parameter.replace("SUBJECT", datasetIdSubject);
if(datasetIdObject != null && !datasetIdObject.isEmpty()) if(datasetIdObject != null && !datasetIdObject.isEmpty())
parameter = parameter.replace("OBJECT", datasetIdObject); obj.put("id2", datasetIdObject);
logger.debug("API request for getting relationship is going to be " + parameter); logger.debug("API request for getting relationship is going to be " + obj.toJSONString());
HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + path); HttpPost request = new HttpPost(CKAN_CATALOGUE_URL + path);
request.addHeader("Authorization", apiKey); request.addHeader("Authorization", apiKey);
StringEntity params = new StringEntity(parameter); StringEntity params = new StringEntity(obj.toJSONString());
request.setEntity(params); request.setEntity(params);
HttpResponse response = httpClient.execute(request); HttpResponse response = httpClient.execute(request);
logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase()); logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase());
if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){ if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
// parse the json and convert to java beans String res = EntityUtils.toString(response.getEntity());
BufferedReader br = new BufferedReader(
new InputStreamReader((response.getEntity().getContent())));
String output;
String res = "";
while ((output = br.readLine()) != null) {
res += output;
}
if(res == "")
return toReturn;
// parse the json object returned // parse the json object returned
JSONParser parser = new JSONParser(); JSONParser parser = new JSONParser();
@ -1432,7 +1346,6 @@ public class DataCatalogueImpl implements DataCatalogue{
return toReturn; return toReturn;
} }
@SuppressWarnings("unchecked")
@Override @Override
public boolean assignDatasetToGroup(String groupNameOrId, String datasetNameOrId, String apiKey) { public boolean assignDatasetToGroup(String groupNameOrId, String datasetNameOrId, String apiKey) {
@ -1491,26 +1404,23 @@ public class DataCatalogueImpl implements DataCatalogue{
// now we patch the dataset with the new group // now we patch the dataset with the new group
String pathUpdatePatch = CKAN_CATALOGUE_URL + "/api/3/action/package_patch"; String pathUpdatePatch = CKAN_CATALOGUE_URL + "/api/3/action/package_patch";
String parameterPostPatch = "{\"id\":\"PACKAGE_ID\", \"groups\":[GROUPS]}";
parameterPostPatch = parameterPostPatch.replace("PACKAGE_ID", datasetNameOrId); JSONObject req = new JSONObject();
String singleGroup = "{\"name\":\"GROUP_ID\"}"; req.put("id", datasetNameOrId);
// evaluate parameterPostPatch JSONArray groups = new JSONArray();
String replaceGROUPS = "";
for (int i = 0; i < fetchedGroups.size(); i++) { for (int i = 0; i < fetchedGroups.size(); i++) {
replaceGROUPS += singleGroup.replace("GROUP_ID", fetchedGroups.get(i)); JSONObject groupJSON = new JSONObject();
if(i != fetchedGroups.size() - 1) groupJSON.put("name", fetchedGroups.get(i));
replaceGROUPS += ","; groups.add(groupJSON);
} }
req.put("groups", groups);
// replace this into parameterPostPatch logger.debug("Request for patch is going to be " + req.toJSONString());
parameterPostPatch = parameterPostPatch.replace("GROUPS", replaceGROUPS);
logger.debug("Request for patch is going to be " + parameterPostPatch);
HttpPost request = new HttpPost(pathUpdatePatch); HttpPost request = new HttpPost(pathUpdatePatch);
request.addHeader("Authorization", CKAN_TOKEN_SYS); request.addHeader("Authorization", CKAN_TOKEN_SYS);
StringEntity params = new StringEntity(parameterPostPatch); StringEntity params = new StringEntity(req.toJSONString());
request.setEntity(params); request.setEntity(params);
HttpResponse responsePatch = httpClient.execute(request); HttpResponse responsePatch = httpClient.execute(request);
logger.debug("Response code is " + responsePatch.getStatusLine().getStatusCode() + " and response message is " + responsePatch.getStatusLine().getReasonPhrase()); logger.debug("Response code is " + responsePatch.getStatusLine().getStatusCode() + " and response message is " + responsePatch.getStatusLine().getReasonPhrase());
@ -1529,7 +1439,7 @@ public class DataCatalogueImpl implements DataCatalogue{
return false; return false;
} }
@SuppressWarnings("unchecked")
@Override @Override
public boolean removeDatasetFromGroup(String groupNameOrId, public boolean removeDatasetFromGroup(String groupNameOrId,
String datasetNameOrId, String apiKey) { String datasetNameOrId, String apiKey) {
@ -1714,6 +1624,7 @@ public class DataCatalogueImpl implements DataCatalogue{
return toReturn; return toReturn;
} }
@Override @Override
public boolean deleteProduct(String datasetId, String apiKey, boolean purge) { public boolean deleteProduct(String datasetId, String apiKey, boolean purge) {
@ -1738,8 +1649,9 @@ public class DataCatalogueImpl implements DataCatalogue{
String path = CKAN_CATALOGUE_URL + "/api/3/action/dataset_purge"; String path = CKAN_CATALOGUE_URL + "/api/3/action/dataset_purge";
HttpPost request = new HttpPost(path); HttpPost request = new HttpPost(path);
request.addHeader("Authorization", CKAN_TOKEN_SYS); // this must be a sys_admin key request.addHeader("Authorization", CKAN_TOKEN_SYS); // this must be a sys_admin key
String entityBody = "{\"id\": \"" + datasetId + "\"}"; JSONObject object = new JSONObject();
StringEntity params = new StringEntity(entityBody); object.put("id", datasetId);
StringEntity params = new StringEntity(object.toJSONString());
request.setEntity(params); request.setEntity(params);
HttpResponse response = httpClient.execute(request); HttpResponse response = httpClient.execute(request);
@ -1795,20 +1707,14 @@ public class DataCatalogueImpl implements DataCatalogue{
// Patch package path // Patch package path
String patchPackage = CKAN_CATALOGUE_URL + "/api/3/action/package_patch"; String patchPackage = CKAN_CATALOGUE_URL + "/api/3/action/package_patch";
// Request parameters to be replaced JSONObject obj = new JSONObject();
String parameter = "{" obj.put("id", datasetId);
+ "\"id\":\"DATASET_ID\"," obj.put("searchable", searchableAsString);
+ "\"searchable\":\"SEARCHABLE\""
+ "}";
// replace with right data
parameter = parameter.replace("DATASET_ID", datasetId);
parameter = parameter.replace("SEARCHABLE", searchableAsString);
try(CloseableHttpClient httpClient = HttpClientBuilder.create().build();) { try(CloseableHttpClient httpClient = HttpClientBuilder.create().build();) {
HttpPost request = new HttpPost(patchPackage); HttpPost request = new HttpPost(patchPackage);
request.addHeader("Authorization", CKAN_TOKEN_SYS); request.addHeader("Authorization", CKAN_TOKEN_SYS);
StringEntity params = new StringEntity(parameter); StringEntity params = new StringEntity(obj.toJSONString());
request.setEntity(params); request.setEntity(params);
HttpResponse response = httpClient.execute(request); HttpResponse response = httpClient.execute(request);
logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase()); logger.debug("Response code is " + response.getStatusLine().getStatusCode() + " and response message is " + response.getStatusLine().getReasonPhrase());
@ -1888,7 +1794,7 @@ public class DataCatalogueImpl implements DataCatalogue{
} }
} }
@SuppressWarnings("unchecked")
@Override @Override
public boolean patchResource(String resourceId, String url, public boolean patchResource(String resourceId, String url,
String name, String description, String urlType, String apiKey) { String name, String description, String urlType, String apiKey) {
@ -1940,7 +1846,6 @@ public class DataCatalogueImpl implements DataCatalogue{
return false; return false;
} }
@SuppressWarnings("unchecked")
@Override @Override
public boolean patchProductCustomFields(String productId, String apiKey, public boolean patchProductCustomFields(String productId, String apiKey,
Map<String, List<String>> customFieldsToChange) { Map<String, List<String>> customFieldsToChange) {
@ -2052,7 +1957,7 @@ public class DataCatalogueImpl implements DataCatalogue{
return false; return false;
} }
@SuppressWarnings("unchecked")
@Override @Override
public boolean removeCustomField(String productId, String key, public boolean removeCustomField(String productId, String key,
String value, String apiKey) { String value, String apiKey) {
@ -2127,7 +2032,6 @@ public class DataCatalogueImpl implements DataCatalogue{
} }
@SuppressWarnings("unchecked")
@Override @Override
public boolean removeTag(String productId, String apiKey, String tagToRemove) { public boolean removeTag(String productId, String apiKey, String tagToRemove) {
@ -2255,7 +2159,7 @@ public class DataCatalogueImpl implements DataCatalogue{
return null; return null;
} }
@SuppressWarnings("unchecked")
@Override @Override
public boolean setGroupParent(String parentName, String groupName) { public boolean setGroupParent(String parentName, String groupName) {

View File

@ -18,10 +18,10 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Property; import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
import org.gcube.common.resources.gcore.utils.XPathHelper; import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datacatalogue.ckanutillibrary.server.exceptions.ApplicationProfileNotFoundException; import org.gcube.datacatalogue.ckanutillibrary.shared.ex.ApplicationProfileNotFoundException;
import org.gcube.datacatalogue.ckanutillibrary.server.exceptions.NoApplicationProfileMasterException; import org.gcube.datacatalogue.ckanutillibrary.shared.ex.NoApplicationProfileMasterException;
import org.gcube.datacatalogue.ckanutillibrary.server.exceptions.NoDataCatalogueRuntimeResourceException; import org.gcube.datacatalogue.ckanutillibrary.shared.ex.NoDataCatalogueRuntimeResourceException;
import org.gcube.datacatalogue.ckanutillibrary.server.exceptions.ServiceEndPointException; import org.gcube.datacatalogue.ckanutillibrary.shared.ex.ServiceEndPointException;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query; import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery; import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
@ -49,7 +49,7 @@ public class DataCatalogueRunningCluster {
private final static String RUNTIME_CATALOGUE_RESOURCE_NAME = "CKanDataCatalogue"; private final static String RUNTIME_CATALOGUE_RESOURCE_NAME = "CKanDataCatalogue";
private final static String PLATFORM_CATALOGUE_NAME = "Tomcat"; private final static String PLATFORM_CATALOGUE_NAME = "Tomcat";
// api key property // api key property for SYSADMIN
private final static String API_KEY_PROPERTY = "API_KEY"; private final static String API_KEY_PROPERTY = "API_KEY";
// property to retrieve the master service endpoint into the /root scope // property to retrieve the master service endpoint into the /root scope
@ -58,7 +58,7 @@ public class DataCatalogueRunningCluster {
// url of the http uri for this scope // url of the http uri for this scope
private final static String URL_RESOLVER = "URL_RESOLVER"; private final static String URL_RESOLVER = "URL_RESOLVER";
// retrieved data // retrieved data
private List<String> datacatalogueUrls = new ArrayList<String>(); private List<String> datacatalogueUrls = new ArrayList<String>();
private List<String> hostsDB = new ArrayList<String>(); private List<String> hostsDB = new ArrayList<String>();
@ -87,198 +87,223 @@ public class DataCatalogueRunningCluster {
// set the scope // set the scope
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
logger.debug("Retrieving database information.");
List<ServiceEndpoint> resources = getConfigurationFromISFORDB(); List<ServiceEndpoint> resources = getConfigurationFromISFORDB();
evaluateRightConfigurationDB(resources);
if (resources.size() == 0){
throw new NoDataCatalogueRuntimeResourceException("There is no Runtime Resource having name " + RUNTIME_DB_RESOURCE_NAME +" and Platform " + PLATFORM_DB_NAME + " in this scope.");
}
else {
try{
if(resources.size() > 1){
boolean oneWasMaster = false;
logger.info("Too many Runtime Resource having name " + RUNTIME_DB_RESOURCE_NAME +" in this scope.. Looking for the one that has the property " + IS_MASTER_ROOT_KEY_PROPERTY);
for (ServiceEndpoint res : resources) {
Iterator<AccessPoint> accessPointIterator = res.profile().accessPoints().iterator();
while (accessPointIterator.hasNext()) {
ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator
.next();
// get the is master property
Property entry = accessPoint.propertyMap().get(IS_MASTER_ROOT_KEY_PROPERTY);
String isMaster = entry != null ? entry.value() : null;
if(isMaster == null || !isMaster.equals("true"))
continue;
// set this variable
oneWasMaster = true;
// add this host
hostsDB.add(accessPoint.address().split(":")[0]);
// save the port
int port = Integer.parseInt(accessPoint.address().split(":")[1]);
portsDB.add(port);
// save the name of the cluster (this should be unique)
nameDB = accessPoint.name();
// save user and password
passwordDB = StringEncrypter.getEncrypter().decrypt(accessPoint.password());
userDB = accessPoint.username();
// now break
break;
}
}
// if none of them was master, throw an exception
if(!oneWasMaster)
throw new NoApplicationProfileMasterException("There is no application profile with MASTER property");
}else{
logger.debug(resources.toString());
for (ServiceEndpoint res : resources) {
Iterator<AccessPoint> accessPointIterator = res.profile().accessPoints().iterator();
while (accessPointIterator.hasNext()) {
ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator
.next();
// add this host
hostsDB.add(accessPoint.address().split(":")[0]);
// save the port
int port = Integer.parseInt(accessPoint.address().split(":")[1]);
portsDB.add(port);
// save the name of the cluster (this should be unique)
nameDB = accessPoint.name();
// save user and password
passwordDB = StringEncrypter.getEncrypter().decrypt(accessPoint.password());
userDB = accessPoint.username();
}
}
}
}catch(Exception e ){
throw new ServiceEndPointException(e.toString());
}
}
logger.debug("Retrieving ckan data catalogue service end point information and sysadmin token."); logger.debug("Retrieving ckan data catalogue service end point information and sysadmin token.");
resources = getConfigurationFromISFORCatalogueUrl(); resources = getConfigurationFromISFORCatalogueUrl();
evaluateRightConfigurationCatalogue(resources);
if (resources.size() == 0){
logger.error("There is no Runtime Resource having name " + RUNTIME_CATALOGUE_RESOURCE_NAME +" and Platform " + PLATFORM_CATALOGUE_NAME + " in this scope.");
throw new NoDataCatalogueRuntimeResourceException();
}
else {
logger.debug(resources.toString());
try{
if(resources.size() > 1){
boolean oneWasMaster = false;
logger.info("Too many Runtime Resource having name " + RUNTIME_CATALOGUE_RESOURCE_NAME +" in this scope.. Looking for the one that has the property " + IS_MASTER_ROOT_KEY_PROPERTY);
for (ServiceEndpoint res : resources) {
Iterator<AccessPoint> accessPointIterator = res.profile().accessPoints().iterator();
while (accessPointIterator.hasNext()) {
ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator
.next();
// get the is master property
Property entry = accessPoint.propertyMap().get(IS_MASTER_ROOT_KEY_PROPERTY);
String isMaster = entry != null ? entry.value() : null;
if(isMaster == null || !isMaster.equals("true"))
continue;
// set this variable
oneWasMaster = true;
// add this host
datacatalogueUrls.add(accessPoint.address());
// retrieve sys admin token
sysAdminToken = accessPoint.propertyMap().get(API_KEY_PROPERTY).value();
sysAdminToken = StringEncrypter.getEncrypter().decrypt(sysAdminToken);
// retrieve URL_RESOLVER
if(accessPoint.propertyMap().containsKey(URL_RESOLVER))
urlResolver = accessPoint.propertyMap().get(URL_RESOLVER).value();
// break now
break;
}
}
// if none of them was master, throw an exception
if(!oneWasMaster)
throw new NoApplicationProfileMasterException("There is no application profile with MASTER property");
}else{
for (ServiceEndpoint res : resources) {
Iterator<AccessPoint> accessPointIterator = res.profile().accessPoints().iterator();
while (accessPointIterator.hasNext()) {
ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator
.next();
// add this host
datacatalogueUrls.add(accessPoint.address());
// retrieve sys admin token
sysAdminToken = accessPoint.propertyMap().get(API_KEY_PROPERTY).value();
sysAdminToken = StringEncrypter.getEncrypter().decrypt(sysAdminToken);
// get the is manage product property
Property entry = accessPoint.propertyMap().get(IS_MANAGE_PRODUCT_ENABLED);
String isManageProduct = entry != null ? entry.value() : null;
if(isManageProduct != null && isManageProduct.equals("true")){
logger.info("Manage product is enabled in this scope");
manageProductEnabled = true;
}
// retrieve URL_RESOLVER
if(accessPoint.propertyMap().containsKey(URL_RESOLVER))
urlResolver = accessPoint.propertyMap().get(URL_RESOLVER).value();
}
}
}
}catch(Exception e){
throw new ServiceEndPointException("There is no service end point for such information");
}
}
// finally get the url in which the ckan portlet is deployed // finally get the url in which the ckan portlet is deployed
logger.debug("Looking for portlet url in " + ScopeProvider.instance.get() + " scope" ); logger.debug("Looking for portlet url in " + ScopeProvider.instance.get() + " scope" );
portletUrl = getPortletUrlFromInfrastrucure(); portletUrl = getPortletUrlFromInfrastrucure();
}catch(Exception e) { }catch(Exception e) {
logger.warn("The following error occurred: " + e.toString()); logger.warn("The following error occurred: " + e.toString());
throw e;
}finally{ }finally{
ScopeProvider.instance.set(currentScope); ScopeProvider.instance.set(currentScope);
} }
} }
/**
* Evaluate the right configuration about ckan
* @param resources
* @throws NoDataCatalogueRuntimeResourceException
* @throws ServiceEndPointException
*/
private void evaluateRightConfigurationCatalogue(
List<ServiceEndpoint> resources) throws NoDataCatalogueRuntimeResourceException, ServiceEndPointException {
if (resources.size() == 0){
logger.error("There is no Runtime Resource having name " + RUNTIME_CATALOGUE_RESOURCE_NAME +" and Platform " + PLATFORM_CATALOGUE_NAME + " in this scope.");
throw new NoDataCatalogueRuntimeResourceException();
}
else {
logger.debug(resources.toString());
try{
if(resources.size() > 1){
boolean oneWasMaster = false;
logger.info("Too many Runtime Resource having name " + RUNTIME_CATALOGUE_RESOURCE_NAME +" in this scope.. Looking for the one that has the property " + IS_MASTER_ROOT_KEY_PROPERTY);
for (ServiceEndpoint res : resources) {
Iterator<AccessPoint> accessPointIterator = res.profile().accessPoints().iterator();
while (accessPointIterator.hasNext()) {
ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator
.next();
// get the is master property
Property entry = accessPoint.propertyMap().get(IS_MASTER_ROOT_KEY_PROPERTY);
String isMaster = entry != null ? entry.value() : null;
if(isMaster == null || !isMaster.equals("true"))
continue;
// set this variable
oneWasMaster = true;
// add this host
datacatalogueUrls.add(accessPoint.address());
// retrieve sys admin token
sysAdminToken = accessPoint.propertyMap().get(API_KEY_PROPERTY).value();
sysAdminToken = StringEncrypter.getEncrypter().decrypt(sysAdminToken);
// retrieve URL_RESOLVER
if(accessPoint.propertyMap().containsKey(URL_RESOLVER))
urlResolver = accessPoint.propertyMap().get(URL_RESOLVER).value();
// break now
break;
}
}
// if none of them was master, throw an exception
if(!oneWasMaster)
throw new NoApplicationProfileMasterException("There is no application profile with MASTER property");
}else{
ServiceEndpoint res = resources.get(0);
Iterator<AccessPoint> accessPointIterator = res.profile().accessPoints().iterator();
while (accessPointIterator.hasNext()) {
ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator
.next();
// add this host
datacatalogueUrls.add(accessPoint.address());
// retrieve sys admin token
sysAdminToken = accessPoint.propertyMap().get(API_KEY_PROPERTY).value();
sysAdminToken = StringEncrypter.getEncrypter().decrypt(sysAdminToken);
// get the is manage product property
Property entry = accessPoint.propertyMap().get(IS_MANAGE_PRODUCT_ENABLED);
String isManageProduct = entry != null ? entry.value() : null;
if(isManageProduct != null && isManageProduct.equals("true")){
logger.info("Manage product is enabled in this scope");
manageProductEnabled = true;
}
// retrieve URL_RESOLVER
if(accessPoint.propertyMap().containsKey(URL_RESOLVER))
urlResolver = accessPoint.propertyMap().get(URL_RESOLVER).value();
}
}
}catch(Exception e){
throw new ServiceEndPointException("There is no service end point for such information");
}
}
}
/**
* Retrieve the right DB information
* @param resources
* @throws ServiceEndPointException
* @throws NoDataCatalogueRuntimeResourceException
*/
private void evaluateRightConfigurationDB(List<ServiceEndpoint> resources) throws ServiceEndPointException, NoDataCatalogueRuntimeResourceException {
if (resources.size() == 0){
throw new NoDataCatalogueRuntimeResourceException("There is no Runtime Resource having name " + RUNTIME_DB_RESOURCE_NAME +" and Platform " + PLATFORM_DB_NAME + " in this scope.");
}
else {
try{
if(resources.size() > 1){
boolean oneWasMaster = false;
logger.info("Too many Runtime Resource having name " + RUNTIME_DB_RESOURCE_NAME +" in this scope.. Looking for the one that has the property " + IS_MASTER_ROOT_KEY_PROPERTY);
for (ServiceEndpoint res : resources) {
Iterator<AccessPoint> accessPointIterator = res.profile().accessPoints().iterator();
while (accessPointIterator.hasNext()) {
ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator
.next();
// get the is master property
Property entry = accessPoint.propertyMap().get(IS_MASTER_ROOT_KEY_PROPERTY);
String isMaster = entry != null ? entry.value() : null;
if(isMaster == null || !isMaster.equals("true"))
continue;
// set this variable
oneWasMaster = true;
// add this host
hostsDB.add(accessPoint.address().split(":")[0]);
// save the port
int port = Integer.parseInt(accessPoint.address().split(":")[1]);
portsDB.add(port);
// save the name of the cluster (this should be unique)
nameDB = accessPoint.name();
// save user and password
passwordDB = StringEncrypter.getEncrypter().decrypt(accessPoint.password());
userDB = accessPoint.username();
// now break
break;
}
}
// if none of them was master, throw an exception
if(!oneWasMaster)
throw new NoApplicationProfileMasterException("There is no application profile with MASTER property");
}else{
logger.debug(resources.toString());
ServiceEndpoint res = resources.get(0);
Iterator<AccessPoint> accessPointIterator = res.profile().accessPoints().iterator();
while (accessPointIterator.hasNext()) {
ServiceEndpoint.AccessPoint accessPoint = (ServiceEndpoint.AccessPoint) accessPointIterator
.next();
// add this host
hostsDB.add(accessPoint.address().split(":")[0]);
// save the port
int port = Integer.parseInt(accessPoint.address().split(":")[1]);
portsDB.add(port);
// save the name of the cluster (this should be unique)
nameDB = accessPoint.name();
// save user and password
passwordDB = StringEncrypter.getEncrypter().decrypt(accessPoint.password());
userDB = accessPoint.username();
}
}
}catch(Exception e ){
throw new ServiceEndPointException(e.toString());
}
}
}
/** /**
* Retrieve endpoints information from IS for DB * Retrieve endpoints information from IS for DB
* @return list of endpoints for ckan database * @return list of endpoints for ckan database
* @throws Exception * @throws Exception
*/ */
private List<ServiceEndpoint> getConfigurationFromISFORDB() throws Exception{ private static List<ServiceEndpoint> getConfigurationFromISFORDB() throws Exception{
SimpleQuery query = queryFor(ServiceEndpoint.class); SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_DB_RESOURCE_NAME +"'"); query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_DB_RESOURCE_NAME +"'");
@ -294,7 +319,7 @@ public class DataCatalogueRunningCluster {
* @return list of endpoints for ckan data catalogue * @return list of endpoints for ckan data catalogue
* @throws Exception * @throws Exception
*/ */
private List<ServiceEndpoint> getConfigurationFromISFORCatalogueUrl() throws Exception{ private static List<ServiceEndpoint> getConfigurationFromISFORCatalogueUrl() throws Exception{
SimpleQuery query = queryFor(ServiceEndpoint.class); SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_CATALOGUE_RESOURCE_NAME +"'"); query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_CATALOGUE_RESOURCE_NAME +"'");
@ -309,7 +334,7 @@ public class DataCatalogueRunningCluster {
* Retrieve the url of the ckan portlet deployed into this scope * Retrieve the url of the ckan portlet deployed into this scope
* @return * @return
*/ */
private String getPortletUrlFromInfrastrucure() { private static String getPortletUrlFromInfrastrucure() {
String scope = ScopeProvider.instance.get(); String scope = ScopeProvider.instance.get();
logger.debug("Trying to fetch applicationProfile profile from the infrastructure for " + APPLICATION_PROFILE_NAME + " scope: " + scope); logger.debug("Trying to fetch applicationProfile profile from the infrastructure for " + APPLICATION_PROFILE_NAME + " scope: " + scope);

View File

@ -110,5 +110,5 @@ public class UtilMethods {
throw new IllegalArgumentException("Key or scope null"); throw new IllegalArgumentException("Key or scope null");
return key.concat(scope); return key.concat(scope);
} }
} }

View File

@ -1,4 +1,4 @@
package org.gcube.datacatalogue.ckanutillibrary.server.models; package org.gcube.datacatalogue.ckanutillibrary.shared;
import java.io.Serializable; import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package org.gcube.datacatalogue.ckanutillibrary.server.models; package org.gcube.datacatalogue.ckanutillibrary.shared;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -1,4 +1,4 @@
package org.gcube.datacatalogue.ckanutillibrary.server.models; package org.gcube.datacatalogue.ckanutillibrary.shared;
/** /**
* Allowed relationships between packages(datasets). Some of them are not supported yet due to the problem * Allowed relationships between packages(datasets). Some of them are not supported yet due to the problem

View File

@ -1,4 +1,4 @@
package org.gcube.datacatalogue.ckanutillibrary.server.models; package org.gcube.datacatalogue.ckanutillibrary.shared;
import java.io.Serializable; import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package org.gcube.datacatalogue.ckanutillibrary.server.models; package org.gcube.datacatalogue.ckanutillibrary.shared;
/** /**
* The current state of this group/user * The current state of this group/user

View File

@ -1,4 +1,4 @@
package org.gcube.datacatalogue.ckanutillibrary.server.exceptions; package org.gcube.datacatalogue.ckanutillibrary.shared.ex;
@SuppressWarnings("serial") @SuppressWarnings("serial")
/** /**

View File

@ -1,4 +1,4 @@
package org.gcube.datacatalogue.ckanutillibrary.server.exceptions; package org.gcube.datacatalogue.ckanutillibrary.shared.ex;
/** /**
* Thrown when there are more than one application profile, but none of them was set as master * Thrown when there are more than one application profile, but none of them was set as master

View File

@ -1,4 +1,4 @@
package org.gcube.datacatalogue.ckanutillibrary.server.exceptions; package org.gcube.datacatalogue.ckanutillibrary.shared.ex;
/** /**
* No Data Catalogue node found. * No Data Catalogue node found.

View File

@ -1,4 +1,4 @@
package org.gcube.datacatalogue.ckanutillibrary.server.exceptions; package org.gcube.datacatalogue.ckanutillibrary.shared.ex;
/** /**
* Exception thrown when it is not possible retrieve information from the ServiceEndpoint * Exception thrown when it is not possible retrieve information from the ServiceEndpoint

View File

@ -1,4 +1,4 @@
package org.gcube.datacatalogue.ckanutillibrary.server.exceptions; package org.gcube.datacatalogue.ckanutillibrary.shared.ex;
/** /**
* Too many clusters in this scope exception. * Too many clusters in this scope exception.

View File

@ -10,10 +10,10 @@ import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datacatalogue.ckanutillibrary.server.models.CKanUserWrapper;
import org.gcube.datacatalogue.ckanutillibrary.server.models.CkanDatasetRelationship;
import org.gcube.datacatalogue.ckanutillibrary.server.models.DatasetRelationships;
import org.gcube.datacatalogue.ckanutillibrary.server.utils.UtilMethods; import org.gcube.datacatalogue.ckanutillibrary.server.utils.UtilMethods;
import org.gcube.datacatalogue.ckanutillibrary.shared.CKanUserWrapper;
import org.gcube.datacatalogue.ckanutillibrary.shared.CkanDatasetRelationship;
import org.gcube.datacatalogue.ckanutillibrary.shared.DatasetRelationships;
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg; import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;