Index: src/perl/register-dataset.cgi
===================================================================
--- src/perl/register-dataset.cgi	(revision 3597)
+++ src/perl/register-dataset.cgi	(revision 3598)
@@ -1212,8 +1212,8 @@
     # putting everything else under project
     $doc .= "<project>";
     $doc .= titleElement();
-    my %originators = personnelCreate();
-    $doc .= personnelList(\%originators, 'personnel');
+    my %originators = personnelCreate('personnel');
+    $doc .= personnelList(\%originators);
     $doc .= abstractElement();
     $doc .= "<studyAreaDescription>\n";
     $doc .= coverageElement();
@@ -1231,8 +1231,8 @@
     $doc .= titleElement();
     $doc .= creatorElement();
     $doc .= contactElement('creator');
-    my %originators = personnelCreate();
-    $doc .= personnelList(\%originators, 'associatedParty');
+    my %originators = personnelCreate('associatedParty');
+    $doc .= personnelList(\%originators);
 
     $doc .= pubElement();
     $doc .= abstractElement();
@@ -1253,13 +1253,23 @@
 # EML document creation functions
 
 sub personnelCreate {
-    # TODO: improve flow for personnel, associatedParty
+    # passed parameter defines default role for individuals
+    my $defaultRole = shift;
     # element name => objects of that type
     my %orig = (
-                'personnel'          => [],
+                'creator'          => [],
+                'metadataProvider' => [],
+                'publisher'        => [],
+                $defaultRole       => [],
             );
+    # form name => EML element name
+    my %roles = (
+                 'Originator'        => 'creator',
+                 'Metadata Provider' => 'metadataProvider',
+                 'Publisher'         => 'publisher',
+              );
 
-    push (@{$orig{personnel}}, [$FORM::providerGivenName, $FORM::providerSurName, 'Metadata Provider']);
+    push (@{$orig{'metadataProvider'}}, [$FORM::providerGivenName, $FORM::providerSurName]);
 
     # Additional originators
     foreach my $origName (param()) {
@@ -1271,50 +1281,45 @@
                 my $first = normalize(param("origNamefirst" . $origNum));
                 my $last  = normalize(param("origNamelast" . $origNum));
                 my $origRole = param("origRole" . $origNum);
+                my $roleName = $roles{$origRole};
+                if (!hasContent($roleName)) {
+                  $roleName = $defaultRole;
+                }
 
-                push (@{$orig{personnel}}, [$first, $last, $origRole]);
+                #debug("XXXXX role name: " . $roleName);
+                push (@{$orig{$roleName}}, [$first, $last, $origRole]);
             }
         }
     }
-    return %orig
+    return %orig;
 }
 
 sub personnelList {
     my ($orig, $type) = @_;
     my %orig = %$orig;
-
+    
     my $elemList = "";
-    
-    foreach my $v (@{$orig->{'personnel'}}) {
-        my ($first, $last, $role) = @$v;
-        my $elemRole = $type;
-        my $elem = "<individualName>\n";
-        $elem .= "<givenName>".normalize($first)."</givenName>\n";
-        $elem .= "<surName>".normalize($last)."</surName>\n";
-        $elem .= "</individualName>\n";
+    foreach my $role (keys %orig) {
+        foreach my $v (@{$orig->{$role}}) {
+            my ($first, $last, $origRole) = @$v;
+            my $elem = "<individualName>\n";
+            $elem .= "<givenName>".normalize($first)."</givenName>\n";
+            $elem .= "<surName>".normalize($last)."</surName>\n";
+            $elem .= "</individualName>\n";
 
-        if ($role eq "Originator") {
-            $elemRole = 'creator';
-        }
-        elsif ($role eq "Metadata Provider") {
-            $elemRole = 'metadataProvider';
-        }
-        elsif ($role eq "Publisher") {
-            $elemRole = 'publisher';
-        }
-        else {
-            $elemRole = $type;
-        }
+            if (($role eq 'personnel') && ($FORM::origNameOrgContact)) {
+                $elem .= "<organizationName>$FORM::origNameOrgContact</organizationName>\n";
+            }
 
-        if (($elemRole eq 'personnel') && ($FORM::origNameOrgContact) ) {
-            $elem .= "<organizationName>$FORM::origNameOrgContact</organizationName>\n";
+            if (($role eq 'personnel') || ($role eq 'associatedParty')) {
+                my $roleElem = $role;
+                if (hasContent($origRole)) {
+                    $roleElem = $origRole;
+                }
+                $elem .= "<role>".normalize($roleElem)."</role>\n";
+            }
+            $elemList .= "<$role>$elem</$role>\n";
         }
-
-        if (($elemRole eq 'personnel') || ($elemRole eq 'associatedParty') ) {
-            $elem .= "<role>".normalize($role)."</role>\n";
-        }
-
-        $elemList .= "<$elemRole>\n$elem</$elemRole>\n";
     }
     return $elemList;
 }
@@ -1362,7 +1367,7 @@
     while ( my ($docid, $data) = each(%entityObjects) ) {
         my $accessStub = qq|<additionalMetadata>
             <describes>$data->{'distribid'}</describes>
-                <access authSystem="knb" order="allowFirst">
+                <access authSystem="knb" order="denyFirst">
                     $skinAccess
                     $userAccess 
                     <deny>
