(file) Return to Globalization_HOWTO.htm CVS log (file) (dir) Up to [Pegasus] / pegasus / doc

Diff for /pegasus/doc/Globalization_HOWTO.htm between version 1.5.2.1 and 1.11

version 1.5.2.1, 2003/12/01 19:57:38 version 1.11, 2008/12/16 18:55:36
Line 30 
Line 30 
 used as part of the table name inside the bundle.<br> used as part of the table name inside the bundle.<br>
       </td>       </td>
     </tr>     </tr>
       <tr>
         <td style="vertical-align: top;">08/04/06<br>
         </td>
         <td style="vertical-align: top;">Marek Szermutzky<br>
         </td>
         <td style="vertical-align: top;">Section 2.2.5. &nbsp; Added information how to write platform specific messages.<br>
         </td>
       </tr>
       <tr>
         <td style="vertical-align: top;">01/23/07<br>
         </td>
         <td style="vertical-align: top;">Sushma Fernandes<br>
         </td>
         <td style="vertical-align: top;">Section 2.2.5. &nbsp; Added information on special considerations while creating a new message.<br>
         </td>
       </tr>
   </tbody>   </tbody>
 </table> </table>
 <p><br> <p><br>
Line 253 
Line 269 
 different language.&nbsp; Please refer to PEP58 for details on these different language.&nbsp; Please refer to PEP58 for details on these
 provider scenarios. <br> provider scenarios. <br>
 &nbsp; </p> &nbsp; </p>
 <p>Pegasus 2.3 has added classes for the localization support.&nbsp;  <p>
 There are new classes called AcceptLanguages and ContentLanguages that  The Accept-Language and Content-Language headers are encapsulated
 encapsulate the Accept-Language and Content-Language headers,  in AcceptLanguageList and ContentLanguageList classes, respectively.
 respectively.&nbsp; These classes are basically containers of  These classes contain LanguageTag objects.  The AcceptLanguageList class
 AcceptLanguageElement and ContentLanguageElement, where a language  keeps its LanguageTags prioritized based on quality,
 element represents one language tag.&nbsp; The AcceptLanguages class  
 will keep the AcceptLanguageElement's prioritized based on quality,  
 according to RFC 2616. <br> according to RFC 2616. <br>
 &nbsp; </p> &nbsp; </p>
 <p>AcceptLanguages and ContentLanguages are the objects used by code  <p>AcceptLanguageList and ContentLanguageList are the objects used by code
 throughout the request/response processing, from the client to the throughout the request/response processing, from the client to the
 server to the providers and back.&nbsp; The server handles the creation server to the providers and back.&nbsp; The server handles the creation
 of these objects from the HTTP headers.&nbsp; Code at each point in the of these objects from the HTTP headers.&nbsp; Code at each point in the
 process will have access to these objects. <br> process will have access to these objects. <br>
 &nbsp; </p> &nbsp; </p>
 <p>Please refer to the following files for details on the new Pegasus  <p>Please refer to the following files for details on the Pegasus
 classes. <br>  language interfaces.<br>
 &nbsp; </p> &nbsp; </p>
 <ul> <ul>
   <li> pegasus/src/Pegasus/Common/AcceptLanguages.h</li>    <li> pegasus/src/Pegasus/Common/AcceptLanguageList.h</li>
   <li> pegasus/src/Pegasus/Common/AcceptLanguageElement.h</li>    <li> pegasus/src/Pegasus/Common/ContentLanguageList.h</li>
   <li> pegasus/src/Pegasus/Common/ContentLanguages.h</li>    <li> pegasus/src/Pegasus/Common/LanguageTag.h</li>
   <li> pegasus/src/Pegasus/Common/ContentLanguageElement.h</li>  
   <li> pegasus/src/Pegasus/Common/LanguageElementContainer.h</li>  
   <li> pegasus/src/Pegasus/Common/LanguageElement.h</li>  
 </ul> </ul>
 <p><br> <p><br>
 See the sections below for details on how to write clients and See the sections below for details on how to write clients and
