ckan-util-library/src/main/java/org/gcube/datacatalogue/ckanutillibrary/CKanUtilsInterface.java

135 lines
4.0 KiB
Java
Raw Normal View History

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;
import org.gcube.datacatalogue.ckanutillibrary.models.ResourceBean;
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 {
/**
* Retrieve the API_KEY given the username .
* @param username
* @return an API_KEY string
*/
public String getApiKeyFromUser(String username);
/**
* 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);
/**
* Returns the list of organizations to whom the user belongs.
* @param username
* @return a list of organizations
*/
public List<CkanOrganization> getOrganizationsByUser(String username);
/**
* Returns the list of organizations' names to whom the user belongs.
* @param username
* @return a list of organizations
*/
public List<String> getOrganizationsNamesByUser(String username);
/**
* 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.
* @return the catalogue url or exception if not found
*/
public String getCatalogueUrl();
/**
* Return the url of the database
*/
public String getCKANDBUrl();
/**
* Get the list of licenses' titles.
* @return the list of licenses' titles
*/
public List<String> getLicenseTitles();
/**
* Finds the id associated to the chosen license
* @param chosenLicense
* @return the id on success, null otherwise
*/
public String findLicenseIdByLicense(String chosenLicense);
/**
* 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);
/**
* 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);
}