2 use NCIP::Configuration;
7 use base qw(Class::Accessor);
18 my $nicp = NCIP->new($config_dir);
26 my $class = ref $proto || $proto;
27 my $config_dir = shift;
29 my $config = NCIP::Configuration->new($config_dir);
30 $self->{config} = $config;
31 return bless $self, $class;
35 =head2 process_request()
37 my $response = $ncip->process_request($xml);
45 my $request_type = $self->handle_initiation($xml);
46 unless ($request_type) {
48 # We have invalid xml, or we can't figure out what kind of request this is
52 #my $response = "<HTML> <HEAD> <TITLE>Hello There</TITLE> </HEAD> <BODY> <H1>Hello You Big JERK!</H1> Who would take this book seriously if the first eaxample didn't say \"hello world\"? </BODY> </HTML>";
58 =head2 handle_initiation
62 sub handle_initiation {
67 $dom = XML::LibXML->load_xml( string => $xml );
70 warn "Invalid xml, caught error: $_";
74 # should check validity with validate at this point
75 my $request_type = $self->parse_request($dom);
85 # this should perhaps be in it's own module
88 my $validity = $dom->is_valid();
90 # we could validate against the dtd here, might be good?
91 # my $dtd = XML::LibXML::Dtd->parse_string($dtd_str);
92 # my $validity = $dom->is_valid($dtd);
93 # perhaps we could check the ncip version and validate that too
100 my $nodes = $dom->findnodes('/*');
101 if ( $nodes->[0]->nodeName() ne 'ns1:NCIPMessage' ) {
103 # we don't have a valid ncip message
108 my @childnodes = $nodes->[0]->childNodes();
110 # the second child should be the type of request
111 if ( $childnodes[1] && $childnodes[1]->nodeName =~ /ns1\:(.*)/ ) {
115 # just while developing return not found
116 return ('Not_found');