From 306abaa8bafcd31a1a29fe903427bb135fd68953 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Mon, 30 Sep 2013 13:43:02 +1300 Subject: [PATCH] Continuing on working on the Item handlers Signed-off-by: Chris Cormack --- lib/NCIP.pm | 7 ++++--- lib/NCIP/Handler.pm | 12 ++++++------ lib/NCIP/Handler/LookupItem.pm | 6 +++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/NCIP.pm b/lib/NCIP.pm index 86c7328..75f9e68 100644 --- a/lib/NCIP.pm +++ b/lib/NCIP.pm @@ -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 ); } diff --git a/lib/NCIP/Handler.pm b/lib/NCIP/Handler.pm index 4fda628..fc179eb 100644 --- a/lib/NCIP/Handler.pm +++ b/lib/NCIP/Handler.pm @@ -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; } diff --git a/lib/NCIP/Handler/LookupItem.pm b/lib/NCIP/Handler/LookupItem.pm index 6629da6..fd51551 100644 --- a/lib/NCIP/Handler/LookupItem.pm +++ b/lib/NCIP/Handler/LookupItem.pm @@ -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; } -- 2.43.2