| 1 | # ==================================================================== | ||
| 2 | # Copyright (c) 2004 IBM Corporation | ||
| 3 | # All rights reserved. This program and the accompanying materials | ||
| 4 | # are made available under the terms of the Common Public License v1.0 | ||
| 5 | # which accompanies this distribution, and is available at | ||
| 6 | # http://www.opensource.org/licenses/cpl.php | ||
| 7 | # | ||
| 8 | # ===================================================================== | ||
| 9 | package LS::Authority::WSDL::Constants; | ||
| 10 | |||
| 11 | use strict; | ||
| 12 | use warnings; | ||
| 13 | |||
| 14 | use vars qw( $SCHEMA_TYPES ); | ||
| 15 | |||
| 16 | |||
| 17 | $SCHEMA_TYPES = 'http://www.ibm.com/LSID/Standard/WSDL/SchemaTypes'; | ||
| 18 | |||
| 19 | |||
| 20 | package LS::Authority::WSDL::Constants::Protocols; | ||
| 21 | |||
| 22 | use strict; | ||
| 23 | use warnings; | ||
| 24 | |||
| 25 | use vars qw( | ||
| 26 | $HTTP $HTTP_GET $HTTP_POST | ||
| 27 | $SOAP | ||
| 28 | $FTP | ||
| 29 | $FILESYSTEM | ||
| 30 | $MIME | ||
| 31 | |||
| 32 | %URI | ||
| 33 | |||
| 34 | $LIST | ||
| 35 | |||
| 36 | $DEBUG | ||
| 37 | ); | ||
| 38 | |||
| 39 | |||
| 40 | use Carp qw(:DEFAULT); | ||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | # | ||
| 46 | # BEGIN( ) - Base initialization of this module | ||
| 47 | # | ||
| 48 | sub BEGIN { | ||
| 49 | |||
| 50 | # Create a list of protocols available that can be iterated | ||
| 51 | # over by client code | ||
| 52 | $LIST = [ | ||
| 53 | keys(%URI), | ||
| 54 | ]; | ||
| 55 | |||
| 56 | |||
| 57 | # | ||
| 58 | # $DEBUG - Controls whether there is debugging output | ||
| 59 | # Default is 1, debugging output | ||
| 60 | # | ||
| 61 | $DEBUG = 1; | ||
| 62 | |||
| 63 | |||
| 64 | # | ||
| 65 | # The following variables are used | ||
| 66 | # to describe the protocol scheme used | ||
| 67 | # in all of the WSDL endpoints | ||
| 68 | # | ||
| 69 | $HTTP = 'http'; | ||
| 70 | $HTTP_GET = 'GET'; | ||
| 71 | $HTTP_POST = 'POST'; | ||
| 72 | |||
| 73 | $SOAP = 'soap'; | ||
| 74 | |||
| 75 | $FTP = 'ftp'; | ||
| 76 | |||
| 77 | $FILESYSTEM = 'file'; | ||
| 78 | |||
| 79 | $MIME = 'mime'; | ||
| 80 | |||
| 81 | |||
| 82 | # | ||
| 83 | # %URI - A mapping from protocol to its URI | ||
| 84 | # | ||
| 85 | %URI = ( | ||
| 86 | $HTTP=> 'http://schemas.xmlsoap.org/wsdl/http/', | ||
| 87 | $SOAP=> 'http://schemas.xmlsoap.org/wsdl/soap/', | ||
| 88 | $FTP=> 'http://www.ibm.com/wsdl/ftp/', | ||
| 89 | |||
| 90 | $FILESYSTEM=> 'http://www.ibm.com/wsdl/filesystem/', | ||
| 91 | |||
| 92 | $MIME=> 'http://schemas.xmlsoap.org/wsdl/mime/', | ||
| 93 | ); | ||
| 94 | } | ||
| 95 | |||
| 96 | |||
| 97 | # | ||
| 98 | # protocolToURI( $protocol ) - Helper function to map a protocol on to its URI | ||
| 99 | # | ||
| 100 | # Parameters: | ||
| 101 | # | ||
| 102 | # $protocol - A string containing the protocol scheme | ||
| 103 | # | ||
| 104 | # Returns: | ||
| 105 | # | ||
| 106 | # undef if there is an error or the protocol does not have a URI | ||
| 107 | # or, the URI of the protocol | ||
| 108 | # | ||
| 109 | sub protocolToURI { | ||
| 110 | |||
| 111 | my $protocol = shift; | ||
| 112 | |||
| 113 | unless($protocol) { | ||
| 114 | |||
| 115 | print STDERR Carp::longmess('Missing protocol parameter') | ||
| 116 | if($DEBUG); | ||
| 117 | |||
| 118 | return undef; | ||
| 119 | } | ||
| 120 | |||
| 121 | return $URI{ $protocol }; | ||
| 122 | } | ||
| 123 | |||
| 124 | |||
| 125 | # | ||
| 126 | # uriToProtocol( $lookupURI ) - Looks up the protocol scheme name for a given URI. | ||
| 127 | # | ||
| 128 | # Parameters: | ||
| 129 | # $lookupURI - The URI used to locate the protocol scheme | ||
| 130 | # | ||
| 131 | # Returns: | ||
| 132 | # undef if there is an error or the protocol scheme is not found otherwise, | ||
| 133 | # the protocol scheme is returned | ||
| 134 | # | ||
| 135 | sub uriToProtocol { | ||
| 136 | |||
| 137 | my $lookupURI = shift; | ||
| 138 | |||
| 139 | unless($lookupURI) { | ||
| 140 | |||
| 141 | print STDERR Carp::longmess('Missing URI parameter') | ||
| 142 | if($DEBUG); | ||
| 143 | |||
| 144 | return undef; | ||
| 145 | } | ||
| 146 | |||
| 147 | foreach my $key (keys(%URI)) { | ||
| 148 | |||
| 149 | return $key if($URI{ $key } eq $lookupURI); | ||
| 150 | } | ||
| 151 | |||
| 152 | return undef; | ||
| 153 | } | ||
| 154 | |||
| 155 | |||
| 156 | |||
| 157 | 1; | ||
| 158 | |||
| 159 | __END__ |