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; return userId;
} }
/** @Override
* Retrieve the list of organizations ids public List<String> getOrganizationsIds(){
* @return
*/
private List<String> getOrganizationsIds(){
List<String> toReturn = new ArrayList<String>(); List<String> toReturn = new ArrayList<String>();
CkanClient client = new CkanClient(CKAN_CATALOGUE_URL); CkanClient client = new CkanClient(CKAN_CATALOGUE_URL);
@ -313,6 +310,21 @@ public class CKanUtilsImpl implements CKanUtilsInterface{
return toReturn; 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 @Override
public String getCatalogueUrl() { public String getCatalogueUrl() {
return CKAN_CATALOGUE_URL; return CKAN_CATALOGUE_URL;

View File

@ -64,6 +64,18 @@ public interface CKanUtilsInterface {
*/ */
public List<String> getLicenseTitles(); 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 * Finds the id associated to the chosen license
* @param chosenLicense * @param chosenLicense