2002/ws/desc/tools setup-namespaces,NONE,1.1

Update of /sources/public/2002/ws/desc/tools
In directory homer:/tmp/cvs-serv8909

Added Files:
	setup-namespaces 
Log Message:
Script to set date space schemas and boilerplates up
Not working yet


--- NEW FILE: setup-namespaces ---
#!/usr/bin/perl
#
# @@@ not working yet

use strict;
use File::Copy;

if ($#ARGV != 4) {
    die "Usage: $0 <pubdir> <doc> <year> <month> <day>";
}

#my $WWW = $ENV{WWW};
# @@@@
my $WWW = '/tmp/WWW';
my ($PUBDIR, $DOC, $Y, $M, $D) = @ARGV;
my $TARGET = "$WWW/$Y/$M/wsdl";

if (! -d $WWW) {
    die "\$WWW ($WWW) doesn't exist";
}

###########################################################################

sub createDir() {
    my $d = $_[0];
    if (! -d $d) {
	mkdir($d) || die "$!";
    }
}

&createDir("$WWW/$Y");
&createDir("$WWW/$Y/$M");
&createDir("$TARGET");
&createDir("$TARGET/style");

###########################################################################

my $ID;
if ($DOC =~ m/wsdl20-$Y$M$D/) {
    $ID = 'PART1';
}
elsif ($DOC =~ m/wsdl20-patterns-$Y$M$D/) {
    $ID = 'PART2';
}
elsif ($DOC =~ m/wsdl20-bindings-$Y$M$D/) {
    $ID = 'PART3';
} else {
    die "Unknown document type";
}

my $htaccessTemplate = "# .htaccess created by setup-namespaces; edit carefully
RewriteEngine On
RewriteBase   /$Y/$M/wsdl

# PART1-BEGIN
# PART1-END

# PART2-BEGIN
# PART2-END

# PART3-BEGIN
# PART3-END
";

sub updateHtaccess() {
    my $htaccess = "$TARGET/.htaccess";
    my $f;
    my $c;
    if (-f $htaccess) {
	open($f, "$htaccess");
	$c = join('', <$f>);
    } else {
	$c = $htaccessTemplate;
    }
    my $v = "# $ID-BEGIN\n";
    if ($ID eq 'PART1') {
	$v .= '
DirectoryIndex wsdl20.xsd
';
    }
    elsif ($ID eq 'PART2') {
	$v .= '
RewriteRule   ^in-out$                  patterns.html
RewriteRule   ^out-only$                patterns.html
RewriteRule   ^robust-out-only$         patterns.html
RewriteRule   ^robust-in-only$          patterns.html
RewriteRule   ^out-in$                  patterns.html
RewriteRule   ^in-only$                 patterns.html
RewriteRule   ^in-multi-out$            patterns.html
RewriteRule   ^out-multi-in$            patterns.html
RewriteRule   ^asynch-out-in$           patterns.html
';
    }
    $v .= "\n# $ID-END\n";
    $c =~ s/\# $ID-BEGIN\n.*\# $ID-END\n/$v/s;
    open($f, "> $htaccess");
    print $f $c;
    close($f);
}

&updateHtaccess();

###########################################################################

sub moveSchema() {
    my $src = "$PUBDIR/$_[0]";
    my $dst = "$TARGET/$_[0]";
    move($src, $dst) || die "mv $src $dst: $!";
}

if ($ID eq 'PART1') {
    &moveSchema("wsdl20.xsd", "wsdl20.xsd");
}
elsif ($ID eq 'PART2') {
}
elsif ($ID eq 'PART3') {
    &moveSchema("wsdl20-soap.xsd", "soap12.xsd");
    &moveSchema("wsdl20-http.xsd", "http.xsd");
}

###########################################################################

# @@@ HTML placeholders: patterns.html, style/rpc.html, etc.

Received on Monday, 26 July 2004 14:45:26 UTC