1 martin 1.8 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 martin 1.8 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 yi.zhou 1.1 //
|
28 martin 1.8 //////////////////////////////////////////////////////////////////////////
|
29 yi.zhou 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_IndicationFormatter_h
33 #define Pegasus_IndicationFormatter_h
34
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/Common/Linkage.h>
37 #include <Pegasus/Common/String.h>
|
38 kumpf 1.7 #include <Pegasus/Common/Array.h>
39 #include <Pegasus/Common/CIMInstance.h>
40 #include <Pegasus/Common/CIMClass.h>
41 #include <Pegasus/Common/CIMValue.h>
42 #include <Pegasus/Common/CIMPropertyList.h>
43 #include <Pegasus/Common/ContentLanguageList.h>
|
44 yi.zhou 1.1
45 PEGASUS_NAMESPACE_BEGIN
46
|
47 kumpf 1.6 /**
|
48 yi.zhou 1.1 The IndicationFormatter class formats an indication message.
49 */
50 class PEGASUS_COMMON_LINKAGE IndicationFormatter
51 {
52 public:
53
54 /**
|
55 kumpf 1.6 Based on subscription instance, gets the formatted indication text
56 message from the received indication instance.
|
57 yi.zhou 1.1
|
58 yi.zhou 1.2 @param subscription the subscription instance
59 @param indication the received indication instance
|
60 kumpf 1.6 @param contentLangs the Content-Languages in the
61 subscription instance
|
62 yi.zhou 1.1
|
63 kumpf 1.6 @return String containing the formatted indication text message
|
64 yi.zhou 1.1 */
|
65 yi.zhou 1.2 static String getFormattedIndText(
|
66 kumpf 1.6 const CIMInstance& subscription,
67 const CIMInstance& indication,
68 const ContentLanguageList& contentLangs);
|
69 yi.zhou 1.1
70
71 /**
|
72 kumpf 1.6 Validates the syntax and the provided type for the property
73 TextFormat in the instance.
74 If the value of the property has a syntax error, or the
75 provided type does not match the property type,
|
76 yi.zhou 1.1 an exception is thrown.
77
|
78 kumpf 1.6 This function is called by the _canCreate function, and is used to
79 validate the syntax and the provided type for the property
80 TextFormat in the Formatted Subscription instance.
|
81 yi.zhou 1.1
82 @param textFormatStr the string to be validated
|
83 kumpf 1.6 @param indicationClass the indication class
84 @param textFormatParams the value of the TextFormatParameters
|
85 yi.zhou 1.1
|
86 kumpf 1.6 @throw CIM_ERR_INVALID_PARAMETER if there is a syntax error
87 for the value of property
88 TextFormat or type mismatch
|
89 yi.zhou 1.1 */
|
90 kumpf 1.6 static void validateTextFormat(
91 const String& textFormatStr,
92 const CIMClass& indicationClass,
93 const Array<String>& textFormatParams);
|
94 yi.zhou 1.1
95 /**
|
96 kumpf 1.6 Validates the value of the property TextFormatParameters in the
97 subscriptionInstance.
|
98 yi.zhou 1.1 If the property name in the TextFormatParameters is not the name
|
99 kumpf 1.6 contained in the select clause of the associated filter query
100 in the filterInstance, an exception is thrown.
|
101 yi.zhou 1.1
102 @param propertyList the list of properties to be validated
103 @param indicationClass the indication class
|
104 kumpf 1.6 @param textFormatParams the value of the property
105 TextFormatParameters
|
106 yi.zhou 1.1
107 @throw CIM_ERR_INVALID_PARAMETER if the select clause of the
|
108 kumpf 1.6 filter query does not contain
109 the provided property name
|
110 yi.zhou 1.1 */
|
111 kumpf 1.6 static void validateTextFormatParameters(
112 const CIMPropertyList& propertyList,
113 const CIMClass& indicationClass,
114 const Array<String>& textFormatParams);
|
115 yi.zhou 1.1
116 private:
117
118 /**
|
119 kumpf 1.7 Gets a specified indication property value from an indication instance.
|
120 yi.zhou 1.1
|
121 kumpf 1.7 @param propertyName The name of the property for which to get the value.
122 @param arrayIndex The array index of the value to get, if the property
123 has an array value. A value of PEG_NOT_FOUND indicates that all
124 array values are requested.
125 @param indication The indication from which to get the property value.
126 @param contentLangs The language in which to encode the value.
|
127 yi.zhou 1.1 @return String containing property value
128 */
129 static String _getIndPropertyValue(
|
130 kumpf 1.6 const String& propertyName,
|
131 kumpf 1.7 Uint32 arrayIndex,
|
132 kumpf 1.6 const CIMInstance& indication,
133 const ContentLanguageList& contentLangs);
|
134 yi.zhou 1.1
135 /**
|
136 kumpf 1.7 Retrieves the array values contained by the specified CIMValue.
|
137 kumpf 1.6
|
138 kumpf 1.7 @param value The CIMValue from which to get the array values.
139 @param arrayIndex The array index for which to get the value. A value
140 of PEG_NOT_FOUND indicates that all values are requested.
141 @param contentLangs The language in which to encode the value.
142 @return String containing array values contained by the CIMValue.
|
143 yi.zhou 1.1 */
144 static String _getArrayValues(
|
145 kumpf 1.7 const CIMValue& value,
146 Uint32 arrayIndex,
|
147 kumpf 1.6 const ContentLanguageList& contentLangs);
|
148 yi.zhou 1.1
149 /**
|
150 kumpf 1.7 Parses an index value from a string. The string must represent an
151 unsigned integer. Leading and trailing whitespace is ignored.
|
152 yi.zhou 1.1
|
153 kumpf 1.7 @param indexStr The string from which to parse the index.
154 @throw CIM_ERR_INVALID_PARAMETER If the string is improperly formatted.
155 */
156 static Uint32 _parseIndex(const String& indexStr);
|
157 yi.zhou 1.1
|
158 kumpf 1.7 /**
159 Trims leading and trailing whitespace from a String.
160 @param s The string from which to trim whitespace.
161 */
162 static void _trim(String& s);
|
163 yi.zhou 1.1
164 /**
|
165 kumpf 1.6 Validates the provided property type string.
|
166 yi.zhou 1.1 If the provided property type does not match the type of the property,
|
167 kumpf 1.6 or the provided property type is not valid type, or the dynamic
168 content with an array index refers to a non array type, an
169 exception is thrown.
|
170 yi.zhou 1.1
171 This function is called by the _validatePropertySyntaxAndType
|
172 kumpf 1.6 function, and is used to validate the provided property type.
|
173 yi.zhou 1.1
|
174 kumpf 1.6 @param indicationClass the indication class
175 @param propertyParam the provided property
176 @param propertyTypeStr the provided property type
177 @param isArray indicates whether refers to an array type
|
178 yi.zhou 1.1
179 @throw CIM_ERR_INVALID_PARAMETER if the provided property type is
|
180 kumpf 1.6 unexpected
|
181 yi.zhou 1.1 */
|
182 kumpf 1.6 static void _validatePropertyType(
183 const CIMClass& indicationClass,
184 const String& propertyParam,
185 const String& propertyTypeStr,
186 const Boolean& isArray);
|
187 yi.zhou 1.1
|
188 yi.zhou 1.2 /**
|
189 kumpf 1.6 Constructs a default indication text message from the received
190 indication instance.
|
191 yi.zhou 1.2
192 @param indication the received indication instance
|
193 kumpf 1.6 @param contentLangs the Content-Languages in the
194 subscription instance
|
195 yi.zhou 1.2
|
196 kumpf 1.6 @return String containing default indication text message
|
197 yi.zhou 1.2 */
198 static String _formatDefaultIndicationText(
|
199 kumpf 1.6 const CIMInstance& indication,
200 const ContentLanguageList& contentLangs);
|
201 yi.zhou 1.2
202 /**
203 Constructs a human readable indication text message from the
|
204 kumpf 1.6 specified indication textFormat, textFormatParams, and
205 received indication instance.
|
206 yi.zhou 1.2
|
207 kumpf 1.6 @param textFormat the specified indication textFormat
|
208 yi.zhou 1.2 @param textFormatParams the indexed array containing the names
|
209 kumpf 1.6 of properties defined in the select
210 clause of the associated
211 CIM_IndicationFilter Query
212 @param indication the received indication instance
213 @param contentLangs the Content-Languages in the
214 subscription instance
|
215 yi.zhou 1.2
|
216 kumpf 1.6 @return String containing a human readable indication text message
|
217 yi.zhou 1.2 */
218 static String _formatIndicationText(
|
219 kumpf 1.6 const String& textFormat,
220 const Array<String>& textFormatParams,
221 const CIMInstance& indication,
222 const ContentLanguageList& contentLangs);
|
223 yi.zhou 1.1 };
224
225 PEGASUS_NAMESPACE_END
226
227 #endif /* Pegasus_IndicationFormatter_h */
|