2016-06-07 16:00:05 +02:00
|
|
|
package org.gcube.datacatalogue.ckanutillibrary;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import org.gcube.datacatalogue.ckanutillibrary.models.CKanUserWrapper;
|
|
|
|
import org.gcube.datacatalogue.ckanutillibrary.models.ROLES_IN_ORGANIZATION;
|
2016-06-14 12:31:19 +02:00
|
|
|
import org.gcube.datacatalogue.ckanutillibrary.models.ResourceBean;
|
2016-06-07 16:00:05 +02:00
|
|
|
|
|
|
|
import eu.trentorise.opendata.jackan.model.CkanOrganization;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the ckan-util-library interface that shows the utility methods.
|
|
|
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
|
|
|
*/
|
|
|
|
public interface CKanUtilsInterface {
|
2016-06-10 16:26:01 +02:00
|
|
|
|
2016-06-07 16:00:05 +02:00
|
|
|
/**
|
|
|
|
* Retrieve the API_KEY given the username .
|
|
|
|
* @param username
|
|
|
|
* @return an API_KEY string
|
|
|
|
*/
|
|
|
|
public String getApiKeyFromUser(String username);
|
2016-06-10 16:26:01 +02:00
|
|
|
|
2016-06-07 16:00:05 +02:00
|
|
|
/**
|
|
|
|
* Retrieve the user given the API_KEY (the user is retrieved if it is active).
|
|
|
|
* @param username
|
|
|
|
* @return an API_KEY string
|
|
|
|
*/
|
|
|
|
public CKanUserWrapper getUserFromApiKey(String apiKey);
|
2016-06-10 16:26:01 +02:00
|
|
|
|
2016-06-07 16:00:05 +02:00
|
|
|
/**
|
|
|
|
* Returns the list of organizations to whom the user belongs.
|
|
|
|
* @param username
|
|
|
|
* @return a list of organizations
|
|
|
|
*/
|
|
|
|
public List<CkanOrganization> getOrganizationsByUser(String username);
|
2016-06-10 16:26:01 +02:00
|
|
|
|
2016-06-07 16:00:05 +02:00
|
|
|
/**
|
|
|
|
* Returns the list of organizations' names to whom the user belongs.
|
|
|
|
* @param username
|
|
|
|
* @return a list of organizations
|
|
|
|
*/
|
|
|
|
public List<String> getOrganizationsNamesByUser(String username);
|
2016-06-10 16:26:01 +02:00
|
|
|
|
2016-06-07 16:00:05 +02:00
|
|
|
/**
|
|
|
|
* Given a username and a list of roles to be matched, find the organizations to who the user
|
|
|
|
* belongs and the role(s) he has in them.
|
|
|
|
* @param username
|
|
|
|
* @param rolesToMatch
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public Map<String, List<ROLES_IN_ORGANIZATION>> getGroupsAndRolesByUser(String username, List<ROLES_IN_ORGANIZATION> rolesToMatch);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the ckan catalogue url in this scope.
|
2016-06-08 18:31:25 +02:00
|
|
|
* @return the catalogue url or exception if not found
|
2016-06-07 16:00:05 +02:00
|
|
|
*/
|
|
|
|
public String getCatalogueUrl();
|
2016-06-10 16:26:01 +02:00
|
|
|
|
2016-06-10 14:15:38 +02:00
|
|
|
/**
|
|
|
|
* Return the url of the database
|
|
|
|
*/
|
|
|
|
public String getCKANDBUrl();
|
2016-06-10 16:26:01 +02:00
|
|
|
|
2016-06-07 16:00:05 +02:00
|
|
|
/**
|
|
|
|
* Get the list of licenses' titles.
|
2016-06-08 18:31:25 +02:00
|
|
|
* @return the list of licenses' titles
|
2016-06-07 16:00:05 +02:00
|
|
|
*/
|
|
|
|
public List<String> getLicenseTitles();
|
2016-06-10 16:26:01 +02:00
|
|
|
|
2016-06-07 16:00:05 +02:00
|
|
|
/**
|
|
|
|
* Finds the id associated to the chosen license
|
|
|
|
* @param chosenLicense
|
2016-06-08 18:31:25 +02:00
|
|
|
* @return the id on success, null otherwise
|
2016-06-07 16:00:05 +02:00
|
|
|
*/
|
|
|
|
public String findLicenseIdByLicense(String chosenLicense);
|
2016-06-10 16:26:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set dataset private
|
|
|
|
* @param priv
|
|
|
|
* @param organizationId
|
|
|
|
* @param datasetId
|
|
|
|
* @param owner
|
|
|
|
* @return true on success, false otherwise
|
|
|
|
*/
|
|
|
|
public boolean setDatasetPrivate(boolean priv, String organizationId, String datasetId, String owner);
|
|
|
|
|
2016-06-14 12:31:19 +02:00
|
|
|
/**
|
|
|
|
* Add a resource described by the bean to the dataset id into resource.datasetId
|
|
|
|
* @param resource
|
|
|
|
* @return String the id of the resource on success, null otherwise
|
|
|
|
*/
|
|
|
|
public String addResourceToDataset(ResourceBean resource);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the resource with id resourceId from the dataset in which it is.
|
|
|
|
* @param username
|
|
|
|
* @param resourceId
|
|
|
|
* @return true on success, false otherwise.
|
|
|
|
*/
|
|
|
|
public boolean deleteResourceFromDataset(String username, String resourceId);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a dataset with those information.
|
|
|
|
* @param username
|
|
|
|
* @param withId
|
|
|
|
* @param title
|
|
|
|
* @param organizationNameOrId
|
|
|
|
* @param author
|
|
|
|
* @param authorMail
|
|
|
|
* @param maintainer
|
|
|
|
* @param maintainerMail
|
|
|
|
* @param version
|
|
|
|
* @param description
|
|
|
|
* @param licenseId
|
|
|
|
* @param tags
|
|
|
|
* @param customFields
|
|
|
|
* @param resources
|
|
|
|
* @param setPublic (manage visibility)
|
|
|
|
* @return the id of the dataset on success, null otherwise
|
|
|
|
*/
|
|
|
|
public String createCKanDataset(String username, String withId, String title, String organizationNameOrId, String author,
|
|
|
|
String authorMail, String maintainer, String maintainerMail, long version, String description, String licenseId,
|
|
|
|
List<String> tags, Map<String, String> customFields, List<ResourceBean> resources, boolean setPublic);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given the id or the name of the dataset it returns its current url (e.g., http://ckan-catalogue-address.org/dataset/dataset-name)
|
|
|
|
* @param username
|
|
|
|
* @param datasetId
|
|
|
|
* @return The url of the dataset on success, null otherwise
|
|
|
|
*/
|
|
|
|
public String getUrlFromDatasetIdOrName(String username, String datasetIdOrName);
|
2016-06-07 16:00:05 +02:00
|
|
|
}
|