INTEGRATION: CWS native99 (1.23.408); FILE MERGED

2007/08/07 14:00:11 is 1.23.408.1: #i80410# enable multiple services.rdb files
This commit is contained in:
Ivo Hinkelmann 2007-08-20 14:26:43 +00:00
parent e0958148ba
commit 2091c26915

View file

@ -4,9 +4,9 @@
#
# $RCSfile: servicesfile.pm,v $
#
# $Revision: 1.23 $
# $Revision: 1.24 $
#
# last change: $Author: obo $ $Date: 2006-07-10 18:51:00 $
# last change: $Author: ihi $ $Date: 2007-08-20 15:26:43 $
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1.
@ -429,7 +429,7 @@ sub register_pythoncomponents
sub register_all_components
{
my ( $filesarrayref, $regcompfileref, $servicesfile, $regcomprdb, $includepatharrayref ) = @_;
my ( $servicesgid, $filesarrayref, $regcompfileref, $servicesfile, $regcomprdb, $includepatharrayref ) = @_;
my $registererrorflag = 0;
@ -442,6 +442,11 @@ sub register_all_components
my $onefile = ${$filesarrayref}[$i];
my $styles = "";
my $regmergefile = "";
my $registryid = "";
if ( $onefile->{'RegistryID'} ) { $registryid = $onefile->{'RegistryID'}; }
if ( $servicesgid ne $registryid ) { next; } # only registration for the current $servicesgid
if ( $onefile->{'Regmergefile'} ) { $regmergefile = $onefile->{'Regmergefile'}; }
@ -733,6 +738,151 @@ sub prepare_regcomp_rdb
return $regcomprdb;
}
################################################################
# Collecting all gids of the databases, that are part of
# the file definition
################################################################
sub collect_all_services_gids
{
my ($filesarrayref) = @_;
my @databasegids = ();
my $error_occured = 0;
my @error_files = ();
for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
{
my $onefile = ${$filesarrayref}[$i];
if ( $onefile->{'RegistryID'} )
{
my $databasegid = $onefile->{'RegistryID'};
if (! installer::existence::exists_in_array($databasegid, \@databasegids)) { push(@databasegids, $databasegid); }
}
else
{
push(@error_files, $onefile->{'gid'});
$error_occured = 1;
}
}
if ( $error_occured )
{
my $infoline = "ERROR: Style UNO_COMPONENT is set, but no RegistryID is assigned!\n";
push( @installer::globals::logfileinfo, $infoline);
print $infoline;
for ( my $j = 0; $j <= $#error_files; $j++ )
{
$infoline = "$error_files[$j]\n";
push( @installer::globals::logfileinfo, $infoline);
print $infoline;
}
installer::exiter::exit_program("ERROR: File defintion error.", "collect_all_services_gids");
}
return \@databasegids;
}
######################################################################
# All gids in $databasegids are as RegistryID assigned to files.
# For all this Registry Files a definition has to exist.
######################################################################
sub check_defintion_of_databasegids
{
my ($databasegids, $registryfiles) = @_;
my @registryfiles = ();
# First check: For all assigned Registry files, a definition of
# a file with flag STARREGISTRY has to exist.
for ( my $i = 0; $i <= $#{$databasegids}; $i++ )
{
my $onegid = ${$databasegids}[$i];
my $gid_defined = 0;
for ( my $j = 0; $j <= $#{$registryfiles}; $j++ )
{
my $registrygid = ${$registryfiles}[$j]->{'gid'};
if ( $onegid eq $registrygid )
{
$gid_defined = 1;
last;
}
}
if ( ! $gid_defined )
{
installer::exiter::exit_program("ERROR: Gid $onegid is assigned to file(s), but not defined!", "check_defintion_of_databasegids");
}
}
# Second check: If there is a file defined as StarRegistry, is a file with flag UNO_COMPONENT assigned?
for ( my $j = 0; $j <= $#{$registryfiles}; $j++ )
{
my $onefile = ${$registryfiles}[$j];
my $registrygid = $onefile->{'gid'};
my $gid_assigned = 0;
for ( my $i = 0; $i <= $#{$databasegids}; $i++ )
{
my $onegid = ${$databasegids}[$i];
if ( $onegid eq $registrygid )
{
$gid_assigned = 1;
last;
}
}
if ( ! $gid_assigned )
{
my $infoline = "Warning: $registrygid is defined with flag STARREGISTRY, but no file is assigned to the registry.\n";
push( @installer::globals::logfileinfo, $infoline);
}
else
{
push(@registryfiles, $onefile);
}
}
return \@registryfiles;
}
################################################################
# Some files have flag UNO_COMPONENT, but are not registered
# with regcomp. This files use the regmerge mechanism, that
# is not used in this perl-file. Therefore this files
# have to be filtered out here.
################################################################
sub filter_regmergefiles
{
my ($unocomponentfiles) = @_;
my @regcompfiles = ();
for ( my $i = 0; $i <= $#{$unocomponentfiles}; $i++ )
{
my $onefile = ${$unocomponentfiles}[$i];
my $regmergefile = "";
if ( $onefile->{'Regmergefile'} ) { $regmergefile = $onefile->{'Regmergefile'}; }
if ( $regmergefile ne "" ) { next; }
push(@regcompfiles, $onefile);
}
return \@regcompfiles;
}
################################################################
# Creating services.rdb file by registering all uno components
################################################################
@ -741,11 +891,34 @@ sub create_services_rdb
{
my ($filesarrayref, $includepatharrayref, $languagestringref) = @_;
my $servicesname = "services.rdb";
# collecting all services files
my $unocomponentfiles = installer::worker::collect_all_items_with_special_flag($filesarrayref, "UNO_COMPONENT");
$unocomponentfiles = filter_regmergefiles($unocomponentfiles);
installer::logger::include_header_into_logfile("Creating $servicesname:");
if ( $#{$unocomponentfiles} > -1 ) # not empty -> at least one file with flag UNO_COMPONENT
{
my $databasegids = collect_all_services_gids($unocomponentfiles);
my $servicesdir = installer::systemactions::create_directories($servicesname, $languagestringref);
my $registryfiles = installer::worker::collect_all_items_with_special_flag($filesarrayref, "STARREGISTRY");
$registryfiles = check_defintion_of_databasegids($databasegids, $registryfiles);
# Now the creation of all files with flag STARREGISTRY can begin
for ( my $i = 0; $i <= $#{$registryfiles}; $i++ )
{
my $registryfile = ${$registryfiles}[$i];
# my $servicesname = "services.rdb";
my $servicesname = $registryfile->{'Name'}; # not unique!
my $servicesgid = $registryfile->{'gid'}; # unique
# my $uniquedirname = $servicesgid . "_rdb";
my $uniquedirname = $servicesgid;
installer::logger::include_header_into_logfile("Creating $servicesname ($servicesgid):");
# my $servicesdir = installer::systemactions::create_directories($servicesname, $languagestringref);
my $servicesdir = installer::systemactions::create_directories($uniquedirname, $languagestringref);
if ( $^O =~ /cygwin/i && $ENV{'USE_SHELL'} eq "4nt" )
{ # $servicesdir is used as a parameter for regcomp and has to be DOS style
@ -762,7 +935,6 @@ sub create_services_rdb
if ( -f $servicesfile ) { unlink($servicesfile); }
# if ((-f $servicesfile) && (!($installer::globals::services_rdb_created))) { $installer::globals::services_rdb_created = 1; }
# if ((!($installer::globals::services_rdb_created)) && $installer::globals::servicesrdb_can_be_created ) # This has to be done once
if ( $installer::globals::servicesrdb_can_be_created ) # This has to be done always
{
@ -813,7 +985,8 @@ sub create_services_rdb
# and now iteration over all files
my $error_during_registration = register_all_components($filesarrayref, $regcompfileref, $servicesfile, $regcomprdb, $includepatharrayref);
# my $error_during_registration = register_all_components($filesarrayref, $regcompfileref, $servicesfile, $regcomprdb, $includepatharrayref);
my $error_during_registration = register_all_components($servicesgid, $unocomponentfiles, $regcompfileref, $servicesfile, $regcomprdb, $includepatharrayref);
# Dependent from the success, the registration directory can be renamed.
@ -822,7 +995,7 @@ sub create_services_rdb
$servicesdir = installer::systemactions::rename_string_in_directory($servicesdir, "inprogress", "witherror");
push(@installer::globals::removedirs, $servicesdir);
# and exiting the packaging process
installer::exiter::exit_program("ERROR: Could not register all components!", "create_services_rdb");
installer::exiter::exit_program("ERROR: Could not register all components for file $servicesname ($servicesgid)!", "create_services_rdb");
}
else
{
@ -854,9 +1027,11 @@ sub create_services_rdb
}
}
# Adding the services.rdb to the filearray
add_services_sourcepath_into_filearray( $filesarrayref, $servicesfile, $servicesname );
# Adding the new services file source path to the filearray
$registryfile->{'sourcepath'} = $servicesfile; # setting the sourcepath!
# add_services_sourcepath_into_filearray( $filesarrayref, $servicesfile, $servicesname );
}
}
# Setting the global variable $installer::globals::services_rdb_created