From d37c40b44e769e8a44a5d0ad06ad38169a03f195 Mon Sep 17 00:00:00 2001 From: Alex Sassmannshausen Date: Mon, 6 Feb 2017 09:54:14 +0100 Subject: [PATCH] Remove BLDSS configuration from Config.pm. * Koha/Illrequest/Config.pm (getLibraryPrivileges, getDefaultFormats) (getCredentials, getApiUrl, getApiSpecFile): Remove procedures. (_load_configuration): Remove BLDSS specific config. https://bugs.koha-community.org/show_bug.cgi?id=7317 --- Koha/Illrequest/Config.pm | 147 +--------------------------------------------- 1 file changed, 1 insertion(+), 146 deletions(-) diff --git a/Koha/Illrequest/Config.pm b/Koha/Illrequest/Config.pm index 87264b8..69937d3 100644 --- a/Koha/Illrequest/Config.pm +++ b/Koha/Illrequest/Config.pm @@ -137,22 +137,6 @@ sub getPrefixes { return $values; } -=head3 getLibraryPrivileges - - my $privileges= $config->getLibraryPrivileges; - -Return the LibraryPrivilege definitions defined by our config. - -=cut - -sub getLibraryPrivileges { - my ( $self ) = @_; - my $values= $self->{configuration}->{library_privileges}->{branch} || {}; - $values->{default} = - $self->{configuration}->{library_privileges}->{default}; - return $values; -} - =head3 getLimitRules my $rules = $config->getLimitRules('brw_cat' | 'branch') @@ -186,52 +170,6 @@ sub getDigitalRecipients { return $values; } -=head3 getDefaultFormats - - my $defaultFormat = $config->getLimitRules('brw_cat' | 'branch') - -Return the hash of ILL default formats defined by our config. - -=cut - -sub getDefaultFormats { - my ( $self, $type ) = @_; - die "Unexpected type." unless ( $type eq 'brw_cat' || $type eq 'branch' ); - my $values = $self->{configuration}->{default_formats}->{$type}; - $values->{default} = $self->{configuration}->{default_formats}->{default}; - return $values; -} - -=head3 getCredentials - - my $credentials = $config->getCredentials($branchCode); - -Fetch the best-fit credentials: if we have credentials for $branchCode, use -those; otherwise fall back on default credentials. If neither can be found, -simply populate application details, and populate key details with 0. - -=cut - -sub getCredentials { - my ( $self, $branchCode ) = @_; - my $creds = $self->{configuration}->{credentials} - || die "We have no credentials defined. Please check koha-conf.xml."; - - my $exact = { api_key => 0, api_auth => 0 }; - if ( $branchCode && $creds->{api_keys}->{$branchCode} ) { - $exact = $creds->{api_keys}->{$branchCode} - } elsif ( $creds->{api_keys}->{default} ) { - $exact = $creds->{api_keys}->{default}; - } - - return { - api_key => $exact->{api_key}, - api_key_auth => $exact->{api_auth}, - api_application => $creds->{api_application}->{key}, - api_application_auth => $creds->{api_application}->{auth}, - }; -} - =head3 censorship my $censoredValues = $config->censorship($hash); @@ -251,33 +189,6 @@ sub censorship { return $self->{configuration}->{censorship}; } -=head3 getApiUrl - - my $api_url = $config->getApiUrl; - -Return the url for the api configured by koha-conf.xml, or the fall-back url. - -=cut - -sub getApiUrl { - my ( $self ) = @_; - return $self->{configuration}->{api_url}; -} - -=head3 getApiSpecFile - - my $api_spec_file = $config->getApiSpecFile; - -Return the path pointing to the API specfile, if it indeed exists, from by -koha-conf.xml, or 0. - -=cut - -sub getApiSpecFile { - my ( $self ) = @_; - return $self->{configuration}->{spec_file} || 0; -} - =head3 _load_configuration my $configuration = $config->_load_configuration($config_from_xml); @@ -292,32 +203,17 @@ file to ensure we have only valid input there. sub _load_configuration { my ( $from_xml, $unmediated ) = @_; - my $xml_config = $from_xml->{configuration}; - my $xml_api_url = $from_xml->{api_url}; my $xml_backend_dir = $from_xml->{backend_directory}; - - # Input validation - die "CONFIGURATION has not been defined in koha-conf.xml." - unless ( ref($xml_config) eq "HASH" ); - die "APPLICATION has not been defined in koha-conf.xml." - unless ( ref($from_xml->{application}) eq "HASH" ); + my $xml_config = $from_xml->{configuration} || {}; # Default data structure to be returned my $configuration = { backend_directory => $xml_backend_dir, - api_url => $xml_api_url || 'http://apitest.bldss.bl.uk', - spec_file => $from_xml->{api_specification}, censorship => { censor_notes_staff => 0, censor_reply_date => 0, }, - credentials => { - api_application => {}, - api_keys => {}, - }, - library_privileges => {}, limits => {}, - default_formats => {}, digital_recipients => {}, prefixes => {}, }; @@ -373,12 +269,6 @@ sub _load_configuration { config => $configuration }); - # Application key & auth - $configuration->{credentials}->{api_application} = { - key => $from_xml->{application}->{key}, - auth => $from_xml->{application}->{auth}, - }; - # Censorship my $staff_comments = $from_xml->{staff_request_comments}; $configuration->{censorship}->{censor_notes_staff} = 1 @@ -448,20 +338,6 @@ sub _load_unit_config { } } - # Add library_privilege rules (only per branch). - # LIBRARY_PRIVILEGE := 1 || 0 - unless ( $type && 'brw_cat' eq $type ) { - if ( $unit->{library_privilege} ) { - if ( 'default' eq $id ) { - $config->{library_privileges}->{$id} = - $unit->{library_privilege}; - } else { - $config->{library_privileges}->{branch}->{$id} = - $unit->{library_privilege}; - } - } - } - # Add prefix rules. # PREFIX := string if ( $unit->{prefix} ) { @@ -483,27 +359,6 @@ sub _load_unit_config { } } - # Add default_formats types. - # FORMAT && QUALITY && QUANTITY && SERVICE && SPEED := x >= 0 - if ( ref $unit->{default_formats} eq 'HASH' ) { - my @fields = qw(format quality quantity service speed); - if ( 'default' eq $id ) { - for ( @fields ) { - my $val = $unit->{default_formats}->{$_}; - die "Invalid default_formats: '$_' missing" - unless $val; - $config->{default_formats}->{$id}->{$_} = $val; - } - } else { - for ( @fields ) { - my $val = $unit->{default_formats}->{$_}; - die "Invalid default_formats: '$_' missing" - unless $val; - $config->{default_formats}->{$type}->{$id}->{$_} = $val; - } - } - } - return $config; } -- 2.1.4