Line 391 
Line 402 
 &nbsp; </p> &nbsp; </p>
 <p>The MessageLoader is the place where the Accept-Language header, <p>The MessageLoader is the place where the Accept-Language header,
 Content-Language header, and the ICU resource bundles, join up.&nbsp; Content-Language header, and the ICU resource bundles, join up.&nbsp;
 The MessageLoader class is designed to receive an AcceptLanguages  The MessageLoader class is designed to receive an AcceptLanguageList
 object, and a set of parameters indicating the bundle base-name and object, and a set of parameters indicating the bundle base-name and
 message ID to use.&nbsp; The AcceptLanguages object contains the list of  message ID to use.&nbsp; The AcceptLanguageList object contains the list of
 requested languages sent by the client.&nbsp; The MessageLoader requested languages sent by the client.&nbsp; The MessageLoader
 searches for the message in the set of bundles named with the base-name, searches for the message in the set of bundles named with the base-name,
 using the AcceptLanguages for the list of specific translated bundles  using the AcceptLanguageList for the list of specific translated bundles
 to search.&nbsp; The MessageLoader returns the message that it found, to search.&nbsp; The MessageLoader returns the message that it found,
 along with a ContentLanguages object indicating the language of the  along with a ContentLanguageList object indicating the language of the
 message.&nbsp; The ContentLanguages object should be used to indicate  message.&nbsp; The ContentLanguageList object should be used to indicate
 the language of the response sent back to the client. <br> the language of the response sent back to the client. <br>
 &nbsp; </p> &nbsp; </p>
 <p>The MessageLoaderParms object contains the parameters to load the <p>The MessageLoaderParms object contains the parameters to load the
Line 441 
Line 452 
 Note: defaults to the bundle containing the Pegasus server messages.</td> Note: defaults to the bundle containing the Pegasus server messages.</td>
     </tr>     </tr>
     <tr>     <tr>
       <td>AcceptLanguages acceptlanguages;</td>        <td>AcceptLanguageList acceptlanguages;</td>
       <td>Input.&nbsp; <br>       <td>Input.&nbsp; <br>
 Optional <br> Optional <br>
 Default: AcceptLanguages::EMPTY</td>  Default: AcceptLanguageList()</td>
       <td>Contains the list of preferred languages, in priority       <td>Contains the list of preferred languages, in priority
 order.&nbsp; This is combined with msg_src_path to determine which order.&nbsp; This is combined with msg_src_path to determine which
 resource bundles to search for for the msg_id.&nbsp;&nbsp; If not empty, resource bundles to search for for the msg_id.&nbsp;&nbsp; If not empty,
 overrides useThreadLocale and useProcessLocale.</td> overrides useThreadLocale and useProcessLocale.</td>
     </tr>     </tr>
     <tr>     <tr>
       <td>ContentLanguages contentlanguages;</td>        <td>ContentLanguageList contentlanguages;</td>
       <td>Output</td>       <td>Output</td>
       <td>Contains the language that MessageLoader found for the       <td>Contains the language that MessageLoader found for the
 msg_id.&nbsp;</td> msg_id.&nbsp;</td>
Line 469 
Line 480 
       <td>Input <br>       <td>Input <br>
 Optional <br> Optional <br>
 Default = <font color="#ff0000">true</font></td> Default = <font color="#ff0000">true</font></td>
       <td>If true, MessageLoader will use the AcceptLanguages set by        <td>If true, MessageLoader will use the AcceptLanguageList set by
 Pegasus into the caller's Thread.&nbsp;&nbsp; See the Note below for Pegasus into the caller's Thread.&nbsp;&nbsp; See the Note below for
 details.&nbsp;</td> details.&nbsp;</td>
     </tr>     </tr>
     <tr>     <tr>
       <td>Boolean useICUfallback</td>  
       <td>Input <br>  
 Optional <br>  
 Default = false</td>  
       <td>If true, use ICU's fallback mechnism to search more general  
 resource bundles if the msg_id cannot be found.&nbsp; Note: the  
 recommended setting is false if you are using an AcceptLanguages from a  
 CIM client.&nbsp; The Accept-Languages HTTP header from the client  
 contains the fallback specifications. &nbsp;Using ICU's fallback in this  
 case may lead to returning a language that the client didn't ask for.</td>  
     </tr>  
     <tr>  
       <td>Formatter::Arg arg0; <br>       <td>Formatter::Arg arg0; <br>
 &nbsp;Formatter::Arg arg1; <br> &nbsp;Formatter::Arg arg1; <br>
 &nbsp;Formatter::Arg arg2; <br> &nbsp;Formatter::Arg arg2; <br>
