201 lines
5.5 KiB
Java
201 lines
5.5 KiB
Java
package org.gcube.datacatalogue.ckanutillibrary.server;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
|
|
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
|
|
|
import eu.trentorise.opendata.jackan.model.CkanDataset;
|
|
import eu.trentorise.opendata.jackan.model.CkanGroup;
|
|
import eu.trentorise.opendata.jackan.model.CkanLicense;
|
|
import eu.trentorise.opendata.jackan.model.CkanOrganization;
|
|
|
|
public interface DataCatalogue {
|
|
|
|
/**
|
|
* Finds the id associated to the chosen license
|
|
*
|
|
* @param chosenLicense
|
|
* @return the id on success, null otherwise
|
|
*/
|
|
String findLicenseIdByLicenseTitle(String chosenLicense);
|
|
|
|
/**
|
|
* 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. Information are not
|
|
* encrypted.
|
|
*
|
|
* @param datasetId
|
|
* @return The url of the dataset on success, null otherwise
|
|
*/
|
|
String getUnencryptedUrlFromDatasetIdOrName(String datasetIdOrName);
|
|
|
|
/**
|
|
* Create a dataset with those information. The method allows to have multiple
|
|
* values for the same custom field key. NOTE: unfortunately java doesn't
|
|
* support overload in java interface methods (that's way I cannot use the same
|
|
* name for the method)
|
|
*
|
|
* @param title
|
|
* @param name (unique identifier)
|
|
* @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: Admin role is needed)
|
|
* @return the id of the dataset on success, null otherwise
|
|
* @throws Exception
|
|
*/
|
|
String createCKanDatasetMultipleCustomFields(String title, String name, String organizationNameOrId, String author,
|
|
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) throws Exception;
|
|
|
|
/**
|
|
* Patch a product with product id productId by using the couples in
|
|
* customFieldsToChange. NOTE: only the specified custom fields will be changed.
|
|
* If a custom field with a given key already exists, and removeOld is set to
|
|
* false, the new values are added at the end of the list. Otherwise they are
|
|
* lost.
|
|
*
|
|
* @param productId
|
|
* @param customFieldsToChange
|
|
* @param removeOld
|
|
* @return
|
|
*/
|
|
boolean patchProductCustomFields(String productId, Map<String, List<String>> customFieldsToChange,
|
|
boolean removeOld);
|
|
|
|
/**
|
|
* 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
|
|
*/
|
|
String addResourceToDataset(ResourceBean resource) throws Exception;
|
|
|
|
/**
|
|
* Remove the resource with id resourceId from the dataset in which it is.
|
|
*
|
|
* @param resourceId
|
|
* @return true on success, false otherwise.
|
|
*/
|
|
boolean deleteResourceFromDataset(String resourceId);
|
|
|
|
/**
|
|
* Create a dataset with those information.
|
|
*
|
|
* @param apiKey
|
|
* @param title
|
|
* @param name (unique identifier)
|
|
* @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: Admin role is needed)
|
|
* @return the id of the dataset on success, null otherwise
|
|
* @throws Exception
|
|
*/
|
|
|
|
/**
|
|
* Checks if a product with such name already exists. Please remember that the
|
|
* name is unique.
|
|
*
|
|
* @param nameOrId the name or the id of the dataset to check
|
|
* @return
|
|
*/
|
|
boolean existProductWithNameOrId(String nameOrId);
|
|
|
|
/**
|
|
* 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 apiKey
|
|
* @return
|
|
*/
|
|
Map<String, Map<CkanGroup, RolesCkanGroupOrOrg>> getUserRoleByGroup(String username, String apiKey);
|
|
|
|
/**
|
|
* Get the list of licenses' titles.
|
|
*
|
|
* @return the list of licenses' titles
|
|
*/
|
|
List<String> getLicenseTitles();
|
|
|
|
/**
|
|
* Retrieve ckan licenses
|
|
*
|
|
* @return
|
|
*/
|
|
List<CkanLicense> getLicenses();
|
|
|
|
/**
|
|
* Retrieve the url of the uri resolver for this catalogue instance/scope
|
|
*
|
|
* @return
|
|
*/
|
|
String getUriResolverUrl();
|
|
|
|
/**
|
|
* Return the manage product property
|
|
*
|
|
* @return the manage product property
|
|
*/
|
|
boolean isManageProductEnabled();
|
|
|
|
/**
|
|
* Return the catalogue portlet for this context(i.e. scope)
|
|
*
|
|
* @return
|
|
*/
|
|
String getPortletUrl();
|
|
|
|
/**
|
|
* Return the ckan catalogue url in this scope.
|
|
*
|
|
* @return the catalogue url
|
|
*/
|
|
String getCatalogueUrl();
|
|
|
|
|
|
/**
|
|
* Returns the list of organizations to whom the user belongs (with any role)
|
|
* @param username
|
|
* @return a list of organizations
|
|
*/
|
|
List<CkanOrganization> getOrganizationsByUser(String username);
|
|
|
|
/**
|
|
* Returns the list of groups to whom the user belongs (with any role)
|
|
* @param username
|
|
* @return a list of groups
|
|
*/
|
|
List<CkanGroup> getGroupsByUser(String username);
|
|
|
|
/**
|
|
* Retrieve a ckan dataset given its id
|
|
* @param datasetId
|
|
* @return
|
|
*/
|
|
CkanDataset getDataset(String datasetId, String apiKey);
|
|
|
|
}
|