65 lines
1.2 KiB
Perl
65 lines
1.2 KiB
Perl
use v5.10.1;
|
|
use strict;
|
|
use warnings;
|
|
use Carp;
|
|
|
|
use ACU::Config;
|
|
use ACU::LDAP;
|
|
use ACU::Log;
|
|
|
|
sub update_project
|
|
{
|
|
my $args = shift;
|
|
|
|
my $project_id = $args->{param}{id};
|
|
my $year = $args->{param}{year} // LDAP::get_year;
|
|
|
|
if (! $project_id) {
|
|
log ERROR, "No project_id given.";
|
|
return "No project_id given";
|
|
}
|
|
|
|
my $butler;
|
|
if (exists $args->{files}{"butler.xml"}) {
|
|
$butler = $args->{files}{"butler.xml"};
|
|
}
|
|
if (! $butler) {
|
|
log ERROR, "Invalid butler.xml received!";
|
|
return "Invalid butler.xml received!";
|
|
}
|
|
|
|
log INFO, "Update $year/$project_id/butler.xml";
|
|
|
|
return $_ if (create_tree($year, $project_id));
|
|
|
|
open my $out, ">", "$main::intradata/$year/$project_id/butler.xml";
|
|
print $out $butler;
|
|
close $out;
|
|
|
|
return "Ok";
|
|
}
|
|
|
|
|
|
sub delete_project
|
|
{
|
|
log WARN, "delete_project: not implemented."
|
|
}
|
|
|
|
|
|
sub create_tree($$)
|
|
{
|
|
my $year = shift;
|
|
my $project_id = shift;
|
|
|
|
if (! -d "$main::intradata/$year/")
|
|
{
|
|
log ERROR, "No directory for year $year. Ask a root to create it.";
|
|
return "No directory for year $year. Ask a root to create it.";
|
|
}
|
|
|
|
mkdir "$main::intradata/$year/$project_id/" if (! -e "$main::intradata/$year/$project_id/");
|
|
|
|
return 0;
|
|
}
|
|
|
|
1;
|