Line 508 
Line 507 
 <p>Notes: <br> <p>Notes: <br>
 &nbsp; </p> &nbsp; </p>
 <p>The "useThreadLocale" parameter defaults to true.&nbsp; This flag <p>The "useThreadLocale" parameter defaults to true.&nbsp; This flag
 indicates to use the AcceptLanguages object set by Pegasus into the  indicates to use the AcceptLanguageList object set by Pegasus into the
 Pegasus Thread in which the caller's code is running.&nbsp; This Pegasus Thread in which the caller's code is running.&nbsp; This
 AcceptLanguages object reflects the languages requested by the  AcceptLanguageList object reflects the languages requested by the
 client.&nbsp; This is useful for code that may not have access to the client.&nbsp; This is useful for code that may not have access to the
 AcceptLanguages from the client.&nbsp; Pegasus sets this AcceptLanguages  AcceptLanguageList from the client.&nbsp; Pegasus sets this AcceptLanguageList
 object into the Thread of providers and internal Pegasus code.&nbsp; object into the Thread of providers and internal Pegasus code.&nbsp;
 For this reason, it is recommended that provider and internal Pegasus For this reason, it is recommended that provider and internal Pegasus
 code use the "useThreadLocale" flag instead of explicity passing in an code use the "useThreadLocale" flag instead of explicity passing in an
 AcceptLanguages object.&nbsp; See the Provider Developer and Pegasus  AcceptLanguageList object.&nbsp; See the Provider Developer and Pegasus
 Developer sections for details. <br> Developer sections for details. <br>
 &nbsp; </p> &nbsp; </p>
 <p>The "useProcessLocale" flag can be used to tell MessageLoader to use <p>The "useProcessLocale" flag can be used to tell MessageLoader to use
Line 529 
Line 528 
 &nbsp; </p> &nbsp; </p>
 <p>"Master switch" <br> <p>"Master switch" <br>
 The MessageLoader class has a public static Boolean variable called The MessageLoader class has a public static Boolean variable called
 _useProcessLocale that may be used to override all the AcceptLanguages  _useProcessLocale that may be used to override all the AcceptLanguageList
 and useThreadLocale settings in the MessageLoaderParms objects passed and useThreadLocale settings in the MessageLoaderParms objects passed
 in.&nbsp; This is useful for CLI code (eg cimconfig) that needs to in.&nbsp; This is useful for CLI code (eg cimconfig) that needs to
 localize its messages based on the locale of its process, which refects localize its messages based on the locale of its process, which refects
 the locale set by the user running the CLI (eg. $LANG on Unix).&nbsp; the locale set by the user running the CLI (eg. $LANG on Unix).&nbsp;
 The CLI code may call Pegasus APIs that are coded to use the Thread's The CLI code may call Pegasus APIs that are coded to use the Thread's
 AcceptLanguages, which will not be set in this case.&nbsp; The  AcceptLanguageList, which will not be set in this case.&nbsp; The
 _useProcessLocale static variable tells the MessageLoader to ignore the _useProcessLocale static variable tells the MessageLoader to ignore the
 AcceptLanguages, useThreadLocale, and useProcessLocale settings in  AcceptLanguageList, useThreadLocale, and useProcessLocale settings in
 MessageLoaderParms that it gets.&nbsp; The MessageLoader will use the MessageLoaderParms that it gets.&nbsp; The MessageLoader will use the
 default process locale, as determined by ICU, in this case. <br> default process locale, as determined by ICU, in this case. <br>
 &nbsp; </p> &nbsp; </p>
 <p><i>Important Note:</i>&nbsp; The MessageLoader defaults to <i>not </i>use  <p><i>Important Note:</i>&nbsp; The MessageLoader does <i>not</i> use
 the "fallback" mechanism described in the ICU Resource Management the "fallback" mechanism described in the ICU Resource Management
 section.&nbsp; This is because the Accept-Language header itself section.&nbsp; This is because the Accept-Language header itself
 describes the fallback that the client wants.&nbsp; However, the  describes the fallback that the client wants.&nbsp; If the
 MessageLoader does "fallback" to the root resource bundle if none of the  MessageLoader cannot find a message file for any of the languages
 languages in AcceptLanguages can be found.&nbsp; If the root resource  in the AcceptLanguageList, it will try the default process locale.
 bundle cannot be found, then the default_msg is returned.&nbsp; The  If this fails, the ICU root resource bundle will be tried.<br>
 "useICUFallback" flag can be set to have MessageLoader use ICU fallback  
 on all message load attempts.&nbsp; However, usage of this flag for  
 client requests may lead to incorrect results.&nbsp; For example, a  
 client sets Accept-Language to french, german, and spanish, in that  
 order, but there is no french resource bundle.&nbsp; A call to  
 MessageLoader with useICUfallback == true would cause the root resource  
 bundle string to be returned on the attempt to load from the french  
 bundle.&nbsp; But the client requested german to be the fallback after  
 french. <br>  
 &nbsp; </p> &nbsp; </p>
 <p>Please refer to the following files for details on the new Pegasus <p>Please refer to the following files for details on the new Pegasus
 classes. <br> classes. <br>
