Skip to content

andmar8/CKAN-Java-Client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CKANClient-J

A (very much) work in progress

Provides an interface to a CKAN 1.8+ installation and is concentrating on the version 3 API

Dependencies

I'm currently building against (but other versions may work):

Using the code

Very simple example to connect to datahub, search for datasets and then get details for a given dataset with (optional) debugging on (debugging will show you what is returned on the HTTP response)

        org.ckan.Client client = new org.ckan.Client(new org.ckan.Connection("http://datahub.io"),"YOUR_API_KEY");

        Dataset ds = null;
        DatasetSearchResult sr = null;
        try
        {
            sr = client.searchDatasets("test-dataset");
        }
        catch(Exception cke)
        {
            System.out.println(cke);
        }
        DatasetSearchList dsl = sr.result;
        List results = dsl.results;
        Iterator iterator = results.iterator();
        while(iterator.hasNext())
        {
            ds = iterator.next();
            System.out.println(ds);
        }

        try
        {
            ds = client.debugThis().getDataset("test-dataset");
        }
        catch(CKANException cke)
        {
            System.out.println(cke);
        }
        System.out.println(ds);

If the debug output is a bit too garbled for your liking, try copying and pasting into this which makes reading the response a lot easier

ACTIONS API

Methods currently implemented (some more thoroughly than others... at the moment):

(WIP = Work In Progress)

  • createDataset
  • createGroup
  • createMember
  • createRelated - WIP
  • deleteDataset
  • deleteGroup
  • deleteRelated -
  • deleteTaskStatus -
  • deleteVocabulary -
  • --findDatasets-- -> replaced by searchDatasets
  • followDataset
  • followUser
  • getActivityDetailList
  • getAmFollowingDataset
  • getAmFollowingUser
  • getCurrentPackageListWithResources
  • getDashboardActivityList
  • getDashboardActivityListHTML
  • getDataset
  • getDatasetFolloweeCount
  • getDatasetFolloweeList
  • getDatasetFollowerCount
  • getDatasetFollowerList
  • getFormatAutoComplete
  • getGroup
  • getGroupActivityList
  • getGroupActivityListHTML
  • getGroupList - WIP
  • getGroupListAuthz
  • getGroupPackages
  • getGroupRevisions
  • getLicenceList
  • getMemberList - WIP
  • getPackageActivityList
  • getPackageRelationships - WIP
  • getPackageRevisions
  • getResource
  • getResourceStatus
  • getRevision
  • getRevisionList
  • getRolesList - WIP
  • getUser
  • getUserActivityList
  • getUserActivityListHTML
  • getUserAutocomplete
  • getUserFollowerCount
  • getUserFollowerList
  • getUserList
  • getVocabulary - WIP
  • getVocabularyList - WIP
  • searchDatasets - WIP
  • unfollowDataset
  • unfollowUser
  • updateDataset

Notes to self:

  • Add factory/ies for results... and maybe for requests too?
  • Add param objects or keep overloaded methods?
  • Refactor code again once the API methods are complete
  • Some people are prob not gonna like Allman braces/indenting in java
  • Look at the 301 issue

About

Java client library for interacting with CKAN

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%