Catmandu-FedoraCommons - Perl interface to Fedora Commons using the REST-based API-A,API-M
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-

High-Level
-=-=-=-=-=

 use Catmandu::Store::FedoraCommons;

 # Create a default FedoraCommons store with a Dublin Core model
 my $store = Catmandu::Store::FedoraCommons->new(
                baseurl  => 'http://localhost:8080/fedora' ,
                username => 'fedoraAdmin' ,
                password => 'fedoraAdmin' ,
                model => 'Catmandu::Store::FedoraCommons::DC' );

 my $obj = { title => [ 'My Title' ] , creator => [ 'Patrick'] };

 $store->bag->add($obj);

 $store->bag->each(sub {
	my $obj = $_[0];
	my $pid = $obj->{_id};
	
	printf "Title: %s\n" , $obj->{title}->[0];
	
	my $ds = $store->fedora->listDatastreams(pid => $pid);
	
	for (@{ $ds->{datastream} }) {
	    printf " %s\n" , $_->{dsid};
	}
 });

Low-Level
-=-=-=-=-=
 use Catmandu::FedoraCommons;
 
 my $fedora = Catmandu::FedoraCommons->new('http://localhost:8080/fedora','fedoraAdmin','fedoraAdmin');

 my $result = $fedora->findObjects(terms=>'*');

 die "error" unless $result->is_ok;

 my $hits = $res->parse_content;

 for my $hit (@{ $hits }) {
    printf "%s\n" , $hit->{pid};
 }

 my $result = $fedora->listDatastreams(pid => 'demo:29')->parse_content;

 $fedora->addDatastream(
                pid => 'demo:29', 
                dsID => 'TEST' , 
                file => 't/marc.xml',
                mimeType => 'text/xml' , 
                controlGroup => 'X');