Line 570 
Line 560 
 classes described above.&nbsp; Note: this a generic example.&nbsp; Each classes described above.&nbsp; Note: this a generic example.&nbsp; Each
 of the developer sections below have 'real-life' examples that are of the developer sections below have 'real-life' examples that are
 better suited to each type of code. </p> better suited to each type of code. </p>
 <p>// Build an AcceptLanguages with some language elements <br>  <p>// Build an AcceptLanguageList with some language elements <br>
 AcceptLanguages acceptLangs; <br>  AcceptLanguageList acceptLangs; <br>
 acceptLangs.add(AcceptLanguageElement("fr", 0.5)); <br>  acceptLangs.insert(LanguageTag("fr"), 0.5); <br>
 acceptLangs.add(AcceptLanguageElement("de", 0.8)); <br>  acceptLangs.insert(LanguageTag("de"), 0.8); <br>
 acceptLangs.add(AcceptLanguageElement("es", 0.4)); </p>  acceptLangs.insert(LanguageTag("es"), 0.4); </p>
 <p>// Construct a MessageLoaderParms <br> <p>// Construct a MessageLoaderParms <br>
 MessageLoaderParms parms("msgID", "default message"); <br> MessageLoaderParms parms("msgID", "default message"); <br>
 parms. msg_src_path = "/my_msg_dir/my_bundle"; <br> parms. msg_src_path = "/my_msg_dir/my_bundle"; <br>
Line 584 
Line 574 
 String localizedMsg = MessageLoader::getMessage(parms); <br> String localizedMsg = MessageLoader::getMessage(parms); <br>
 &nbsp; <br> &nbsp; <br>
 &nbsp; </p> &nbsp; </p>
 <h4> 2.2.4 Message Writing Guidelines</h4>  <h4> 2.2.5 Message Writing Guidelines</h4>
 <p><br> <p><br>
 Here are some basic rules for writing messages: <br> Here are some basic rules for writing messages: <br>
 &nbsp; </p> &nbsp; </p>
Line 603 
Line 593 
 ultimately the customer.</li> ultimately the customer.</li>
   <li> <b>TODO </b>- find a good message writing guide to link to</li>   <li> <b>TODO </b>- find a good message writing guide to link to</li>
 </ul> </ul>
   
   <p><b>When do I create a new message ?</b></p>
   
   <p>A new message should be created if a message is needed with a content not
   described by any existing message.</p>
   
   <p>A new message should be created if the number or placement of substitution
   parameters of an existing message would require an update.</p>
   
   <p>It is not necessary to create a new message if just the text of the message
   is changed, while the meaning is kept. For instance if the
   event(error,warning,whatever) is described more precisely by the new message
   text, it is not necessary to create a new message, but the existing one should
   be updated.</p>
   
   <p><b>Are there any special considerations while creating a new message ? </b></p>
   
   <ul>
   <li>If a message definition contains text within a single quote
   it is not interpreted in any way.
   
   <p><i>Example:</i></p>
   <p> Server.CIMOperationRequestAuthorizer.NOT_IN_AUTHORIZED_GRP:
       string {"PGS05202: User '{0}' is not authorized to access CIM data."}
   </p>
   
   <p><i>Processed message:</i></p>
   <p>  User {0} is not authorized to access CIM data.  </p>
   </li>
   
   <li> For a single quote to appear in a processed message, it needs to be preceded by
   another single quote.
   
   <p><i>Example:</i></p>
   <p> Server.CIMOperationRequestAuthorizer.NOT_IN_AUTHORIZED_GRP:
       string {"PGS05202: User ''{0}'' is not authorized to access CIM data."}
   </p>
   
   <p><i>Processed message:</i></p>
   <p>  User 'wbemuser' is not authorized to access CIM data.  </p>
   </li>
   
   <li> For a double quote to appear in a processed message, it needs to be preceded by
   a back slash.
   
   <p><i>Example:</i></p>
   <p>
   ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.
   UNSUPPORTED_USERCONTEXT_VALUE:string {"PGS03029: Unsupported UserContext
   value: \"{0}\"."}
   </p>
   
   <p><i>Processed message:</i></p>
   <p>  Unsupported UserContext value: "10".  </p>
   </li>
   </ul>
   
   <p>&nbsp;</p>
   
   <p><b>How do I write a platform specific
   message ? </b></p>
   
   <p>Platform specific messages generate in a non-platform specific source file
   should be formatted with a .&lt;platform&gt; or .STANDARD suffix.</p>
   
   <p><i>Example:</i></p>
   <p>Compiler.cmdline.cimmof.cmdline.MENU.PEGASUS_OS_HPUX</p>
   <p>Compiler.cmdline.cimmof.cmdline.MENU.PEGASUS_OS_OS40</p>
   <p>Compiler.cmdline.cimmof.cmdline.MENU.STANDARD</p>
   
   <p>&nbsp;</p>
   
   <p><b>Where should I place platform specific
   messages ? </b></p>
   
   <p>As described in the message bundle file pegasusServer_en.txt messages belong
   into the section corresponding the file they are created in. This does account
   the same to platform specific messages.</p>
   <p>If a message is generated inside a source file not specific to a single
   platform, the message should be part of the message bundle section of that
   source file.</p>
   <p>If a new platform specific message is generated inside a platform specific
   source file, the message belongs to the platform specific section of the
   message bundle file.</p>
   
   <p><i>Examples:</i></p>
   
   <p>ProviderManager.ProviderAgent.ProviderAgent.UNINITIALIZED_SECURITY_SETUP.PEGASUS_OS_ZOS
   - this message is and should be part of the section for the ProviderAgent as it
   is generated inside the provider agent and not a z/OS platform specific file</p>
   <p>Common.safCheckzOS_inline.BAD_WBEM_SECURITY_SETUP - this message does and
   should reside inside the platform specific section as the message is generated
   in a z/OS platform only file</p>
   
   <p>&nbsp;</p>
   
 <h4> 2.2.5 Localized Exceptions</h4> <h4> 2.2.5 Localized Exceptions</h4>
 <p><br> <p><br>
 The base Exception class, and derived classes, have been updated to The base Exception class, and derived classes, have been updated to
