2 # Copyright (C) 2013 MnSCU/PALS
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of version 2 of the GNU General Public
8 # License as published by the Free Software Foundation.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public
16 # License along with this program; if not, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 # parse-config: Parse an XML-format
21 # ACS configuration file and build the configuration
25 package NCIPServer::NCIP::Configuration;
31 use XML::Simple qw(:strict);
33 use NCIPServer::NCIP::Configuration::Account;
34 use NCIPServer::NCIP::Configuration::Institution;
36 my $parser = new XML::Simple(
43 institutions => 'institution',
45 ForceArray => [ 'login', 'institution' ],
49 my ($class, $config_file) = @_;
50 my $cfg = $parser->XMLin($config_file);
52 foreach my $acct (values %{$cfg->{accounts}}) {
53 new NCIPServer::NCIP::Configuration::Account $acct;
56 foreach my $inst (values %{$cfg->{institutions}}) {
57 new NCIPServer::NCIP::Configuration::Institution $inst;
60 return bless $cfg, $class;
65 return values %{$self->{accounts}};
70 return values %{$self->{institutions}};
78 NCIPServer::NCIP::Configuration - abstraction/accessor for NCIP configs
82 use NCIPServer::NCIP::Configuration;
83 my $config = NCIPServer::NCIP::Configuration->new($ARGV[0]);
85 foreach my $acct ($config->accounts) {
86 print "Found account: '", $acct->id, "', part of '";
87 print $acct->institution, "'\n";