From c65fd986f59860354f2716cf7c94789e05885c03 Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Mon, 11 Jan 2016 06:27:16 +0000 Subject: [PATCH] Manage Common/Constants.pm with jsongenerator and add $hashParameters constant --- Makefile | 1 + .../lib/Lemonldap/NG/Common/Conf/Constants.pm | 16 ++--- .../lib/Lemonldap/NG/Manager/Build.pm | 65 +++++++++++++++++++ scripts/jsongenerator.pl | 11 ++-- 4 files changed, 80 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 7803a15de..49f9ad7b8 100644 --- a/Makefile +++ b/Makefile @@ -129,6 +129,7 @@ MANAGERJSONDST=$(SRCMANAGERDIR)/site/static/struct.json \ $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Attributes.pm \ $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Constants.pm \ $(SRCCOMMONDIR)/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm \ + $(SRCCOMMONDIR)/lib/Lemonldap/NG/Common/Conf/Constants.pm \ _example/conf/lmConf-1.js PERLCOMMONSRC:=$(shell find $(SRCCOMMONDIR)/lib -name '*.pm') PERLCOMMONDST=$(SRCCOMMONDIR)/blib/lib/Lemonldap/NG/Common.pm diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Constants.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Constants.pm index 02544376d..6f39b5d2a 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Constants.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Constants.pm @@ -1,11 +1,11 @@ +# This file is generated by Lemonldap::NG::Manager::Build. Don't modify it by hand package Lemonldap::NG::Common::Conf::Constants; use strict; -use utf8; use Exporter 'import'; - use base qw(Exporter); -our $VERSION = '1.0.2'; + +our $VERSION = '1.9.0'; # CONSTANTS @@ -23,6 +23,8 @@ use constant HANDLERSECTION => "handler"; use constant MANAGERSECTION => "manager"; use constant SESSIONSEXPLORERSECTION => "sessionsExplorer"; use constant APPLYSECTION => "apply"; +our $hashParameters = '(?:(?:g(?:r(?:antSessionRule|oup)|lobalStorageOption|oogleExportedVar)|l(?:o(?:calSessionStorageOption|goutService)|dapExportedVar)|ca(?:s(?:StorageOption|Attribute)|ptchaStorageOption)|(?:(?:d(?:emo|bi)|facebook|webID)E|e)xportedVar|p(?:ersistentStorageOption|ortalSkinRule)|re(?:moteGlobalStorageOption|loadUrl)|notificationStorageOption|CAS_proxiedService|macro)s|s(?:aml(?:S(?:PMetaDataNode|torageOptions)|IDPMetaDataNode)|essionDataToRemember|laveExportedVars)|o(?:idc(?:S(?:erviceMetaDataAuthnContext|torageOptions)|[OR]PMetaDataNode)|penIdExportedVars)|a(?:uthChoiceModules|pplicationList)|virtualHost)'; + our %EXPORT_TAGS = ( 'all' => [ @@ -41,13 +43,11 @@ our %EXPORT_TAGS = ( MANAGERSECTION SESSIONSEXPLORERSECTION APPLYSECTION + $hashParameters ) ] ); - -our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); - -our @EXPORT = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = ( @{ $EXPORT_TAGS{'all'} } ); 1; -__END__ diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build.pm index 0026c3b76..9223cb195 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build.pm @@ -18,6 +18,7 @@ has confTreeFile => ( isa => 'Str', is => 'ro', required => 1 ); has managerConstantsFile => ( isa => 'Str', is => 'ro', required => 1 ); has managerAttributesFile => ( isa => 'Str', is => 'ro', required => 1 ); has defaultValuesFile => ( isa => 'Str', is => 'ro', required => 1 ); +has confConstantsFile => ( isa => 'Str', is => 'ro', required => 1 ); has firstLmConfFile => ( isa => 'Str', is => 'ro', required => 1 ); my @managerAttrKeys = qw(keyTest select type test msgFail default); @@ -216,6 +217,70 @@ $defaultAttr} close F; print STDERR "done\n"; + printf STDERR $format, $self->confConstantsFile; + $ra = Regexp::Assemble->new; + foreach ( @simpleHashKeys, sort keys %cnodesRe ) { + $ra->add($_); + } + my $confConstants = "our \$hashParameters = '" . $ra->as_string . "';\n"; + open( F, ">", $self->confConstantsFile ) or die($!); + print F < -1; +use constant UNKNOWN_ERROR => -2; +use constant DATABASE_LOCKED => -3; +use constant UPLOAD_DENIED => -4; +use constant SYNTAX_ERROR => -5; +use constant DEPRECATED => -6; +use constant DEFAULTCONFFILE => "/usr/local/lemonldap-ng/etc/lemonldap-ng.ini"; +use constant DEFAULTSECTION => "all"; +use constant CONFSECTION => "configuration"; +use constant PORTALSECTION => "portal"; +use constant HANDLERSECTION => "handler"; +use constant MANAGERSECTION => "manager"; +use constant SESSIONSEXPLORERSECTION => "sessionsExplorer"; +use constant APPLYSECTION => "apply"; +$confConstants + +our %EXPORT_TAGS = ( + 'all' => [ + qw( + CONFIG_WAS_CHANGED + UNKNOWN_ERROR + DATABASE_LOCKED + UPLOAD_DENIED + SYNTAX_ERROR + DEPRECATED + DEFAULTCONFFILE + DEFAULTSECTION + CONFSECTION + PORTALSECTION + HANDLERSECTION + MANAGERSECTION + SESSIONSEXPLORERSECTION + APPLYSECTION + \$hashParameters + ) + ] +); +our \@EXPORT_OK = ( \@{ \$EXPORT_TAGS{'all'} } ); +our \@EXPORT = ( \@{ \$EXPORT_TAGS{'all'} } ); + +1; +EOF + close F; + print STDERR "done\n"; + printf STDERR $format, $self->managerAttributesFile; my $managerAttr = { map { diff --git a/scripts/jsongenerator.pl b/scripts/jsongenerator.pl index f38e3680b..c7dd40ddb 100755 --- a/scripts/jsongenerator.pl +++ b/scripts/jsongenerator.pl @@ -3,11 +3,12 @@ use Lemonldap::NG::Manager::Build; Lemonldap::NG::Manager::Build->run( - structFile => "lemonldap-ng-manager/site/static/struct.json", - confTreeFile => "lemonldap-ng-manager/site/static/js/conftree.js", - managerConstantsFile => "lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Constants.pm", + structFile => 'lemonldap-ng-manager/site/static/struct.json', + confTreeFile => 'lemonldap-ng-manager/site/static/js/conftree.js', + managerConstantsFile => 'lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Constants.pm', managerAttributesFile => 'lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm', - defaultValuesFile => "lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm", - firstLmConfFile => "_example/conf/lmConf-1.js", + defaultValuesFile => 'lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm', + confConstantsFile => 'lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Constants.pm', + firstLmConfFile => '_example/conf/lmConf-1.js', );