Line 610 
Line 696 
 MessageLoaderParms object.&nbsp; These constructors will use the MessageLoaderParms object.&nbsp; These constructors will use the
 MessageLoaderParms object to call the MessageLoader to load the MessageLoaderParms object to call the MessageLoader to load the
 localized exception message.&nbsp; The localized message is saved in the localized exception message.&nbsp; The localized message is saved in the
 Exception.&nbsp; The ContentLanguages object returned by MessageLoader  Exception.&nbsp; The ContentLanguageList object returned by MessageLoader
 is also saved in the Exception.&nbsp; This indicates the language of is also saved in the Exception.&nbsp; This indicates the language of
 the message.&nbsp; The ContentLanguages object is used later to set the  the message.&nbsp; The ContentLanguageList object is used later to set the
 Content-Language header in the HTTP message to the client. <br> Content-Language header in the HTTP message to the client. <br>
 &nbsp; </p> &nbsp; </p>
 <p>The old Exception constructors that take a String will remain.&nbsp; <p>The old Exception constructors that take a String will remain.&nbsp;
Line 671 
Line 757 
 provider does not need to know what the Accept-Language is.&nbsp; This provider does not need to know what the Accept-Language is.&nbsp; This
 is the recommended method to load messages based on the client's request.</li> is the recommended method to load messages based on the client's request.</li>
   <br>   <br>
 &nbsp; <li> The OperationContext will contain an AcceptLanguages object  &nbsp; <li> The OperationContext will contain an AcceptLanguageList object
 that has the Accept-Language requested by the client.&nbsp; The provider that has the Accept-Language requested by the client.&nbsp; The provider
 can use this AcceptLanguages object to load strings with MessageLoader.</li>  can use this AcceptLanguageList object to load strings with MessageLoader.</li>
 </ul> </ul>
 <p><br> <p><br>
 The OperationContext will also contain a ContentLanguages object that  The OperationContext will also contain a ContentLanguageList object that
 is set from the Content-Language in the client request.&nbsp; This is is set from the Content-Language in the client request.&nbsp; This is
 the language of the CIM objects being passed to the provider on that the language of the CIM objects being passed to the provider on that
 request.&nbsp; A localized provider should store the content language request.&nbsp; A localized provider should store the content language
Line 733 
Line 819 
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 // We are going to let the message loader parameters default to use the <br> // We are going to let the message loader parameters default to use the <br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 // AcceptLanguages that Pegasus set into our thread. <br>  // AcceptLanguageList that Pegasus set into our thread. <br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 // (this equals the AcceptLanguages requested by the client) <br>  // (this equals the AcceptLanguageList requested by the client) <br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 // Note: This parms object could be constructed once and <br> // Note: This parms object could be constructed once and <br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Line 769 
Line 855 
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 // of parms to the language that it found for the message. <br> // of parms to the language that it found for the message. <br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 ContentLanguages rtnLangs = parms.contentlanguages; </p>  ContentLanguageList rtnLangs = parms.contentlanguages; </p>
 <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 // We need to tag the instance we are returning with the <br> // We need to tag the instance we are returning with the <br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// the &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// the
