Continuing on working on the Item handlers
authorChris Cormack <chrisc@catalyst.net.nz>
Mon, 30 Sep 2013 00:43:02 +0000 (13:43 +1300)
committerChris Cormack <chrisc@catalyst.net.nz>
Mon, 30 Sep 2013 00:43:02 +0000 (13:43 +1300)
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
lib/NCIP.pm
lib/NCIP/Handler.pm
lib/NCIP/Handler/LookupItem.pm

index 86c7328..75f9e68 100644 (file)
@@ -5,7 +5,7 @@ use Modern::Perl;
 use XML::LibXML;
 use Try::Tiny;
 
-use Object::Tiny qw{xmldoc config};
+use Object::Tiny qw{xmldoc config namespace};
 
 our $VERSION = '0.01';
 our $nsURI   = 'http://www.niso.org/2008/ncip';
@@ -29,7 +29,8 @@ sub new {
     my $config_dir = shift;
     my $self       = {};
     my $config     = NCIP::Configuration->new($config_dir);
-    $self->{config} = $config;
+    $self->{config}    = $config;
+    $self->{namespace} = $nsURI;
     return bless $self, $class;
 
 }
@@ -53,7 +54,7 @@ sub process_request {
 
         #bail out for now
     }
-    my $handler = NCIP::Handler->new($request_type);
+    my $handler = NCIP::Handler->new( $self->namespace(), $request_type );
     return $handler->handle( $self->xmldoc );
 }
 
index 4fda628..fc179eb 100644 (file)
@@ -17,16 +17,16 @@ package NCIP::Handler;
 #===============================================================================
 
 use Modern::Perl;
-use Object::Tiny qw{ type };
+use Object::Tiny qw{ type namespace };
 
 use NCIP::Handler::LookupItem;
 
 sub new {
-    my $class    = shift;
-    my $type     = shift;
-    my $xmldoc   = shift;
-    my $subclass = __PACKAGE__ . "::" . $type;
-    my $self     = bless { type => $type }, $subclass;
+    my $class     = shift;
+    my $namespace = shift;
+    my $type      = shift;
+    my $subclass  = __PACKAGE__ . "::" . $type;
+    my $self      = bless { type => $type, namspace => $namespace }, $subclass;
     return $self;
 }
 
index 6629da6..fd51551 100644 (file)
@@ -20,13 +20,17 @@ package NCIP::Handler::LookupItem;
 use Modern::Perl;
 
 use NCIP::Handler;
+use NCIP::Item;
+
 our @ISA = qw(NCIP::Handler);
 
 sub handle {
     my $self   = shift;
     my $xmldoc = shift;
     if ($xmldoc) {
-        # my ($item_id) = $dom->getElementsByTagNameNS( $nsURI, 'ItemId' );
+        my ($item_id) =
+          $xmldoc->getElementsByTagNameNS( $self->namespace(), 'ItemId' );
+        my $item = NCIP::Item->new( { itemid => $item_id } );
     }
     return $self->type;
 }