You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by ar...@apache.org on 2017/03/30 22:33:53 UTC

svn commit: r1789595 - in /vcl/trunk/managementnode/lib/VCL: DataStructure.pm utils.pm

Author: arkurth
Date: Thu Mar 30 22:33:53 2017
New Revision: 1789595

URL: http://svn.apache.org/viewvc?rev=1789595&view=rev
Log:
VCL-1030
Added explicit subroutines to DataStructure.pm:
get_user_affiliation_sitewwwaddress
get_user_affiliation_helpaddress

These get the values for the Global affiliation if not defined for the user's affiliation.

Removed code which had been setting default values from utils.pm::get_user_info.

Modified:
    vcl/trunk/managementnode/lib/VCL/DataStructure.pm
    vcl/trunk/managementnode/lib/VCL/utils.pm

Modified: vcl/trunk/managementnode/lib/VCL/DataStructure.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=1789595&r1=1789594&r2=1789595&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/DataStructure.pm Thu Mar 30 22:33:53 2017
@@ -471,9 +471,9 @@ $SUBROUTINE_MAPPINGS{user_login_id} = '$
 $SUBROUTINE_MAPPINGS{user_width} = '$self->request_data->{user}{width}';
 $SUBROUTINE_MAPPINGS{user_adminlevel_name} = '$self->request_data->{user}{adminlevel}{name}';
 $SUBROUTINE_MAPPINGS{user_affiliation_dataupdatetext} = '$self->request_data->{user}{affiliation}{dataUpdateText}';
-$SUBROUTINE_MAPPINGS{user_affiliation_helpaddress} = '$self->request_data->{user}{affiliation}{helpaddress}';
+#$SUBROUTINE_MAPPINGS{user_affiliation_helpaddress} = '$self->request_data->{user}{affiliation}{helpaddress}';
 $SUBROUTINE_MAPPINGS{user_affiliation_name} = '$self->request_data->{user}{affiliation}{name}';
-$SUBROUTINE_MAPPINGS{user_affiliation_sitewwwaddress} = '$self->request_data->{user}{affiliation}{sitewwwaddress}';
+#$SUBROUTINE_MAPPINGS{user_affiliation_sitewwwaddress} = '$self->request_data->{user}{affiliation}{sitewwwaddress}';
 $SUBROUTINE_MAPPINGS{user_imtype_name} = '$self->request_data->{user}{IMtype}{name}';
 $SUBROUTINE_MAPPINGS{user_use_public_keys} = '$self->request_data->{user}{usepublickeys}';
 $SUBROUTINE_MAPPINGS{user_ssh_public_keys} = '$self->request_data->{user}{sshpublickeys}';
@@ -2425,6 +2425,73 @@ sub get_connect_method_protocol_port_arr
 }
 
 #/////////////////////////////////////////////////////////////////////////////
+
+=head2 get_user_affiliation_sitewwwaddress
+
+ Parameters  : none
+ Returns     : string
+ Description : Returns the affiliation.sitewwwaddress for the user's affiliation
+               if populated. If not, returns the value for the Global
+               affiliation. If that's not populated, returns vcl.apache.org.
+
+=cut
+
+sub get_user_affiliation_sitewwwaddress {
+	my $self = shift;
+	if (ref($self) !~ /VCL::/i) {
+		notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it must be called as a class method");
+		return 0;
+	}
+	
+	# Try to retrieve the value for the user's affiliation
+	if ($self->request_data->{user}{affiliation}{sitewwwaddress}) {
+		return $self->request_data->{user}{affiliation}{sitewwwaddress};
+	}
+	
+	# Try to retrieve the value for the Global affiliation
+	my $affiliation_info = get_affiliation_info('Global');
+	if ($affiliation_info && $affiliation_info->{sitewwwaddress}) {
+		return $affiliation_info->{sitewwwaddress};
+	}
+	
+	return 'vcl.apache.org';
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 get_user_affiliation_helpaddress
+
+ Parameters  : none
+ Returns     : string
+ Description : Returns the affiliation.helpaddress for the user's affiliation
+               if populated. If not, returns the value for the Global
+               affiliation. If that's not populated, returns
+               'help@vcl.example.edu'.
+
+=cut
+
+sub get_user_affiliation_helpaddress {
+	my $self = shift;
+	if (ref($self) !~ /VCL::/i) {
+		notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it must be called as a class method");
+		return 0;
+	}
+	
+	# Try to retrieve the value for the user's affiliation
+	if ($self->request_data->{user}{affiliation}{helpaddress}) {
+		return $self->request_data->{user}{affiliation}{helpaddress};
+	}
+	
+	# Try to retrieve the value for the Global affiliation
+	my $affiliation_info = get_affiliation_info('Global');
+	if ($affiliation_info && $affiliation_info->{helpaddress}) {
+		return $affiliation_info->{helpaddress};
+	}
+	
+	return 'help@vcl.example.edu';
+}
+
+#/////////////////////////////////////////////////////////////////////////////
 
 1;
 __END__

Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1789595&r1=1789594&r2=1789595&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Thu Mar 30 22:33:53 2017
@@ -7021,14 +7021,6 @@ EOF
 		$user_info->{STANDALONE} = 1;
 	}
 	
-	# Set the user's affiliation sitewwwaddress and help address if not defined or blank
-	if (!$user_info->{affiliation}{sitewwwaddress}) {
-		$user_info->{affiliation}{sitewwwaddress} = 'http://cwiki.apache.org/VCL';
-	}
-	if (!$user_info->{affiliation}{helpaddress}) {
-		$user_info->{affiliation}{helpaddress} = 'nobody@example.com';
-	}
-	
 	#notify($ERRORS{'DEBUG'}, 0, "retrieved info for user '$user_identifier', affiliation: '$affiliation_identifier':\n" . format_data($user_info));
 	$ENV{user_info}{$user_identifier} = $user_info;
 	$ENV{user_info}{$user_identifier}{RETRIEVAL_TIME} = time;