Line 801 
Line 887 
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 // We are going to let the message loader parameters default to use the <br> // We are going to let the message loader parameters default to use the <br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 // AcceptLanguages that Pegasus set into our thread. <br>  // AcceptLanguageList that Pegasus set into our thread. <br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 // (this equals the AcceptLanguages requested by the client) <br>  // (this equals the AcceptLanguageList requested by the client) <br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 // Note: This parms object could be constructed once and <br> // Note: This parms object could be constructed once and <br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Line 897 
Line 983 
 <p>&nbsp;&nbsp; // Language priority is martian, pig-latin, and <p>&nbsp;&nbsp; // Language priority is martian, pig-latin, and
 french.&nbsp; We should <br> french.&nbsp; We should <br>
 &nbsp;&nbsp; // get french back, even though its the lowest priority <br> &nbsp;&nbsp; // get french back, even though its the lowest priority <br>
 &nbsp; AcceptLanguages acceptLangs; <br>  &nbsp; AcceptLanguageList acceptLangs; <br>
 &nbsp; acceptLangs.add(AcceptLanguageElement("x-martian")); <br>  &nbsp; acceptLangs.insert(LanguageTag("x-martian"), 1.0); <br>
 &nbsp; acceptLangs.add(AcceptLanguageElement("fr", 0.1)); <br>  &nbsp; acceptLangs.insert(LanguageTag("fr"), 0.1); <br>
 &nbsp; acceptLangs.add(AcceptLanguageElement("x-pig-latin", 0.4)); </p>  &nbsp; acceptLangs.insert(LanguageTag("x-pig-latin"), 0.4); </p>
 <p>&nbsp;&nbsp;&nbsp; // Set the requested languages into the CIMClient <br> <p>&nbsp;&nbsp;&nbsp; // Set the requested languages into the CIMClient <br>
 &nbsp; client.setRequestAcceptLanguages(acceptLangs); </p> &nbsp; client.setRequestAcceptLanguages(acceptLangs); </p>
 <p>&nbsp;&nbsp; // Get the instance <br> <p>&nbsp;&nbsp; // Get the instance <br>
Line 919 
Line 1005 
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 get(returnedString); </p> get(returnedString); </p>
 <p>&nbsp; // Check that we got back french <br> <p>&nbsp; // Check that we got back french <br>
 &nbsp; ContentLanguages CL_FR("fr"); <br>  &nbsp; ContentLanguageList CL_FR(); <br>
   &nbsp; CL_FR.append(LanguageTag("fr")); <br>
 &nbsp; String expectedFRString = "oui"; <br> &nbsp; String expectedFRString = "oui"; <br>
 &nbsp; PEGASUS_ASSERT(CL_FR == client.getResponseContentLanguages()); <br> &nbsp; PEGASUS_ASSERT(CL_FR == client.getResponseContentLanguages()); <br>
 &nbsp; PEGASUS_ASSERT(expectedFRString == returnedString); </p> &nbsp; PEGASUS_ASSERT(expectedFRString == returnedString); </p>
Line 961 
Line 1048 
 ICU.&nbsp; If ICU is installed on the client system then CIMClient will ICU.&nbsp; If ICU is installed on the client system then CIMClient will
 set the Accept-Language from the default ICU process locale.&nbsp; If set the Accept-Language from the default ICU process locale.&nbsp; If
 ICU is not installed then the caller is required to set an ICU is not installed then the caller is required to set an
 AcceptLanguages into CIMClient that meets the ISO-639 and IS0-3166  AcceptLanguageList into CIMClient that meets the ISO-639 and IS0-3166
 standards.&nbsp; Note:&nbsp; this is useful for local clients, such as standards.&nbsp; Note:&nbsp; this is useful for local clients, such as
 the Pegasus CLIs, where ICU would be installed on both the client and the Pegasus CLIs, where ICU would be installed on both the client and
 server sides. <br> server sides. <br>
