Tidying up output, removing blank lines
authorChris Cormack <chrisc@catalyst.net.nz>
Thu, 2 Jan 2014 22:04:01 +0000 (11:04 +1300)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 2 Jan 2014 22:04:01 +0000 (11:04 +1300)
lib/NCIP/Handler.pm
lib/NCIP/Handler/LookupUser.pm
templates/includes/LookupUserResponse.inc

index bf1d7c7..713967c 100644 (file)
@@ -41,7 +41,11 @@ sub render_output {
 
     my $vars     = shift;
     my $template = Template->new(
-        { INCLUDE_PATH => $self->templates, } );
+        {
+            INCLUDE_PATH => $self->templates,
+            POST_CHOMP   => 1
+        }
+    );
     my $output;
     $template->process( $templatename, $vars, \$output );
     return $output;
index d766122..891eedb 100644 (file)
@@ -36,8 +36,13 @@ sub handle {
         my $user = NCIP::User->new(
             { userid => $user_id->textContent(), ils => $self->ils } );
         $user->initialise();
-        my $root = $xmldoc->documentElement();
+
+        # if we have blank user, we need to return that
+        # and can skip looking for elementtypes
+
+        my $root     = $xmldoc->documentElement();
         my @elements = $root->findnodes('LookupUser/UserElementType/Value');
+
         #set up the variables for our template
         my $vars;
         $vars->{'messagetype'} = 'LookupUserResponse';
index ec03c40..f6ce676 100644 (file)
@@ -1,3 +1,17 @@
+<UserOptionalFields>
 [% FOREACH element IN elements %]
-  [% element.textContent %]
+  [% IF element.textContent == 'User Address Information' %]
+    
+  [% END %]
+  [% IF element.textContent == 'Name Information' %]
+    <NameInformation>
+      <PersonalNameInformation>
+        <StructuredPersonalUserName>
+          <GivenName>[% user.userdata.firstname %]</GivenName>
+          <Surname>[% user.userdata.surname %]</Surname>
+        </StructuredPersonalUserName>
+      </PersonalNameInformation>
+    </NameInformation>
+  [% END %]
 [% END %]
+</UserOptionalFields/>