# -- # Kernel/Modules/PublicRepository.pm - provides a local repository # Copyright (C) 2001-2006 OTRS GmbH, http://otrs.org/ # -- # $Id: PublicRepository.pm,v 1.4 2006/10/09 17:38:03 mh Exp $ # -- # This software comes with ABSOLUTELY NO WARRANTY. For details, see # the enclosed file COPYING for license information (GPL). If you # did not receive this file, see http://www.gnu.org/licenses/gpl.txt. # -- package Kernel::Modules::PublicRepository; use strict; use Kernel::System::Package; use vars qw($VERSION); $VERSION = '$Revision: 1.4 $'; $VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/; sub new { my $Type = shift; my %Param = @_; # allocate new hash for object my $Self = {}; bless ($Self, $Type); foreach (keys %Param) { $Self->{$_} = $Param{$_}; } # check needed Opjects foreach (qw(ParamObject LayoutObject LogObject ConfigObject)) { if (!$Self->{$_}) { $Self->{LayoutObject}->FatalError(Message => "Got no $_!"); } } $Self->{PackageObject} = Kernel::System::Package->new(%Param); return $Self; } sub Run { my $Self = shift; my %Param = @_; my $File = $Self->{ParamObject}->GetParam(Param => 'File') || ''; $File =~ s/^\///g; my $AccessControlRexExp = $Self->{ConfigObject}->Get('Package::RepositoryAccessRegExp'); if (!$AccessControlRexExp) { return $Self->{LayoutObject}->ErrorScreen( Message => 'Need config Package::RepositoryAccessRegExp', ); } else { if ($ENV{REMOTE_ADDR} !~ /^$AccessControlRexExp$/) { return $Self->{LayoutObject}->ErrorScreen( Message => 'Authentication failed!', ); } } # get repository index if ($File =~ /otrs.xml$/) { # get repository index my $Index = ""; $Index .= "\n"; my @List = $Self->{PackageObject}->RepositoryList(); foreach my $Package (@List) { $Index .= "\n"; $Index .= " $Package->{Name}->{Content}-$Package->{Version}->{Content}\n"; $Index .= $Self->{PackageObject}->PackageBuild(%{$Package}, Type => 'Index'); $Index .= "\n"; } $Index .= "\n"; return $Self->{LayoutObject}->Attachment( Type => 'inline', # inline|attached Filename => 'otrs.xml', ContentType => 'text/xml', Content => $Index, ); } # export package else { my $Name = ''; my $Version = ''; if ($File =~ /^(.*)\-(.+?)$/) { $Name = $1; $Version = $2; } my $Package = $Self->{PackageObject}->RepositoryGet( Name => $Name, Version => $Version, ); return $Self->{LayoutObject}->Attachment( Type => 'inline', # inline|attached Filename => "$Name-$Version", ContentType => 'text/xml', Content => $Package, ); } } 1;