Added a method to retrieve all organizations' names

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@129155 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-06-18 08:12:47 +00:00
parent 9ea6242cf0
commit 3a2ab0b8c1
2 changed files with 29 additions and 5 deletions

View File

@ -295,11 +295,8 @@ public class CKanUtilsImpl implements CKanUtilsInterface{
return userId;
}
/**
* Retrieve the list of organizations ids
* @return
*/
private List<String> getOrganizationsIds(){
@Override
public List<String> getOrganizationsIds(){
List<String> toReturn = new ArrayList<String>();
CkanClient client = new CkanClient(CKAN_CATALOGUE_URL);
@ -312,6 +309,21 @@ public class CKanUtilsImpl implements CKanUtilsInterface{
return toReturn;
}
@Override
public List<String> getOrganizationsNames(){
List<String> toReturn = new ArrayList<String>();
CkanClient client = new CkanClient(CKAN_CATALOGUE_URL);
List<CkanOrganization> orgs = client.getOrganizationList();
for (CkanOrganization ckanOrganization : orgs) {
logger.debug("Retrieved org " + ckanOrganization.getName());
toReturn.add(ckanOrganization.getName());
}
return toReturn;
}
@Override
public String getCatalogueUrl() {

View File

@ -63,6 +63,18 @@ public interface CKanUtilsInterface {
* @return the list of licenses' titles
*/
public List<String> getLicenseTitles();
/**
* Retrieve the list of organizations ids
* @return
*/
public List<String> getOrganizationsIds();
/**
* Retrieve the list of organizations names
* @return
*/
public List<String> getOrganizationsNames();
/**
* Finds the id associated to the chosen license