Line 1006 
Line 1093 
 <p><b>Server Design Points:</b> <br> <p><b>Server Design Points:</b> <br>
 &nbsp; </p> &nbsp; </p>
 <p>The CIMMessage object has been expanded to include an <p>The CIMMessage object has been expanded to include an
 AcceptLanguages object and a ContentLanguages object.&nbsp; For  AcceptLanguageList object and a ContentLanguageList object in its
   OperationContext member.&nbsp; For
 CIMRequestMessage, these objects contain the Accept-Language and CIMRequestMessage, these objects contain the Accept-Language and
 Content-Language headers that were built from the client request.&nbsp; Content-Language headers that were built from the client request.&nbsp;
 For CIMResponseMessage, the ContentLanguages object is used to build the  For CIMResponseMessage, the ContentLanguageList object is used to build the
 Content-Language header associated with the CIM <i>objects </i>in the Content-Language header associated with the CIM <i>objects </i>in the
 response message.&nbsp; The AcceptLanguages object in the  response message.&nbsp; The AcceptLanguageList object in the
 CIMResponseMessage is ignored. <br> CIMResponseMessage is ignored. <br>
 &nbsp; </p> &nbsp; </p>
 <p>The localization of the cimException object in the <p>The localization of the cimException object in the
Line 1020 
Line 1108 
 localized by the time it is built into the XML.&nbsp; For this reason, localized by the time it is built into the XML.&nbsp; For this reason,
 the localization of the exception is the responsibility of the code the localization of the exception is the responsibility of the code
 throwing the exception.&nbsp; (The goal of the design is to make that throwing the exception.&nbsp; (The goal of the design is to make that
 easy - see below).&nbsp; The ContentLanguages object in the  easy - see below).&nbsp; The ContentLanguageList object in the
 CIMResponseMessage has NO relation to this exception.&nbsp; The CIMResponseMessage has NO relation to this exception.&nbsp; The
 cimException object keeps its own localization information once it is cimException object keeps its own localization information once it is
 created. <br> created. <br>
Line 1028 
Line 1116 
 <p>To enable exceptions to be localized, the ability was added to set a <p>To enable exceptions to be localized, the ability was added to set a
 global language for all the code running from a Pegasus Thread global language for all the code running from a Pegasus Thread
 object.&nbsp; The top level code for a Thread can set a global object.&nbsp; The top level code for a Thread can set a global
 AcceptLanguages object that can be accessed by all the low-level  AcceptLanguageList object that can be accessed by all the low-level
 functions that it calls.&nbsp; This will allow an exception thrown by functions that it calls.&nbsp; This will allow an exception thrown by
 the low-level function to be localized based on this global the low-level function to be localized based on this global
 AcceptLanguages object.&nbsp; Note:&nbsp; This applies only to Threads  AcceptLanguageList object.&nbsp; Note:&nbsp; This applies only to Threads
 that are managed by a ThreadPool. <br> that are managed by a ThreadPool. <br>
 &nbsp; </p> &nbsp; </p>
 <p>Each service in the request path of the Pegasus server sets the <p>Each service in the request path of the Pegasus server sets the
 AcceptLanguages into its Thread from the AcceptLanguages in the  AcceptLanguageList into its Thread from the AcceptLanguageList in the
 CIMRequestMessage object that it dequeues.&nbsp; This sets the global CIMRequestMessage object that it dequeues.&nbsp; This sets the global
 langauge for all the functions in the same thread that are called below langauge for all the functions in the same thread that are called below
 handleEnqueue.&nbsp; <i>If you are writing a new service that processes handleEnqueue.&nbsp; <i>If you are writing a new service that processes
Line 1047 
Line 1135 
 <p>With all that background, here is how code running in a Pegasus <p>With all that background, here is how code running in a Pegasus
 service can throw a localized exception: <br> service can throw a localized exception: <br>
 This example assumes that the top-level code in the service had set the This example assumes that the top-level code in the service had set the
 global thread AcceptLanguages beforehand.&nbsp; As described above,  global thread AcceptLanguageList beforehand.&nbsp; As described above,
 every service in Pegasus should do that.&nbsp; The code here may be every service in Pegasus should do that.&nbsp; The code here may be
 buried several layers deep in the call chain, but does not need to know buried several layers deep in the call chain, but does not need to know
 the AcceptLanguage of the current client request. </p>  the AcceptLanguagList of the current client request. </p>
 <p>// First, construct a MessageLoaderParms <br> <p>// First, construct a MessageLoaderParms <br>
 // <br> // <br>
 // Notes: <br> // Notes: <br>
Line 1060 
Line 1148 
 //&nbsp; 3) The MessageLoaderParms will default to use the Pegasus //&nbsp; 3) The MessageLoaderParms will default to use the Pegasus
 server resource bundle <br> server resource bundle <br>
 //&nbsp; 4) The MessageLoaderParms will default to use the //&nbsp; 4) The MessageLoaderParms will default to use the
 AcceptLanguages set into the current Thread.&nbsp; Don't change this! <br>  AcceptLanguageList set into the current Thread.&nbsp; Don't change this! <br>
 //&nbsp; 5) You might need to set the arguments for the message into //&nbsp; 5) You might need to set the arguments for the message into
 the MessageLoaderParms <br> the MessageLoaderParms <br>
 MessageLoaderParms parms("errorMessageID", "default message"); </p> MessageLoaderParms parms("errorMessageID", "default message"); </p>
Line 1088 
Line 1176 
 e.getMessage()); <br> e.getMessage()); <br>
 } <br> } <br>
 &nbsp; </p> &nbsp; </p>
 <p>This type of code would have lost the ContentLanguages saved in "e",  <p>This type of code would have lost the ContentLanguageList saved in "e",
 so that the Content-Language would not be set in HTTP response to the so that the Content-Language would not be set in HTTP response to the
 client. <br> client. <br>
 &nbsp; </p> &nbsp; </p>
 <p>For Pegasus 2.3, these types of macro calls can stay.&nbsp; The <p>For Pegasus 2.3, these types of macro calls can stay.&nbsp; The
 TraceableCIMException constructed by the macro will "re-localize".&nbsp; TraceableCIMException constructed by the macro will "re-localize".&nbsp;
 That is, the "CIM" part of the message (the part based on the error That is, the "CIM" part of the message (the part based on the error
 code) will be localized at throw time, and the ContentLanguages  code) will be localized at throw time, and the ContentLanguageList
 re-established.&nbsp; A key is to avoid a "language mismatch" problem re-established.&nbsp; A key is to avoid a "language mismatch" problem
 between the CIM part of the message and the extra part of the between the CIM part of the message and the extra part of the
 message.&nbsp; The design point here is that all internal exceptions message.&nbsp; The design point here is that all internal exceptions
 thrown by Pegasus code are localized using the global AcceptLanguages  thrown by Pegasus code are localized using the global AcceptLanguageList
 of the Thread...see above. <br> of the Thread...see above. <br>
 &nbsp; </p> &nbsp; </p>
 <p>In the future, it will be safer and more maintainable to use of <p>In the future, it will be safer and more maintainable to use of
Line 1118 
Line 1206 
 e.getMessage( )); <br> e.getMessage( )); <br>
 } <br> } <br>
 &nbsp; </p> &nbsp; </p>
 <p>This guarantees that the ContentLanguages in "e" is copied to the  <p>This guarantees that the ContentLanguageList in "e" is copied to the
 newly created TraceableCIMException. <br> newly created TraceableCIMException. <br>
 &nbsp; </p> &nbsp; </p>
 <p>In the case where the extra message for the CIMException is <p>In the case where the extra message for the CIMException is
Line 1176 
Line 1264 
 &nbsp; </p> &nbsp; </p>
 <p> </p> <p> </p>
 <hr> <hr>
 <p><i>Copyright (c) 2003 BMC Software; Hewlett-Packard Development  <p><i>
 Company, L.P.; IBM Corp.; The Open Group</i> </p>  Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 <p><i>Permission is hereby granted, free of charge, to any person  Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
 obtaining a copy&nbsp; of this software and associated documentation  Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
 files (the "Software"), to deal in the Software without restriction,  IBM Corp.; EMC Corporation, The Open Group.
 including without limitation the rights to use, copy, modify, merge,  Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
 publish, distribute, sublicense, and/or sell copies of the Software, and  IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 to permit persons to whom the Software is furnished to do so, subject  Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 to the following conditions:</i> </p>  EMC Corporation; VERITAS Software Corporation; The Open Group.
 <p><i>THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE  Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 INCLUDED IN ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE  EMC Corporation; Symantec Corporation; The Open Group.
 SOFTWARE IS PROVIDED&nbsp; "AS IS", WITHOUT WARRANTY OF ANY KIND,  </i> </p>
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF  
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  <p><i>
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  Permission is hereby granted, free of charge, to any person obtaining a copy
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  of this software and associated documentation files (the "Software"), to
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE  deal in the Software without restriction, including without limitation the
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</i> <br>  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 &nbsp; <br>  sell copies of the Software, and to permit persons to whom the Software is
 &nbsp; </p>  furnished to do so, subject to the following conditions:
   </i> </p>
   
   <p><i>
   THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
   ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
   "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
   LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
   PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   </i> <br>
   <br>
   </p>
 </body> </body>
 </html> </html>


Legend:
Removed from v.1.5.2.1  
changed lines
  Added in v.1.11

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2